fix(app): stabilize todo dock e2e with composer probe (#17267)

This commit is contained in:
Luke Parker
2026-03-13 12:21:50 +10:00
committed by GitHub
parent dcb17c6a67
commit 96b1d8f639
6 changed files with 350 additions and 74 deletions

View File

@@ -1,4 +1,4 @@
import { createEffect, createMemo, on, onCleanup } from "solid-js"
import { createEffect, createMemo, on, onCleanup, onMount } from "solid-js"
import { createStore } from "solid-js/store"
import type { PermissionRequest, QuestionRequest, Todo } from "@opencode-ai/sdk/v2"
import { useParams } from "@solidjs/router"
@@ -8,6 +8,7 @@ import { useLanguage } from "@/context/language"
import { usePermission } from "@/context/permission"
import { useSDK } from "@/context/sdk"
import { useSync } from "@/context/sync"
import { composerDriver, composerEnabled, composerEvent } from "@/testing/session-composer"
import { sessionPermissionRequest, sessionQuestionRequest } from "./session-request-tree"
export const todoState = (input: {
@@ -47,7 +48,50 @@ export function createSessionComposerState(options?: { closeMs?: number | (() =>
return !!permissionRequest() || !!questionRequest()
})
const [test, setTest] = createStore({
on: false,
live: undefined as boolean | undefined,
todos: undefined as Todo[] | undefined,
})
const pull = () => {
const id = params.id
if (!id) {
setTest({ on: false, live: undefined, todos: undefined })
return
}
const next = composerDriver(id)
if (!next) {
setTest({ on: false, live: undefined, todos: undefined })
return
}
setTest({
on: true,
live: next.live,
todos: next.todos?.map((todo) => ({ ...todo })),
})
}
onMount(() => {
if (!composerEnabled()) return
pull()
createEffect(on(() => params.id, pull, { defer: true }))
const onEvent = (event: Event) => {
const detail = (event as CustomEvent<{ sessionID?: string }>).detail
if (detail?.sessionID !== params.id) return
pull()
}
window.addEventListener(composerEvent, onEvent)
onCleanup(() => window.removeEventListener(composerEvent, onEvent))
})
const todos = createMemo((): Todo[] => {
if (test.on && test.todos !== undefined) return test.todos
const id = params.id
if (!id) return []
return globalSync.data.session_todo[id] ?? []
@@ -64,7 +108,10 @@ export function createSessionComposerState(options?: { closeMs?: number | (() =>
})
const busy = createMemo(() => status().type !== "idle")
const live = createMemo(() => busy() || blocked())
const live = createMemo(() => {
if (test.on && test.live !== undefined) return test.live
return busy() || blocked()
})
const [store, setStore] = createStore({
responding: undefined as string | undefined,
@@ -116,6 +163,10 @@ export function createSessionComposerState(options?: { closeMs?: number | (() =>
// Keep stale turn todos from reopening if the model never clears them.
const clear = () => {
if (test.on && test.todos !== undefined) {
setTest("todos", [])
return
}
const id = params.id
if (!id) return
globalSync.todo.set(id, [])