feat(web): React UI v2.0 — Phase 2 Tasks 23-25 (SSE + WS + reducer)#21
Merged
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Phase 2 Batch B of React UI v2.0 — the live-data plumbing. After this lands, Phase 2 Batch C (data hooks composing apiFetch + SSE + reducer) becomes a 7-task parallel batch.
useEventSource(url, onMessage, enabled)(web/src/api/sse.ts) +MockEventSourcetest helper. JSON-parse-and-drop-malformed pattern. Closes the connection on unmount; intentionally excludesonMessagefrom deps to avoid reconnect-per-render. 2 tests.useWebSocket(url, onMessage, enabled)(web/src/api/ws.ts) +MockWebSockethelper. Identical signature touseEventSourceso it's drop-in substitutable when SSE is blocked by a corporate proxy. 4 tests including malformed JSON skip +enabled=falseno-connect.sessionReducer(web/src/state/sessionReducer.ts) — pure reducer with two actions (bootstrap,event) and avm_seqwatermark that drops stale/duplicate events. Handlesagent_finished,tool_invoked,approval_pending,status_changedevent kinds; unknown kinds still advancevmSeqand append to the events buffer. Returns the same state reference on stale events (test assertsexpect(next).toBe(state)). 7 table-driven tests.Validation
cd web && npm install→ 0 vulnerabilitiesnpm run typecheck→ exit 0npx vitest run→ 46 passed / 0 failed (Phase 2 Batch A's 33 + 2 SSE + 4 WS + 7 reducer)npm run build→ clean, 194 kB JS, 8.1 kB CSSNothing touches
src/runtime/— nodist/app.pyregen.Design notes
eslint-disable-next-line react-hooks/exhaustive-depscomments in the hooks are intentional —onMessageis omitted from the dep array to avoid reconnecting on every render. ESLint isn't installed yet (Task 20b), but the comments are harmless placeholders for when it is.sessionReduceris fully pure: no closures, no async, no side effects. Same state reference returned for no-op cases.agent_started,session.created,session.status_changed, lessons updates). Those will be added as the canvas + monitors need them in Phases 4-5. Today's set covers the bootstrap + happy-path delta application.Test plan
🤖 Generated with Claude Code