feat(web): React UI v2.0 — Phase 2 Tasks 26+27+30+31 (data hooks + selectedRef)#22
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 C subset of React UI v2.0 — the data composition layer that turns the primitives from Batch A/B into hooks that components can consume directly. After this lands, only Tasks 28 (useApprovalsQueue) and 29 (useAgentDefinitions) remain in Phase 2; both are independent and dispatch in parallel as a final mini-batch.
useSessionFull(sid)(web/src/state/useSessionFull.ts) — composesuseReducer(sessionReducer)+apiFetch('/sessions/{sid}/full')for bootstrap +useEventSource('/sessions/{sid}/events')for live deltas. Exposes{ state, isLoading, error, refresh }. SSE gated on bootstrapped flag so no event lands before initial state. 3 tests.useSessionList()(web/src/state/useSessionList.ts) — fetch/sessions+ subscribe/sessions/recent/eventsforsession.created/session.status_changed/session.agent_runningdeltas.SessionSummaryshape kept local to the hook (not promoted totypes.tsuntil Phase 3 needs it). 3 tests.useUiHints()(web/src/state/useUiHints.ts) —@tanstack/react-querycache-once for/config/ui-hints.staleTime: Infinity, gcTime: Infinitysince UiConfig is loaded at app startup and immutable. 2 tests.selectedRef(web/src/state/selectedRef.tsx) — React Context selection model with{ kind: 'agent'|'tool_call'|'message'|null, id?: string }. Two-context split (value + setter) so components that only calluseSetSelected()don't re-render on selection change. Throws when consumed outside Provider. 4 tests.Validation
cd web && npm install→ 0 vulnerabilitiesnpm run typecheck→ exit 0npx vitest run→ 58 passed / 0 failed (Phase 2 Batch B's 46 + 12 new)npm run build→ cleanNothing touches
src/runtime/— nodist/app.pyregen.Design notes
apiFetch,useEventSource,sessionReducer) — no logic duplication.useSessionListusessetStaterather than the reducer because cross-session deltas don't need vm_seq watermarking (each session has its own seq scope).selectedRefdeliberately uses Context rather than Zustand to avoid the dep. The two-context split (SelectedRefContext+SetSelectedRefContext) keeps re-renders narrow when only the setter is consumed.useUiHintsdoesn't share the_helpers/render.tsxtest wrapper — it inlines its own QueryClient withgcTime: 0for test isolation. Intentional.Out of scope (next batch)
useApprovalsQueue()— derived fromuseSessionList(), filters pending-approval tool calls.useAgentDefinitions()— react-query cache-once for/api/v1/agents.Both will land in a final Phase 2 Batch D (parallel, ~10 min total) before Phase 3 (Shell components) starts.
Test plan
🤖 Generated with Claude Code