rework /resume slash command

This commit is contained in:
tanzhenxin
2025-12-16 19:54:55 +08:00
parent 9942b2b877
commit 2837aa6b7c
16 changed files with 724 additions and 1232 deletions

View File

@@ -99,6 +99,7 @@ import { processVisionSwitchOutcome } from './hooks/useVisionAutoSwitch.js';
import { useSubagentCreateDialog } from './hooks/useSubagentCreateDialog.js';
import { useAgentsManagerDialog } from './hooks/useAgentsManagerDialog.js';
import { useAttentionNotifications } from './hooks/useAttentionNotifications.js';
import { useSessionSelect } from './hooks/useSessionSelect.js';
const CTRL_EXIT_PROMPT_DURATION_MS = 1000;
@@ -439,60 +440,13 @@ export const AppContainer = (props: AppContainerProps) => {
const { isResumeDialogOpen, openResumeDialog, closeResumeDialog } =
useResumeCommand();
// Handle resume session selection
const handleResumeSessionSelect = useCallback(
async (sessionId: string) => {
if (!config) {
return;
}
// Close dialog immediately to prevent input capture during async operations
closeResumeDialog();
const {
SessionService,
buildApiHistoryFromConversation,
replayUiTelemetryFromConversation,
uiTelemetryService,
} = await import('@qwen-code/qwen-code-core');
const { buildResumedHistoryItems } = await import(
'./utils/resumeHistoryUtils.js'
);
const cwd = config.getTargetDir();
const sessionService = new SessionService(cwd);
const sessionData = await sessionService.loadSession(sessionId);
if (!sessionData) {
return;
}
// Reset and replay UI telemetry to restore metrics
uiTelemetryService.reset();
replayUiTelemetryFromConversation(sessionData.conversation);
// Build UI history items using existing utility
const uiHistoryItems = buildResumedHistoryItems(sessionData, config);
// Build API history for the LLM client
const clientHistory = buildApiHistoryFromConversation(
sessionData.conversation,
);
// Update client history
config.getGeminiClient()?.setHistory(clientHistory);
config.getGeminiClient()?.stripThoughtsFromHistory();
// Update session in config
config.startNewSession(sessionId);
startNewSession(sessionId);
// Clear and load history
historyManager.clearItems();
historyManager.loadHistory(uiHistoryItems);
},
[config, closeResumeDialog, historyManager, startNewSession],
);
const handleResumeSessionSelect = useSessionSelect({
config,
historyManager,
closeResumeDialog,
startNewSession,
remount: refreshStatic,
});
const {
showWorkspaceMigrationDialog,