Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d516ea5
feat: Add session persistence and fix serialization issues
JiechengZhao Jul 12, 2025
c13a784
feat(cli): Refactor session persistence into a dedicated hook
JiechengZhao Jul 13, 2025
158d669
refactor(session): use async file loading for session persistence
JiechengZhao Jul 14, 2025
8fbf19a
refactor(session): update tests to use integration testing
JiechengZhao Jul 14, 2025
706899f
fix(session): Add array validation for loaded session history
JiechengZhao Jul 15, 2025
d3bdf41
fix(session): Assign unique IDs to loaded history items
JiechengZhao Jul 15, 2025
86100ac
fix(session): Import HistoryItemUser and HistoryItemGemini for type c…
JiechengZhao Jul 15, 2025
34bb111
fix(session): Add length check before calling loadHistory
JiechengZhao Jul 15, 2025
36226e4
fix(session): Remove misleading error log for malformed history items
JiechengZhao Jul 15, 2025
56acc2a
refactor(session): Optimize useEffect with useRef for history state
JiechengZhao Jul 15, 2025
b6ac52f
fix(session): Improve error handling for saving session history
JiechengZhao Jul 16, 2025
76556b0
Update packages/cli/src/ui/hooks/useSessionPersistence.ts
JiechengZhao Jul 16, 2025
73fefb3
fix(session): Merge loaded history with current history to prevent da…
JiechengZhao Jul 16, 2025
868575b
fix(session): Handle race condition in loadSession and improve saving…
JiechengZhao Jul 16, 2025
fb1f7c6
fix(cli): remove duplicate line in useSessionPersistence.ts
JiechengZhao Jul 17, 2025
baf2eee
feat: Add session persistence and onLoadComplete callback
JiechengZhao Jul 22, 2025
09527e9
Update packages/cli/src/ui/hooks/useSessionPersistence.ts
JiechengZhao Jul 22, 2025
057f172
Refactor: Store session file in user's home directory
JiechengZhao Jul 23, 2025
d0aa799
fix test
JiechengZhao Jul 23, 2025
90b7c5a
fix onloadComplete
JiechengZhao Jul 23, 2025
2a3f773
Merge branch 'main' into feat/session-persistence
JiechengZhao Jul 23, 2025
b4a1a14
Merge branch 'main' into feat/session-persistence
JiechengZhao Jul 27, 2025
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ packages/*/coverage/
packages/cli/src/generated/
.integration-tests/
packages/vscode-ide-companion/*.vsix

tmp_run_preflight_without_proxy.sh
4 changes: 4 additions & 0 deletions packages/cli/src/config/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ describe('loadCliConfig', () => {
vi.resetAllMocks();
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
process.env.GEMINI_API_KEY = 'test-api-key'; // Ensure API key is set for tests
delete process.env.https_proxy;
delete process.env.http_proxy;
delete process.env.HTTPS_PROXY;
delete process.env.HTTP_PROXY;
});

afterEach(() => {
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/config/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export interface Settings {

// Add other settings here.
ideMode?: boolean;
'session.persistence'?: boolean;
memoryDiscoveryMaxDirs?: number;
}

Expand Down
19 changes: 16 additions & 3 deletions packages/cli/src/ui/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ import { HistoryItemDisplay } from './components/HistoryItemDisplay.js';
import { ContextSummaryDisplay } from './components/ContextSummaryDisplay.js';
import { IDEContextDetailDisplay } from './components/IDEContextDetailDisplay.js';
import { useHistory } from './hooks/useHistoryManager.js';
import { useSessionPersistence } from './hooks/useSessionPersistence.js';
import process from 'node:process';

import {
getErrorMessage,
type Config,
Expand Down Expand Up @@ -118,6 +120,15 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
}, []);

const { history, addItem, clearItems, loadHistory } = useHistory();
const sessionPersistence = settings.merged['session.persistence'];
const [sessionLoaded, setSessionLoaded] = useState(false);
const onLoadComplete = useCallback(() => setSessionLoaded(true), []);
useSessionPersistence({
sessionPersistence,
history,
loadHistory,
onLoadComplete,
});
const {
consoleMessages,
handleNewMessage,
Expand Down Expand Up @@ -698,6 +709,7 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
if (
initialPrompt &&
!initialPromptSubmitted.current &&
sessionLoaded &&
!isAuthenticating &&
!isAuthDialogOpen &&
!isThemeDialogOpen &&
Expand All @@ -711,6 +723,7 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
}, [
initialPrompt,
submitQuery,
sessionLoaded,
isAuthenticating,
isAuthDialogOpen,
isThemeDialogOpen,
Expand All @@ -722,7 +735,7 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
if (quittingMessages) {
return (
<Box flexDirection="column" marginBottom={1}>
{quittingMessages.map((item) => (
{quittingMessages.map((item: HistoryItem) => (
<HistoryItemDisplay
key={item.id}
availableTerminalHeight={
Expand Down Expand Up @@ -776,7 +789,7 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
)}
{!settings.merged.hideTips && <Tips config={config} />}
</Box>,
...history.map((h) => (
...history.map((h: HistoryItem) => (
<HistoryItemDisplay
terminalWidth={mainAreaWidth}
availableTerminalHeight={staticAreaMaxItemHeight}
Expand All @@ -788,7 +801,7 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
)),
]}
>
{(item) => item}
{(item: React.ReactNode) => item}
</Static>
<OverflowProvider>
<Box ref={pendingHistoryItemRef} flexDirection="column">
Expand Down
Loading