fix(agent): 输入草稿按会话保留,切换会话、关抽屉不丢
会话面板与新对话输入框的草稿原来是组件内状态,切到别的会话或 Esc 关抽屉就没了。 改为按会话(以及列表页 / 抽屉两处新对话)分键记在模块里,发送成功后清掉。 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
1 parent
164a27fd80
commit
9f499ac7c2
5 files changed
+86
-6
No files matched your search
@@ -108,3 +108,20 @@ export function usePageListGroup(activeRun?: AgentRunGroup | null): [AgentRunGro
|
||||
);
|
||||
return [group, change];
|
||||
}
|
||||
|
||||
// ── 输入草稿:按会话(和两处新对话输入框)分开记,切换会话、关抽屉不丢;发送成功后清掉。模块级,刷新页面才清 ──
|
||||
|
||||
const drafts = new Map<string, string>();
|
||||
export const DRAFT_PAGE_GOAL = "goal:page";
|
||||
export const DRAFT_DRAWER_GOAL = "goal:drawer";
|
||||
export const runDraftKey = (runId: string) => `run:${runId}`;
|
||||
|
||||
export function readDraft(key: string | undefined): string {
|
||||
return key ? (drafts.get(key) ?? "") : "";
|
||||
}
|
||||
|
||||
export function writeDraft(key: string | undefined, text: string): void {
|
||||
if (!key) return;
|
||||
if (text.trim()) drafts.set(key, text);
|
||||
else drafts.delete(key);
|
||||
}
|
||||
Reference in new issue
Block a user