mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-31 16:31:08 -07:00
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:
@@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user