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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: close three temporary-route gaps found in review (#6285)
[._.]/ Adam Eivydbd772c3da55
diff --git a/client/src/components/cos/PersistentMindRoutePanel.jsx b/client/src/components/cos/PersistentMindRoutePanel.jsxindex 49d375cde0..1809e5a57e 100644--- a/client/src/components/cos/PersistentMindRoutePanel.jsx+++ b/client/src/components/cos/PersistentMindRoutePanel.jsx@@ -47,11 +47,16 @@ export default function PersistentMindRoutePanel({const activeProvider = activeRoute?.providerId? providers.find((provider) => provider.id === activeRoute.providerId) || null: null;- // Editing a preset while a message that selected it is still in flight is a- // refusal, not a route swap — the server re-validates the accepted route- // against the saved one. Say so here rather than letting the turn fail with- // no explanation on the page that offered the edit.+ // Editing or deleting a preset while a message that selected it is still in+ // flight is a refusal, not a route swap — the server re-validates the+ // accepted route against the saved list. Say so here rather than letting the+ // turn fail with no explanation on the page that offered the edit.+ //+ // `presets` is safe to read as authoritative: it arrives in the same payload+ // as `session`, so a session can never be visible against a not-yet-loaded+ // list.const savedPreset = session ? findMindThinkingPreset(presets, session.presetId) : null;+ const presetRemoved = Boolean(session?.resolvable && !savedPreset);const routeDrifted = Boolean(session?.resolvable && savedPreset && !sameMindRoute(session, savedPreset));const lastTemporary = temporaryMindTurns(turnExecutions).slice(-1)[0] || null;const queuedTemporary = state?.queuedTemporaryMessageCount || 0;@@ -88,6 +93,7 @@ export default function PersistentMindRoutePanel({Borrowing <span className="font-medium">{session.label || session.presetId}</span> for this turn only.{!session.resolvable && ' Its saved route is no longer valid, so this turn will be refused rather than answered on another model.'}{routeDrifted && ' That preset has been edited since this message was accepted, so this turn will be refused — send a new message to authorize its new route.'}+ {presetRemoved && ' That preset has been removed since this message was accepted, so this turn will be refused rather than answered on another model.'}</p>)}diff --git a/client/src/components/cos/tabs/MindTab.jsx b/client/src/components/cos/tabs/MindTab.jsxindex 495d3e37fc..bdcdca3e83 100644--- a/client/src/components/cos/tabs/MindTab.jsx+++ b/client/src/components/cos/tabs/MindTab.jsx@@ -883,7 +883,7 @@ export default function MindTab() {presets={thinkingPresets}turnExecutions={turnExecutions}selectedPresetId={selectedPresetId}- onReturnToDefault={clearPresetSelection}+ onReturnToDefault={() => selectPreset(null)}onCancelSession={() => runLifecycle('pause')}cancelPending={lifecyclePending === 'pause'}onInspectSession={inspectSession}diff --git a/client/src/components/cos/tabs/MindTab.temporaryRoute.test.jsx b/client/src/components/cos/tabs/MindTab.temporaryRoute.test.jsxindex 2a9d76ed0e..b803abe86b 100644--- a/client/src/components/cos/tabs/MindTab.temporaryRoute.test.jsx+++ b/client/src/components/cos/tabs/MindTab.temporaryRoute.test.jsx@@ -215,6 +215,54 @@ describe('MindTab temporary thinking sessions', () => {expect(second.thinkingPreset).toEqual(first.thinkingPreset);});+ it('retires the frozen route when Return to default is used after a failed send', async () => {+ const user = userEvent.setup();+ api.sendPersistentMindMessage.mockRejectedValueOnce(new Error('Network unavailable'));+ renderTab();+ await composerLoaded();++ await user.selectOptions(screen.getByLabelText('Send with another model'), 'deep-think');+ await user.type(screen.getByLabelText('Message'), 'Reason carefully.');+ await user.click(screen.getByRole('button', { name: 'Send with Deep think' }));+ await waitFor(() => expect(screen.getByText(/Network unavailable/)).toBeTruthy());++ // The route panel's Return to default must retire the frozen draft route,+ // not merely drop the URL param — otherwise the retry below re-submits the+ // paid route the user just stepped away from, under the reused id.+ const panel = screen.getByRole('region', { name: 'Thinking route' });+ await user.click(within(panel).getByRole('button', { name: /Return to default/ }));++ await waitFor(() => expect(screen.getByRole('button', { name: 'Send message' })).toBeTruthy());+ await user.click(screen.getByRole('button', { name: 'Send message' }));++ await waitFor(() => expect(api.sendPersistentMindMessage).toHaveBeenCalledTimes(2));+ const [first] = api.sendPersistentMindMessage.mock.calls[0];+ const [second] = api.sendPersistentMindMessage.mock.calls[1];+ expect(second.thinkingPresetId).toBeUndefined();+ expect(second.thinkingPreset).toBeUndefined();+ // A different route is a different request, so it cannot wear the same key.+ expect(second.id).not.toBe(first.id);+ });++ it('warns that an in-flight session will be refused once its preset is deleted', async () => {+ api.getPersistentMind.mockResolvedValue(response({+ thinkingPresets: { schemaVersion: 1, presets: [] },+ state: {+ ...response().state,+ status: 'thinking',+ activeTurnId: 'turn-1',+ activeRoute: { providerId: 'example-cloud', model: 'example-large', effort: 'high' },+ activeThinkingSession: {+ presetId: 'deep-think', label: 'Deep think', providerId: 'example-cloud', model: 'example-large', effort: 'high', resolvable: true,+ },+ },+ }));+ renderTab();++ const panel = await screen.findByRole('region', { name: 'Thinking route' });+ await waitFor(() => expect(within(panel).getByText(/has been removed since this message was accepted/)).toBeTruthy());+ });+it('shows the actual running route beside the default and cancels through the lifecycle API', async () => {const user = userEvent.setup();api.getPersistentMind.mockResolvedValue(response({diff --git a/client/src/lib/mindThinkingPresets.js b/client/src/lib/mindThinkingPresets.jsindex 5dd9803360..f4ecd0bbcb 100644--- a/client/src/lib/mindThinkingPresets.js+++ b/client/src/lib/mindThinkingPresets.js@@ -203,15 +203,19 @@ const TERMINAL_TURN_STATUSES = Object.freeze(['completed', 'failed', 'denied', '/*** Terminal outcome of one turn, from its own status when it has one and- * otherwise from its last receipt. A turn that is still running reads as- * `running`, never as a silent success.+ * otherwise from its last receipt.+ *+ * A turn that has not finished reads as `running` REGARDLESS of its receipts.+ * A turn spans bounded tool rounds, so round 0 can report `completed` while+ * the turn is still working — consulting the last receipt first would call an+ * in-flight turn finished, and the caller renders that as a terminal outcome.*/export function mindTurnOutcome(turn) {if (TERMINAL_TURN_STATUSES.includes(turn?.status)) return turn.status;- const calls = Array.isArray(turn?.calls) ? turn.calls : [];+ if (!turn?.completedAt) return 'running';+ const calls = Array.isArray(turn.calls) ? turn.calls : [];const last = calls[calls.length - 1];- if (TERMINAL_TURN_STATUSES.includes(last?.outcome)) return last.outcome;- return turn?.completedAt ? 'completed' : 'running';+ return TERMINAL_TURN_STATUSES.includes(last?.outcome) ? last.outcome : 'completed';}/**diff --git a/client/src/lib/mindThinkingPresets.test.js b/client/src/lib/mindThinkingPresets.test.jsindex 5b4feb49dc..fffee1127d 100644--- a/client/src/lib/mindThinkingPresets.test.js+++ b/client/src/lib/mindThinkingPresets.test.js@@ -70,8 +70,20 @@ describe('mindTurnOutcome / mindTurnElapsedMs', () => {expect(mindTurnElapsedMs({ turnId: 't', startedAt: '2026-09-01T00:00:00.000Z', calls: [] })).toBeNull();});- it('falls back to the last receipt when the turn carries no terminal status', () => {- const turn = { turnId: 't', status: 'thinking', calls: [{ outcome: 'completed', elapsedMs: 40 }, { outcome: 'denied', elapsedMs: 2 }] };+ it('keeps an in-flight multi-round turn running after an early round completes', () => {+ // A turn spans bounded tool rounds. Round 0 reporting `completed` is not a+ // finished turn, and the caller renders the answer as terminal.+ const turn = { turnId: 't', status: 'thinking', completedAt: null, calls: [{ outcome: 'completed', elapsedMs: 40 }] };+ expect(mindTurnOutcome(turn)).toBe('running');+ });++ it('falls back to the last receipt once the turn has finished', () => {+ const turn = {+ turnId: 't',+ status: 'thinking',+ completedAt: '2026-09-01T00:00:00.000Z',+ calls: [{ outcome: 'completed', elapsedMs: 40 }, { outcome: 'denied', elapsedMs: 2 }],+ };expect(mindTurnOutcome(turn)).toBe('denied');expect(mindTurnElapsedMs(turn)).toBe(42);});