Skip to content

fix(chat): preserve whitespace in structured transcript content - #50565

Closed
Afloat16 wants to merge 1 commit into
stablyai:mainfrom
Afloat16:afloat16/orca50-20261127-transcript-content-whitespace
Closed

Afloat16 wants to merge 1 commit into
stablyai:mainfrom
Afloat16:afloat16/orca50-20261127-transcript-content-whitespace

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

ELI5

Preserve code indentation and final newlines in structured chat transcripts.

What Changed

Preserve original meaningful text, thinking and tool-output content when it arrives in structured blocks. Keep identifier normalization and whitespace-only message suppression.

Why

Object-shaped text and tool outputs were trimmed while equivalent string content was preserved. A file read beginning with indentation and indented Markdown lost its first-line indentation and final newline.

src/main/native-chat/transcript-decoding/transcript-line-decoders-claude.ts; src/main/native-chat/transcript-decoding/transcript-line-decoders-omp.ts.

Linked Issue

Fixes #50564

Visual Proof

N/A — no graphical layout or interaction change; data-level evidence follows.

Before/after data-level reproduction of the same input:

Before After
Two real decodeClaudeTranscriptLine regressions failed: object text became unindented and structured tool output lost leading spaces and final LF. Both decoder regressions pass, including thinking blocks, object and array tool outputs, ordinary text, and whitespace-only message suppression.

No graphical layout change is included. The evidence above is from the production operation; no desktop screenshot is claimed.

Testing

  • I manually tested these changes locally through the production-entry reproduction described above
  • Automated tests added/updated, or explained why not below
  • Every added test fails without this change and avoids the test anti-patterns

Parser data integrity with real production entry points

node config/scripts/test-runtime/execution-policy/run-vitest.mjs run --config config/vitest.config.ts src/main/native-chat/transcript-decoding/transcript-content-whitespace.test.ts

Locally exercised on Linux with Node 24.22.3. External API cases use protocol fixtures; no live provider account, graphical desktop, macOS, Windows or remote SSH execution is claimed.

Changed-code quality passed with zero findings. Node typecheck passed (17,005 files); web typecheck passed (16,094 files). The integrated regression run passed 51 tests in 30 files; the Drive performance contract passed separately. The final three test typing changes were rerun and passed. These are aggregate first-batch results, not per-PR test counts.

The required pnpm check:changed --base=9890ea181c0f9ae59fb82da64c4a6fbc0504a817 was attempted after final edits. It stopped in the workspace-package build because this environment rejects the tsx CLI's local IPC socket (listen EPERM). The full gate/build is therefore not claimed to pass; CI remains required. The process-host build entry executed successfully using node --import tsx --conditions=orca-source.

Performance

Only meaningful content keeps its original whitespace. Identifiers and labels remain trimmed. Empty messages remain suppressed. No new I/O or whole-transcript scans.

Risk

Level: Low

Only meaningful content keeps its original whitespace. Identifiers and labels remain trimmed. Empty messages remain suppressed. No new I/O or whole-transcript scans.

A plain revert restores the previous behavior; no schema migration is introduced.

AI Disclosure

Core contribution owner: @Afloat16. Required tooling disclosure: GPT-6 Astra Pro was used for implementation and review.

Review

Reviewed the production caller, baseline failure, ordinary controls, data integrity and additional work. No new shell commands, path grammar, remote protocol fields, polling or UI layout were introduced. SSH/remote, mobile and agent integrations retain their existing entry points.

Agent skill upstream boundary

  • Not applicable: this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments or documentation.

Notes

Related work checked for distinct scope:

Checklist

  • This PR is small and focused
  • I explained what changed and why, including the mechanism and before/after result
  • I stated the risk and how to back it out
  • Before/after data evidence is included; no graphical layout change
  • Self-reviewed for correctness, security and performance
  • Cross-platform, SSH/remote and path/shortcut impact considered
  • Full lint/typecheck/test/build gate: component results and local IPC limitation are recorded above; CI still needs to cover the complete gate

@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The transcript decoder now preserves original whitespace in non-empty structured text, thinking, and tool-output strings. It rejects strings that contain only whitespace. New tests compare structured content with equivalent plain text and cover ordinary replies and whitespace-only content.

Severity of issue fixed: Low

Merge Risk: Minimal · up to 9920f

Structured transcript blocks now keep their indentation and trailing newlines, matching plain-string content. Whitespace-only messages are still suppressed. The change is small and easy to revert, and I found no merge-blocking risk. Confirm that CI passes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title 'fix(chat): preserve whitespace in structured transcript content' names the main change: whitespace in structured transcript blocks (text, thinking, tool output) is now preserved. The raw su…
Description check Passed The description follows the template well. It has ELI5, What Changed, Why, Linked Issue (Fixes #50564), Visual Proof (N/A with a reason and data-level evidence), Testing with checkboxes and commands, …
Linked Issues check Passed Directly linked issue #50564 asks that structured Claude transcript text, thinking, and tool output keep leading indentation and final newlines. Identifier normalization and whitespace-only suppressio…
Out of Scope Changes check Passed The whole-PR diff changes only src/main/native-chat/transcript-decoding/transcript-record-blocks.ts, per the diff and summary. The changes are the whitespace-preserving content helper and its use in t…
Full details: Title check

Explanation

The title 'fix(chat): preserve whitespace in structured transcript content' names the main change: whitespace in structured transcript blocks (text, thinking, tool output) is now preserved. The raw summary confirms contentString and toolResultOutput now keep original whitespace, and the added tests cover this behavior. The title is specific and concise, and it follows a conventional commit style.

Full details: Description check

Explanation

The description follows the template well. It has ELI5, What Changed, Why, Linked Issue (Fixes #50564), Visual Proof (N/A with a reason and data-level evidence), Testing with checkboxes and commands, Performance, Risk with level and revert path, AI Disclosure, Review, Agent skill boundary, Notes, and Checklist. Gaps: the Performance section is a single line but gives a reason. The Risk section repeats the Performance text. The Testing section reports a failed full gate, and the final checklist item is left unchecked. The 'What Changed' section mixes in a file path list. The 'Every added test fails without this change' box is checked, but the description gives no per-test evidence beyond the before/after table. These are minor and do not make the description incomplete.

Full details: Linked Issues check

Explanation

Directly linked issue #50564 asks that structured Claude transcript text, thinking, and tool output keep leading indentation and final newlines. Identifier normalization and whitespace-only suppression must remain.

Evidence at reviewed head, from the whole-PR diff against merge base 9890ea1:

  • transcript-record-blocks.ts adds contentString(), which accepts a string when value.trim() is non-empty and returns the original, untrimmed string. It returns null for whitespace-only input.
  • claudeContentBlock() uses contentString() for type 'text' and for thinking (thinking, then text). Original whitespace is kept. Whitespace-only blocks still return null, so they are suppressed.
  • toolResultOutput() uses contentString() for object-shaped and array-shaped tool output (text, then content). Original whitespace is kept. Whitespace-only parts are skipped.
  • Identifiers and names still use extractString() (tool name, tool_use_id, id, image fields). Identifier trimming is retained.
  • claudeContentBlocks() string-content path still checks content.trim() for emptiness and returns the original string.

Uncertainty:

  • Tool results that match the isClaudeToolResultContent() fallback in the default branch use claudeToolResultText() from shared/agent-hook-listener/providers/claude/transcripts/claude-tool-content. That file is not in the diff. Its whitespace behavior was not inspected.
  • The PR description and summary name transcript-line-decoders-claude.ts and transcript-line-decoders-omp.ts as changed. The diff for both files is empty. The requirement is met through transcript-record-blocks.ts. The description is inaccurate on this point.
  • The new test file transcript-content-whitespace.test.ts was not inspected. Test results are taken from the PR description, not from independent verification.
Full details: Out of Scope Changes check

Explanation

The whole-PR diff changes only src/main/native-chat/transcript-decoding/transcript-record-blocks.ts, per the diff and summary. The changes are the whitespace-preserving content helper and its use in toolResultOutput() and claudeContentBlock(). Both are the direct implementation of #50564. The summary also lists transcript-content-whitespace.test.ts (+37 lines). It adds regression tests for the same behavior, which supports the implementation. No unrelated behavior change was found. The related issues #46311 and #31554 were reviewed for scope only and are not implemented here.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 43f4f159-66de-4222-b136-c31717911e36
Commits

Reviewing files that changed from the base of the PR and between e54fd94 and 9920f6d.

Files selected for processing: 2

  • src/main/native-chat/transcript-decoding/transcript-content-whitespace.test.ts
  • src/main/native-chat/transcript-decoding/transcript-record-blocks.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@nwparker

Copy link
Copy Markdown
Contributor

Thanks @Afloat16 for finding this and for the fix! I've carried it forward in #50670, rebased on current main with a few follow-ups from review: text blocks now drop their edge blank lines so copied replies stay clean, tool-result parts no longer get doubled newlines, and the result preview skips leading blank lines. Your authorship is kept through a Co-authored-by trailer on the commit. Closing this one in favor of #50670.

@nwparker nwparker closed this Nov 27, 2026
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.

[Bug]: Structured transcript text loses indentation and final newlines

2 participants