Commit Graph

17 Commits

Author SHA1 Message Date
Kit Langton cb588ab4b9 fix(bus): acquire PubSub subscription eagerly to close /event race
`bus.subscribe(def)` and `bus.subscribeAll()` previously returned a
`Stream` whose underlying `PubSub.subscribe` ran lazily on first pull
(via `Stream.unwrap`). When a Stream was built in one place and consumed
in another — e.g. the `/event` SSE handler, which returns the stream
inside `HttpServerResponse.stream` for the body-pump fiber to consume
later — any publish in the hand-off window was lost.

The `/event` handler's `Stream.concat(server.connected, events)` shape
made this concrete: the events stream's PubSub.subscribe was only run
*after* `server.connected` was emitted and flushed to the socket, so
publishes that landed between the client receiving `server.connected`
and the body-pump fiber pulling from `events` were silently dropped.
SDK consumers (`client.event.subscribe()`, the Slack bot,
`opencode run --attach`) hit this routinely because they typically
subscribe and then trigger something that publishes (e.g.
`sdk.part.update`).

Change the bus interface so subscribe / subscribeAll return
`Effect<Stream, never, Scope>`. The subscription is now acquired
eagerly when the caller yields the effect, lives in the caller's
scope, and is released by the scope's finalizer. Any publish after
`yield*` is buffered into the subscription queue regardless of when
the consumer activates.

Migrated callers:
- /event handler (handlers/event.ts)
- plugin/index.ts
- project/project.ts
- project/vcs.ts
- share/share-next.ts

Regression tests added:
- test/bus/bus-effect.test.ts — 3 unit tests for eager subscribe,
  including the /event-shape Stream.concat pattern.
- test/server/httpapi-event-diagnostics.test.ts — 7 diagnostic
  tests (D1-D7) isolating each variable in the publisher chain. D7
  (no-op AppRuntime warmup) is the smallest regression trigger.
- test/server/httpapi-sdk.test.ts — end-to-end SDK subscription
  through /event during a sync.run-driven publish.
2026-05-16 22:32:55 -04:00
Kit Langton 195f592640 refactor(server): simplify listener lifecycle (#27413) 2026-05-15 00:00:52 +00:00
Kit Langton 6d3b2fe08b test(server): stabilize SDK project skill prompt test (#27239) 2026-05-13 03:01:29 +00:00
opencode-agent[bot] c9df833d2c chore: generate 2026-05-13 01:45:20 +00:00
Kit Langton d1356f509e test(server): migrate HTTP API SDK test to Effect runner (#27208) 2026-05-13 01:43:35 +00:00
Kit Langton 11363170ca fix(sdk): wrap thrown error bodies in Error
SDK throwOnError paths now convert structured response bodies into real Error instances while preserving the original body and status in cause.
2026-05-09 18:46:43 -04:00
Kit Langton 28b03595bf research: delete Hono backend (do not merge) (#25667) 2026-05-09 13:10:42 +00:00
Kit Langton 11c33d52a5 test(server): cover REST API project skills (#26451) 2026-05-09 02:23:21 +00:00
Kit Langton 8555de8189 Type session not-found errors (#25818) 2026-05-05 21:33:47 -04:00
Kit Langton 7d91d3b1ed Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
Kit Langton 4c4860fb24 Replace Instance.disposeAll/load with fixture helper (#25418) 2026-05-02 10:56:15 -04:00
Kit Langton dddfcbf0d8 test: port instance HttpApi path/vcs read coverage to Effect 2026-04-30 11:07:00 -04:00
Kit Langton cee9610d26 refactor: use Effect config for HttpApi authorization (#25035) 2026-04-29 22:22:32 -04:00
opencode-agent[bot] a3f7ea2555 chore: generate 2026-04-29 13:47:48 +00:00
Kit Langton d3df8e1180 test(httpapi): clean up SDK parity tests 2026-04-29 09:46:17 -04:00
Kit Langton 6015084fa2 Prepare Effect HttpApi backend parity (#24853) 2026-04-29 09:34:50 -04:00
Kit Langton 379e7f3f20 test(httpapi): cover sdk effect routes (#24836) 2026-04-28 16:34:06 -04:00