| ... | ... | @@ -252,7 +252,8 @@ import { |
| 252 | 252 | setActivePreviewTab, |
| 253 | 253 | useThreadPreviewState, |
| 254 | 254 | } from "../previewStateStore"; |
| 255 | | import { BrowserSettingsReadError } from "../browser/openFileInPreview"; |
| 255 | import { BrowserSettingsReadError, openUrlInPreview } from "../browser/openFileInPreview"; |
| 256 | import { resolveDiscoveredServerUrl } from "../browser/browserTargetResolver"; |
| 256 | 257 | import { previewRuntimeTabId } from "../browser/previewRuntimeTabId"; |
| 257 | 258 | import { addBrowserSurface } from "./preview/addBrowserSurface"; |
| 258 | 259 | import { closePreviewSession } from "./preview/closePreviewSession"; |
| ... | ... | @@ -4892,12 +4893,32 @@ export default function ChatView(props: ChatViewProps) { |
| 4892 | 4893 | data: `${script.command}\r`, |
| 4893 | 4894 | }, |
| 4894 | 4895 | }); |
| 4895 | | if (writeResult._tag === "Failure" && !isAtomCommandInterrupted(writeResult)) { |
| 4896 | | const error = squashAtomCommandFailure(writeResult); |
| 4897 | | setThreadError( |
| 4898 | | activeThreadId, |
| 4899 | | error instanceof Error ? error.message : `Failed to run script "${script.name}".`, |
| 4900 | | ); |
| 4896 | if (writeResult._tag === "Failure") { |
| 4897 | if (!isAtomCommandInterrupted(writeResult)) { |
| 4898 | const error = squashAtomCommandFailure(writeResult); |
| 4899 | setThreadError( |
| 4900 | activeThreadId, |
| 4901 | error instanceof Error ? error.message : `Failed to run script "${script.name}".`, |
| 4902 | ); |
| 4903 | } |
| 4904 | return; |
| 4905 | } |
| 4906 | if (script.autoOpenPreview && script.previewUrl && isPreviewSupportedInRuntime()) { |
| 4907 | const previewResult = await openUrlInPreview({ |
| 4908 | threadRef: activeThreadRef, |
| 4909 | url: resolveDiscoveredServerUrl(activeThreadRef.environmentId, script.previewUrl), |
| 4910 | openPreview, |
| 4911 | }); |
| 4912 | if (previewResult._tag === "Failure" && !isAtomCommandInterrupted(previewResult)) { |
| 4913 | const error = squashAtomCommandFailure(previewResult); |
| 4914 | toastManager.add( |
| 4915 | stackedThreadToast({ |
| 4916 | type: "error", |
| 4917 | title: "Could not open preview", |
| 4918 | description: error instanceof Error ? error.message : "An unexpected error occurred.", |
| 4919 | }), |
| 4920 | ); |
| 4921 | } |
| 4901 | 4922 | } |
| 4902 | 4923 | }, |
| 4903 | 4924 | [ |
| ... | ... | @@ -4913,6 +4934,7 @@ export default function ChatView(props: ChatViewProps) { |
| 4913 | 4934 | setLastInvokedScriptByProjectId, |
| 4914 | 4935 | environmentId, |
| 4915 | 4936 | openTerminal, |
| 4937 | openPreview, |
| 4916 | 4938 | activeKnownTerminalIds, |
| 4917 | 4939 | allocatableActiveTerminalIds, |
| 4918 | 4940 | runningTerminalIds, |