mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-25 10:04:40 +00:00
fix(app): fork should copy prompt into new session (#17375)
This commit is contained in:
@@ -66,6 +66,7 @@ export const DialogFork: Component = () => {
|
|||||||
directory: sdk.directory,
|
directory: sdk.directory,
|
||||||
attachmentName: language.t("common.attachment"),
|
attachmentName: language.t("common.attachment"),
|
||||||
})
|
})
|
||||||
|
const dir = base64Encode(sdk.directory)
|
||||||
|
|
||||||
sdk.client.session
|
sdk.client.session
|
||||||
.fork({ sessionID, messageID: item.id })
|
.fork({ sessionID, messageID: item.id })
|
||||||
@@ -75,10 +76,8 @@ export const DialogFork: Component = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
dialog.close()
|
dialog.close()
|
||||||
navigate(`/${base64Encode(sdk.directory)}/session/${forked.data.id}`)
|
prompt.set(restored, undefined, { dir, id: forked.data.id })
|
||||||
requestAnimationFrame(() => {
|
navigate(`/${dir}/session/${forked.data.id}`)
|
||||||
prompt.set(restored)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.catch((err: unknown) => {
|
.catch((err: unknown) => {
|
||||||
const message = err instanceof Error ? err.message : String(err)
|
const message = err instanceof Error ? err.message : String(err)
|
||||||
|
|||||||
@@ -151,6 +151,11 @@ const MAX_PROMPT_SESSIONS = 20
|
|||||||
|
|
||||||
type PromptSession = ReturnType<typeof createPromptSession>
|
type PromptSession = ReturnType<typeof createPromptSession>
|
||||||
|
|
||||||
|
type Scope = {
|
||||||
|
dir: string
|
||||||
|
id?: string
|
||||||
|
}
|
||||||
|
|
||||||
type PromptCacheEntry = {
|
type PromptCacheEntry = {
|
||||||
value: PromptSession
|
value: PromptSession
|
||||||
dispose: VoidFunction
|
dispose: VoidFunction
|
||||||
@@ -265,6 +270,7 @@ export const { use: usePrompt, provider: PromptProvider } = createSimpleContext(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const session = createMemo(() => load(params.dir!, params.id))
|
const session = createMemo(() => load(params.dir!, params.id))
|
||||||
|
const pick = (scope?: Scope) => (scope ? load(scope.dir, scope.id) : session())
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ready: () => session().ready(),
|
ready: () => session().ready(),
|
||||||
@@ -280,8 +286,8 @@ export const { use: usePrompt, provider: PromptProvider } = createSimpleContext(
|
|||||||
session().context.updateComment(path, commentID, next),
|
session().context.updateComment(path, commentID, next),
|
||||||
replaceComments: (items: FileContextItem[]) => session().context.replaceComments(items),
|
replaceComments: (items: FileContextItem[]) => session().context.replaceComments(items),
|
||||||
},
|
},
|
||||||
set: (prompt: Prompt, cursorPosition?: number) => session().set(prompt, cursorPosition),
|
set: (prompt: Prompt, cursorPosition?: number, scope?: Scope) => pick(scope).set(prompt, cursorPosition),
|
||||||
reset: () => session().reset(),
|
reset: (scope?: Scope) => pick(scope).reset(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1477,6 +1477,7 @@ export default function Page() {
|
|||||||
|
|
||||||
const fork = (input: { sessionID: string; messageID: string }) => {
|
const fork = (input: { sessionID: string; messageID: string }) => {
|
||||||
const value = draft(input.messageID)
|
const value = draft(input.messageID)
|
||||||
|
const dir = base64Encode(sdk.directory)
|
||||||
return sdk.client.session
|
return sdk.client.session
|
||||||
.fork(input)
|
.fork(input)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
@@ -1488,10 +1489,8 @@ export default function Page() {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
navigate(`/${base64Encode(sdk.directory)}/session/${next.id}`)
|
prompt.set(value, undefined, { dir, id: next.id })
|
||||||
requestAnimationFrame(() => {
|
navigate(`/${dir}/session/${next.id}`)
|
||||||
prompt.set(value)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.catch(fail)
|
.catch(fail)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user