From 78037d996b5484f953d389a981c4a9d93cb56c49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A1=BE=E7=9B=BC?= Date: Thu, 23 Apr 2026 10:31:35 +0800 Subject: [PATCH] fix(cli): stabilize resume callback deps (#3533) --- packages/cli/src/ui/hooks/useResumeCommand.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/ui/hooks/useResumeCommand.ts b/packages/cli/src/ui/hooks/useResumeCommand.ts index 0dcc3b54c..037b75f3c 100644 --- a/packages/cli/src/ui/hooks/useResumeCommand.ts +++ b/packages/cli/src/ui/hooks/useResumeCommand.ts @@ -62,9 +62,11 @@ export function useResumeCommand( const { config, historyManager, startNewSession, setSessionName, remount } = options ?? {}; + const hasHistoryManager = !!historyManager; + const { clearItems, loadHistory } = historyManager || {}; const handleResume = useCallback( async (sessionId: string) => { - if (!config || !historyManager || !startNewSession) { + if (!config || !hasHistoryManager || !startNewSession) { return; } @@ -88,8 +90,8 @@ export function useResumeCommand( // Reset UI history. const uiHistoryItems = buildResumedHistoryItems(sessionData, config); - historyManager.clearItems(); - historyManager.loadHistory(uiHistoryItems); + clearItems?.(); + loadHistory?.(uiHistoryItems); // Update session history core. config.startNewSession(sessionId, sessionData); @@ -114,7 +116,9 @@ export function useResumeCommand( [ closeResumeDialog, config, - historyManager, + hasHistoryManager, + clearItems, + loadHistory, startNewSession, setSessionName, remount,