mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
Session-Level Conversation History Management (#1113)
This commit is contained in:
@@ -12,7 +12,6 @@ import {
|
||||
logUserPrompt,
|
||||
} from '@qwen-code/qwen-code-core';
|
||||
import { render } from 'ink';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import dns from 'node:dns';
|
||||
import os from 'node:os';
|
||||
import { basename } from 'node:path';
|
||||
@@ -59,6 +58,7 @@ import { getUserStartupWarnings } from './utils/userStartupWarnings.js';
|
||||
import { getCliVersion } from './utils/version.js';
|
||||
import { computeWindowTitle } from './utils/windowTitle.js';
|
||||
import { validateNonInteractiveAuth } from './validateNonInterActiveAuth.js';
|
||||
import { showResumeSessionPicker } from './ui/components/ResumeSessionPicker.js';
|
||||
|
||||
export function validateDnsResolutionOrder(
|
||||
order: string | undefined,
|
||||
@@ -110,7 +110,7 @@ function getNodeMemoryArgs(isDebugMode: boolean): string[] {
|
||||
|
||||
import { ExtensionEnablementManager } from './config/extensions/extensionEnablement.js';
|
||||
import { loadSandboxConfig } from './config/sandboxConfig.js';
|
||||
import { runZedIntegration } from './zed-integration/zedIntegration.js';
|
||||
import { runAcpAgent } from './acp-integration/acpAgent.js';
|
||||
|
||||
export function setupUnhandledRejectionHandler() {
|
||||
let unhandledRejectionOccurred = false;
|
||||
@@ -158,7 +158,7 @@ export async function startInteractiveUI(
|
||||
process.platform === 'win32' || nodeMajorVersion < 20
|
||||
}
|
||||
>
|
||||
<SessionStatsProvider>
|
||||
<SessionStatsProvider sessionId={config.getSessionId()}>
|
||||
<VimModeProvider settings={settings}>
|
||||
<AppContainer
|
||||
config={config}
|
||||
@@ -207,9 +207,8 @@ export async function main() {
|
||||
const settings = loadSettings();
|
||||
migrateDeprecatedSettings(settings);
|
||||
await cleanupCheckpoints();
|
||||
const sessionId = randomUUID();
|
||||
|
||||
const argv = await parseArguments(settings.merged);
|
||||
let argv = await parseArguments(settings.merged);
|
||||
|
||||
// Check for invalid input combinations early to prevent crashes
|
||||
if (argv.promptInteractive && !process.stdin.isTTY) {
|
||||
@@ -253,7 +252,6 @@ export async function main() {
|
||||
settings.merged,
|
||||
[],
|
||||
new ExtensionEnablementManager(ExtensionStorage.getUserExtensionsDir()),
|
||||
sessionId,
|
||||
argv,
|
||||
);
|
||||
|
||||
@@ -319,6 +317,18 @@ export async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
// Handle --resume without a session ID by showing the session picker
|
||||
if (argv.resume === '') {
|
||||
const selectedSessionId = await showResumeSessionPicker();
|
||||
if (!selectedSessionId) {
|
||||
// User cancelled or no sessions available
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
// Update argv with the selected session ID
|
||||
argv = { ...argv, resume: selectedSessionId };
|
||||
}
|
||||
|
||||
// We are now past the logic handling potentially launching a child process
|
||||
// to run Gemini CLI. It is now safe to perform expensive initialization that
|
||||
// may have side effects.
|
||||
@@ -332,7 +342,6 @@ export async function main() {
|
||||
settings.merged,
|
||||
extensions,
|
||||
extensionEnablementManager,
|
||||
sessionId,
|
||||
argv,
|
||||
);
|
||||
|
||||
@@ -386,7 +395,7 @@ export async function main() {
|
||||
}
|
||||
|
||||
if (config.getExperimentalZedIntegration()) {
|
||||
return runZedIntegration(config, settings, extensions, argv);
|
||||
return runAcpAgent(config, settings, extensions, argv);
|
||||
}
|
||||
|
||||
let input = config.getQuestion();
|
||||
@@ -469,7 +478,7 @@ export async function main() {
|
||||
});
|
||||
|
||||
if (config.getDebugMode()) {
|
||||
console.log('Session ID: %s', sessionId);
|
||||
console.log('Session ID: %s', config.getSessionId());
|
||||
}
|
||||
|
||||
await runNonInteractive(nonInteractiveConfig, settings, input, prompt_id);
|
||||
|
||||
Reference in New Issue
Block a user