Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix([issue-3615]): route cursor on its command before the name-substring arms

Adam Eivy6feff626a377
diff --git a/client/src/utils/providers.js b/client/src/utils/providers.js
index 210817aadb..efb02fe1c5 100644
--- a/client/src/utils/providers.js
+++ b/client/src/utils/providers.js
@@ -178,11 +178,16 @@ export const supportsModelRefresh = (provider) => {
if (isCliProvider(provider)) {
if (isOllamaBackedProvider(provider)) return true;
- if (name.includes('antigravity') || isAntigravityCommand(command)) return true;
// Command-only, matching the server's cursor arm — which deliberately omits
// a name test so an unrelated provider named e.g. "Cursor Notes" doesn't
- // claim a refresh the server would refuse.
+ // claim a refresh the server would refuse. Kept above the name-substring
+ // tests to mirror the server's own ordering (see `_refreshCLIProviderModels`):
+ // there, a renamed "Cursor Claude Opus" must reach the cursor fetcher rather
+ // than the Anthropic one. Ordering is immaterial to this predicate's boolean
+ // result — every arm here returns true — but the mirror is only readable, and
+ // only stays checkable, if it matches the dispatch it claims to mirror.
if (isCursorCommand(command)) return true;
+ if (name.includes('antigravity') || isAntigravityCommand(command)) return true;
// Deliberately the RAW command string, not a basename: the server's claude
// and gemini arms compare `provider.command === 'claude'` exactly. Matching
// on basename here would re-open the same 404 in a new place — a renamed,
diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.js
index 9df1dd8ca8..d286ef9de3 100644
--- a/client/src/utils/providers.test.js
+++ b/client/src/utils/providers.test.js
@@ -818,10 +818,11 @@ describe('supportsModelRefresh', () => {
if (p.type === 'api') return true;
if (p.type === 'cli') {
if (isOllamaBackedProvider(p)) return true;
+ // Command-only, and ABOVE the name tests — the server orders it that way
+ // so a renamed "Cursor Claude Opus" reaches the cursor fetcher.
+ if (isCursorCommand(p.command)) return true;
if (name.includes('claude') || p.command === 'claude') return true;
if (name.includes('antigravity') || isAntigravityCommand(p.command)) return true;
- // Command-only — the server's cursor arm carries no name test.
- if (isCursorCommand(p.command)) return true;
if (name.includes('gemini') || p.command === 'gemini') return true;
return false; // server throws → route 404s
}
diff --git a/server/lib/aiToolkit/providers.js b/server/lib/aiToolkit/providers.js
index 8de60abe1b..eaee9eb963 100644
--- a/server/lib/aiToolkit/providers.js
+++ b/server/lib/aiToolkit/providers.js
@@ -857,6 +857,28 @@ export function createProviderService(config = {}) {
return await this._fetchOllamaToolCapableModels(provider);
}
+ // Cursor is keyed on the command BASENAME — path/exe-tolerant like the
+ // antigravity branch, so a binary configured by absolute path still
+ // refreshes rather than falling through to the throw below while the
+ // client's mirrored gate still offers the button. Unlike every vendor
+ // around it there is deliberately NO name test: "cursor" is an ordinary
+ // English word (a DB cursor, a text cursor), so a `name.includes('cursor')`
+ // clause would hijack the refresh for an unrelated provider the user
+ // happened to name "Cursor Notes".
+ //
+ // It sits ABOVE the name-substring branches on purpose, and the order is
+ // load-bearing: those branches match on the DISPLAY NAME, so a cursor
+ // provider a user renamed "Cursor Claude Opus" or "Cursor Antigravity"
+ // would otherwise be routed to _fetchAnthropicModels / _fetchAntigravityModels
+ // and have that vendor's catalog persisted onto it — ids cursor-agent will
+ // reject, written silently because the client (command-keyed) shows the
+ // Refresh button. An exact command match is a stronger identity signal
+ // than a name substring, so it must win. Same reasoning that already puts
+ // the ollama check first.
+ if (isCursorCommand(provider.command)) {
+ return await this._fetchCursorModels(provider);
+ }
+
if (providerName.includes('claude') || provider.command === 'claude') {
return await this._fetchAnthropicModels(provider);
}
@@ -870,17 +892,6 @@ export function createProviderService(config = {}) {
return await this._fetchAntigravityModels(provider);
}
- // Keyed on the command basename for the same reason as the antigravity
- // branch: a path- or `.exe`-configured binary must still refresh, or the
- // client's mirrored gate offers a Refresh button that falls through to the
- // throw below. Unlike every vendor around it there is deliberately NO name
- // test — "cursor" is an ordinary English word (a DB cursor, a text
- // cursor), so a `name.includes('cursor')` clause would hijack the refresh
- // for an unrelated provider the user happened to name "Cursor Notes".
- if (isCursorCommand(provider.command)) {
- return await this._fetchCursorModels(provider);
- }
-
if (providerName.includes('gemini') || provider.command === 'gemini') {
return await this._fetchGeminiModels(provider);
}
diff --git a/server/lib/aiToolkit/providers.test.js b/server/lib/aiToolkit/providers.test.js
index a44aa60ecd..cfc395f751 100644
--- a/server/lib/aiToolkit/providers.test.js
+++ b/server/lib/aiToolkit/providers.test.js
@@ -930,6 +930,25 @@ describe('Provider Service', () => {
expect(after.models).toEqual(stored);
});
+ // Regression: the command-keyed cursor branch must sit ABOVE the
+ // name-substring branches. When it sat below them, a cursor provider the
+ // user renamed "Cursor Claude Opus" matched `name.includes('claude')` first
+ // and had Anthropic's 15 static ids persisted onto it — ids cursor-agent
+ // rejects — written silently, because the client's gate is command-keyed and
+ // showed the Refresh button.
+ it.skipIf(process.platform === 'win32')('routes on the command even when the NAME contains another vendor', async () => {
+ const command = await writeFakeCursor(SAMPLE);
+ for (const name of ['Cursor Claude Opus', 'Cursor Antigravity', 'Cursor Gemini 3.5']) {
+ const p = await providerService.createProvider({
+ name, type: 'cli', command, models: ['auto'], defaultModel: 'auto',
+ });
+ const updated = await providerService.refreshProviderModels(p.id);
+ expect(updated, `${name}: refresh returned null`).not.toBeNull();
+ expect(updated.models, `${name}: got another vendor's catalog`).toContain('gpt-5.3-codex-low');
+ expect(updated.models).not.toContain('claude-opus-5');
+ }
+ });
+
it('does not hijack an unrelated provider that merely has "cursor" in its name', async () => {
// The cursor arm is command-keyed on purpose — "cursor" is an ordinary
// English word, so a name test would claim a refresh for a provider whose