-
Notifications
You must be signed in to change notification settings - Fork 253
refactor: retire 'fake' from the live backend surface #3249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e1b0e67
refactor: retire 'fake' from the live backend surface
Astro-Han 3356b6c
fix(desktop): stop the pending chat view from claiming a retired backend
Astro-Han 2ddb813
refactor(core): give provider recognition one own-property-safe owner
Astro-Han 798e392
fix: stop promising a rebind that retired-backend sessions cannot take
Astro-Han ad908a4
fix(desktop): keep the pending chat view from naming a model it canno…
Astro-Han 33a5519
fix: refuse the retired backend on Automation writes, not just at act…
Astro-Han 6295359
refactor: stop letting callers choose a session backend
Astro-Han File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
apps/desktop/src/main/__tests__/pending-session-view.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import assert from 'node:assert/strict'; | ||
| import test from 'node:test'; | ||
| import { pendingSessionView } from '../../renderer/pending-session-view.js'; | ||
|
|
||
| test('the pending chat view names no connection or model it cannot know', () => { | ||
| const view = pendingSessionView({ | ||
| sessionId: 'session-1', | ||
| name: '新任务', | ||
| permissionMode: 'ask', | ||
| }); | ||
|
|
||
| // #3211: the placeholder used to claim `backend: 'fake'` / `model: | ||
| // 'fake-model'`, borrowing a retired backend to mean "not loaded". | ||
| assert.equal(view.backend, 'ai-sdk'); | ||
| assert.equal(view.id, 'session-1'); | ||
| assert.equal(view.permissionMode, 'ask'); | ||
| assert.equal(view.connectionLocked, false); | ||
|
|
||
| // The empty pair is load-bearing: this fallback covers any active id whose | ||
| // summary has not arrived, so naming a plausible connection/model would let | ||
| // the model switcher drop a real switch onto that model as a no-op against a | ||
| // session that was never on it. | ||
| assert.equal(view.llmConnectionSlug, ''); | ||
| assert.equal(view.model, ''); | ||
| }); | ||
|
|
||
| test('the pending chat view matches no offered model choice', () => { | ||
| const view = pendingSessionView({ | ||
| sessionId: 'session-2', | ||
| name: '新任务', | ||
| permissionMode: 'execute', | ||
| }); | ||
| const offered = [ | ||
| { connectionSlug: 'anthropic', model: 'claude-sonnet-4-5-20250929' }, | ||
| { connectionSlug: 'openai', model: 'gpt-5' }, | ||
| ]; | ||
|
|
||
| assert.equal( | ||
| offered.some( | ||
| (choice) => | ||
| choice.connectionSlug === view.llmConnectionSlug && choice.model === view.model, | ||
| ), | ||
| false, | ||
| ); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import type { PermissionMode } from '@maka/core/permission'; | ||
| import type { SessionSummary } from '@maka/core/session'; | ||
|
|
||
| export interface PendingSessionViewInput { | ||
| sessionId: string; | ||
| name: string; | ||
| permissionMode: PermissionMode; | ||
| } | ||
|
|
||
| /** | ||
| * The `SessionSummary` the chat view shows between "a session id became active" | ||
| * and "its real summary arrived". | ||
| * | ||
| * The connection and model read empty because they are genuinely unknown: this | ||
| * fallback covers every active id without a loaded summary, not just a freshly | ||
| * created task, so the session behind it may be an existing one bound to any | ||
| * model. An empty pair matches no offered choice, which is how the model | ||
| * switcher's current-value and no-op comparisons read "not yet known" — naming | ||
| * a plausible model instead would let a switch onto that model be silently | ||
| * dropped as a no-op against a session that was never on it. | ||
| * | ||
| * It used to say `backend: 'fake'` / `model: 'fake-model'`, borrowing a retired | ||
| * backend (#3211) to mean "not loaded". The unknown-ness is the same; the | ||
| * borrowed name is gone. | ||
| */ | ||
| export function pendingSessionView(input: PendingSessionViewInput): SessionSummary { | ||
| return { | ||
| id: input.sessionId, | ||
| name: input.name, | ||
| isFlagged: false, | ||
| isArchived: false, | ||
| labels: [], | ||
| hasUnread: false, | ||
| status: 'active', | ||
| backend: 'ai-sdk', | ||
| llmConnectionSlug: '', | ||
| connectionLocked: false, | ||
| model: '', | ||
| permissionMode: input.permissionMode, | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.