Repository navigation
AOT/runtime: verify the three Worker entrypoints of OpenCode v1.18.30 end-to-end (TUI server worker, OpenTUI parser worker, thread-stream) #10103
Copy link
Copy link
Closed
Labels
enhancementNew capability or improvementNew capability or improvementparityCompatibility gap with Node.js, ECMAScript, or the supported ecosystemCompatibility gap with Node.js, ECMAScript, or the supported ecosystem
Description
Parent: #10107. Closes the unticked acceptance boxes of #8509 ("OpenCode's TUI worker starts, serves requests, reloads, and terminates cleanly"; "parser/diff worker smoke tests").
Facts
- TUI server worker —
packages/opencode/src/cli/cmd/tui.ts:210-214:new Worker(file, { env: Object.fromEntries(...) })wherefile = await target()(tui.ts:52-56: defineOPENCODE_WORKER_PATHelsenew URL("../tui/worker.ts", import.meta.url)). Entrypackages/opencode/src/cli/tui/worker.ts. Parent talks overRpc.client<typeof rpc>(worker)(structured-clone messages),client.call("reload")onSIGUSR2(tui.ts:216-220),client.call("shutdown")+worker.terminate()on stop (tui.ts:224-230). The worker hosts the whole server/session runtime (Effect, sqlite, providers) — i.e. most of the graph executes on the worker thread. - OpenTUI tree-sitter worker —
@opentui/core/chunk-bun-t2myhmwd.js:8398new Worker(workerPath)withworkerPathfrom defineOTUI_TREE_SITTER_WORKER_PATHelseimport.meta.resolve("@opentui/core/parser.worker")(:8464). Entry@opentui/core/parser.worker.js(Emscripten loader + grammars, runtime/AOT (refines #8508): Emscripten main+side-module loading (web-tree-sitter + grammars) and wasm-bindgen (photon) for OpenCode v1.18.30 #10102). Inside the worker the code uses nodeparentPortfromnode:worker_threads(parser.worker.js:3621,chunk:8203) while the parent uses the WebWorkerAPI: both shapes must interoperate. - thread-stream (
thread-stream/index.js:72, pino transport) — only on the GitLab login path via fastify; low priority.
Also:write-file-atomiconly readsworker_threads.isMainThread;source-map-supportchecksisMainThread(Code Mode path).
Scope
- Worker entry discovery for both spellings (define string path;
new URL(relative, import.meta.url);import.meta.resolve(pkg-subpath)— compile: build-time defines (--define, Bun.build semantics) and the no-define fallbacks OpenCode relies on (import.meta.resolve,new URL(..., import.meta.url)) #10101), compiled as separate native entries packaged with the binary (per AOT: compile and register Web Worker entry modules used by full-source OpenCode #8509). Workeroptions:env(full copy ofprocess.env),terminate(), error/exit events,postMessagestructured clone of the RPC payloads used bypackages/opencode/src/cli/tui/worker.ts(plain objects, arrays, strings, Uint8Array),parentPort.on("message")inside the worker.- Async-context/GC: the worker runs the Effect runtime and sqlite; confirm moving-GC roots and native handles are per-thread safe (ws/pty/sqlite handles created on the worker).
- Signals:
SIGUSR2reload path.
Acceptance
- Native binary TUI boots: worker starts, first RPC round-trip completes, first frame renders.
-
kill -USR2 <pid>triggersclient.call("reload")without crashing; Ctrl-C shuts down within the 5 s timeout and exits 0. - Parser worker highlights code in the TUI (with runtime/AOT (refines #8508): Emscripten main+side-module loading (web-tree-sitter + grammars) and wasm-bindgen (photon) for OpenCode v1.18.30 #10102).
- A reduced fixture (parent
.ts+ worker.tsusingnew URL("./w.ts", import.meta.url)and aparentPort-style worker) is added tocrates/perry/testsand passes on macOS and Linux.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew capability or improvementNew capability or improvementparityCompatibility gap with Node.js, ECMAScript, or the supported ecosystemCompatibility gap with Node.js, ECMAScript, or the supported ecosystem
Activity
proggeramlug commentedon Sep 12, 2026
Fixed by #10133, landed on
mainvia merge train #10139 at64d1209b62.The close keyword does not fire through a train branch, so closing manually.