Skip to content

Commit 17612cc

Browse files
committed
Address image preview review feedback
1 parent 0fa2ec2 commit 17612cc

3 files changed

Lines changed: 36 additions & 30 deletions

File tree

‎apps/web/src/browser/openFileInPreview.test.ts‎

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -100,35 +100,35 @@ describe("openFileInPreview", () => {
100100
expect(JSON.stringify(error)).not.toContain("signed-secret-token");
101101
expect(openPreview).not.toHaveBeenCalled();
102102
});
103-
});
104103

105-
it("does not apply an older preview response after another caller starts a newer request", async () => {
106-
const firstSnapshot = snapshot("tab-1", "https://assets.test/first.png");
107-
const secondSnapshot = snapshot("tab-2", "https://assets.test/second.png");
108-
let resolveFirst!: (result: AtomCommandResult<PreviewSessionSnapshot, never>) => void;
109-
const openPreview: OpenPreviewMutation<never> = ({ input }) =>
110-
input.url === "https://assets.test/first.png"
111-
? new Promise<AtomCommandResult<PreviewSessionSnapshot, never>>((resolve) => {
112-
resolveFirst = resolve;
113-
})
114-
: Promise.resolve(AsyncResult.success(secondSnapshot));
115-
116-
const firstRequest = openUrlInPreview({
117-
threadRef,
118-
url: "https://assets.test/first.png",
119-
openPreview,
120-
});
104+
it("does not apply an older preview response after another caller starts a newer request", async () => {
105+
const firstSnapshot = snapshot("tab-1", "https://assets.test/first.png");
106+
const secondSnapshot = snapshot("tab-2", "https://assets.test/second.png");
107+
let resolveFirst!: (result: AtomCommandResult<PreviewSessionSnapshot, never>) => void;
108+
const openPreview: OpenPreviewMutation<never> = ({ input }) =>
109+
input.url === "https://assets.test/first.png"
110+
? new Promise<AtomCommandResult<PreviewSessionSnapshot, never>>((resolve) => {
111+
resolveFirst = resolve;
112+
})
113+
: Promise.resolve(AsyncResult.success(secondSnapshot));
114+
115+
const firstRequest = openUrlInPreview({
116+
threadRef,
117+
url: "https://assets.test/first.png",
118+
openPreview,
119+
});
121120

122-
await openUrlInPreview({
123-
threadRef,
124-
url: "https://assets.test/second.png",
125-
openPreview,
126-
});
127-
resolveFirst(AsyncResult.success(firstSnapshot));
128-
await firstRequest;
121+
await openUrlInPreview({
122+
threadRef,
123+
url: "https://assets.test/second.png",
124+
openPreview,
125+
});
126+
resolveFirst(AsyncResult.success(firstSnapshot));
127+
await firstRequest;
129128

130-
expect(readThreadPreviewState(threadRef).snapshot).toEqual(secondSnapshot);
131-
expect(
132-
selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, threadRef).surfaces,
133-
).toEqual([{ id: "browser:tab-2", kind: "preview", resourceId: "tab-2" }]);
129+
expect(readThreadPreviewState(threadRef).snapshot).toEqual(secondSnapshot);
130+
expect(
131+
selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, threadRef).surfaces,
132+
).toEqual([{ id: "browser:tab-2", kind: "preview", resourceId: "tab-2" }]);
133+
});
134134
});

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2991,7 +2991,10 @@ function ChatViewContent(props: ChatViewProps) {
29912991
stackedThreadToast({
29922992
type: "warning",
29932993
title: "Unable to open image preview",
2994-
description: error instanceof Error ? error.message : "Opening the file instead.",
2994+
description:
2995+
error instanceof Error
2996+
? `${error.message} Opening the file instead.`
2997+
: "Opening the file instead.",
29952998
}),
29962999
);
29973000
openFallback();

‎apps/web/src/components/DiffPanel.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,10 @@ export default function DiffPanel({
541541
stackedThreadToast({
542542
type: "warning",
543543
title: "Unable to open image preview",
544-
description: error instanceof Error ? error.message : "Opening the file instead.",
544+
description:
545+
error instanceof Error
546+
? `${error.message} Opening the file instead.`
547+
: "Opening the file instead.",
545548
}),
546549
);
547550
openFallback();

0 commit comments

Comments
 (0)