Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 6 additions & 23 deletions ui/desktop/src/__tests__/sessions.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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', () => {
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',
Expand Down
6 changes: 6 additions & 0 deletions ui/desktop/src/acp/__tests__/sessions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
5 changes: 2 additions & 3 deletions ui/desktop/src/acp/sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
8 changes: 0 additions & 8 deletions ui/desktop/src/sessions.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep untitled sessions visible

When ACP omits SessionInfo.title (now normalized to name: '' in sessionInfoToSession), this helper returns an empty string for a non-recipe, non-renamed session. SessionActionsHeader renders that value directly in the top-center title button, so those sessions show a blank header instead of “New Chat” or an untitled placeholder; the old message-count heuristic hid this case. A fallback for an empty session.name would preserve the generated-title fix without blanking untitled sessions.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sessions should never be untitled

}

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,
Expand Down
Loading