refactor: optimize model cache updates by moving to session_start hook & bump to 0.2.1

This commit is contained in:
Simon Shi
2026-06-16 13:39:24 +08:00
parent 8fb093bac0
commit 26be3e0e17
3 changed files with 22 additions and 11 deletions
+1 -8
View File
@@ -12,7 +12,7 @@ import type {
} from "@earendil-works/pi-ai";
import * as PiAi from "@earendil-works/pi-ai";
import { buildAuthHeaders, getMachineId } from "./cosy.js";
import { getCachedModelConfig, isCacheStale, updateQoderModelsCache } from "./models.js";
import { getCachedModelConfig } from "./models.js";
import { getCachedCredentials } from "./oauth.js";
import { qoderEncodeBody } from "./qoder-encoding.js";
import { ThinkingTagParser } from "./thinking-parser.js";
@@ -107,13 +107,6 @@ export function streamQoder(
const email = cachedCreds?.email || "user@qoder.com";
const machineID = cachedCreds?.machineID || getMachineId();
// Passively rebuild the models cache if it's missing or stale.
// Login/refresh are the only other rebuild triggers, so without this a
// deleted cache file never gets recreated while the token stays valid.
if (isCacheStale()) {
updateQoderModelsCache(accessToken, userID, name, email).catch(() => {});
}
const qoderModel = model.id;
const modelConfig = getCachedModelConfig(qoderModel) || {
key: qoderModel,