summaryrefslogtreecommitdiffhomepage
path: root/packages/app/src/context
diff options
context:
space:
mode:
authorDaniel Polito <[email protected]>2026-01-13 15:28:08 -0300
committerGitHub <[email protected]>2026-01-13 12:28:08 -0600
commit3600bd27f481c461734e517a40e01cd4e899e10f (patch)
treee8d1a426a81ff04a4dfc2fb88ab925e4977bd936 /packages/app/src/context
parent92089bb295ffc62e681baf5c93336e97a052b26e (diff)
downloadopencode-3600bd27f481c461734e517a40e01cd4e899e10f.tar.gz
opencode-3600bd27f481c461734e517a40e01cd4e899e10f.zip
feat(desktop): Ask Question Tool Support (#8232)
Diffstat (limited to 'packages/app/src/context')
-rw-r--r--packages/app/src/context/global-sync.tsx75
1 files changed, 75 insertions, 0 deletions
diff --git a/packages/app/src/context/global-sync.tsx b/packages/app/src/context/global-sync.tsx
index ddac1f228..c11edd292 100644
--- a/packages/app/src/context/global-sync.tsx
+++ b/packages/app/src/context/global-sync.tsx
@@ -16,6 +16,7 @@ import {
type LspStatus,
type VcsInfo,
type PermissionRequest,
+ type QuestionRequest,
createOpencodeClient,
} from "@opencode-ai/sdk/v2/client"
import { createStore, produce, reconcile } from "solid-js/store"
@@ -49,6 +50,9 @@ type State = {
permission: {
[sessionID: string]: PermissionRequest[]
}
+ question: {
+ [sessionID: string]: QuestionRequest[]
+ }
mcp: {
[name: string]: McpStatus
}
@@ -98,6 +102,7 @@ function createGlobalSync() {
session_diff: {},
todo: {},
permission: {},
+ question: {},
mcp: {},
lsp: [],
vcs: undefined,
@@ -208,6 +213,38 @@ function createGlobalSync() {
}
})
}),
+ sdk.question.list().then((x) => {
+ const grouped: Record<string, QuestionRequest[]> = {}
+ for (const question of x.data ?? []) {
+ if (!question?.id || !question.sessionID) continue
+ const existing = grouped[question.sessionID]
+ if (existing) {
+ existing.push(question)
+ continue
+ }
+ grouped[question.sessionID] = [question]
+ }
+
+ batch(() => {
+ for (const sessionID of Object.keys(store.question)) {
+ if (grouped[sessionID]) continue
+ setStore("question", sessionID, [])
+ }
+ for (const [sessionID, questions] of Object.entries(grouped)) {
+ setStore(
+ "question",
+ sessionID,
+ reconcile(
+ questions
+ .filter((q) => !!q?.id)
+ .slice()
+ .sort((a, b) => a.id.localeCompare(b.id)),
+ { key: "id" },
+ ),
+ )
+ }
+ })
+ }),
]).then(() => {
setStore("status", "complete")
})
@@ -396,6 +433,44 @@ function createGlobalSync() {
)
break
}
+ case "question.asked": {
+ const sessionID = event.properties.sessionID
+ const questions = store.question[sessionID]
+ if (!questions) {
+ setStore("question", sessionID, [event.properties])
+ break
+ }
+
+ const result = Binary.search(questions, event.properties.id, (q) => q.id)
+ if (result.found) {
+ setStore("question", sessionID, result.index, reconcile(event.properties))
+ break
+ }
+
+ setStore(
+ "question",
+ sessionID,
+ produce((draft) => {
+ draft.splice(result.index, 0, event.properties)
+ }),
+ )
+ break
+ }
+ case "question.replied":
+ case "question.rejected": {
+ const questions = store.question[event.properties.sessionID]
+ if (!questions) break
+ const result = Binary.search(questions, event.properties.requestID, (q) => q.id)
+ if (!result.found) break
+ setStore(
+ "question",
+ event.properties.sessionID,
+ produce((draft) => {
+ draft.splice(result.index, 1)
+ }),
+ )
+ break
+ }
case "lsp.updated": {
const sdk = createOpencodeClient({
baseUrl: globalSDK.url,