Skip to content

feat(web): positron web chat client — three-panel who/what/where + talk-to-Asha (#29 slices 3–4) - #1744

Merged
joelteply merged 4 commits into
canaryfrom
feat/positron-web-chat-client
Jul 3, 2026
Merged

joelteply merged 4 commits into
canaryfrom
feat/positron-web-chat-client

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

What

Builds the web <chat-widget> (WIDGET-AS-STATE-KIND outlier A) on the positron read surface, reinvented on @continuum/sdk-typescript — not a repair of the legacy src/{browser,widgets,server,daemons} Node monolith. Renders Joel's who / what / where-which three-panel layout from one live ChatViewState, with "talk to Asha normally" (send) working.

Bundles the two slices that make it runnable:

  • Slice 3 — StateConnection (SDK): the subscribe→state client. Sends subscribe {kinds, layers, last_seen}, drains ServerMessage::state envelopes to per-kind handlers. Wire-identical to the core's WsClientMessage/WsServerMessage ingress.
  • Slice 4 — <chat-widget> (apps/web): the Lit host + pure view model + template + SDK wiring.

How it hangs together

Two sockets to the same core WS ingress (apps/web/src/index.ts is the only file touching both the SDK and the DOM):

  • READ — StateConnection subscribed to kind="chat"; each envelope → ChatState pushed onto widget.state, Lit re-renders. Same read surface (Build(deps-dev): Bump eslint from 9.24.0 to 9.30.0 #84) the persona observes.
  • SEND — Continuum command client; compose bar issues one chat/send into the room on screen. Asha's reply returns through the READ stream — no optimistic local append to drift.

Layering, each testable in isolation:
chatViewModel (pure projection, unit-tested browser-free) → renderChat (pure Lit template) → ChatWidget (Lit host: reactive state + compose/send) → index.ts (SDK wiring).

Fail-loud, no invented defaults

src/config.ts: wsUrl and senderId have no fabricated defaults. The core's WS ingress is opt-in (binds 127.0.0.1:$CONTINUUM_CORE_WS only when set; no hardcoded port), and the WS transport establishes no identity yet (session() is {}; pairing is #37/#38) — a minted senderId would create a ghost citizen. Both resolve from ?core=/?me= query params → VITE_ env, else throw naming what's missing. <chat-widget> fails loud on an unwired sendHandler and surfaces send errors in-UI (never silently drops a message).

Boy-scout fix

sdk/typescript/Events.ts now re-exports Subscription — the generated EventApi (sdk_codegen/events.rs) imports it from '../Events' and it IS the public return type of subscribe(), so Events is its single source. Cleared a pre-existing SDK type error reachable through the barrel.

Validation (pure TS — never npm start/./jtag)

  • tsc --noEmit clean on apps/web.
  • vitest run — 6/6 on chatViewModel.spec.ts (slice 4) + StateConnection.spec.ts (slice 3).

Scope

STOP before slice 5 (the apps/tui, outlier B). Identity pairing (#37/#38) and the wall/kanban widgets are later slices — the vendored view closure is chat-only by design.

🤖 Generated with Claude Code

joelteply and others added 3 commits July 3, 2026 10:14
…l/typescript tree

The 14 continuum-positron ViewState wire types (chat/kanban/wall) were
emitting their ts-rs output to the crate-default `core/continuum-positron/
bindings/` dir — outside the canonical `protocol/typescript/` export root
every other Rust->TS boundary uses, so the types never reached TS
consumers (the #80 drift, positron facet). This is the read-surface
prerequisite for a type-safe web `<chat-widget>` that renders Asha's live
`ChatViewState` (#29).

Change: all 14 types (`ChatMessageView`, `SenderKind`, `Provenance`,
`RosterSlotView`, `ChatViewState`; the 7 kanban types; `WallPostView`,
`WallViewState`) now carry
`#[ts(export, export_to = "../../../protocol/typescript/positron/<T>.ts")]`
— resolved relative to `<crate>/bindings/`, landing them in the shared
`protocol/typescript/positron/` module alongside every other boundary
type. Regenerated via `cargo test -p continuum-positron` (82 passed);
hand-wrote the per-module `index.ts` barrel the ratchet
(`generated_barrel_sync`) requires; deleted the now-stale crate-default
`bindings/` dir.

positron is clean against the barrel ratchet (its per-module barrel
matches its .ts exactly). The pre-existing whole-tree barrel drift across
the other ~46 modules is #80 proper (the stale legacy-Node generator
targeting `workers/`/`shared/generated/`) — left untouched here; not
CI-gated (neither the ts-rs drift-guard nor `-p continuum-core --lib`
runs this integration-test ratchet) and out of scope for this unit.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
WIDGET-AS-STATE-KIND slice 3: the TS client for positron's state-down wire —
the third flow the command/event pair doesn't model. A consumer declares the
widget `kind`s it wants; the substrate pushes a ViewState snapshot immediately
and every live change after, with no per-update request. This is what a
`<chat-widget>` needs to mirror a room's live ChatViewState (slice 4, next).

The core already serves this end-to-end (ws.rs routes Subscribe → per-connection
run_session, streams State frames back; proven by
ws_subscribe_streams_a_live_state_frame_over_a_real_socket). On the wire the
Subscribe/State frames are byte-identical to positron's own
ClientMessage::Subscribe / ServerMessage::State, so StateConnection is typed
against the vendored positron frames directly — one source of truth for the
state wire, sidestepping continuum's WsClientMessage bare-import gap (#80).

- Vendor the 8-file positron wire closure into sdk/typescript/generated/positron/
  (self-contained workspace package, not a cross-repo file: dep — public-user
  safe). The ts-codegen emitter is off by default and doesn't own this subdir,
  so the vendored files survive.
- StateConnection: opens its own WS (state-only for now; commands still ride
  WebSocketTransport — the core multiplexes both, folding them is a later
  consolidation), sends one Subscribe on connect, routes each State frame to its
  per-kind sink. Tracks latest revision per kind → replays as last_seen on
  re-subscribe. Delivers the raw StateEnvelope — the app owns the payload→
  ViewState merge (SDK holds zero view logic). Exhaustive over ServerMessage so a
  new server frame is a compile error. Fails loud: no-kinds, empty-layers, drop,
  connect-error all surface; nothing swallowed.
- 9 vitest specs against a FakeWebSocket (sibling of WebSocketTransport.spec.ts):
  subscribe framing, per-kind routing, full-envelope delivery, last_seen replay,
  off() teardown, and the four fail-loud paths.

Validation: 9/9 specs pass; typecheck adds zero errors (4 pre-existing SDK
failures in conformance.spec.ts + generated/EventApi.ts are untouched by this).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…slice 4)

WIDGET-AS-STATE-KIND slice 4 (outlier A, the web `<chat-widget>`): reinvent the
chat client on `@continuum/sdk-typescript` — NOT a repair of the legacy
src/{browser,widgets,server,daemons} Node monolith. Renders Joel's
who/what/where-which layout from one live positron `ChatViewState`, with
"talk to Asha normally" (send) working.

Two sockets to the same core WS ingress (src/index.ts is the only file touching
both the SDK and the DOM):
  - READ  — StateConnection subscribed to kind="chat"; each envelope → ChatState
    pushed onto widget.state, Lit re-renders. Same read surface (#84) the persona
    observes.
  - SEND  — Continuum command client; compose bar issues one chat/send into the
    room on screen. Asha's reply returns through the READ stream (no optimistic
    local append to drift).

Layering, each testable in isolation:
  chatViewModel (pure projection, unit-tested browser-free)
    → renderChat (pure Lit template)
    → ChatWidget (Lit host: reactive state + compose/send, fails loud on unwired
      sendHandler, surfaces send errors in-UI — never silently drops a message)
    → index.ts (SDK wiring).

Fail-loud config (src/config.ts): wsUrl and senderId have NO invented defaults.
The core's WS ingress is opt-in (binds 127.0.0.1:$CONTINUUM_CORE_WS only when set;
no hardcoded port), and the WS transport establishes no identity yet (session() is
{}; pairing is #37/#38), so a fabricated senderId would create a ghost citizen.
Both resolve from ?core=/?me= query params → VITE_ env, or fail loud naming what's
missing and how to supply it.

SDK payload reachability: vendored the chat ViewState closure into
sdk/typescript/generated/views/ (ChatViewState + ChatMessageView/RosterSlotView/
SenderKind/Provenance) and re-exported from the barrel, so apps/web depends only
on @continuum/sdk-typescript — kept separate from the neutral generated/positron/
transport types, re-vendored from protocol/typescript/positron/ on change.

Boy-scout fix (was blocking apps/web typecheck): sdk/typescript/Events.ts now
re-exports `Subscription`. The generated EventApi (sdk_codegen/events.rs) imports
it from '../Events', and it IS the public return type of subscribe(), so Events is
its single source — this cleared a pre-existing SDK type error reachable through
the barrel.

Validated pure-TS (never npm start/jtag): `tsc --noEmit` clean on apps/web;
`vitest run` 6/6 on the view-model spec. STOP before slice 5 (the tui, outlier B).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…29 review)

Two non-blocking findings from the PR #1744 review, both tightening fail-loud:

- .env.example shipped the nil UUID as VITE_CONTINUUM_USER_ID, which sailed past
  config.ts's empty-string guard and would mint a ghost citizen from an unedited
  copy — undercutting the file's own "never fabricated" warning. Blank it so a
  copied-but-unedited .env trips the guard.
- chat/send: add an explicit `success === false` throw alongside the existing
  `warning` surface. A kernel failure already rejects in the transport, but this
  hardens against any handler that reports failure in-band instead — the message
  is never silently dropped, the widget shows it and keeps the draft.

Re-validated pure-TS: tsc --noEmit clean; vitest 6/6; `vite build` transpiles the
SDK .ts source through the bundler (25 modules → 33 KB) — the bundler smoke the
reviewer couldn't run, now green.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply merged commit 6af2d68 into canary Jul 3, 2026
4 checks passed
@joelteply
joelteply deleted the feat/positron-web-chat-client branch July 3, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant