Skip to content

feat: add persistent word-wrap setting for chat code blocks and tables#3480

Open
imabdulazeez wants to merge 5 commits into
pingdotgg:mainfrom
imabdulazeez:feat/chat-code-block-word-wrap
Open

feat: add persistent word-wrap setting for chat code blocks and tables#3480
imabdulazeez wants to merge 5 commits into
pingdotgg:mainfrom
imabdulazeez:feat/chat-code-block-word-wrap

Conversation

@imabdulazeez

@imabdulazeez imabdulazeez commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

What Changed

Added a Wrap code blocks and tables client setting that controls whether long content in chat messages wraps by default — covering both code blocks and tables.

  • New chatWordWrap boolean in the client settings schema (ClientSettingsSchema + ClientSettingsPatch), defaulting to true. (Renamed from the earlier chatCodeBlockWordWrap now that it governs more than code blocks.)
  • MarkdownCodeBlock seeds its per-block wrapped state from this setting instead of always starting unwrapped.
  • MarkdownTable now seeds its expanded (wrap) state from the same setting, so wide tables render with wrapped cells by default instead of truncating. The footer expand/collapse toggle still works for ad-hoc overrides.
  • Added a Wrap code blocks and tables row to the General settings panel (Switch + per-setting reset button), and wired it into the settings restore/reset flow and the "modified settings" summary.
  • Removed the orphaned data-wrap table CSS; tables wrap via the existing [data-expanded="true"] styling.
  • Updated the desktop ClientSettings test fixture to the renamed field.

Why

Long, unwrapped lines in chat code blocks and wide table cells force horizontal scrolling, which is awkward to read. Previously each block/table started in its non-wrapped state with users having to toggle every one individually. This adds a single, persisted preference so users can make wrapping the default across both content types, while keeping the per-element toggle for exceptions. Default is true so the more readable behavior is on out of the box.

Screenshots

Settings → General — new "Wrap code blocks and tables" toggle

image

Chat code block + table with wrap default applied

image image

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes (after only)
  • I included a video for animation/interaction changes

Note

Cursor Bugbot is generating a summary for commit 6684c33. Configure here.

Note

Add persistent word-wrap setting for chat code blocks, tables, diffs, and file previews

  • Replaces the separate diffWordWrap and chatWordWrap settings with a single unified wordWrap boolean in ClientSettingsSchema, defaulting to true.
  • Chat code blocks and tables in ChatMarkdown.tsx now initialize their wrapped/expanded state from settings.wordWrap instead of hardcoded false.
  • Diff view and file preview panels are updated to read from settings.wordWrap, and the Settings UI label is renamed from 'Diff line wrapping' to 'Word wrap'.
  • Behavioral Change: wordWrap defaults to true on first decode, so all surfaces wrap by default for new and existing users whose stored settings lack the key.

Macroscope summarized cf71bb9.

- adds `chatCodeBlockWordWrap` client setting (default: true)
- uses persisted setting as default wrap state in code blocks
- adds toggle in general settings panel with reset support
@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 228ada45-9f60-44e6-8835-51a0aacbf6cd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jun 21, 2026
@macroscopeapp

macroscopeapp Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

Unable to check for correctness in cf71bb9. An unresolved review comment identifies a medium-severity bug where word-wrap state won't update after component mount. Additionally, this PR changes runtime behavior by modifying defaults and extending where the setting applies.

You can customize Macroscope's approvability policy. Learn more.

- extends wrap setting to cover table cells as well as code blocks
- updates setting key, UI labels, and reset logic
@imabdulazeez imabdulazeez changed the title feat: add persistent markdown word-wrap setting for chat feat: add persistent word-wrap setting for chat code blocks and tables Jun 22, 2026
Comment thread packages/contracts/src/settings.ts Outdated

export const ClientSettingsSchema = Schema.Struct({
autoOpenPlanSidebar: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
chatWordWrap: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually this should probalby just be wordWrap and be applied as default to diff and code views in general?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense. let me look into it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juliusmarminge this is done, please check :)

image

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6684c33. Configure here.

const [expanded, setExpanded] = useState(false);
const [expanded, setExpanded] = useState(
useClientSettings((settings) => settings.chatWordWrap)
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chat wrap ignores updated settings

Medium Severity

The MarkdownTable and MarkdownCodeBlock components initialize their expanded and wrapped states from the chatWordWrap setting using useState. This causes them to only read the setting once on mount. As a result, changes to the chatWordWrap setting (e.g., after async hydration or user toggling) don't update the component's wrap/expand state, leading to an incorrect display until the component remounts.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6684c33. Configure here.

@imabdulazeez imabdulazeez force-pushed the feat/chat-code-block-word-wrap branch from cdb1184 to 6684c33 Compare June 22, 2026 18:05
- single wordWrap setting covers code blocks, tables, diffs, and file previews
- obsolete chatWordWrap/diffWordWrap keys are stripped on decode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants