mirror of
https://github.com/aaif-goose/goose.git
synced 2026-07-03 14:10:03 +02:00
fix(ui): preserve user-set session name for recipe-based chats (#9079)
Signed-off-by: Douwe Osinga <douwe@squareup.com> Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
committed by
GitHub
parent
66c89db942
commit
12604a8838
@@ -1,5 +1,6 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { shouldShowNewChatTitle } from '../sessions';
|
||||
import { getSessionDisplayName } from '../hooks/useNavigationSessions';
|
||||
import type { Session } from '../api';
|
||||
|
||||
// Helper to build a minimal Session object for testing.
|
||||
@@ -105,3 +106,25 @@ describe('session reuse scoping (fix for #7601)', () => {
|
||||
expect(windowAOld?.id).toBe('empty-a');
|
||||
});
|
||||
});
|
||||
|
||||
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',
|
||||
user_set_name: true,
|
||||
message_count: 2,
|
||||
recipe: { title: 'Some Recipe' } as unknown as Session['recipe'],
|
||||
});
|
||||
expect(getSessionDisplayName(session)).toBe('My Renamed Chat');
|
||||
});
|
||||
|
||||
it('falls back to the recipe title when the user has not renamed', () => {
|
||||
const session = makeSession({
|
||||
name: 'auto-generated',
|
||||
user_set_name: false,
|
||||
message_count: 2,
|
||||
recipe: { title: 'Some Recipe' } as unknown as Session['recipe'],
|
||||
});
|
||||
expect(getSessionDisplayName(session)).toBe('Some Recipe');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -256,6 +256,9 @@ export function useNavigationSessions(options: UseNavigationSessionsOptions = {}
|
||||
}
|
||||
|
||||
export function getSessionDisplayName(session: Session): string {
|
||||
if (session.user_set_name) {
|
||||
return session.name;
|
||||
}
|
||||
if (session.recipe?.title) {
|
||||
return session.recipe.title;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user