diff --git a/ui/desktop/src/__tests__/sessions.test.ts b/ui/desktop/src/__tests__/sessions.test.ts index 42d564460108..9d80ad0ffa5e 100644 --- a/ui/desktop/src/__tests__/sessions.test.ts +++ b/ui/desktop/src/__tests__/sessions.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from 'vitest'; -import { getSessionDisplayName, shouldShowNewChatTitle } from '../sessions'; +import { getSessionDisplayName } from '../sessions'; import { prependUnique } from '../hooks/useNavigationSessions'; import type { SessionListItem } from '../acp/sessions'; import type { Session } from '../types/session'; @@ -30,33 +30,16 @@ function makeListItem(overrides: Partial = {}): SessionListItem }; } -describe('shouldShowNewChatTitle', () => { - it('returns true for an empty session without a user-set name', () => { - const session = makeSession({ message_count: 0, user_set_name: false }); - expect(shouldShowNewChatTitle(session)).toBe(true); - }); - - it('returns false when the session has messages', () => { - const session = makeSession({ message_count: 3, user_set_name: false }); - expect(shouldShowNewChatTitle(session)).toBe(false); - }); - - it('returns false when the user has set a custom name', () => { - const session = makeSession({ message_count: 0, user_set_name: true }); - expect(shouldShowNewChatTitle(session)).toBe(false); - }); - - it('returns false when the session has a recipe', () => { +describe('getSessionDisplayName (fix for #8865)', () => { + it('returns the normalized session name even when message count metadata is stale', () => { const session = makeSession({ - message_count: 0, + name: 'Generated title', user_set_name: false, - recipe: { title: 'Recipe', steps: [] } as unknown as Session['recipe'], + message_count: 0, }); - expect(shouldShowNewChatTitle(session)).toBe(false); + expect(getSessionDisplayName(session)).toBe('Generated title'); }); -}); -describe('getSessionDisplayName (fix for #8865)', () => { it('returns the user-set name for a recipe session that has been renamed', () => { const session = makeSession({ name: 'My Renamed Chat', diff --git a/ui/desktop/src/acp/__tests__/sessions.test.ts b/ui/desktop/src/acp/__tests__/sessions.test.ts index c6ca72620be2..c3437c945d9e 100644 --- a/ui/desktop/src/acp/__tests__/sessions.test.ts +++ b/ui/desktop/src/acp/__tests__/sessions.test.ts @@ -33,6 +33,12 @@ describe('ACP sessions', () => { expect(session.session_type).toBe('scheduled'); }); + it('does not synthesize a title when ACP omits one', () => { + const session = sessionInfoToSession(sessionInfo({ title: undefined })); + + expect(session.name).toBe(''); + }); + it('returns session info refreshed after loading the ACP session', async () => { const loadedSessionInfo = sessionInfo({ _meta: { diff --git a/ui/desktop/src/acp/sessions.ts b/ui/desktop/src/acp/sessions.ts index dc1c18321ec4..e03f82b341ac 100644 --- a/ui/desktop/src/acp/sessions.ts +++ b/ui/desktop/src/acp/sessions.ts @@ -7,7 +7,6 @@ import type { } from '@agentclientprotocol/sdk'; import type { GooseExtension, SessionImportSource } from '@aaif/goose-sdk'; import { getAcpClient } from './acpConnection'; -import { DEFAULT_CHAT_TITLE } from '../contexts/ChatContext'; import type { ExtensionLoadResult } from '../types/extensions'; import type { Session } from '../types/session'; import type { Recipe } from '../recipe'; @@ -93,7 +92,7 @@ export function sessionInfoToSession(s: SessionInfo, loadMeta: LoadSessionMeta = return { id: String(s.sessionId), - name: s.title ?? DEFAULT_CHAT_TITLE, + name: s.title ?? '', working_dir: loadMeta.workingDir ?? s.cwd, created_at: createdAt, updated_at: updatedAt, @@ -116,7 +115,7 @@ function sessionInfoToListItem(s: SessionInfo): SessionListItem { const meta = sessionInfoMeta(s); return { id: String(s.sessionId), - name: s.title ?? DEFAULT_CHAT_TITLE, + name: s.title ?? '', workingDir: s.cwd, updatedAt: s.updatedAt ?? '', messageCount: meta.messageCount ?? 0, diff --git a/ui/desktop/src/sessions.ts b/ui/desktop/src/sessions.ts index 18ad1e670e32..5988b749300a 100644 --- a/ui/desktop/src/sessions.ts +++ b/ui/desktop/src/sessions.ts @@ -1,6 +1,5 @@ import type { Session } from './types/session'; import type { ExtensionConfig } from './types/extensions'; -import { DEFAULT_CHAT_TITLE } from './contexts/ChatContext'; import type { setViewType } from './hooks/useNavigation'; import type { FixedExtensionEntry } from './components/ConfigContext'; import { AppEvents } from './constants/events'; @@ -14,16 +13,9 @@ export function getSessionDisplayName(session: Session): string { if (session.recipe?.title) { return session.recipe.title; } - if (shouldShowNewChatTitle(session)) { - return DEFAULT_CHAT_TITLE; - } return session.name; } -export function shouldShowNewChatTitle(session: Session): boolean { - return !session.user_set_name && session.message_count === 0 && !session.recipe?.title; -} - export function resumeSession(session: Session, setView: setViewType) { const eventDetail = { sessionId: session.id,