Skip to content

Commit b944064

Browse files
ASRagabclaude
andauthored
fix(ui): improve diff preview for added and deleted files (#49)
Added files no longer trigger broken GapView/TrailingGap context fetches. Deleted files show a "This file was deleted" banner instead of raw hunks. Status badges for Added/Deleted now render with tinted backgrounds. Footer line totals now include uncommitted/untracked files. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2f1d498 commit b944064

3 files changed

Lines changed: 26 additions & 12 deletions

File tree

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ release/
55
node_modules/
66
.worktrees/
77
.claude/
8+
.omc/
89
.planning/
910
.letta/
1011
package-lock.json

src/components/ChangedFilesList.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,8 @@ export function ChangedFilesList(props: ChangedFilesListProps) {
115115
});
116116
});
117117

118-
const totalAdded = createMemo(() =>
119-
files().reduce((s, f) => s + (f.committed ? f.lines_added : 0), 0),
120-
);
121-
const totalRemoved = createMemo(() =>
122-
files().reduce((s, f) => s + (f.committed ? f.lines_removed : 0), 0),
123-
);
118+
const totalAdded = createMemo(() => files().reduce((s, f) => s + f.lines_added, 0));
119+
const totalRemoved = createMemo(() => files().reduce((s, f) => s + f.lines_removed, 0));
124120
const uncommittedCount = createMemo(() => files().filter((f) => !f.committed).length);
125121

126122
/** For each file, compute the display filename and an optional disambiguating directory. */

src/components/ScrollingDiffView.tsx

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { For, Show, createSignal, createEffect, onMount, onCleanup } from 'solid-js';
22
import type { JSX } from 'solid-js';
3-
import { theme } from '../lib/theme';
3+
import { theme, bannerStyle } from '../lib/theme';
44
import { sf } from '../lib/fontScale';
55
import { getStatusColor } from '../lib/status-colors';
66
import { openFileInEditor } from '../lib/shell';
@@ -591,7 +591,10 @@ function FileSection(props: {
591591
padding: '2px 8px',
592592
'border-radius': '4px',
593593
color: getStatusColor(props.file.status),
594-
background: 'rgba(255,255,255,0.06)',
594+
background:
595+
props.file.status === 'M'
596+
? 'rgba(255,255,255,0.06)'
597+
: `color-mix(in srgb, ${getStatusColor(props.file.status)} 15%, transparent)`,
595598
}}
596599
>
597600
{STATUS_LABELS[props.file.status] ?? props.file.status}
@@ -672,9 +675,23 @@ function FileSection(props: {
672675
</div>
673676
</Show>
674677

675-
<Show when={!props.file.binary}>
678+
<Show when={!props.file.binary && props.file.status === 'D'}>
679+
<div
680+
style={{
681+
...bannerStyle(theme.error),
682+
margin: '12px',
683+
'font-size': sf(12),
684+
'text-align': 'center',
685+
'font-weight': '600',
686+
}}
687+
>
688+
This file was deleted
689+
</div>
690+
</Show>
691+
692+
<Show when={!props.file.binary && props.file.status !== 'D'}>
676693
<div style={{ 'padding-bottom': '8px', background: 'rgba(0, 0, 0, 0.15)' }}>
677-
<Show when={props.file.hunks.length > 0 && props.file.status !== 'D'}>
694+
<Show when={props.file.hunks.length > 0 && props.file.status === 'M'}>
678695
<GapView
679696
startLine={1}
680697
endLine={props.file.hunks[0].newStart}
@@ -691,7 +708,7 @@ function FileSection(props: {
691708
<For each={props.file.hunks}>
692709
{(hunk, hunkIdx) => (
693710
<>
694-
<Show when={hunkIdx() > 0}>
711+
<Show when={hunkIdx() > 0 && props.file.status === 'M'}>
695712
<GapView
696713
startLine={
697714
props.file.hunks[hunkIdx() - 1].newStart +
@@ -777,7 +794,7 @@ function FileSection(props: {
777794
</>
778795
)}
779796
</For>
780-
<Show when={props.file.hunks.length > 0 && props.file.status !== 'D'}>
797+
<Show when={props.file.hunks.length > 0 && props.file.status === 'M'}>
781798
<TrailingGap
782799
lastHunk={props.file.hunks[props.file.hunks.length - 1]}
783800
lang={lang()}

0 commit comments

Comments
 (0)