feat(web): React UI v2.0 — Phase 2 Tasks 21-22 (TS types + apiFetch)#20
Merged
Conversation
…meout) The TS spec from the design doc omitted two literal status values the backend actually emits. Adding them now so Task 25's reducer can switch on the full set without TS narrowing errors. The 'auto_rejected' value in the spec is kept — the UI synthesizes it on HITL timeout per §16.5.
|
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 A of React UI v2.0 — the foundational types and HTTP client that downstream hooks (Tasks 23-31) build on.
web/src/api/types.ts(90 lines): hand-authored TypeScript types mirroring/api/v1/*schemas —Session,AgentRun,ToolCall,AgentDefinition,SessionEvent,SessionFullBundle,UiHints,AppView,ApiError. v2.1 should generate from OpenAPI.web/src/api/client.ts+ tests (3 tests):apiFetch<T>(path, options)with/api/v1prefix,localStorage['asr.token']→Authorization: Bearer …, structuredApiClientError({status, code, message, details}) on 4xx/5xx.ToolCall.statusliteral union widened to includeexecuted_with_notifyandtimeout(backendToolStatusemits these; the spec missed them). Without this fix, Task 25's reducer would hit type narrowing errors when switching on event payloads.Validation
cd web && npm install→ 0 vulnerabilitiesnpm run typecheck→ exit 0npx vitest run→ 33 passed / 0 failed (Phase 1's 30 + 3 new client tests)npm run build→ cleanNothing touches
src/runtime/— nodist/app.pyregen.Implementation note
client.tsusesawait res.clone().json()(notawait res.json()) when reading error bodies. This handles the test pattern where the sameResponseinstance is consumed twice — without.clone(),bodyUsed=trueafter the first read silently drops the error code. It's a safer choice in production too (keeps the body readable for retry/logging if needed).Type drift surfaced for future follow-up
The backend cross-check found a few smaller drifts that don't block Phase 2 but should be addressed before v2.0-rc1:
Session.token_usage— backend has it (session-level rollup); TS doesn't. Apps surfacing rolled-up token totals would need it.Session.status— backend is openstr; TS narrows to a Literal union. The narrowing may miss edge statuses.AgentRun.token_usage— TS marks optional; backend always present (default_factory=TokenUsage). Intentional per the spec, but TS could tighten.These are tracked as latent items and don't change wire compatibility.
Test plan
🤖 Generated with Claude Code