Repository navigation
fix(chat): show a patch in one column on a phone - #1325
Merged
Merged
Conversation
Two columns of code need two code columns, and a phone does not have two: at 390px each half is about 150px, so every line of a real edit wrapped inside its own half and the two halves had to be compared from memory. The patch now takes the columns the viewport has. - `SplitFilesView()` reads `useIsMobile()` and hands `PatchDiffFiles` a `layout`, so both the `apply_patch` card and a result's patch switch together and a phone never renders one view of each. - `unifiedDiffLines()` (`lib/patch.ts`) turns a file's paired rows into patch order: a removed line above the line that replaces it, context lines printed once. `components/FileViewer.tsx` reads the same rows through it, so its diff and the card's cannot drift. - One gutter, since a second costs the width the code needed: a removed line keeps the old number, every other line the new one, as FileViewer's gutter already did. Hunk headers stay dropped, and a multi-file patch names each section by its own path instead of `Before` / `After` over one column. - Desktop layout is unchanged; tests pin both, and count the context lines the two columns pay for by printing twice.
Resolves the conflicts with agegr#1304's hunk-gap rows: unifiedDiffLines() passes a file's gap rows through, so the file viewer's diff keeps its "N unchanged lines" markers and the one-column card draws them too, with the same row the two-column view uses (DiffGapRow). Co-Authored-By: Claude Opus 5.5 <[email protected]>
StackedDiffLineView took oldLineNo ?? newLineNo, so a context line, which has both, showed its old number: after an added line the gutter repeated or went backwards (added 12, then context 12 where the file has 13). A removed line now keeps the old number and every other line the new one, the rule the file viewer's gutter uses and the doc note describes. A deleted file's section was named /dev/null; it now takes the old path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The demo copies of lib/patch.ts, FileViewer.tsx and MessageView.tsx get the same change as the app: unifiedDiffLines() with its gap rows, the file viewer's diff reading through it, and SplitFilesView choosing two columns or one by useIsMobile(). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Owner
|
Thanks @brynne8, this is a real improvement. On
I also checked the |
# Conflicts: # AGENTS.md # docs/agents/sessions.md
This was referenced Oct 21, 2026
Hwwwww-dev
pushed a commit
to Hwwwww-dev/pi-web
that referenced
this pull request
Oct 22, 2026
Keeps the dev-side features (keepalive dock, turnRendered chat, ThinkingRow paging, minimap, chat-only, mobile PWA) and takes main's architecture where it superseded local copies (lease/reattach stream model agegr#1328, applyLoadedAgentState, live active time agegr#1334, tool argument rows agegr#1324, patch two-column view agegr#1325, search highlights).
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 6, 2026
* fix(chat): show a patch in one column on a phone Two columns of code need two code columns, and a phone does not have two: at 390px each half is about 150px, so every line of a real edit wrapped inside its own half and the two halves had to be compared from memory. The patch now takes the columns the viewport has. - `SplitFilesView()` reads `useIsMobile()` and hands `PatchDiffFiles` a `layout`, so both the `apply_patch` card and a result's patch switch together and a phone never renders one view of each. - `unifiedDiffLines()` (`lib/patch.ts`) turns a file's paired rows into patch order: a removed line above the line that replaces it, context lines printed once. `components/FileViewer.tsx` reads the same rows through it, so its diff and the card's cannot drift. - One gutter, since a second costs the width the code needed: a removed line keeps the old number, every other line the new one, as FileViewer's gutter already did. Hunk headers stay dropped, and a multi-file patch names each section by its own path instead of `Before` / `After` over one column. - Desktop layout is unchanged; tests pin both, and count the context lines the two columns pay for by printing twice. * fix(chat): number a one-column patch's context lines by the new file StackedDiffLineView took oldLineNo ?? newLineNo, so a context line, which has both, showed its old number: after an added line the gutter repeated or went backwards (added 12, then context 12 where the file has 13). A removed line now keeps the old number and every other line the new one, the rule the file viewer's gutter uses and the doc note describes. A deleted file's section was named /dev/null; it now takes the old path. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(demo): mirror the one-column patch on a phone The demo copies of lib/patch.ts, FileViewer.tsx and MessageView.tsx get the same change as the app: unifiedDiffLines() with its gap rows, the file viewer's diff reading through it, and SplitFilesView choosing two columns or one by useIsMobile(). Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(sessions): describe the one-column pair order and its gap rows Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Alex Yang <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 8, 2026
* fix(chat): show a patch in one column on a phone Two columns of code need two code columns, and a phone does not have two: at 390px each half is about 150px, so every line of a real edit wrapped inside its own half and the two halves had to be compared from memory. The patch now takes the columns the viewport has. - `SplitFilesView()` reads `useIsMobile()` and hands `PatchDiffFiles` a `layout`, so both the `apply_patch` card and a result's patch switch together and a phone never renders one view of each. - `unifiedDiffLines()` (`lib/patch.ts`) turns a file's paired rows into patch order: a removed line above the line that replaces it, context lines printed once. `components/FileViewer.tsx` reads the same rows through it, so its diff and the card's cannot drift. - One gutter, since a second costs the width the code needed: a removed line keeps the old number, every other line the new one, as FileViewer's gutter already did. Hunk headers stay dropped, and a multi-file patch names each section by its own path instead of `Before` / `After` over one column. - Desktop layout is unchanged; tests pin both, and count the context lines the two columns pay for by printing twice. * fix(chat): number a one-column patch's context lines by the new file StackedDiffLineView took oldLineNo ?? newLineNo, so a context line, which has both, showed its old number: after an added line the gutter repeated or went backwards (added 12, then context 12 where the file has 13). A removed line now keeps the old number and every other line the new one, the rule the file viewer's gutter uses and the doc note describes. A deleted file's section was named /dev/null; it now takes the old path. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(demo): mirror the one-column patch on a phone The demo copies of lib/patch.ts, FileViewer.tsx and MessageView.tsx get the same change as the app: unifiedDiffLines() with its gap rows, the file viewer's diff reading through it, and SplitFilesView choosing two columns or one by useIsMobile(). Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(sessions): describe the one-column pair order and its gap rows Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Alex Yang <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it does
A tool card's patch — an
apply_patchcall, or a result carryingdetails.patch/details.diff— now takes the columns the viewport has. On a desktop it is unchanged: two code columns, before on the left, after on the right. At or below the mobile breakpoint (640px) it renders as one column instead, each removed line above the line that replaces it, one gutter, context lines printed once.SplitFilesView()readsuseIsMobile()and handsPatchDiffFilesalayout("split"/"stacked"). Both theapply_patchcard and a result's patch render through that dispatcher, so a phone never gets one view of each.unifiedDiffLines()(lib/patch.ts) turns a file's paired split rows back into patch order — a removed line above the line that replaces it, a context row once rather than twice.components/FileViewer.tsx's diff reads the same rows through it, so the card's one-column view and the file viewer's diff cannot drift;FileViewer's own flattening is now that call, and its"unchanged"line type became"context".FileViewer's gutter already used. Hunk headers stay dropped as in the two-column view. A multi-file patch names each section by the file's own path (its new path, the one that survives) instead of theBefore/Afterlabels, which over a single column would read as two columns.Why it matters
Two columns of code need two code columns, and a phone does not have two. At a 390px viewport each half is about 150px, so every changed line of a real edit wraps inside its own half and the two halves have to be compared from memory. The one column is what the file viewer's diff has always been; a patch card now matches it where the screen is narrow, and nothing changes where it is not.
Reproduction
On today's
main: open a session with anapply_patch(oredit) tool call whose result carries a patch, expand the card, and size the viewport to about 390px. Each of the two columns is roughly 150px wide, every changed line wraps within its own half, and the before/after pair can only be compared from memory. At desktop width the two-column view is what is wanted and is untouched by this change.Scope
One change split out of a Bun-running fork (
brynne8/pi-web-bun) into a single-purpose branch on today'smain; one feature per PR.Testing
Added assertions pin both layouts, and count the context lines the two columns pay for by printing twice:
lib/patch.test.mjs:unifiedDiffLines()flattens a file's rows to one column in patch order (removed above added, context once, exact line numbers), and drops hunk headers and the padded empty rows a one-sided change leaves in the split view.components/MessageView.test.mjs: aneditcard's patch still reaches the two-column view while there is room; the same patch in one column prints no line twice and puts the removed line above what replaces it; one column names each file section by its path and never emits theBefore/Afterlabels; and the layout is taken once, in the dispatcher both call sites go through.Baseline on
origin/main(b017cd4), with these two test files dropped in unchanged: 5 fail — the 5 new assertions (unifiedDiffLines is not a function;PatchDiffFilesnot exported), while the desktop-pinning test passes. On the branch all 5 pass.Commands run on the branch (Node v26.7.0):
npm test— 2784 tests, 2783 pass, 0 fail, 1 skipped. Theorigin/mainbaseline is 2778 tests, 2777 pass, 0 fail, 1 skipped; failures, not totals, are the comparison.bun test lib/patch.test.mjs components/MessageView.test.mjs— 48 pass, 0 fail.bun x tsc --noEmit— clean.bun run lint— clean.bun test(whole suite) does not complete on this machine: it stalls afterlib/mcp-sign-in.test.mjsonorigin/mainand on the branch alike, and the partial failure sets are the same pre-existing families (node:module.findPackageJSONmissing under Bun, global-state ordering), 109 onorigin/mainvs 110 on the branch, differing only in unrelated integration tests. Upstream'stestscript is Node-only (node --test), so these are not introduced by this change; the touched files are green under Bun.Provenance
Source commit
cbd6589("fix(chat): show a tool card's patch in one column on a phone"), carried over to this branch's base on today'smain.