Skip to content

fix(web): notebook error tracebacks no longer show color codes - #36698

Closed
StiensWout wants to merge 2 commits into
pingdotgg:mainfrom
StiensWout:t3/strip-notebook-error-ansi
Closed

StiensWout wants to merge 2 commits into
pingdotgg:mainfrom
StiensWout:t3/strip-notebook-error-ansi

Conversation

@StiensWout

Copy link
Copy Markdown
Contributor

Saved IPython notebook errors display raw terminal color codes, making their tracebacks hard to read. Strip SGR sequences from traceback frames before joining them, keeping the existing frame-boundary behavior. Cell sources, literal escape spellings and other output kinds retain their existing handling.

Found by the GPT 6.1 Sol bughunt and independently confirmed by Claude Opus 5.5 with a freshly produced default IPython notebook. Small fast-lane fix in the existing parser helper, with no new state or UI flow.

Proof

  • Extended the existing foreign-format parser case: red on base, green on head. Covers SGR removal, newline boundaries, source preservation and literal escape spellings.
  • Temporary Chromium attachment diagnostic: producer notebook fails on base and passes on the fix; plain control passes on both. Uses the real worker/parser and NotebookPreview, with only source highlighting mocked.
  • Temporary full-app notebook-error-ansi.e2e.ts scenario through Files: pnpm exec vp run scenarios:prove scripts/scenarios/notebook-error-ansi.e2e.ts --base 8cb551a3cec68767054b67b790b8293ac1e7859a --head HEAD fails on base and passes on head.
  • Lead's integrated Browser Files pass confirmed a clean traceback ending in ZeroDivisionError: division by zero.
  • pnpm exec vp run check:changed passes.
  • Local cubic: no issues; hosted repository context unavailable for the fork.
Before After
Before After

Captures show the equivalent reviewed patch before its unchanged rebase. Temporary diagnostics and scenario are proof artifacts, not committed renderer tests. Only saved error outputs are proved; no claim about ANSI in streams or non-SGR terminal controls. Source highlighting was still loading when the captures were taken.

Council review

Delegate Round 1
Claude Opus 5.5 9/10
GPT 6.1 Sol 10/10

No blockers or shoulds. Opus nits retained: SGR-only frames retain existing blank-line behavior; the shared terminal helper accepts different SGR syntax, so reusing it is a separate change. Stream ANSI handling remains outside this fix.

Created with GPT 6.1 Sol (lead, bughunt and review) and Claude Opus 5.5 (verification, build, trim and review) in T3 Code through the Codex and Claude harnesses.

Closes #36697

StiensWout and others added 2 commits November 14, 2026 12:34
IPython colors every saved traceback frame with ANSI SGR sequences, and the
notebook preview printed them raw into a plain <pre>. Strip SGR from error
traceback frames only; stream text, sources and literal escape spellings stay
as saved, and the frame newline boundary is unchanged.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: GPT 6.1 Sol <codex@openai.com>
Co-authored-by: GPT 6.1 Sol <codex@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 14, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 3d1120f

Macroscope's review found this PR approvable — Notebook error previews now remove terminal color codes while preserving separation between traceback frames. This is a localized display correction with no changes to stored notebook data or product defaults.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The notebook file preview removes ANSI SGR color sequences from string traceback frames. The updated test checks that traceback text is cleaned while literal escape notation and ANSI sequences in code cell source remain preserved.

Changes: Notebook traceback preview

Layer / File(s) Summary
Traceback cleanup and notebook test coverage
apps/web/src/components/files/extendedDocumentPreview.ts, apps/web/src/components/files/FilePreviewPanel.test.ts
tracebackLines strips ANSI SGR sequences from string frames before checking newline boundaries. The notebook test verifies cleaned traceback text and preserved code cell source.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: geezoria

Merge Risk: Minimal · up to 3d112

Saved notebook error tracebacks now display as readable text without visible color codes. The change is narrow and covered by the updated parser test, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: notebook error tracebacks no longer show ANSI color codes. The raw summary shows the change strips SGR sequences from traceback frames in tracebackLines, and the objec…
Description check Passed The description follows the template's main ideas. It states the problem (saved IPython error outputs show raw color codes), the change (strip SGR sequences from traceback frames before joining, keep …
Linked Issues check Passed Issue #36697 requires saved notebook error tracebacks to display as readable plain text with frame boundaries preserved. The raw summary states that tracebackLines in apps/web/src/components/files/e…
Out of Scope Changes check Passed The changes, as summarized, touch two files: the notebook traceback helper tracebackLines in apps/web/src/components/files/extendedDocumentPreview.ts and its test in apps/web/src/components/files/Fi…
Full details: Title check

Explanation

The title names the main change: notebook error tracebacks no longer show ANSI color codes. The raw summary shows the change strips SGR sequences from traceback frames in tracebackLines, and the objectives state the same goal. The title uses the conventional commit format the template asks for.

Full details: Description check

Explanation

The description follows the template's main ideas. It states the problem (saved IPython error outputs show raw color codes), the change (strip SGR sequences from traceback frames before joining, keep frame-boundary behavior), the scope (saved error outputs only; links issue #36697 and says it is a small fix), and verification (a parser test red on base and green on head, a Chromium diagnostic, a full-app scenario, and check:changed). Its verification is specific and states what was not claimed. It does not contain the template's HTML comments, which is acceptable. The Scope section gives an issue link, so no justification for skipping an issue is needed. Minor gap: the Problem section does not give separate reproduction steps, but the linked issue and verification cover them.

Full details: Linked Issues check

Explanation

Issue #36697 requires saved notebook error tracebacks to display as readable plain text with frame boundaries preserved. The raw summary states that tracebackLines in apps/web/src/components/files/extendedDocumentPreview.ts now removes ANSI SGR sequences from string traceback frames before joining them, and keeps the existing newline-before-frame rule. The extended test in apps/web/src/components/files/FilePreviewPanel.test.ts covers ANSI-colored frames, a trailing SGR sequence, a literal \x1b spelling, and preservation of a code cell source containing an escape sequence. Together these address the issue's coding requirement and its automated test expectation. Limitation: the repository diff and the changed helper body could not be read (diff inspection unavailable, and the file read was truncated before tracebackLines). This PASS relies on the raw summary and the PR description, not on a direct reading of the changed code. The PR description also reports a temporary browser diagnostic and full-app scenario that fail on base and pass on head; these were not independently verified.

Full details: Out of Scope Changes check

Explanation

The changes, as summarized, touch two files: the notebook traceback helper tracebackLines in apps/web/src/components/files/extendedDocumentPreview.ts and its test in apps/web/src/components/files/FilePreviewPanel.test.ts. Both fall within the reported objective of stripping SGR sequences from saved notebook error traceback frames. The test additions for cell sources and literal escape spellings verify the stated preservation constraints rather than adding unrelated behavior. No unrelated change is identified. Limitation: the full changed-file list and diff could not be read in this review, so completeness rests on the supplied summary.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

Note

This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 1159aa2 and 3d1120f.

Files selected for processing: 2

  • apps/web/src/components/files/FilePreviewPanel.test.ts
  • apps/web/src/components/files/extendedDocumentPreview.ts

Limit details: You’ve used all 10 included reviews currently available.

@juliusmarminge

Copy link
Copy Markdown
Member

Thanks for this. #31929 makes the same change and is the one being kept.

#31929 fixes the same saved-notebook traceback problem. It uses the existing shared plain-text helper and extends that helper to support colon-form SGR colors, keeping this cleanup in one place.

Your source-preservation and literal-escape assertions are useful additions that could strengthen the retained fix.

Closing as a duplicate.

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

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Saved notebook errors display raw terminal color codes

2 participants