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
1 change: 1 addition & 0 deletions packages/cli/src/config/config.loadMemory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ describe('loadCliConfig memory discovery', () => {
promptWords: [],
set: undefined,
query: undefined,
continue: undefined,
};

const { ExtensionEnablementManager, ExtensionStorage } =
Expand Down
10 changes: 10 additions & 0 deletions packages/cli/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export interface CliArgs {
promptWords: string[] | undefined;
query: string | undefined;
set: string[] | undefined;
continue: boolean | undefined;
}

export async function parseArguments(settings: Settings): Promise<CliArgs> {
Expand Down Expand Up @@ -354,6 +355,13 @@ export async function parseArguments(settings: Settings): Promise<CliArgs> {
description: 'Dump request body to ~/.llxprt/dumps/ on API errors.',
default: false,
})
.option('continue', {
alias: 'C',
type: 'boolean',
description:
'Resume the most recent session for this project. Can be combined with --prompt to continue with a new message.',
default: false,
})
.deprecateOption(
'telemetry',
'Use settings.json instead. This flag will be removed in a future version.',
Expand Down Expand Up @@ -640,6 +648,7 @@ export async function parseArguments(settings: Settings): Promise<CliArgs> {
promptWords: result.promptWords as string[] | undefined,
query: queryFromPromptWords,
set: result.set as string[] | undefined,
continue: result.continue as boolean | undefined,
};

return cliArgs;
Expand Down Expand Up @@ -1317,6 +1326,7 @@ export async function loadCliConfig(
shouldUseNodePtyShell: effectiveSettings.shouldUseNodePtyShell,
enablePromptCompletion: effectiveSettings.enablePromptCompletion ?? false,
eventEmitter: appEvents,
continueSession: argv.continue ?? false,
});

const enhancedConfig = config;
Expand Down
47 changes: 47 additions & 0 deletions packages/cli/src/gemini.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ import {
SettingsService,
DebugLogger,
ProfileManager,
SessionPersistenceService,
type PersistedSession,
} from '@vybestack/llxprt-code-core';
import { themeManager } from './ui/themes/theme-manager.js';
import { getStartupWarnings } from './utils/startupWarnings.js';
Expand Down Expand Up @@ -218,6 +220,50 @@ export async function startInteractiveUI(
workspaceRoot: string,
) {
const version = await getCliVersion();

// Load previous session if --continue flag was used
let restoredSession: PersistedSession | null = null;
const initialPrompt = config.getQuestion();

if (config.isContinueSession()) {
const persistence = new SessionPersistenceService(
config.storage,
config.getSessionId(),
);
restoredSession = await persistence.loadMostRecent();

if (restoredSession) {
const formattedTime =
SessionPersistenceService.formatSessionTime(restoredSession);

if (initialPrompt) {
// User provided both --continue and --prompt
console.log(chalk.cyan(`Resuming session from ${formattedTime}`));
const truncatedPrompt =
initialPrompt.length > 50
? `${initialPrompt.slice(0, 50)}...`
: initialPrompt;
console.log(
chalk.dim(
`Your prompt "${truncatedPrompt}" will be submitted after session loads.`,
),
);
} else {
console.log(chalk.green(`Resumed session from ${formattedTime}`));
}
} else {
if (initialPrompt) {
console.log(
chalk.yellow(
'No previous session found. Starting fresh with your prompt.',
),
);
} else {
console.log(chalk.yellow('No previous session found. Starting fresh.'));
}
}
}

// Detect and enable Kitty keyboard protocol once at startup
await detectAndEnableKittyProtocol();
setWindowTitle(basename(workspaceRoot), settings);
Expand Down Expand Up @@ -257,6 +303,7 @@ export async function startInteractiveUI(
settings={settings}
startupWarnings={startupWarnings}
version={version}
restoredSession={restoredSession ?? undefined}
/>
</SettingsContext.Provider>
</ErrorBoundary>
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/ui/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { useReducer } from 'react';
import type { Config } from '@vybestack/llxprt-code-core';
import type { Config, PersistedSession } from '@vybestack/llxprt-code-core';
import type { LoadedSettings } from '../config/settings.js';
import { KeypressProvider } from './contexts/KeypressContext.js';
import { MouseProvider } from './contexts/MouseContext.js';
Expand All @@ -28,6 +28,7 @@ interface AppProps {
settings: LoadedSettings;
startupWarnings?: string[];
version: string;
restoredSession?: PersistedSession;
}

/**
Expand Down
Loading
Loading