重构 Agent 聊天,支持分支管理与消息克隆

This commit is contained in:
2026-04-30 13:05:45 +08:00
parent e5ca9e24aa
commit 36d1a8d6ea
20 changed files with 1722 additions and 586 deletions
+4
View File
@@ -41,6 +41,8 @@ interface ChatToolState {
lastAction: ChatToolAction | null;
/** Monotonically increasing counter lets subscribers detect new actions. */
actionSeq: number;
/** Timestamp of the most recent action dispatch. */
lastActionAt: number;
/** Dispatch a tool action from the chat. */
dispatch: (action: ChatToolAction) => void;
}
@@ -48,9 +50,11 @@ interface ChatToolState {
export const useChatToolStore = create<ChatToolState>((set) => ({
lastAction: null,
actionSeq: 0,
lastActionAt: 0,
dispatch: (action) =>
set((state) => ({
lastAction: action,
actionSeq: state.actionSeq + 1,
lastActionAt: Date.now(),
})),
}));