fix(cli): stabilize resume callback deps (#3533)

This commit is contained in:
顾盼 2026-04-23 10:31:35 +08:00 committed by GitHub
parent 69da115dcf
commit 78037d996b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,