fix(chat): restore fork prompts in the destination composer (#3387)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user