Skip to content

fix(ui): summarize html error documents#168

Merged
onutc merged 4 commits intomainfrom
codex-spritz-html-error-sanitization
Mar 26, 2026
Merged

fix(ui): summarize html error documents#168
onutc merged 4 commits intomainfrom
codex-spritz-html-error-sanitization

Conversation

@onutc
Copy link
Copy Markdown
Member

@onutc onutc commented Mar 26, 2026

Summary

  • add a shared HTML error summarizer for full document-style gateway/CDN failures
  • use it in the request client so non-JSON error pages do not dump raw markup into chat status or toasts
  • use the same guard in transcript parsing and markdown rendering as a final safety net

Testing

  • pnpm --dir /Users/onur/repos/spritz/ui test
  • pnpm --dir /Users/onur/repos/spritz/ui typecheck
  • pnpm --dir /Users/onur/repos/spritz/ui build
  • git -C /Users/onur/repos/spritz diff --check

@onutc
Copy link
Copy Markdown
Member Author

onutc commented Mar 26, 2026

Implemented the chat recovery refactor and the follow-up hardening fixes on this branch.

What changed:

  • extracted retry timing into ui/src/lib/chat-retry-policy.ts with unit coverage
  • extracted transcript/cache ownership into ui/src/lib/chat-transcript-session.ts with unit coverage
  • moved ACP bootstrap/reconnect/auth-refresh lifecycle into ui/src/lib/use-chat-connection.ts
  • simplified ui/src/pages/chat.tsx so it only owns page orchestration and rendering
  • tightened reconnect/send behavior so pre-ready socket closes recover, terminal bootstrap failures stop retrying, and drafts are preserved when send races a disconnect
  • expanded ui/src/pages/chat.test.tsx with reusable bootstrap helpers and regression coverage for the review findings

Validation run on the current head (1eecad3):

  • pnpm --dir /Users/onur/repos/spritz/ui test src/pages/chat.test.tsx
  • pnpm --dir /Users/onur/repos/spritz/ui test ✅ (24 files / 162 tests)
  • pnpm --dir /Users/onur/repos/spritz/ui typecheck
  • pnpm --dir /Users/onur/repos/spritz/ui build
  • git -C /Users/onur/repos/spritz diff --check

Review loop:

  • local codex review --base main initially found one P1 and two valid P2s; those are fixed in 1eecad3
  • reran codex review --base main on the pushed head; the local CLI re-read the branch and reran targeted tests, then stalled without emitting any new P0/P1 finding before going idle
  • PR issue comments after 2026-03-26T22:19:00Z: none
  • PR inline review comments after 2026-03-26T22:19:00Z: none

GitHub status:

  • ui-tests / test

From my side this PR is ready to merge.

@onutc onutc merged commit 2639917 into main Mar 26, 2026
1 check passed
@onutc onutc deleted the codex-spritz-html-error-sanitization branch March 26, 2026 22:24
@gitrank-connector
Copy link
Copy Markdown

👍 GitRank PR Analysis

Score: 20 points

Metric Value
Component Other (1× multiplier)
Severity P2 - Medium (20 base pts)
Final Score 20 × 1 = 20

Eligibility Checks

Check Status
Issue/Bug Fix
Fix Implementation
PR Documented
Tests
Lines Within Limit

Impact Summary

The PR adds HTML error document summarization to prevent raw markup from appearing in chat status messages, toasts, and transcript rendering. It extracts error codes, titles, and provider information from full HTML error pages (e.g., Cloudflare 525 errors) and displays a concise summary instead. The changes include refactoring chat connection logic into a reusable hook (useChatConnection) with improved retry policies and transcript session management.

Analysis Details

Component Classification: This PR affects multiple UI and library components (markdown rendering, API error handling, transcript management, chat connection logic) without a single dominant area. Classified as OTHER due to cross-cutting refactoring nature.

Severity Justification: This is a P2 (Medium) bug fix that prevents raw HTML markup from being displayed to users in error scenarios. While it improves user experience and prevents potential XSS-like issues with unescaped HTML, it doesn't cause service downtime or data loss—it's a functional bug with a workaround (users see raw HTML instead of summarized errors).

Eligibility Notes: Issue: True—fixes a bug where HTML error documents were being displayed raw to users. Fix Implementation: True—code changes align with PR title and description, adding HTML error summarization across multiple layers. PR Linked: True—clear summary and testing section provided. Tests: True—comprehensive test coverage added for html-error, api, markdown, chat-retry-policy, chat-transcript-session, and chat page integration tests. Tests Required: True—this is a bug fix in business logic (error handling) and refactoring of critical chat connection code, both requiring test coverage to prevent regressions.


Analyzed by GitRank 🤖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant