Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

fix(coding-agent): refresh the model catalog whenever the model picker opens (#2504)

sirouk59ccdd0021bd
diff --git a/packages/coding-agent/.changes/model-picker-refresh-on-open.md b/packages/coding-agent/.changes/model-picker-refresh-on-open.md
new file mode 100644
index 0000000000..dcc7c8a972
--- /dev/null
+++ b/packages/coding-agent/.changes/model-picker-refresh-on-open.md
@@ -0,0 +1 @@
+- Fixed the model picker showing a stale model list for up to a minute when opened without a search term (Ctrl+L or plain `/model`); it now always refreshes the catalog on open ([#2504](https://github.com/PrimeIntellect-ai/prime-agent/pull/2504) by [@sirouk](https://github.com/sirouk)).
diff --git a/packages/coding-agent/src/modes/interactive/interactive-mode.ts b/packages/coding-agent/src/modes/interactive/interactive-mode.ts
index 618cadfd7d..2467e32d7d 100644
--- a/packages/coding-agent/src/modes/interactive/interactive-mode.ts
+++ b/packages/coding-agent/src/modes/interactive/interactive-mode.ts
@@ -9132,7 +9132,7 @@ export class InteractiveMode {
this.editorContainer.addChild(menu);
focus();
this.ui.requestRender();
- refreshModels(initialModelSearch !== undefined);
+ refreshModels(true);
});
}
diff --git a/packages/coding-agent/test/suite/regressions/2182-picker-selection.test.ts b/packages/coding-agent/test/suite/regressions/2182-picker-selection.test.ts
index 8797f95064..13fa240f84 100644
--- a/packages/coding-agent/test/suite/regressions/2182-picker-selection.test.ts
+++ b/packages/coding-agent/test/suite/regressions/2182-picker-selection.test.ts
@@ -187,6 +187,31 @@ it("toggles model scope instead of typing when Option+S arrives as the composed
await done;
});
+it("refreshes a fresh model catalog when the picker opens without a search", async () => {
+ const f = await fixture();
+ const plain = f.harness.getModel("plain")!;
+ const getModelCatalog = vi.fn(async () => ({ models: [f.model, plain], configuredProviders: [plain.provider] }));
+ const prototype = InteractiveMode.prototype as unknown as Record<string, (...args: unknown[]) => unknown>;
+ const refresh = vi.fn(prototype.getModelSelectorRefreshPromise);
+ Object.assign(f.mode, {
+ agentConnection: { getModelCatalog },
+ connectionModelCatalog: [f.model],
+ connectionModelsFetchedAt: Date.now(),
+ connectionModelsRefreshVersion: 0,
+ getCurrentModel: () => f.model,
+ getCachedModelCandidates: prototype.getCachedModelCandidates,
+ getModelSelectorRefreshPromise: refresh,
+ });
+ const done = f.mode.showConfigurationMenu("models");
+ const listed = () => stripAnsi(f.menu().render(100).join("\n"));
+ expect(listed()).not.toContain("Plain");
+ expect(getModelCatalog).toHaveBeenCalledOnce();
+ await refresh.mock.results[0]?.value;
+ expect(listed()).toContain("Plain");
+ f.menu().handleInput("\x1b");
+ await done;
+});
+
it("does not publish the removed configuration tab action", () => {
expect(Object.keys(KEYBINDINGS)).not.toContain("app.configuration.previousTab");
});