Skip to content

feat(web): add word wrap to file source previews - #1754

Open
techotaku39 wants to merge 1 commit into
tiann:mainfrom
techotaku39:fix/web-file-preview-code-wrap
Open

feat(web): add word wrap to file source previews#1754
techotaku39 wants to merge 1 commit into
tiann:mainfrom
techotaku39:fix/web-file-preview-code-wrap

Conversation

@techotaku39

Copy link
Copy Markdown
Contributor

Summary

  • Add a word-wrap toggle to source-mode file previews.
  • Reuse the existing hapi-code-wrap preference used by conversation detail code surfaces.
  • Preserve the preference across reloads, sessions, tabs, and windows on the same origin.
  • Preserve syntax highlighting and horizontal scrolling when wrapping is disabled.
  • Add regression coverage for persisted state, toggle behavior, and source rendering.
  • No API, data, dependency, or migration changes.

Problem / Motivation

Source-mode file previews currently render long lines using horizontal scrolling and do not expose the existing word-wrap control. This makes large files difficult to read on narrow screens and makes file previews inconsistent with conversation detail code blocks.

Validation

  • bun typecheck — passed.
  • bun run --cwd web test -- src/routes/sessions/file.test.tsx src/components/CodeBlock.test.tsx src/components/assistant-ui/shiki-highlighter.test.tsx src/components/assistant-ui/markdown-text-codeblock.test.tsx src/hooks/useCodeWrap.test.ts — 5 files, 32 tests passed.
  • pwsh -NoProfile -File .\scripts\Invoke-HapiTaskPlaywright.ps1 -Name file-preview-code-wrap -Suite Root -TestArgs terminal-wrap-fidelity.spec.ts — 2/2 passed.
  • bun run build — passed.
  • Full Live Playwright verification through the task wrapper — 3/3 passed:
    • Desktop source preview toggle and reload persistence.
    • Mobile classic scrollbar wrapping without horizontal overflow.
    • Mobile overlay scrollbar wrapping without horizontal overflow.
  • git diff --check — passed.

Related Issues

Refs #1074

AI Disclosure

OpenAI Codex assisted with the implementation and validation. Model: GPT-5.6.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Findings

  • None.

Summary
Review mode: initial. No Blocker, Major, Minor, or Nit issues found in the added/modified lines. The source preview uses the existing shared wrap preference, retains the unwrapped horizontal-scroll path, and keeps the syntax-highlighted content inside the styled pre element. Residual testing risk: the added unit test mocks the Shiki renderer and cannot validate real highlighted DOM or narrow-viewport overflow geometry.

Testing

  • Not run (automation); static review only.
  • GitHub checks at review time: integration passed; test pending.

HAPI Bot

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