summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorismeth <[email protected]>2026-03-05 14:35:16 +0100
committerGitHub <[email protected]>2026-03-05 19:05:16 +0530
commit07348d14a2013b25434b91aecb30a82546bed1c5 (patch)
treefe7f5273d54572be2078cace93346eebe05b6587
parent5f40bd42f844c35b8bfb695fbda20a8ec01f127e (diff)
downloadopencode-07348d14a2013b25434b91aecb30a82546bed1c5.tar.gz
opencode-07348d14a2013b25434b91aecb30a82546bed1c5.zip
fix(app): preserve question dock state across session switches (#16173)
-rw-r--r--packages/app/src/pages/session/composer/session-question-dock.tsx26
1 files changed, 22 insertions, 4 deletions
diff --git a/packages/app/src/pages/session/composer/session-question-dock.tsx b/packages/app/src/pages/session/composer/session-question-dock.tsx
index fd2ced3dc..b22a92eb0 100644
--- a/packages/app/src/pages/session/composer/session-question-dock.tsx
+++ b/packages/app/src/pages/session/composer/session-question-dock.tsx
@@ -8,6 +8,8 @@ import type { QuestionAnswer, QuestionRequest } from "@opencode-ai/sdk/v2"
import { useLanguage } from "@/context/language"
import { useSDK } from "@/context/sdk"
+const cache = new Map<string, { tab: number; answers: QuestionAnswer[]; custom: string[]; customOn: boolean[] }>()
+
export const SessionQuestionDock: Component<{ request: QuestionRequest; onSubmit: () => void }> = (props) => {
const sdk = useSDK()
const language = useLanguage()
@@ -15,16 +17,18 @@ export const SessionQuestionDock: Component<{ request: QuestionRequest; onSubmit
const questions = createMemo(() => props.request.questions)
const total = createMemo(() => questions().length)
+ const cached = cache.get(props.request.id)
const [store, setStore] = createStore({
- tab: 0,
- answers: [] as QuestionAnswer[],
- custom: [] as string[],
- customOn: [] as boolean[],
+ tab: cached?.tab ?? 0,
+ answers: cached?.answers ?? ([] as QuestionAnswer[]),
+ custom: cached?.custom ?? ([] as string[]),
+ customOn: cached?.customOn ?? ([] as boolean[]),
editing: false,
sending: false,
})
let root: HTMLDivElement | undefined
+ let replied = false
const question = createMemo(() => questions()[store.tab])
const options = createMemo(() => question()?.options ?? [])
@@ -107,6 +111,16 @@ export const SessionQuestionDock: Component<{ request: QuestionRequest; onSubmit
})
})
+ onCleanup(() => {
+ if (replied) return
+ cache.set(props.request.id, {
+ tab: store.tab,
+ answers: store.answers.map((a) => (a ? [...a] : [])),
+ custom: store.custom.map((s) => s ?? ""),
+ customOn: store.customOn.map((b) => b ?? false),
+ })
+ })
+
const fail = (err: unknown) => {
const message = err instanceof Error ? err.message : String(err)
showToast({ title: language.t("common.requestFailed"), description: message })
@@ -119,6 +133,8 @@ export const SessionQuestionDock: Component<{ request: QuestionRequest; onSubmit
setStore("sending", true)
try {
await sdk.client.question.reply({ requestID: props.request.id, answers })
+ replied = true
+ cache.delete(props.request.id)
} catch (err) {
fail(err)
} finally {
@@ -133,6 +149,8 @@ export const SessionQuestionDock: Component<{ request: QuestionRequest; onSubmit
setStore("sending", true)
try {
await sdk.client.question.reject({ requestID: props.request.id })
+ replied = true
+ cache.delete(props.request.id)
} catch (err) {
fail(err)
} finally {