diff --git a/src/components/chat/message-input.tsx b/src/components/chat/message-input.tsx index 9a75713..6f09607 100644 --- a/src/components/chat/message-input.tsx +++ b/src/components/chat/message-input.tsx @@ -407,7 +407,7 @@ export function MessageInput({ [tExperts] ) const { shortcuts } = useShortcutSettings() - const effectiveDraftStorageKey = draftStorageKey ?? attachmentTabId ?? null + const effectiveDraftStorageKey = draftStorageKey ?? null const resolvedPlaceholder = placeholder ?? t("askAnything") const [text, setText] = useState(() => { if (!effectiveDraftStorageKey) return "" diff --git a/src/components/conversations/conversation-detail-panel.tsx b/src/components/conversations/conversation-detail-panel.tsx index 69404db..b3a51b9 100644 --- a/src/components/conversations/conversation-detail-panel.tsx +++ b/src/components/conversations/conversation-detail-panel.tsx @@ -66,7 +66,7 @@ import { import { buildConversationDraftStorageKey, buildNewConversationDraftStorageKey, - moveMessageInputDraft, + clearMessageInputDraft, } from "@/lib/message-input-draft" import { ContextMenu, @@ -268,10 +268,10 @@ const ConversationTabView = memo(function ConversationTabView({ const externalId = detail?.summary.external_id ?? undefined const draftStorageKey = useMemo(() => { if (dbConversationId != null) { - return buildConversationDraftStorageKey(selectedAgent, dbConversationId) + return buildConversationDraftStorageKey(dbConversationId) } - return buildNewConversationDraftStorageKey({ tabId }) - }, [dbConversationId, tabId, selectedAgent]) + return buildNewConversationDraftStorageKey() + }, [dbConversationId]) // Use the per-tab workingDir (derived from the tab's own folderId by the // parent) rather than the active folder's path — otherwise switching tabs // briefly exposes the previous folder's path to the ACP auto-connect @@ -625,10 +625,7 @@ const ConversationTabView = memo(function ConversationTabView({ title, effectiveConversationId ) - moveMessageInputDraft( - buildNewConversationDraftStorageKey({ tabId }), - buildConversationDraftStorageKey(selectedAgent, newConversationId) - ) + clearMessageInputDraft(buildNewConversationDraftStorageKey()) statusUpdatedRef.current = false // If the turn already finished while we were creating the // conversation, apply the deferred status directly instead diff --git a/src/lib/message-input-draft.ts b/src/lib/message-input-draft.ts index ed925f5..be808c1 100644 --- a/src/lib/message-input-draft.ts +++ b/src/lib/message-input-draft.ts @@ -1,7 +1,5 @@ "use client" -import type { AgentType } from "@/lib/types" - interface PersistedDraftState { text: string } @@ -83,16 +81,13 @@ function scheduleDraftPersistence(): void { } export function buildConversationDraftStorageKey( - agentType: AgentType, conversationId: number ): string { - return `conv:${agentType}:${conversationId}` + return `conv:${conversationId}` } -export function buildNewConversationDraftStorageKey(params: { - tabId: string -}): string { - return `new:${params.tabId}` +export function buildNewConversationDraftStorageKey(): string { + return "new" } export function loadMessageInputDraft(draftKey: string): string | null { @@ -137,17 +132,3 @@ export function clearMessageInputDraft(draftKey: string): void { /* ignore */ } } - -export function moveMessageInputDraft( - fromDraftKey: string, - toDraftKey: string -): void { - if (fromDraftKey === toDraftKey) return - - const sourceText = loadMessageInputDraft(fromDraftKey) - const targetText = loadMessageInputDraft(toDraftKey) - if (sourceText && !targetText) { - saveMessageInputDraft(toDraftKey, sourceText) - } - clearMessageInputDraft(fromDraftKey) -}