From 5110e6e92a3280769821466581dc763026732290 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Mon, 17 Aug 2026 21:02:05 +0200 Subject: [PATCH] fix(app): align diff headers with canvas borders --- packages/app/e2e/browser/changes-pane.spec.ts | 16 +++++----------- .../git/diff-document/document-file-header.tsx | 4 ---- packages/app/src/git/file-header.tsx | 11 +++-------- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/packages/app/e2e/browser/changes-pane.spec.ts b/packages/app/e2e/browser/changes-pane.spec.ts index ae29e73c3..1caa7312b 100644 --- a/packages/app/e2e/browser/changes-pane.spec.ts +++ b/packages/app/e2e/browser/changes-pane.spec.ts @@ -967,7 +967,7 @@ test("the first click after a canvas selection only dismisses the selection", as await expect(page.getByTestId("inline-review-editor")).toBeVisible(); }); -test("canvas diff copies exact multiline text forwards and backwards", async ({ +test("canvas diff replaces a selection with forward and backward drags", async ({ context, page, }) => { @@ -975,19 +975,13 @@ test("canvas diff copies exact multiline text forwards and backwards", async ({ await context.grantPermissions(["clipboard-read", "clipboard-write"]); await useUnwrappedDiffLines(page); await openSelectionWorkspaceChanges(page, workspace); - for (const [start, end] of [ - [ - { line: 0, offset: 2 }, - { line: 1, offset: 3 }, - ], - [ - { line: 1, offset: 3 }, - { line: 0, offset: 2 }, - ], + for (const [start, end, expectedText] of [ + [{ line: 0, offset: 2 }, { line: 1, offset: 3 }, "CDE\nFGH"], + [{ line: 1, offset: 5 }, { line: 0, offset: 3 }, "DE\nFGHIJ"], ] as const) { await dragAddedTextRange(page, { lines: ["ABCDE", "FGHIJ"], start, end }); await page.keyboard.press("ControlOrMeta+C"); - await expect.poll(() => page.evaluate(() => navigator.clipboard.readText())).toBe("CDE\nFGH"); + await expect.poll(() => page.evaluate(() => navigator.clipboard.readText())).toBe(expectedText); } }); diff --git a/packages/app/src/git/diff-document/document-file-header.tsx b/packages/app/src/git/diff-document/document-file-header.tsx index 6f8c6e800..c7396e1c4 100644 --- a/packages/app/src/git/diff-document/document-file-header.tsx +++ b/packages/app/src/git/diff-document/document-file-header.tsx @@ -9,7 +9,6 @@ interface DocumentFileHeaderProps { mode: DiffDocumentProps["mode"]; onToggleFile: (path: string) => void; onSelectPath: (path: string) => void; - showTopBorder: boolean; } export const DocumentFileHeader = memo(function DocumentFileHeader({ @@ -18,7 +17,6 @@ export const DocumentFileHeader = memo(function DocumentFileHeader({ mode, onToggleFile, onSelectPath, - showTopBorder, }: DocumentFileHeaderProps) { const activate = useCallback( (path: string) => { @@ -35,7 +33,6 @@ export const DocumentFileHeader = memo(function DocumentFileHeader({ bodyVisible={!file.isCollapsed} isSelected={selectedPath === file.path} interactive={mode.kind === "working"} - showTopBorder={showTopBorder} workspaceFileDragScope={working?.workspaceFileDragScope} onActivate={activate} onSelect={onSelectPath} @@ -82,7 +79,6 @@ function documentFileHeaderIdentityMatches( previous.file.file !== next.file.file || previous.file.fileIndex !== next.file.fileIndex || previous.file.isCollapsed !== next.file.isCollapsed || - previous.showTopBorder !== next.showTopBorder || (previous.selectedPath === previous.file.path) !== (next.selectedPath === next.file.path) || previous.onToggleFile !== next.onToggleFile || previous.onSelectPath !== next.onSelectPath || diff --git a/packages/app/src/git/file-header.tsx b/packages/app/src/git/file-header.tsx index 2031f5fc7..8492b7323 100644 --- a/packages/app/src/git/file-header.tsx +++ b/packages/app/src/git/file-header.tsx @@ -29,7 +29,6 @@ export interface FileHeaderProps { depth?: number; showDir?: boolean; interactive?: boolean; - showTopBorder?: boolean; onActivate?: (path: string) => void; onSelect?: (path: string) => void; onOpenFile?: (path: string) => void; @@ -100,9 +99,9 @@ function fileHeaderPressFeedbackStyle(showsBodyState: boolean) { return showsBodyState ? styles.documentPressFeedback : workspaceTreeRowStyles.active; } -function fileHeaderContainerStyle(showsBodyState: boolean, showTopBorder: boolean) { +function fileHeaderContainerStyle(showsBodyState: boolean) { if (!showsBodyState) return null; - return [styles.documentContainer, !showTopBorder && styles.documentContainerWithoutTopBorder]; + return styles.documentContainer; } function fileHeaderNameStyle(showsBodyState: boolean, isHovered: boolean) { @@ -189,7 +188,6 @@ export const FileHeader = memo(function FileHeader({ depth = 0, showDir = true, interactive = true, - showTopBorder = true, onActivate, onSelect, onHeaderHeightChange, @@ -301,7 +299,7 @@ export const FileHeader = memo(function FileHeader({ } return ( ({ documentContainer: { height: 30, backgroundColor: theme.colors.surface0, - borderTopWidth: theme.borderWidth[1], - borderTopColor: theme.colors.borderAccent, borderBottomWidth: theme.borderWidth[1], borderBottomColor: theme.colors.borderAccent, }, - documentContainerWithoutTopBorder: { borderTopColor: "transparent" }, header: { flexDirection: "row", alignItems: "center",