feat(cli): Display user identity (auth, email, tier) on startup (#17591)

Co-authored-by: Keith Guerin <keithguerin@gmail.com>
Co-authored-by: Yuna Seol <yunaseol@google.com>
This commit is contained in:
Yuna Seol
2026-01-29 00:07:52 -05:00
committed by GitHub
parent 6d36219e55
commit 7f066fd3a7
5 changed files with 287 additions and 2 deletions

View File

@@ -219,4 +219,40 @@ describe('useHistoryManager', () => {
expect(result.current.history[0].id).toBeGreaterThanOrEqual(before + 1);
expect(result.current.history[0].id).toBeLessThanOrEqual(after + 1);
});
describe('initialItems with auth information', () => {
it('should initialize with auth information', () => {
const email = 'user@example.com';
const tier = 'Pro';
const authMessage = `Authenticated as: ${email} (Plan: ${tier})`;
const initialItems: HistoryItem[] = [
{
id: 1,
type: 'info',
text: authMessage,
},
];
const { result } = renderHook(() => useHistory({ initialItems }));
expect(result.current.history).toHaveLength(1);
expect(result.current.history[0].text).toBe(authMessage);
});
it('should add items with auth information via addItem', () => {
const { result } = renderHook(() => useHistory());
const email = 'user@example.com';
const tier = 'Pro';
const authMessage = `Authenticated as: ${email} (Plan: ${tier})`;
act(() => {
result.current.addItem({
type: 'info',
text: authMessage,
});
});
expect(result.current.history).toHaveLength(1);
expect(result.current.history[0].text).toBe(authMessage);
expect(result.current.history[0].type).toBe('info');
});
});
});

View File

@@ -36,10 +36,12 @@ export interface UseHistoryManagerReturn {
*/
export function useHistory({
chatRecordingService,
initialItems = [],
}: {
chatRecordingService?: ChatRecordingService | null;
initialItems?: HistoryItem[];
} = {}): UseHistoryManagerReturn {
const [history, setHistory] = useState<HistoryItem[]>([]);
const [history, setHistory] = useState<HistoryItem[]>(initialItems);
const messageIdCounterRef = useRef(0);
// Generates a unique message ID based on a timestamp and a counter.