Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(computer): Use Auto saves Auto when it stands in for This Mac on a remote page

jimine34bbe02c92e
diff --git a/src/components/ComputerPanel.simple.test.ts b/src/components/ComputerPanel.simple.test.ts
index 9ad802f80d..da55d1d7d2 100644
--- a/src/components/ComputerPanel.simple.test.ts
+++ b/src/components/ComputerPanel.simple.test.ts
@@ -540,6 +540,15 @@ describe("A chat pinned to a place", () => {
expect(unpin(render(pinned()))).toBeUndefined();
});
+ it("saves Auto too when Use Auto stands in for This Mac on another server's page", () => {
+ fixture.localComputer = { available: false, support: "unsupported", enabled: false, status: "unavailable", reasonCode: "remote-server" };
+ const button = unpin(render(pinnedOn("local")))!;
+ expect(text(button.props.children)).toBe("Use Auto");
+ (button.props.onClick as () => void)();
+ expect(fixture.dispatch).toHaveBeenCalledWith({ type: "updateBot", botId: "scout", patch: { computer: null } });
+ expect(fixture.dispatch).toHaveBeenCalledWith({ type: "updateTask", botId: "scout", threadId: "thread-scout", patch: { surface: null } });
+ });
+
it("waits out a running turn, as the server refuses a busy chat's place change", () => {
const button = unpin(render(pinnedOn(undefined, { busy: true })))!;
expect(button.props.disabled).toBe(true);
diff --git a/src/components/ComputerPanel.tsx b/src/components/ComputerPanel.tsx
index 22bce83be3..b95d25450f 100644
--- a/src/components/ComputerPanel.tsx
+++ b/src/components/ComputerPanel.tsx
@@ -36,17 +36,7 @@ import { LocalScreenPreview } from "./LocalScreenPreview";
import { LinuxLocalControl } from "./LinuxLocalControl";
import { MacLocalControl } from "./MacLocalControl"; import { WindowsLocalControl } from "./WindowsLocalControl";
import { LocalComputerAutoWarning } from "./LocalComputerAutoWarning";
-import {
- busyBoatView,
- instanceSupportsLocalComputer,
- localComputerDisabledReason,
- localComputerSelectable,
- pageOnRemoteServer,
- persistedComputerSelectionMatches,
- isReadyBoatState,
- resolveBoatPanelAction,
- shouldPollCloudPreview,
-} from "@/lib/local-computer";
+import { busyBoatView, instanceSupportsLocalComputer, localComputerDisabledReason, localComputerSelectable, pageOnRemoteServer, persistedComputerSelectionMatches, isReadyBoatState, resolveBoatPanelAction, shouldPollCloudPreview } from "@/lib/local-computer";
import { moveBetweenTabs, PANEL_TABS, panelTabProps, scrollTabsWithWheel, TAB_PANEL_FOCUS, tabPanelProps, useAndroidTabFallback } from "./computer-panel-tabs";
import { releaseComputerPanelFocus, useComputerPanelEntry } from "@/lib/computer-panel-focus";
import { PANEL_MAX_WIDTH, PANEL_MIN_WIDTH, useComputerPanelResize } from "./computer-panel-resize";
@@ -1154,6 +1144,10 @@ export function ComputerPanel({
else if (mode === "browser") updateComputerSelection({ computer: mode, browser: true });
else updateComputerSelection({ computer: mode });
};
+ const unpinToWorksOn = () => {
+ if (profileBot.computer === "local" && localHidden) updateComputerSelection({ computer: null });
+ dispatch({ type: "updateTask", botId: profileBot.id, threadId: profileBot.threadId, patch: { surface: null } });
+ };
const heldPin = liveTask?.surface && !liveTask.surfaceAuto && profileBot.computer !== "off"
&& liveTask.surface !== profileBot.computer ? liveTask.surface : undefined;
@@ -1784,7 +1778,7 @@ export function ComputerPanel({
type="button"
disabled={Boolean(bot.busy)}
title={bot.busy ? t("place.busy") : undefined}
- onClick={() => dispatch({ type: "updateTask", botId: profileBot.id, threadId: profileBot.threadId, patch: { surface: null } })}
+ onClick={unpinToWorksOn}
className="shrink-0 rounded-md px-2 py-0.5 text-[12px] font-medium leading-5 text-accent-text transition-colors hover:bg-control focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-45 disabled:hover:bg-transparent"
data-testid="place-unpin"
>