mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 08:47:44 +00:00
refactor: Centralize session ID generation and propagation
This commit is contained in:
@@ -120,6 +120,7 @@ export async function loadCliConfig(
|
||||
settings: Settings,
|
||||
extensions: ExtensionConfig[],
|
||||
geminiIgnorePatterns: string[],
|
||||
sessionId: string,
|
||||
): Promise<Config> {
|
||||
loadEnvironment();
|
||||
|
||||
@@ -148,6 +149,7 @@ export async function loadCliConfig(
|
||||
const mcpServers = mergeMcpServers(settings, extensions);
|
||||
|
||||
return new Config({
|
||||
sessionId,
|
||||
contentGeneratorConfig,
|
||||
embeddingModel: DEFAULT_GEMINI_EMBEDDING_MODEL,
|
||||
sandbox: argv.sandbox ?? settings.sandbox,
|
||||
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
WebFetchTool,
|
||||
WebSearchTool,
|
||||
WriteFileTool,
|
||||
sessionId,
|
||||
} from '@gemini-cli/core';
|
||||
|
||||
export async function main() {
|
||||
@@ -57,6 +58,7 @@ export async function main() {
|
||||
settings.merged,
|
||||
extensions,
|
||||
geminiIgnorePatterns,
|
||||
sessionId,
|
||||
);
|
||||
|
||||
// Initialize centralized FileDiscoveryService
|
||||
@@ -180,5 +182,6 @@ async function loadNonInteractiveConfig(
|
||||
nonInteractiveSettings,
|
||||
extensions,
|
||||
config.getGeminiIgnorePatterns(),
|
||||
config.getSessionId(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -190,6 +190,7 @@ describe('App UI', () => {
|
||||
userMemory: '',
|
||||
geminiMdFileCount: 0,
|
||||
showMemoryUsage: false,
|
||||
sessionId: 'test-session-id',
|
||||
// Provide other required fields for ConfigParameters if necessary
|
||||
}) as unknown as MockServerConfig;
|
||||
|
||||
|
||||
@@ -493,7 +493,7 @@ Add any other context about the problem here.
|
||||
description: 'save conversation checkpoint. Usage: /save [tag]',
|
||||
action: async (_mainCommand, subCommand, _args) => {
|
||||
const tag = (subCommand || '').trim();
|
||||
const logger = new Logger();
|
||||
const logger = new Logger(config?.getSessionId() || '');
|
||||
await logger.initialize();
|
||||
const chat = await config?.getGeminiClient()?.getChat();
|
||||
const history = chat?.getHistory() || [];
|
||||
@@ -519,7 +519,7 @@ Add any other context about the problem here.
|
||||
'resume from conversation checkpoint. Usage: /resume [tag]',
|
||||
action: async (_mainCommand, subCommand, _args) => {
|
||||
const tag = (subCommand || '').trim();
|
||||
const logger = new Logger();
|
||||
const logger = new Logger(config?.getSessionId() || '');
|
||||
await logger.initialize();
|
||||
const conversation = await logger.loadCheckpoint(tag);
|
||||
if (conversation.length === 0) {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
import { useState, useEffect } from 'react';
|
||||
import { sessionId } from '@gemini-cli/core';
|
||||
import { Logger } from '@gemini-cli/core';
|
||||
|
||||
/**
|
||||
@@ -14,7 +15,7 @@ export const useLogger = () => {
|
||||
const [logger, setLogger] = useState<Logger | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const newLogger = new Logger();
|
||||
const newLogger = new Logger(sessionId);
|
||||
/**
|
||||
* Start async initialization, no need to await. Using await slows down the
|
||||
* time from launch to see the gemini-cli prompt and it's better to not save
|
||||
|
||||
Reference in New Issue
Block a user