fix: sync generated chat title in header (#10578)

Co-authored-by: Douwe M Osinga <douwe@sidewalklabs.com>
This commit is contained in:
Douwe Osinga
2026-07-27 21:38:17 +02:00
committed by GitHub
parent c95f0e205a
commit af6437ac03
4 changed files with 18 additions and 38 deletions
+10 -27
View File
@@ -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> = {}): 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', () => {
const session = makeSession({
message_count: 0,
user_set_name: false,
recipe: { title: 'Recipe', steps: [] } as unknown as Session['recipe'],
});
expect(shouldShowNewChatTitle(session)).toBe(false);
});
});
describe('getSessionDisplayName (fix for #8865)', () => {
it('returns the normalized session name even when message count metadata is stale', () => {
const session = makeSession({
name: 'Generated title',
user_set_name: false,
message_count: 0,
});
expect(getSessionDisplayName(session)).toBe('Generated title');
});
it('returns the user-set name for a recipe session that has been renamed', () => {
const session = makeSession({
name: 'My Renamed Chat',
@@ -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: {
+2 -3
View File
@@ -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,
-8
View File
@@ -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,