Skip to content

A personal assistant that lives on your desktop, remembers what matters, and can use your Mac for you.

TypeScript

fix(ui): name the panic shortcut in the yolo note only when it is registered

Marcelito35eff00cbb5d
diff --git a/apps/desktop/src-tauri/src/computer/app.rs b/apps/desktop/src-tauri/src/computer/app.rs
index 0743aaa..1baaaa5 100644
--- a/apps/desktop/src-tauri/src/computer/app.rs
+++ b/apps/desktop/src-tauri/src/computer/app.rs
@@ -64,6 +64,11 @@ pub fn set_panic_shortcut_registered(registered: bool) {
PANIC_SHORTCUT_REGISTERED.store(registered, Ordering::SeqCst);
}
+/// Whether the panic shortcut was registered at launch; false off macOS and Windows.
+pub fn panic_shortcut_registered() -> bool {
+ PANIC_SHORTCUT_REGISTERED.load(Ordering::SeqCst)
+}
+
/// The yolo dialog's text, naming the panic shortcut only when it is registered.
pub fn yolo_text(panic_registered: bool) -> &'static str {
if panic_registered {
@@ -514,14 +519,25 @@ pub fn computer_endpoint(computer: State<'_, Computer>) -> Option<Endpoint> {
}
#[tauri::command]
-pub fn computer_permissions(computer: State<'_, Computer>) -> Permissions {
+pub fn computer_permissions(computer: State<'_, Computer>) -> PermissionsAnswer {
#[cfg(any(target_os = "macos", windows))]
- return computer.desktop.permissions();
+ let permissions = computer.desktop.permissions();
#[cfg(not(any(target_os = "macos", windows)))]
- {
+ let permissions = {
let _ = computer;
Permissions { accessibility: false, screen_recording: false, screenshots_supported: false }
- }
+ };
+ PermissionsAnswer { permissions, panic_shortcut: panic_shortcut_registered() }
+}
+
+/// The `computer_permissions` answer: the permissions, plus `panicShortcut`, so Connectors names
+/// the panic shortcut only when it works.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct PermissionsAnswer {
+ #[serde(flatten)]
+ pub permissions: Permissions,
+ pub panic_shortcut: bool,
}
#[tauri::command]
@@ -617,7 +633,7 @@ impl super::Dialogs for NativeDialogs {
}
fn ask_yolo(&self) -> bool {
- self.ask(yolo_text(PANIC_SHORTCUT_REGISTERED.load(Ordering::SeqCst)), YOLO_CHOICE)
+ self.ask(yolo_text(panic_shortcut_registered()), YOLO_CHOICE)
}
}
@@ -718,4 +734,18 @@ Use Stop in the panel or the tray menu instead."
let value = serde_json::to_value(Permissions { accessibility: true, screen_recording: false, screenshots_supported: true }).unwrap();
assert_eq!(value, serde_json::json!({"accessibility": true, "screenRecording": false, "screenshotsSupported": true}));
}
+
+ #[test]
+ fn the_permissions_answer_says_whether_the_panic_shortcut_is_registered() {
+ let permissions = Permissions { accessibility: true, screen_recording: false, screenshots_supported: true };
+ let value = serde_json::to_value(PermissionsAnswer { permissions, panic_shortcut: false }).unwrap();
+ assert_eq!(
+ value,
+ serde_json::json!({"accessibility": true, "screenRecording": false, "screenshotsSupported": true, "panicShortcut": false})
+ );
+ set_panic_shortcut_registered(true);
+ assert!(panic_shortcut_registered());
+ set_panic_shortcut_registered(false);
+ assert!(!panic_shortcut_registered());
+ }
}
diff --git a/apps/desktop/src-tauri/src/computer/mod.rs b/apps/desktop/src-tauri/src/computer/mod.rs
index 98c43e5..eb1e0e1 100644
--- a/apps/desktop/src-tauri/src/computer/mod.rs
+++ b/apps/desktop/src-tauri/src/computer/mod.rs
@@ -184,7 +184,7 @@ pub struct AppInfo {
pub active: bool,
}
-/// The `computer_permissions` reply (L60), plus `screenshotsSupported`: false before macOS 14,
+/// The permissions in the `computer_permissions` answer (L60), plus `screenshotsSupported`: false before macOS 14,
/// where ScreenCaptureKit cannot take screenshots, and before Windows 10 version 2004, which
/// cannot leave Gentle Dot's windows out of them.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
diff --git a/docs/design.md b/docs/design.md
index 5835bd2..734f6c4 100644
--- a/docs/design.md
+++ b/docs/design.md
@@ -179,7 +179,7 @@ The assistant can see the screen and operate apps through a built-in MCP server
- S24.6 Visible state: the app emits `computer://state {active, endsAt?, reason?}` (`computer_status` gives the current one). Between calls, the rose shows the "in control" state (`dot-in_control`, mood `control`: accent rim, steady traveling light) and the panel shows "Controlling your Mac · mm:ss left" with Stop (`computer_stop`). During a screenshot or action call (including an entire batch and its final screenshot), the Dot and panel are temporarily hidden and the top edge of the controlled display glows in the rose's neon with a light traveling along it, without text or logo. The click-through glow must be ready and hiding confirmed before capture or input; failed preparation sends no input. Completion and normal error/Stop paths restore prior visibility without changing saved preferences or taking focus. The tray's "Stop computer control" and the panic shortcut remain independent of the hidden panel; shortcut registration and full-screen tray availability must be verified on the target Mac.
- S24.7 Wiring: the app registers its helper itself, over the app channel, right after it spawns the daemon (`computer_register {url, token}`; the daemon accepts only `http://127.0.0.1:<port>/mcp` and a header-safe key). A window cannot register, repoint, or remove it (L61 closed): the panel only calls `computer_endpoint` to know whether a helper exists. The daemon keeps the endpoint in memory, never in `connectors.json`, and renders `computer: {url, headers: {Authorization: "Bearer <key>"}, exposure: "direct"}` into `mcp.json`, then restarts the engine when idle. The guard's policy lists it under `builtin`, so its tools run without in-engine approval cards. It is removed on `computer_unregister` from the app or when the app's channel closes; windows coming and going do not touch it. A daemon without a channel (`pnpm dev`) gets no helper; the app never uses one (§9, Daemon lifecycle). The key is never logged or sent to a window: `connectors` lists only a built-in "Computer" entry (`builtin: true`) that the connector messages cannot change or remove, no saved or imported connector can take the name `computer`, and the import scan never offers the helper.
- S24.8 Speed: `batch {steps: [{tool, ...args}], intent?}` runs 1 to 20 steps of `click`, `move`, `drag`, `scroll`, `type`, `key`, `open_app`, or `wait` in one call and returns one screenshot. Each step takes the single tool's path (session and epoch, blocklist, risky confirmation, N1/N2 typing rules, coordinates mapped with the screenshot taken before the batch) and counts as one action for the rate limit; a full window delays the step instead of refusing it. Steps are 100 ms apart (1.5 s after `open_app`) so each step's guards read the screen the previous one left. The batch's `intent` applies to every step on top of the step's own. The first refused, declined, or failed step stops the batch; the error says which steps ran and comes with a fresh screenshot while the session lasts (none after Stop or panic). Malformed batches (empty, over 20, a nested `batch`, `screenshot`, `list_apps`, unknown tools, invalid arguments) run nothing. Actions settle 150 ms before their screenshot (`open_app` 1.5 s); screenshots are JPEG quality 65; debug builds optimize `image`, `zune-*`, and this crate (opt-level 1, because the generic encoder is compiled here).
-- S24.9 Yolo mode: in memory only, off at launch. `computer_set_yolo {enabled}` and the tray item "Yolo mode" switch it; turning it on asks a native confirmation ("Turn on yolo mode? Gentle Dot will send, pay, delete, and submit without asking you first, for up to 1 hour. Stop and ⌥⇧Esc still work.", Turn On / Cancel). While on, only the risky-action confirmation is skipped; the grant, blocklist, rate limit, Stop, and panic are unchanged, and Stop or panic end the session, not yolo mode. It turns itself off after 1 hour. `computer://state` and `computer_status` add `yolo` and `yoloEndsAt?`; every switch reports the resulting state, so a declined confirmation flips the UI switch back. Connectors → Computer shows a "Yolo mode" switch, the banner shows "Yolo", and the rose carries a yellow mark (`dot-yolo`).
+- S24.9 Yolo mode: in memory only, off at launch. `computer_set_yolo {enabled}` and the tray item "Yolo mode" switch it; turning it on asks a native confirmation ("Turn on yolo mode? Gentle Dot will send, pay, delete, and submit without asking you first, for up to 1 hour. Stop and ⌥⇧Esc still work.", Turn On / Cancel). While on, only the risky-action confirmation is skipped; the grant, blocklist, rate limit, Stop, and panic are unchanged, and Stop or panic end the session, not yolo mode. It turns itself off after 1 hour. `computer://state` and `computer_status` add `yolo` and `yoloEndsAt?`; every switch reports the resulting state, so a declined confirmation flips the UI switch back. Connectors → Computer shows a "Yolo mode" switch with a note that names the panic shortcut only when `computer_permissions` reports `panicShortcut: true` (registered at launch); otherwise, and until the app answers, it says only that Stop still works, as the dialog does. The banner shows "Yolo", and the rose carries a yellow mark (`dot-yolo`).
- S28 The pink glow where the agent acts:
- What it shows: a pulse on a click, a trail along a drag (drawn on the display where the drag starts), short markers for moves and scrolls, and an outline around the focused element after `type` and `key`, when that element reports a frame (`AXPosition`, `AXSize`, read right after the keys); without one, nothing shows. The glow uses the accent `#f095c8`. It fades about 1.5 s after the last action (1.2 s lit, then a 300 ms fade) and clears at once when the session ends (Stop, panic, timeout). With "Reduce motion" it stays still: no pulse and no trail, only the drag's end.
- Where the marks come from: once an action's input is posted, `perform` hands a `Mark` (global points and a kind) to the helper's glow sink. Each batch step that runs gets its own mark. A refused, declined, stopped, or failed action or step reports nothing. `open_app`, `wait`, `screenshot`, and `list_apps` report nothing either. The sink only queues the mark on a channel, so no check, order, timing, or result changes; a rig test runs the same calls with and without the sink and compares them.
diff --git a/packages/ui/src/components/Computer.tsx b/packages/ui/src/components/Computer.tsx
index 8b154df..7eafe7e 100644
--- a/packages/ui/src/components/Computer.tsx
+++ b/packages/ui/src/components/Computer.tsx
@@ -31,8 +31,9 @@ const PERMISSIONS: [ComputerPermission, string][] = [
export const DEBUG_BUILD_NOTE =
"Debug builds lose these permissions on every rebuild because macOS ties them to the app's signature; grant them again after updating.";
-const yoloNote = (windows: boolean) =>
- `Yolo mode lets the assistant send, pay, delete, and submit without asking you first. It turns itself off after 1 hour or when the app quits; Stop and ${windows ? "Alt+Shift+Esc" : "⌥⇧Esc"} still work.`;
+/** Names the panic shortcut only when the app registered it; until it says so, only Stop is promised. */
+const yoloNote = (windows: boolean, panicShortcut: boolean) =>
+ `Yolo mode lets the assistant send, pay, delete, and submit without asking you first. It turns itself off after 1 hour or when the app quits; ${panicShortcut ? `Stop and ${windows ? "Alt+Shift+Esc" : "⌥⇧Esc"} still work` : "Stop still works"}.`;
const NO_IMAGES_NOTE =
"The current model does not accept images, so the assistant cannot see your screen. Choose a model that does in Profiles.";
@@ -155,7 +156,7 @@ export function ComputerEntry({ info, controls }: ComputerEntryProps) {
<span className="switch-knob" aria-hidden="true" />
</button>
</div>
- <p className="connector-note">{yoloNote(windows)}</p>
+ <p className="connector-note">{yoloNote(windows, granted?.panicShortcut === true)}</p>
{windows ? null : <p className="connector-note">{DEBUG_BUILD_NOTE}</p>}
{info?.noImages ? <p className="connector-note computer-warning">{NO_IMAGES_NOTE}</p> : null}
</li>
diff --git a/packages/ui/src/computer.ts b/packages/ui/src/computer.ts
index 5d00457..87e0fd9 100644
--- a/packages/ui/src/computer.ts
+++ b/packages/ui/src/computer.ts
@@ -15,6 +15,8 @@ export interface ComputerPermissions {
accessibility: boolean;
screenRecording: boolean;
screenshotsSupported?: boolean;
+ /** The app registered the panic shortcut at launch, so it can stop computer control. */
+ panicShortcut?: boolean;
}
export type ComputerPermission = "accessibility" | "screenRecording";
diff --git a/packages/ui/test/computer.test.tsx b/packages/ui/test/computer.test.tsx
index d613d0a..a59e169 100644
--- a/packages/ui/test/computer.test.tsx
+++ b/packages/ui/test/computer.test.tsx
@@ -10,11 +10,18 @@ const HELPER = "http://127.0.0.1:51234/mcp";
const KEY = "s3cr3t-Computer-Key-0123456789abcdef";
const WINDOWS_2004_NOTE =
"Computer control needs Windows 10 version 2004 (build 19041) or newer for screenshots.";
+const YOLO_NOTE_WITHOUT_PANIC =
+ "Yolo mode lets the assistant send, pay, delete, and submit without asking you first. It turns itself off after 1 hour or when the app quits; Stop still works.";
const h = vi.hoisted(() => ({
tauri: true,
endpoint: null as unknown,
- permissions: { accessibility: false, screenRecording: true, screenshotsSupported: true },
+ permissions: {
+ accessibility: false,
+ screenRecording: true,
+ screenshotsSupported: true,
+ panicShortcut: true,
+ },
status: { active: false } as unknown,
invoke: vi.fn(),
send: vi.fn(),
@@ -94,7 +101,12 @@ async function emitState(payload: unknown) {
beforeEach(() => {
h.tauri = true;
h.endpoint = { url: HELPER, token: KEY };
- h.permissions = { accessibility: false, screenRecording: true, screenshotsSupported: true };
+ h.permissions = {
+ accessibility: false,
+ screenRecording: true,
+ screenshotsSupported: true,
+ panicShortcut: true,
+ };
h.status = { active: false };
h.listeners.clear();
h.send = vi.fn();
@@ -191,7 +203,12 @@ describe("the Computer entry in Connectors (S24.5)", () => {
expect(h.invoke).toHaveBeenCalledWith("computer_request_permission", { kind: "accessibility" });
await waitFor(() => expect(invoked("computer_permissions").length).toBe(checks + 1));
- h.permissions = { accessibility: true, screenRecording: true, screenshotsSupported: true };
+ h.permissions = {
+ accessibility: true,
+ screenRecording: true,
+ screenshotsSupported: true,
+ panicShortcut: true,
+ };
await userEvent.click(within(entry).getByRole("button", { name: "Check again" }));
await waitFor(() => expect(accessibility).toHaveTextContent("Allowed"));
expect(accessibility).not.toHaveTextContent("Not allowed");
@@ -199,7 +216,12 @@ describe("the Computer entry in Connectors (S24.5)", () => {
});
it("asks for Screen Recording with its own kind", async () => {
- h.permissions = { accessibility: true, screenRecording: false, screenshotsSupported: true };
+ h.permissions = {
+ accessibility: true,
+ screenRecording: false,
+ screenshotsSupported: true,
+ panicShortcut: true,
+ };
h.state = connectorsOpen([computerEntry()]);
await renderApp("?surface=panel");
const recording = await screen.findByRole("listitem", { name: "Screen Recording" });
@@ -289,7 +311,28 @@ describe("on Windows", () => {
expect(within(entry).queryByText("Screen Recording")).toBeNull();
expect(within(entry).queryByRole("button", { name: "Check again" })).toBeNull();
expect(within(entry).queryByText(DEBUG_NOTE)).toBeNull();
- expect(within(entry).getByText(/Stop and Alt\+Shift\+Esc still work/)).toBeInTheDocument();
+ expect(await within(entry).findByText(/Stop and Alt\+Shift\+Esc still work/)).toBeInTheDocument();
+ });
+
+ it("names Alt+Shift+Esc in the yolo note only when the app registered it", async () => {
+ h.permissions.panicShortcut = false;
+ h.state = connectorsOpen([computerEntry()]);
+ await renderApp("?surface=panel");
+ const entry = await screen.findByRole("listitem", { name: "Computer" });
+ expect(await within(entry).findByText(YOLO_NOTE_WITHOUT_PANIC)).toBeInTheDocument();
+ expect(within(entry).queryByText(/Alt\+Shift\+Esc/)).toBeNull();
+ });
+
+ it("promises no shortcut in the yolo note while the app has not answered", async () => {
+ const answer = h.invoke.getMockImplementation();
+ h.invoke.mockImplementation((command: string, args?: unknown) =>
+ command === "computer_permissions" ? new Promise(() => {}) : answer?.(command, args),
+ );
+ h.state = connectorsOpen([computerEntry()]);
+ await renderApp("?surface=panel");
+ const entry = await screen.findByRole("listitem", { name: "Computer" });
+ expect(within(entry).getByText(YOLO_NOTE_WITHOUT_PANIC)).toBeInTheDocument();
+ expect(within(entry).queryByText(/Alt\+Shift\+Esc/)).toBeNull();
});
it("explains unsupported screenshots require Windows 10 version 2004 or newer", async () => {
@@ -331,7 +374,29 @@ describe("on macOS", () => {
expect(within(entry).queryByText("Windows asks for no permission for computer control.")).toBeNull();
expect(within(entry).queryByText(WINDOWS_2004_NOTE)).toBeNull();
expect(within(entry).queryByText(/Alt\+Shift\+Esc/)).toBeNull();
- expect(within(entry).getByText(/Stop and ⌥⇧Esc still work/)).toBeInTheDocument();
+ expect(await within(entry).findByText(/Stop and ⌥⇧Esc still work/)).toBeInTheDocument();
+ });
+
+ it("names ⌥⇧Esc in the yolo note only when the app registered it", async () => {
+ h.permissions.panicShortcut = false;
+ h.state = connectorsOpen([computerEntry()]);
+ await renderApp("?surface=panel");
+ const entry = await screen.findByRole("listitem", { name: "Computer" });
+ await within(entry).findByText("Allowed");
+ expect(within(entry).getByText(YOLO_NOTE_WITHOUT_PANIC)).toBeInTheDocument();
+ expect(within(entry).queryByText(/⌥⇧Esc/)).toBeNull();
+ });
+
+ it("promises no shortcut in the yolo note when the permissions check fails", async () => {
+ const answer = h.invoke.getMockImplementation();
+ h.invoke.mockImplementation((command: string, args?: unknown) =>
+ command === "computer_permissions" ? Promise.reject(new Error("no answer")) : answer?.(command, args),
+ );
+ h.state = connectorsOpen([computerEntry()]);
+ await renderApp("?surface=panel");
+ const entry = await screen.findByRole("listitem", { name: "Computer" });
+ expect(within(entry).getByText(YOLO_NOTE_WITHOUT_PANIC)).toBeInTheDocument();
+ expect(within(entry).queryByText(/⌥⇧Esc/)).toBeNull();
});
it("names the Mac in the session banner", async () => {