From 9c73a2d8c3fcbed6d213496f279cbd11a45277cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Almeida?= <57680069+zeval@users.noreply.github.com> Date: Thu, 9 Jul 2026 17:25:33 +0100 Subject: [PATCH] fix: keep diff previews tied to the correct file (#1618) * fix: keep diff previews tied to the correct file * fix: handle legacy file editor panel restores * test: align file editor image mock * fix: ignore sibling repo editor sync changes * test: use repo scoped file keys in save tests * fix: guard file editor preview restoration * fix: remove redundant preview path fallback * test: cover repo scoped image previews * test: use repo scoped keys in sync tests * fix: guard stale file editor open fetches * fix: distinguish repeated file editor requests * fix: open single-repo PR diffs without repo filter * fix: keep pending file opens alive --- .../components/task/changes-panel-data.tsx | 4 +- .../task/changes-panel-file-row.test.tsx | 10 +- .../task/changes-panel-file-row.tsx | 8 +- .../task/changes-panel-pr-files.test.tsx | 31 +- .../task/changes-panel-pr-files.tsx | 2 +- .../task/changes-panel-timeline.tsx | 4 +- .../components/task/changes-panel-tree.tsx | 4 +- apps/web/components/task/changes-panel.tsx | 2 +- .../task/dockview-panel-content.diff.test.tsx | 68 ++++ .../task/dockview-panel-content.tsx | 8 +- apps/web/components/task/dockview-shared.tsx | 14 +- .../task/file-editor-panel.image.test.tsx | 108 ++++++ .../web/components/task/file-editor-panel.tsx | Bin 10242 -> 11198 bytes .../task/mobile/mobile-changes-panel.tsx | 2 +- .../task/mobile/mobile-diff-sheet.tsx | 4 +- .../components/task/task-changes-panel.tsx | 4 +- .../git/changes-panel-section-order.spec.ts | 1 - apps/web/hooks/file-editor-state.ts | 137 +++++++ apps/web/hooks/file-editors-sync.test.ts | 78 +++- apps/web/hooks/file-editors-sync.ts | 35 +- .../use-file-editors.build-state.test.ts | 155 +++++++- .../use-file-editors.open-action.test.tsx | 212 +++++++++++ apps/web/hooks/use-file-editors.ts | 346 +++++++++++------- apps/web/hooks/use-file-save-delete.test.ts | 8 +- apps/web/hooks/use-file-save-delete.ts | 56 +-- .../lib/state/dockview-panel-actions.test.ts | 29 ++ apps/web/lib/state/dockview-panel-actions.ts | 10 +- apps/web/lib/state/dockview-store.ts | 11 +- 28 files changed, 1142 insertions(+), 209 deletions(-) create mode 100644 apps/web/components/task/dockview-panel-content.diff.test.tsx create mode 100644 apps/web/components/task/file-editor-panel.image.test.tsx create mode 100644 apps/web/hooks/file-editor-state.ts create mode 100644 apps/web/hooks/use-file-editors.open-action.test.tsx diff --git a/apps/web/components/task/changes-panel-data.tsx b/apps/web/components/task/changes-panel-data.tsx index 2a2a2afb98..6d9e08b39b 100644 --- a/apps/web/components/task/changes-panel-data.tsx +++ b/apps/web/components/task/changes-panel-data.tsx @@ -92,7 +92,7 @@ export type ChangesPanelBodyProps = { loadingOperation: string | null; dialogs: DialogsType; onOpenDiffFile: (path: string, options?: OpenDiffOptions) => void; - onEditFile: (path: string) => void; + onEditFile: (path: string, repo?: string) => void; onOpenCommitDetail?: (sha: string, repo?: string) => void; onOpenReview?: () => void; onRevertCommit?: (sha: string, repo?: string) => void; @@ -265,7 +265,7 @@ export function useChangesPanelData() { type ChangesPanelCallbacks = { onOpenDiffFile: (path: string, options?: OpenDiffOptions) => void; - onEditFile: (path: string) => void; + onEditFile: (path: string, repo?: string) => void; onOpenCommitDetail?: (sha: string, repo?: string) => void; onOpenReview?: () => void; }; diff --git a/apps/web/components/task/changes-panel-file-row.test.tsx b/apps/web/components/task/changes-panel-file-row.test.tsx index a3da1200a9..138e6a17f4 100644 --- a/apps/web/components/task/changes-panel-file-row.test.tsx +++ b/apps/web/components/task/changes-panel-file-row.test.tsx @@ -108,14 +108,18 @@ describe("FileRow truncation (regression: path overlaps diff stats in narrow pan }); }); - it("opens image files in the file preview instead of the diff viewer", () => { + it("opens image files in the file preview with repository context", () => { const onOpenDiff = vi.fn(); const onEditFile = vi.fn(); const { container } = render(