fix(chat): restore fork prompts in the destination composer (#3387)

This commit is contained in:
Andrea V
2026-09-07 20:26:26 +03:00
committed by GitHub
parent a059d54b44
commit 21011cfe0a
9 changed files with 497 additions and 28 deletions
+14
View File
@@ -7,6 +7,7 @@ import { create } from "zustand"
import type { ContextPartMetadata } from '@/lib/messages/contextParts'
import type { AttachedFile } from "@/stores/types/sessionTypes"
import { prepareAttachmentFiles } from "./attachment-files"
import { getChatDraftIdentityKey, type ChatDraftIdentity } from "@/lib/chatDraftPersistence"
const FILE_URI_PREFIX = "file://"
const MAX_ATTACHMENT_PREPARATION_ATTEMPTS = 3
@@ -128,6 +129,12 @@ export type VSCodeActiveEditorFile = {
}
export type InputState = {
pendingComposerRestore: {
target: ChatDraftIdentity
text: string
files: Array<{ url: string; mimeType: string; filename: string }>
} | null
consumePendingComposerRestore: (target: ChatDraftIdentity | null) => InputState["pendingComposerRestore"]
pendingInputText: string | null
pendingInputMode: "replace" | "append" | "append-inline"
pendingSyntheticParts: SyntheticContextPart[] | null
@@ -158,6 +165,13 @@ export type InputState = {
}
export const useInputStore = create<InputState>()((set, get) => ({
pendingComposerRestore: null,
consumePendingComposerRestore: (target) => {
const pending = get().pendingComposerRestore
if (!pending || !target || getChatDraftIdentityKey(pending.target) !== getChatDraftIdentityKey(target)) return null
set({ pendingComposerRestore: null })
return pending
},
pendingInputText: null,
pendingInputMode: "replace",
pendingSyntheticParts: null,