The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): restored background tabs resolve their session title without a click
Teknium8d6a286fe848
diff --git a/apps/desktop/src/app/chat/session-tile.test.ts b/apps/desktop/src/app/chat/session-tile.test.tsindex 3b932138555..46bd2f40434 100644--- a/apps/desktop/src/app/chat/session-tile.test.ts+++ b/apps/desktop/src/app/chat/session-tile.test.ts@@ -1,6 +1,9 @@-import { describe, expect, it } from 'vitest'+import { afterEach, describe, expect, it, vi } from 'vitest'-import { sessionTileResumeFailure } from './session-tile'+import { $gatewayState, $sessions, setSessions } from '@/store/session'+import { $sessionTiles } from '@/store/session-states'++import { sessionTileResumeFailure, startUnrestoredTileTitleBackfill } from './session-tile'describe('sessionTileResumeFailure', () => {it('keeps a confirmed durable session retryable instead of repeating a stale 404', () => {@@ -17,3 +20,43 @@ describe('sessionTileResumeFailure', () => {expect(sessionTileResumeFailure('session not found', true, false)).toBeUndefined()})})++describe('startUnrestoredTileTitleBackfill (#94167)', () => {+ afterEach(() => {+ $gatewayState.set('idle')+ $sessionTiles.set([])+ setSessions([])+ })++ it('backfills unlisted unrestored tiles by id via their ownerRoute once the gateway opens', async () => {+ const ownerRoute = { connectionId: 'conn-a', profile: 'writer' }+ setSessions([{ id: 'listed', title: 'Already listed' } as never])+ $sessionTiles.set([+ { ownerRoute, storedSessionId: 'old-chat' },+ { storedSessionId: 'listed' },+ { runtimeId: 'rt-live', storedSessionId: 'live' },+ { storedSessionId: 'bot', workspaceTabTitle: 'Bot Chat' }+ ])++ const lookup = vi.fn(async (id: string) => {+ const row = { id, title: 'Quarterly review' } as never+ setSessions(prev => [row, ...prev])++ return row+ })++ const stop = startUnrestoredTileTitleBackfill(lookup as never)+ expect(lookup).not.toHaveBeenCalled()++ $gatewayState.set('open')+ await vi.waitFor(() => expect(lookup).toHaveBeenCalledTimes(1))+ expect(lookup).toHaveBeenCalledWith('old-chat', ownerRoute)+ expect($sessions.get().find(row => row.id === 'old-chat')?.title).toBe('Quarterly review')++ // One-shot: a later reconnect does not re-probe.+ $gatewayState.set('idle')+ $gatewayState.set('open')+ expect(lookup).toHaveBeenCalledTimes(1)+ stop()+ })+})diff --git a/apps/desktop/src/app/chat/session-tile.tsx b/apps/desktop/src/app/chat/session-tile.tsxindex 46e5a180c78..30291a5ecee 100644--- a/apps/desktop/src/app/chat/session-tile.tsx+++ b/apps/desktop/src/app/chat/session-tile.tsx@@ -478,6 +478,33 @@ export function tileStoredRow(storedSessionId: string): SessionInfo | undefined)}+/** One-shot by-id title fill for restored tiles that never mount (#94167).+ * A restored background tab has no runtimeId and does not mount its pane, so+ * the resolution effect above never runs; when its row is outside the recents+ * page and project tree, `tileTitle()` reads "New session" until first click.+ * `resolveStoredSession` upserts the row into `$sessions`, which the tab strip+ * already watches — nothing is persisted. Runs once the gateway can answer. */+export function startUnrestoredTileTitleBackfill(lookup = resolveStoredSession): () => void {+ const run = () => {+ if ($gatewayState.get() !== 'open') {+ return+ }++ off()++ for (const tile of $sessionTiles.get()) {+ if (!tile.runtimeId && !tile.workspaceTabTitle && !tileStoredRow(tile.storedSessionId)) {+ void lookup(tile.storedSessionId, tile.ownerRoute).catch(() => undefined)+ }+ }+ }++ const off = $gatewayState.listen(run)+ run()++ return off+}+/** The tab's REGISTERED name. Deliberately the bare placeholder for a draft* rather than its live composer title (`tabTitle` renders that): re-registering* per keystroke would re-render the strip, and holding the draft's text herediff --git a/apps/desktop/src/app/contrib/controller.tsx b/apps/desktop/src/app/contrib/controller.tsxindex ad30d21f666..a1fa39755bf 100644--- a/apps/desktop/src/app/contrib/controller.tsx+++ b/apps/desktop/src/app/contrib/controller.tsx@@ -84,6 +84,7 @@ import { startSessionDrag } from '../chat/session-drag'import {SessionTileCloseConfirm,stackSessionTilesIntoMain,+ startUnrestoredTileTitleBackfill,watchSessionTiles,WorkspaceTabMenu} from '../chat/session-tile'@@ -459,6 +460,7 @@ watchContributedPanes()// into the transparent overlay).if (!isBrowserWindow() && !isHudWindow()) {watchSessionTiles()+ startUnrestoredTileTitleBackfill()watchRouteTiles()watchPreviewTiles()}