fix(web): desktop opens remote environments' browser tabs locally #17316
Mergedjuliusmarmingemerged 1 commit into
main fromrefs/pull/17316/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
juliusmarminge added labelsmacroscope-review
- @@ -412,0 +428,21 @@428+ serverBrowser,429+ snapshot,430+ );431+ const moveLabel =432+ moveTarget === "server" ? `Open in ${environmentLabel}'s browser` : "Open on this computer";433+ const handleMoveTab = useCallback(async () => {434+ if (!moveTarget || !tabId || !snapshot) return;435+ const result = await openPreviewSession({436+ openPreview: open,437+ threadRef,438+ // Loopback means the environment's machine, which this computer reaches by its address.439+ ...(url440+ ? {441+ url:442+ moveTarget === "desktop"443+ ? resolveDiscoveredServerUrl(threadRef.environmentId, url)444+ : url,445+ }446+ : {}),447+ viewport,448+ ...(snapshot.profileId === undefined ? {} : { profileId: snapshot.profileId }),@@ -412,0 +442,21 @@442+ moveTarget === "desktop"443+ ? resolveDiscoveredServerUrl(threadRef.environmentId, url)444+ : url,445+ }446+ : {}),447+ viewport,448+ ...(snapshot.profileId === undefined ? {} : { profileId: snapshot.profileId }),449+ runtime: moveTarget,450+ });451+ if (result._tag === "Failure") {452+ if (isAtomCommandInterrupted(result)) return;453+ const error = squashAtomCommandFailure(result);454+ toastManager.add({455+ type: "error",456+ title: "Unable to move the browser tab",457+ description: error instanceof Error ? error.message : "An error occurred.",458+ });459+ return;460+ }461+ useRightPanelStore.getState().openBrowser(threadRef, result.value.tabId);462+ await closePreviewSession({ closePreview, snapshot, tabId, threadRef });
- @@ -412,0 +428,21 @@428+ serverBrowser,429+ snapshot,430+ );431+ const moveLabel =432+ moveTarget === "server" ? `Open in ${environmentLabel}'s browser` : "Open on this computer";433+ const handleMoveTab = useCallback(async () => {434+ if (!moveTarget || !tabId || !snapshot) return;435+ const result = await openPreviewSession({436+ openPreview: open,437+ threadRef,438+ // Loopback means the environment's machine, which this computer reaches by its address.439+ ...(url440+ ? {441+ url:442+ moveTarget === "desktop"443+ ? resolveDiscoveredServerUrl(threadRef.environmentId, url)444+ : url,445+ }446+ : {}),447+ viewport,448+ ...(snapshot.profileId === undefined ? {} : { profileId: snapshot.profileId }),@@ -412,0 +442,21 @@442+ moveTarget === "desktop"443+ ? resolveDiscoveredServerUrl(threadRef.environmentId, url)444+ : url,445+ }446+ : {}),447+ viewport,448+ ...(snapshot.profileId === undefined ? {} : { profileId: snapshot.profileId }),449+ runtime: moveTarget,450+ });451+ if (result._tag === "Failure") {452+ if (isAtomCommandInterrupted(result)) return;453+ const error = squashAtomCommandFailure(result);454+ toastManager.add({455+ type: "error",456+ title: "Unable to move the browser tab",457+ description: error instanceof Error ? error.message : "An error occurred.",458+ });459+ return;460+ }461+ useRightPanelStore.getState().openBrowser(threadRef, result.value.tabId);462+ await closePreviewSession({ closePreview, snapshot, tabId, threadRef });
juliusmarminge merged this66298aa
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed