fix: address round-4 review findings
- apply(): if a newer invocation changed the catalog while this one awaited the model refresh, exit silently. The superseded invocation otherwise reported the second's catalog in its notice and could fire one extra setModel. Pinned with a deferred-refresh test. - CITATION.cff: drop date-released while the CHANGELOG is [Unreleased] and no release tag exists; version stays 0.1.0. - Tests: 18 (was 17).
This commit is contained in:
1 parent
8d91094022
commit
78e89241a6
3 files changed
+17
-3
No files matched your search
@@ -9,7 +9,6 @@ authors:
|
||||
family-names: "Kucera"
|
||||
email: a.kucera@babylondreams.de
|
||||
version: 0.1.0
|
||||
date-released: "2026-11-25"
|
||||
abstract: >-
|
||||
Nous Portal provider extension for the pi coding agent: subscription
|
||||
device-code OAuth and API-key auth against the Nous inference API,
|
||||
|
||||
@@ -277,6 +277,8 @@ export default function nousPortal(pi: ExtensionAPI) {
|
||||
else writeFileSync(flagPath, next);
|
||||
catalog = next;
|
||||
await ctx.modelRegistry.refresh({ providers: [PROVIDER_ID] });
|
||||
// A newer invocation may have changed the catalog while we awaited; it reports the final state, so stay silent.
|
||||
if (catalog !== next) return;
|
||||
const shown = ctx.modelRegistry.getAvailable().filter((m) => m.provider === PROVIDER_ID && inCatalog(m));
|
||||
// Keep the session usable only when a Nous model just got filtered out; a session on another provider
|
||||
// is left alone, and the notice names the model actually in use, not the first hit.
|
||||
|
||||
+15
-2
@@ -150,10 +150,10 @@ const drive = (flag) => {
|
||||
registerProvider: (input) => Object.assign(provider, input),
|
||||
setModel: async (model) => switched.push(model),
|
||||
});
|
||||
const run = (name, model, available) =>
|
||||
const run = (name, model, available, refresh = async () => {}) =>
|
||||
commands[name].handler("", {
|
||||
model,
|
||||
modelRegistry: { refresh: async () => {}, getAvailable: () => available },
|
||||
modelRegistry: { refresh, getAvailable: () => available },
|
||||
ui: { notify: (message) => notes.push(message) },
|
||||
});
|
||||
return { run, provider, switched, notes };
|
||||
@@ -217,6 +217,19 @@ test("/nous-catalog cycles full → free → promo → full", async () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("overlapping catalog switches: the invocation superseded while awaiting a slow refresh stays silent", async () => {
|
||||
const { run, switched, notes } = drive();
|
||||
const all = [nous("free-a", "free"), nous("promo-a", "promo"), nous("paid")];
|
||||
let release;
|
||||
const gate = new Promise((resolve) => (release = resolve));
|
||||
const first = run("nous-free", undefined, all, () => gate); // apply("free"), then awaits a slow refresh
|
||||
await run("nous-catalog", undefined, all); // reads catalog "free" → applies "promo", refresh resolves at once
|
||||
release();
|
||||
await first;
|
||||
assert.deepEqual(notes.map((n) => n.split(" ")[2]), ["promo"]);
|
||||
assert.deepEqual(switched, []);
|
||||
});
|
||||
|
||||
test("a saved catalog survives restart; a corrupted flag falls back to full", () => {
|
||||
const all = [nous("free-a", "free"), nous("promo-a", "promo"), nous("paid")];
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user