Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ import { closePreviewSession } from "./preview/closePreviewSession";
import { ThreadPreviewMiniPlayer } from "./preview/ThreadPreviewMiniPlayer";
import { subscribePreviewAction } from "./preview/previewActionBus";
import { getConfiguredPreviewUrls } from "./preview/previewEmptyStateLogic";
import { openUrlInPreview } from "~/browser/openFileInPreview";
import {
selectThreadPreviewMiniPlayer,
usePreviewMiniPlayerStore,
Expand Down Expand Up @@ -2880,12 +2881,30 @@ function ChatViewContent(props: ChatViewProps) {
data: `${script.command}\r`,
},
});
if (writeResult._tag === "Failure" && !isAtomCommandInterrupted(writeResult)) {
const error = squashAtomCommandFailure(writeResult);
setThreadError(
activeThreadId,
error instanceof Error ? error.message : `Failed to run script "${script.name}".`,
);
if (writeResult._tag === "Failure") {
if (!isAtomCommandInterrupted(writeResult)) {
const error = squashAtomCommandFailure(writeResult);
setThreadError(
activeThreadId,
error instanceof Error ? error.message : `Failed to run script "${script.name}".`,
);
}
return;
}

if (
script.autoOpenPreview &&
script.previewUrl &&
isPreviewSupportedInRuntime() &&
activeThreadRef
) {
// Preview failures surface in the panel itself, and the script is
// already running — never report one as a failure of the script.
await openUrlInPreview({
threadRef: activeThreadRef,
url: script.previewUrl,
openPreview,
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preview URL skips env rewrite

Medium Severity

Auto-open passes the raw script.previewUrl into openUrlInPreview, so loopback URLs are never rewritten for the thread environment. The same configured script URLs go through resolveDiscoveredServerUrl when opened from the preview empty state, so remote and 0.0.0.0 targets open the wrong host here while manual open works.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 742c1ef. Configure here.

}
},
[
Expand All @@ -2894,6 +2913,7 @@ function ChatViewContent(props: ChatViewProps) {
activeThreadId,
activeThreadRef,
gitCwd,
openPreview,
setTerminalOpen,
setThreadError,
storeNewTerminal,
Expand Down
Loading