cloudaxe-opencode/packages/opencode/src/server
Kit Langton 98fef45553 fix(httpapi): 404 status + body shape for missing-session errors
Two related divergences from Hono are fixed in one move:

1. Status: many session handlers (todo, diff, summarize, fork, abort,
   init, deleteMessage, command, shell, revert, unrevert) didn't wrap
   with mapNotFound, so a thrown NotFoundError surfaced as a 500 defect
   instead of a 404. The fork/diff endpoints also lacked OpencodeNotFound
   in their declared error union, so handlers couldn't surface 404 even
   if they wanted to.

2. Body shape: the existing mapNotFound rebrand to HttpApiError.NotFound
   produced an empty 404 response. Hono returns the NamedError envelope
   `{ name: "NotFoundError", data: { message } }`. SDK consumers reading
   `error.data.message` got undefined.

The fix introduces OpencodeNotFound — a Schema.ErrorClass annotated with
`httpApiStatus: 404` and a body schema matching the legacy NamedError
shape. mapNotFound now rebrands NotFoundError to OpencodeNotFound,
preserving the underlying error message. All session endpoints that take
a sessionID now wrap their service calls with mapNotFound.

A TODO in the handler notes the long-term direction: services should
fail with typed errors directly (Effect<T, SessionNotFound>) and let
HttpApi auto-route status + body via schema annotations, eliminating
mapNotFound entirely. This PR is the pragmatic middle: small surface,
no service-layer changes, fixes the user-visible parity bug.

Unskips the two .todo parity reproducers in httpapi-parity.test.ts.
2026-05-02 23:33:14 -04:00
..
routes fix(httpapi): 404 status + body shape for missing-session errors 2026-05-02 23:33:14 -04:00
adapter.bun.ts refactor(httpapi): fork server startup by flag (#24799) 2026-04-28 11:02:35 -04:00
adapter.node.ts refactor(httpapi): fork server startup by flag (#24799) 2026-04-28 11:02:35 -04:00
adapter.ts refactor(httpapi): fork server startup by flag (#24799) 2026-04-28 11:02:35 -04:00
backend.ts Prepare Effect HttpApi backend parity (#24853) 2026-04-29 09:34:50 -04:00
cors.ts Pass CORS options to HttpApi backend (#25201) 2026-04-30 21:26:32 -04:00
error.ts refactor: remove module barrels (#24554) 2026-04-27 14:33:33 -04:00
event.ts refactor(bus): migrate BusEvent to Effect Schema (#24040) 2026-04-23 15:37:44 -04:00
fence.ts Refactor workspace service boundaries (#25152) 2026-04-30 15:34:37 -04:00
global-lifecycle.ts chore: generate 2026-05-02 23:34:40 +00:00
mdns.ts refactor: remove module barrels (#24554) 2026-04-27 14:33:33 -04:00
middleware.ts Pass CORS options to HttpApi backend (#25201) 2026-04-30 21:26:32 -04:00
projectors.ts refactor: remove module barrels (#24554) 2026-04-27 14:33:33 -04:00
proxy-util.ts chore: generate 2026-04-29 20:52:19 +00:00
proxy.ts Refactor workspace service boundaries (#25152) 2026-04-30 15:34:37 -04:00
server.ts chore: generate 2026-05-01 01:28:37 +00:00
workspace.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00