Skip to content

Commit 742c1ef

Browse files
matthias-tripclaude
andcommitted
fix(web): honor autoOpenPreview when running a project action
The "Open preview automatically when this action runs" toggle has had no effect since #2978: that rewrite moved runProjectScript onto the atom command API and dropped the block that opened the preview panel after the command was written to the terminal. #3842 later restored persistence of previewUrl/autoOpenPreview, so the setting saves and reloads correctly — it simply is not read at run time by anything. Restore the auto-open through the existing openUrlInPreview helper, which already does what the deleted code did by hand (open the session, apply the snapshot, remember the URL, reveal the tab in the right panel). A failed terminal write now returns instead of falling through, so a script that never started cannot open a preview. Preview failures stay silent for the caller: they are surfaced by the panel itself, and the script is already running, so they are not the script's failure. Fixes #5221 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent 64bf016 commit 742c1ef

1 file changed

Lines changed: 26 additions & 6 deletions

File tree

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

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ import { closePreviewSession } from "./preview/closePreviewSession";
134134
import { ThreadPreviewMiniPlayer } from "./preview/ThreadPreviewMiniPlayer";
135135
import { subscribePreviewAction } from "./preview/previewActionBus";
136136
import { getConfiguredPreviewUrls } from "./preview/previewEmptyStateLogic";
137+
import { openUrlInPreview } from "~/browser/openFileInPreview";
137138
import {
138139
selectThreadPreviewMiniPlayer,
139140
usePreviewMiniPlayerStore,
@@ -2880,12 +2881,30 @@ function ChatViewContent(props: ChatViewProps) {
28802881
data: `${script.command}\r`,
28812882
},
28822883
});
2883-
if (writeResult._tag === "Failure" && !isAtomCommandInterrupted(writeResult)) {
2884-
const error = squashAtomCommandFailure(writeResult);
2885-
setThreadError(
2886-
activeThreadId,
2887-
error instanceof Error ? error.message : `Failed to run script "${script.name}".`,
2888-
);
2884+
if (writeResult._tag === "Failure") {
2885+
if (!isAtomCommandInterrupted(writeResult)) {
2886+
const error = squashAtomCommandFailure(writeResult);
2887+
setThreadError(
2888+
activeThreadId,
2889+
error instanceof Error ? error.message : `Failed to run script "${script.name}".`,
2890+
);
2891+
}
2892+
return;
2893+
}
2894+
2895+
if (
2896+
script.autoOpenPreview &&
2897+
script.previewUrl &&
2898+
isPreviewSupportedInRuntime() &&
2899+
activeThreadRef
2900+
) {
2901+
// Preview failures surface in the panel itself, and the script is
2902+
// already running — never report one as a failure of the script.
2903+
await openUrlInPreview({
2904+
threadRef: activeThreadRef,
2905+
url: script.previewUrl,
2906+
openPreview,
2907+
});
28892908
}
28902909
},
28912910
[
@@ -2894,6 +2913,7 @@ function ChatViewContent(props: ChatViewProps) {
28942913
activeThreadId,
28952914
activeThreadRef,
28962915
gitCwd,
2916+
openPreview,
28972917
setTerminalOpen,
28982918
setThreadError,
28992919
storeNewTerminal,

0 commit comments

Comments
 (0)