A personal assistant that lives on your desktop, remembers what matters, and can use your Mac for you.
TypeScript
fix(ui): resolve main conflicts in panic shortcut permissions
egdev62925327442db
diff --cc apps/desktop/src-tauri/src/computer/app.rsindex 1baaaa5,bf786dc..dd6b46f--- a/apps/desktop/src-tauri/src/computer/app.rs+++ b/apps/desktop/src-tauri/src/computer/app.rs@@@ -519,25 -514,14 +519,25 @@@ pub fn computer_endpoint(computer: Stat}#[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 }+ Permissions { accessibility: false, screen_recording: false, screenshots_supported: false, screenshots_unsupported: None }- }+ };+ 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]@@@ -735,17 -725,22 +741,36 @@@ Use Stop in the panel or the tray menuassert_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 permissions = Permissions { accessibility: true, screen_recording: false, screenshots_supported: true, screenshots_unsupported: None };+ 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());+ }+++ /// Why screenshots are unsupported rides next to the bool, which stays as it was for every consumer.+ #[test]+ fn unsupported_screenshots_say_why() {+ let unsupported = |reason| Permissions {+ accessibility: true,+ screen_recording: true,+ screenshots_supported: false,+ screenshots_unsupported: Some(reason),+ };+ assert_eq!(+ serde_json::to_value(unsupported(super::super::ScreenshotsUnsupported::TooOld)).unwrap(),+ serde_json::json!({"accessibility": true, "screenRecording": true, "screenshotsSupported": false, "screenshotsUnsupported": "tooOld"})+ );+ assert_eq!(+ serde_json::to_value(unsupported(super::super::ScreenshotsUnsupported::UnknownVersion)).unwrap(),+ serde_json::json!({"accessibility": true, "screenRecording": true, "screenshotsSupported": false, "screenshotsUnsupported": "unknownVersion"})+ );+ }}diff --cc apps/desktop/src-tauri/src/computer/mod.rsindex eb1e0e1,faf584c..fd409b6--- a/apps/desktop/src-tauri/src/computer/mod.rs+++ b/apps/desktop/src-tauri/src/computer/mod.rs@@@ -184,9 -184,10 +184,10 @@@ pub struct AppInfopub 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.+ /// cannot leave Gentle Dot's windows out of them. `screenshotsUnsupported` says why, only when+ /// they are unsupported.#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]#[serde(rename_all = "camelCase")]pub struct Permissions {diff --cc packages/ui/src/components/Computer.tsxindex 7eafe7e,405808c..ec700af--- a/packages/ui/src/components/Computer.tsx+++ b/packages/ui/src/components/Computer.tsx@@@ -31,9 -31,12 +31,13 @@@ const PERMISSIONS: [ComputerPermissionexport 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 WINDOWS_TOO_OLD_NOTE =+ "Computer control needs Windows 10 version 2004 (build 19041) or newer for screenshots.";+ const WINDOWS_UNKNOWN_VERSION_NOTE =+ "Gentle Dot cannot tell which Windows version this is, so computer control is unavailable: screenshots need Windows 10 version 2004 (build 19041) or newer.";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.";diff --cc packages/ui/src/computer.tsindex 87e0fd9,c490bd2..52066cd--- a/packages/ui/src/computer.ts+++ b/packages/ui/src/computer.ts@@@ -15,8 -15,8 +15,10 @@@ export interface ComputerPermissionsaccessibility: boolean;screenRecording: boolean;screenshotsSupported?: boolean;+ /** The app registered the panic shortcut at launch, so it can stop computer control. */+ panicShortcut?: boolean;+ /** Why screenshots are unsupported, only when they are; an older app sends none. */+ screenshotsUnsupported?: "tooOld" | "unknownVersion";}export type ComputerPermission = "accessibility" | "screenRecording";diff --cc packages/ui/test/computer.test.tsxindex a59e169,2ede02a..156ceb1--- a/packages/ui/test/computer.test.tsx+++ b/packages/ui/test/computer.test.tsx@@@ -10,8 -11,8 +11,10 @@@ const HELPER = "http://127.0.0.1:51234/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 UNKNOWN_WINDOWS_NOTE =+ "Gentle Dot cannot tell which Windows version this is, so computer control is unavailable: screenshots need Windows 10 version 2004 (build 19041) or newer.";const h = vi.hoisted(() => ({tauri: true,@@@ -20,8 -21,7 +23,8 @@@accessibility: false,screenRecording: true,screenshotsSupported: true,+ panicShortcut: true,- },+ } as ComputerPermissions,status: { active: false } as unknown,invoke: vi.fn(),send: vi.fn(),@@@ -373,30 -358,9 +397,31 @@@ describe("on macOS", () =>await within(entry).findByText("Accessibility");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(UNKNOWN_WINDOWS_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 () => {