Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(macos): one-click permission setup with a single automatic restart

Harald Herzeb78b7211d06
diff --git a/docs/BUGS.md b/docs/BUGS.md
index 331a6f8b41..154d35e133 100644
--- a/docs/BUGS.md
+++ b/docs/BUGS.md
@@ -11202,6 +11202,9 @@ rebuild remains a new app to TCC. A Developer-ID signing identity is the
structural fix; until then a rebuild costs the user one round of re-granting,
now visible in the log and explained in the UI.
+**Closed 2026-09-16 by BUG-217.** The bundle is now signed with a per-user
+certificate, so a rebuild keeps the same TCC identity and resets nothing.
+
---
## BUG-160: a spoken question is answered with "Erledigt." and the real answer is thrown away — every Gemini/Vertex Live tool call fakes a mute provider (CRITICAL, FIXED 2026-08-20)
@@ -11369,6 +11372,10 @@ identity is the structural fix. The rebuild guard also arms only after the
first rebuild it observes, so an install already caught in the loop pays for
one more round before it stops.
+**Closed 2026-09-16 by BUG-217.** With the per-user signing certificate a
+necessary rebuild no longer changes the TCC identity; the guard is only a
+safety net now.
+
## BUG-162: dictation silently drops the end of what was said — a deep queue that never applied, a truncation guard that fired once in 797 recordings, and a loss nothing reported (HIGH, FIXED 2026-08-21)
**Symptom (reported 2026-08-21).** "Sometimes the last sentence just is not
@@ -15262,3 +15269,87 @@ with the command that fixes it instead of claiming the app is findable.
`mdutil` output, mount-point resolution, import on registration, a Spotlight
crash never blocks `lsregister`), `tests/unit/diagnostics/test_doctor_diagnostics.py`
(`check_macos_spotlight`).
+
+## BUG-217: macOS asked for every permission again after each rebuild, and the Music prompt never stuck (HIGH, FIXED 2026-09-16)
+
+**Symptom.** After an update or reinstall, Personal Jarvis asked for
+Microphone, Screen Recording, Accessibility, Input Monitoring and Input
+Control all over again. The "Music / Spotify" Automation dialog appeared in
+the middle of a dictation, sometimes on every voice session, and no
+permission view knew it existed. The reporting Mac's install log of the day
+shows the exact moment: a bundle-format rebuild followed by five
+`Reset stale TCC rows for …` lines.
+
+**Root causes, four of them.**
+
+1. *Ad-hoc signature = CDHash identity.* macOS pins every TCC grant to the
+ app's designated requirement. For an ad-hoc signature that requirement is
+ `cdhash H"…"` — the hash of the very bytes that every rebuild changes. So
+ every rebuild was a new app to TCC, the recorded grants were orphaned, and
+ BUG-083 had to reset them so macOS would prompt at all. BUG-159 and
+ BUG-161 both closed with "the underlying churn is the ad-hoc signature
+ itself — still open". It was.
+2. *The Automation consent lived outside the model.* `kTCCServiceAppleEvents`
+ was neither in the installer's reset sweep nor in `PermissionId`; the only
+ thing that ever asked for it was a 3-second `osascript` fired when the
+ ducking toggle was flipped or mid-session. A 3 s timeout kills osascript
+ while the dialog is still up, so the user's answer was never recorded and
+ the next session asked again.
+3. *No live probe for a closed player.* Apple only answers
+ `AEDeterminePermissionToAutomateTarget` for a running target, so a row for
+ it could not simply read the OS.
+4. *Six buttons and a restart to find.* Nothing walked the user through the
+ list; each grant was its own click, its own Settings visit and its own
+ restart decision.
+
+**Fix.**
+
+- `jarvis/setup/macos_signing_identity.py` creates a self-signed
+ code-signing certificate once per user ("Personal Jarvis Local Signing"),
+ imports it into the login keychain with codesign access and trusts it for
+ code signing in the user domain — the one step macOS guards with a
+ password dialog, so only the installer (`--create-signing-identity`) may
+ run it; the app itself only looks the identity up. `macos_app_bundle`
+ signs with it, and the TCC identity is now the designated requirement
+ (`identifier "com.personal-jarvis.desktop" and certificate leaf = H"…"`)
+ instead of the CDHash: verified on macOS 15.7.4 — two differently built
+ bundles, same requirement. A rebuild resets nothing anymore. A healthy
+ ad-hoc bundle is re-signed in place once (same files, atomic swap) at the
+ cost of one final round of re-granting; the running app is never re-signed
+ under itself, because the reset that follows would strip the grants of the
+ process asking. Falls back to ad-hoc (the old behaviour) without a GUI
+ session or when the user declines the dialog.
+- `AppleEvents` joined the reset sweep, and `automation` is the seventh
+ `PermissionId` (feature `audio_ducking`): probed live through
+ `AEDeterminePermissionToAutomateTarget` (ctypes, no pyobjc binding exists)
+ for every installed player; the request flow opens a closed player hidden
+ through `NSWorkspaceOpenConfiguration`, asks with `askUserIfNeeded`, closes
+ what it opened, and records each answer in
+ `macos-automation-consent.json` so the row stays final while the player is
+ closed. Every reset path (`tccutil reset AppleEvents`, an identity change)
+ drops that record. The ducking prewarm waits 120 s for the dialog instead
+ of 3 s, and the player list is shared between the scripts and the row.
+- **Set up everything** (`usePermissions.setupAll`): walks the missing rows
+ in a fixed order — pure dialogs first, Settings-switch rows last — waits
+ for each grant by polling, then restarts the app once when a grant only
+ applies to a fresh process. Onboarding keeps its own final restart; the
+ Settings card and the app-wide banner restart themselves.
+
+**Class rule.** A per-machine build must not carry a per-build identity.
+Anything the OS keys to "which app is this" (TCC, Keychain ACLs, LaunchAgent
+ownership) needs a certificate, not a hash, or every rebuild is a stranger.
+
+**Guards.** `tests/unit/setup/test_macos_signing_identity.py` (the
+`security` choreography, GUI-session refusal, hung dialog, real certificate
+material), `tests/unit/setup/test_macos_app_bundle.py` (designated-requirement
+parsing, identity signing, one-time re-sign with rollback, no reset when the
+requirement is unchanged, the running app is never re-signed),
+`tests/unit/platform/test_permissions.py` (the Automation row: live probe,
+hidden launch and close, recorded answers, strictest player wins, reset and
+identity change forget the answers), `usePermissions.test.tsx` and
+`PermissionsPanel.test.tsx` (the guided flow: order, waiting, cancel, the
+single restart, onboarding leaves the restart to itself).
+
+**Related.** BUG-083, BUG-159, BUG-161 (all "still open" on this point until
+now), `docs/product/privacy-safety-and-support/permissions.md`,
+`docs/os-parity.md`.
diff --git a/docs/os-parity.md b/docs/os-parity.md
index 1268e0c544..be4382b7d5 100644
--- a/docs/os-parity.md
+++ b/docs/os-parity.md
@@ -323,6 +323,20 @@ point), logging the admin repair command when the store is disabled or broken;
unchanged — their index announcements already feed the search the user types
into.
+**Fix pass 2026-09-16 (macOS: one TCC identity for the life of the install,
+BUG-217).** The source installer creates a per-user code-signing certificate
+("Personal Jarvis Local Signing", login keychain, trusted for code signing in
+the user domain — the one password dialog of the install) and signs the bundle
+with it, so macOS pins privacy grants to `identifier + certificate` instead of
+the per-build CDHash: rebuilds and updates keep every grant. Without a GUI
+session, or if the dialog is declined, signing stays ad-hoc and the previous
+"reset on identity change" behaviour applies. The Music/Spotify Automation
+consent is a permission row of its own (`automation`), asked up front through
+`AEDeterminePermissionToAutomateTarget` with a hidden launch of a closed
+player, and **Set up everything** walks all rows and ends in a single restart.
+Windows and Linux: no TCC, no signing identity, the rows read "not required"
+as before.
+
## Audit verdict summary
**No hard breakers found.** No feature crashes on macOS or headless Linux;
diff --git a/docs/product/privacy-safety-and-support/permissions.md b/docs/product/privacy-safety-and-support/permissions.md
index f4ca000512..6aedd7f7f9 100644
--- a/docs/product/privacy-safety-and-support/permissions.md
+++ b/docs/product/privacy-safety-and-support/permissions.md
@@ -19,8 +19,8 @@ Use App Permissions to grant only the local access required by the features
you use. Personal Jarvis has no master permission that unlocks your computer,
accounts, and tool actions at once.
-The current card manages six items for the installed macOS desktop app. Five
-are macOS privacy permissions. The sixth reports whether API keys use macOS
+The current card manages seven items for the installed macOS desktop app. Six
+are macOS privacy permissions. The seventh reports whether API keys use macOS
Keychain. Browser permissions, connected-account access, and Jarvis safety
approvals remain separate.
@@ -37,7 +37,7 @@ approvals remain separate.
screen. A system permission prompt never needs an API key, password, token,
or recovery code.
-During first-run setup, an interactive Mac shows all six rows. **Continue** is
+During first-run setup, an interactive Mac shows all seven rows. **Continue** is
enabled when every row is ready or is waiting for the final setup restart.
Choose **Continue with text only** to skip the remaining grants. Completing
setup restarts the installed desktop app when that restart is available.
@@ -46,7 +46,7 @@ setup restarts the installed desktop app when that restart is available.
| Platform | What App Permissions shows | What you still need to check |
|---|---|---|
-| macOS desktop | Six permission rows and available actions | The installed app identity, native prompts, and any restart notice |
+| macOS desktop | Seven permission rows, **Set up everything**, and the per-row actions | The installed app identity, native prompts, and any restart notice |
| Windows desktop | **No extra desktop privacy permissions are required on this operating system.** | Windows microphone privacy, User Account Control, file access, and the feature itself |
| Linux desktop | The same **Not required** message | Audio device access, file ownership, desktop session, and required desktop tools |
| Headless or remote browser | No local desktop grant can create a microphone or live display | Browser site access and whether the host has the required device or desktop session |
@@ -68,6 +68,7 @@ these visible row names:
| **Accessibility** | Read supported interface structure, focus or move windows, and support reliable input | Computer Use, window control, and global shortcuts | Yes |
| **Input Monitoring** | Listen for configured system-wide keyboard shortcuts | Global shortcuts | Yes |
| **Input control** | Post mouse and keyboard events | Computer Use | No |
+| **Automation (Music & Spotify)** | Send Apple Events to Music and Spotify | Mute music while dictating | No |
| **Keychain (API keys)** | Store API keys in macOS Keychain | Encrypted operating-system credential storage | No |
Current macOS versions may name the Screen Recording pane **Screen & System
@@ -75,7 +76,20 @@ Audio Recording**. **Input control** is Jarvis's label for posting input
events. Its state can follow **Accessibility**, and **Open Settings** may open
the Accessibility pane rather than a separate pane named Input control.
-Grant one item at a time:
+**Set up everything** runs the whole list for you: it raises each native
+dialog in turn, opens the matching System Settings pane for the rows macOS
+only grants there, waits until the switch is on, and finishes with one
+automatic restart when a grant needs a fresh process. **Stop** ends the flow at
+any point; nothing already granted is lost. **Automation** briefly opens a
+closed Music or Spotify in the background so macOS can ask, and closes it
+again.
+
+Grants made this way are recorded against the app's local signing
+certificate, which the installer creates once (macOS asks for your login
+password that one time). They survive every later update and rebuild of the
+app.
+
+Grant one item at a time instead:
1. Move focus to **Allow** for the row you need and activate it. Read the
native macOS prompt before you approve or deny it.
@@ -121,13 +135,12 @@ screenshots, action records, or provider data that already exists.
## Permissions This Card Does Not Manage
-### Automation, Files, and Notifications
+### Files and Notifications
-The optional **Mute music while dictating** setting can ask for macOS
-**Automation** access to Music or Spotify. Automation is not one of the six
-rows. If you deny it, Jarvis skips player-specific volume control and voice can
-continue. Review that access in macOS **System Settings > Privacy & Security >
-Automation**.
+The **Mute music while dictating** setting uses the **Automation (Music &
+Spotify)** row above. If you deny it, Jarvis skips player-specific volume
+control and voice can continue; **Ask again** clears the recorded decision so
+macOS can prompt once more.
There is no general **Files** row, and this flow does not require **Full Disk
Access**. File access depends on the operating-system account running Jarvis,
diff --git a/install/README.md b/install/README.md
index ad479184b0..df0cb3c7cb 100644
--- a/install/README.md
+++ b/install/README.md
@@ -37,9 +37,12 @@ and headless Linux hosts are deliberately not registered.
On macOS, every launch path enters through the same app bundle so privacy
grants stay attached to one identity. The source installer builds a native
-py2app alias launcher, ad-hoc signs it for that machine, verifies the identity
-from inside a LaunchServices process, and preserves the bundle unchanged across
-ordinary updates. A separately distributed binary still requires the release
+py2app alias launcher, signs it with a per-user code-signing certificate it
+creates on the first run (macOS asks for the login password once to trust
+it; grants then survive every rebuild and update), verifies the identity from
+inside a LaunchServices process, and preserves the bundle unchanged across
+ordinary updates. Without that certificate the launcher is ad-hoc signed and a
+rebuild costs one round of re-granting. A separately distributed binary still requires the release
pipeline's Developer-ID signing and notarization. Apple does not permit an installer to
silently grant Microphone, Screen Recording, Accessibility, Input Monitoring,
or input-control access. The app therefore presents one explicit button per
diff --git a/jarvis/ui/web/frontend/src/components/layout/PermissionsAlertBanner.test.tsx b/jarvis/ui/web/frontend/src/components/layout/PermissionsAlertBanner.test.tsx
index d6bd0ab75a..d9b6b99129 100644
--- a/jarvis/ui/web/frontend/src/components/layout/PermissionsAlertBanner.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/layout/PermissionsAlertBanner.test.tsx
@@ -27,6 +27,10 @@ vi.mock("@/hooks/usePermissions", () => ({
request,
openSettings,
reset,
+ setupAll: vi.fn().mockResolvedValue("complete"),
+ cancelSetup: vi.fn(),
+ setupProgress: null,
+ setupNeeded: false,
}),
}));
diff --git a/jarvis/ui/web/frontend/src/components/layout/PermissionsAlertBanner.tsx b/jarvis/ui/web/frontend/src/components/layout/PermissionsAlertBanner.tsx
index d713435205..b216f20356 100644
--- a/jarvis/ui/web/frontend/src/components/layout/PermissionsAlertBanner.tsx
+++ b/jarvis/ui/web/frontend/src/components/layout/PermissionsAlertBanner.tsx
@@ -9,7 +9,9 @@ import {
Mic,
Monitor,
MousePointer2,
+ Music,
ShieldAlert,
+ Wand2,
} from "lucide-react";
import { clsx } from "clsx";
@@ -21,6 +23,7 @@ import {
type PermissionId,
type PermissionItem,
} from "@/hooks/usePermissions";
+import { SetupAllControl } from "@/views/settings/PermissionsPanel";
const ICONS = {
microphone: Mic,
@@ -28,6 +31,7 @@ const ICONS = {
accessibility: Accessibility,
input_monitoring: Keyboard,
event_posting: MousePointer2,
+ automation: Music,
credential_store: KeyRound,
} satisfies Record<PermissionId, typeof Mic>;
@@ -60,7 +64,17 @@ export function PermissionsAlertBanner() {
const pushToast = useEventStore((state) => state.pushToast);
const [collapsed, setCollapsed] = useState(false);
const [restarting, setRestarting] = useState(false);
- const { snapshot, pendingId, request, openSettings, reset } = usePermissions();
+ const {
+ snapshot,
+ pendingId,
+ request,
+ openSettings,
+ reset,
+ setupAll,
+ cancelSetup,
+ setupProgress,
+ setupNeeded,
+ } = usePermissions();
if (!snapshot || snapshot.platform !== "darwin" || snapshot.headless) return null;
@@ -83,6 +97,25 @@ export function PermissionsAlertBanner() {
}
}
+ async function runSetup() {
+ try {
+ const outcome = await setupAll({ autoRestart: true });
+ if (outcome === "restart") {
+ pushToast("info", t("permissions.setup_restarting"));
+ } else if (outcome === "timeout") {
+ pushToast("warning", t("permissions.setup_timeout"));
+ }
+ } catch (exc) {
+ const message = exc instanceof Error ? exc.message : String(exc);
+ pushToast(
+ "error",
+ message === "restart-missions-running"
+ ? t("topbar.restart_missions_running")
+ : message,
+ );
+ }
+ }
+
async function restartApp() {
if (restarting) return;
setRestarting(true);
@@ -131,22 +164,39 @@ export function PermissionsAlertBanner() {
{t(restarting ? "permissions.restarting" : "permissions.restart_now")}
</Button>
) : (
- <Button
- size="sm"
- variant="outline"
- aria-expanded={!collapsed}
- onClick={() => setCollapsed((value) => !value)}
- >
- {collapsed ? (
- <ChevronDown className="mr-1.5 h-3.5 w-3.5" aria-hidden />
- ) : (
- <ChevronUp className="mr-1.5 h-3.5 w-3.5" aria-hidden />
+ <>
+ {/* The whole list in one click; the per-row buttons below stay
+ for anyone who wants to pick. Hidden while the app runs
+ outside its bundle — a grant would land on the wrong identity. */}
+ {setupNeeded && snapshot.app_identity.stable !== false && !setupProgress && (
+ <Button size="sm" data-testid="permissions-setup-all" onClick={() => void runSetup()}>
+ <Wand2 className="mr-1.5 h-3.5 w-3.5" aria-hidden />
+ {t("permissions.setup_all")}
+ </Button>
)}
- {t(collapsed ? "permissions.banner.expand" : "permissions.banner.collapse")}
- </Button>
+ <Button
+ size="sm"
+ variant="outline"
+ aria-expanded={!collapsed}
+ onClick={() => setCollapsed((value) => !value)}
+ >
+ {collapsed ? (
+ <ChevronDown className="mr-1.5 h-3.5 w-3.5" aria-hidden />
+ ) : (
+ <ChevronUp className="mr-1.5 h-3.5 w-3.5" aria-hidden />
+ )}
+ {t(collapsed ? "permissions.banner.expand" : "permissions.banner.collapse")}
+ </Button>
+ </>
)}
</div>
+ {!restartOnly && setupProgress && (
+ <div className="px-4 pb-3">
+ <SetupAllControl progress={setupProgress} onStart={() => undefined} onCancel={cancelSetup} />
+ </div>
+ )}
+
{!restartOnly && !collapsed && (
<div className="space-y-stack px-4 pb-3">
{snapshot.app_identity.stable === false && (
diff --git a/jarvis/ui/web/frontend/src/hooks/usePermissions.test.tsx b/jarvis/ui/web/frontend/src/hooks/usePermissions.test.tsx
index ed4591f1a0..9afc011002 100644
--- a/jarvis/ui/web/frontend/src/hooks/usePermissions.test.tsx
+++ b/jarvis/ui/web/frontend/src/hooks/usePermissions.test.tsx
@@ -81,3 +81,120 @@ it("surfaces a failed native request without losing the last snapshot", async ()
expect(result.current.error).toContain("foreground");
expect(result.current.snapshot?.permissions[0].status).toBe("not_determined");
});
+
+function twoRowSnapshot(
+ microphone: "not_determined" | "granted",
+ accessibility: "not_granted" | "granted",
+ restartRequired = false,
+): PermissionSnapshot {
+ return {
+ platform: "darwin",
+ supported: true,
+ headless: false,
+ app_identity: { stable: true, foreground: true, launched_as_bundle: true },
+ permissions: [
+ {
+ id: "microphone",
+ status: microphone,
+ required: ["voice"],
+ can_request: microphone !== "granted",
+ can_open_settings: true,
+ can_reset: false,
+ restart_required: false,
+ },
+ {
+ // Accessibility has no prompt left here: only the Settings switch.
+ id: "accessibility",
+ status: accessibility,
+ required: ["global_hotkeys"],
+ can_request: false,
+ can_open_settings: accessibility !== "granted",
+ can_reset: false,
+ restart_required: restartRequired,
+ },
+ ],
+ features: {
+ voice: { ready: microphone === "granted", missing: [] },
+ global_hotkeys: { ready: accessibility === "granted", missing: [] },
+ },
+ restart_required: restartRequired,
+ };
+}
+
+it("walks every missing row in order, waits for each grant, then restarts once", async () => {
+ // The fake macOS: the microphone dialog is answered on the request; the
+ // Accessibility switch flips two polls after System Settings opened, and
+ // that grant only applies to a fresh process.
+ let microphone: "not_determined" | "granted" = "not_determined";
+ let accessibility: "not_granted" | "granted" = "not_granted";
+ let pollsSinceSettings = -1;
+ const calls: string[] = [];
+ vi.stubGlobal(
+ "fetch",
+ vi.fn().mockImplementation((url: string, init?: RequestInit) => {
+ if (init?.method === "POST") calls.push(url);
+ if (url === "/api/settings/restart-app") {
+ return Promise.resolve({ ok: true, status: 200, json: () => Promise.resolve({}) });
+ }
+ if (url.includes("/microphone/request")) microphone = "granted";
+ if (url.includes("/accessibility/open-settings")) pollsSinceSettings = 0;
+ else if (url === "/api/permissions/status" && pollsSinceSettings >= 0) {
+ pollsSinceSettings += 1;
+ if (pollsSinceSettings >= 2) accessibility = "granted";
+ }
+ const restart = accessibility === "granted" && pollsSinceSettings >= 0;
+ const body = twoRowSnapshot(microphone, accessibility, restart);
+ const payload = init?.method === "POST" ? { ok: true, snapshot: body } : body;
+ return Promise.resolve({ ok: true, status: 200, json: () => Promise.resolve(payload) });
+ }),
+ );
+
+ const { result } = renderHook(() => usePermissions());
+ await waitFor(() => expect(result.current.setupNeeded).toBe(true));
+
+ let outcome: string | undefined;
+ await act(async () => {
+ outcome = await result.current.setupAll({ autoRestart: true, pollMs: 1 });
+ });
+
+ expect(outcome).toBe("restart");
+ expect(calls).toEqual([
+ "/api/permissions/microphone/request?dry_run=false",
+ "/api/permissions/accessibility/open-settings?dry_run=false",
+ "/api/settings/restart-app",
+ ]);
+ expect(result.current.setupProgress).toBeNull();
+});
+
+it("stops when asked and never restarts without being allowed to", async () => {
+ const calls: string[] = [];
+ vi.stubGlobal(
+ "fetch",
+ vi.fn().mockImplementation((url: string, init?: RequestInit) => {
+ if (init?.method === "POST") calls.push(url);
+ const body = twoRowSnapshot("granted", "not_granted");
+ const payload = init?.method === "POST" ? { ok: true, snapshot: body } : body;
+ return Promise.resolve({ ok: true, status: 200, json: () => Promise.resolve(payload) });
+ }),
+ );
+
+ const { result } = renderHook(() => usePermissions());
+ await waitFor(() => expect(result.current.setupNeeded).toBe(true));
+
+ let run: Promise<string> | undefined;
+ act(() => {
+ run = result.current.setupAll({ pollMs: 1 });
+ });
+ // The Settings pane is open and the switch never flips: the user gives up.
+ await waitFor(() => expect(result.current.setupProgress?.phase).toBe("settings"));
+ act(() => {
+ result.current.cancelSetup();
+ });
+ let outcome: string | undefined;
+ await act(async () => {
+ outcome = await run;
+ });
+
+ expect(outcome).toBe("cancelled");
+ expect(calls).toEqual(["/api/permissions/accessibility/open-settings?dry_run=false"]);
+});
diff --git a/jarvis/ui/web/frontend/src/hooks/usePermissions.ts b/jarvis/ui/web/frontend/src/hooks/usePermissions.ts
index 54674abce4..d6dfc1bb5c 100644
--- a/jarvis/ui/web/frontend/src/hooks/usePermissions.ts
+++ b/jarvis/ui/web/frontend/src/hooks/usePermissions.ts
@@ -1,4 +1,4 @@
-import { useCallback, useEffect, useMemo, useState } from "react";
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { bootSettled } from "@/lib/bootStagger";
@@ -68,6 +68,48 @@ export interface PermissionSnapshot {
restart_required: boolean;
}
+/**
+ * The guided flow asks in this order: the pure dialogs first (a click each),
+ * then the rows that end in a System Settings switch, so the user is never
+ * bounced between Settings and the app more than once per row.
+ */
+export const SETUP_ORDER: readonly PermissionId[] = [
+ "microphone",
+ "automation",
+ "accessibility",
+ "input_monitoring",
+ "screen_recording",
+ "event_posting",
+ "credential_store",
+];
+
+export interface SetupProgress {
+ id: PermissionId;
+ index: number;
+ total: number;
+ /** "prompt" while the native dialog is up, "settings" once only a switch in System Settings is left. */
+ phase: "prompt" | "settings";
+}
+
+export type SetupOutcome = "complete" | "cancelled" | "timeout" | "restart";
+
+const SETTLED_STATES = new Set(["granted", "not_required"]);
+
+/** A row the guided flow still has to deal with. */
+export function needsSetup(item: PermissionItem): boolean {
+ return (
+ item.required.length > 0 &&
+ !SETTLED_STATES.has(item.status) &&
+ !item.restart_required &&
+ item.status !== "unavailable" &&
+ item.status !== "restricted"
+ );
+}
+
+function settled(item: PermissionItem | undefined): boolean {
+ return !item || !needsSetup(item);
+}
+
const EMPTY_SNAPSHOT: PermissionSnapshot = {
platform: "unknown",
supported: false,
@@ -114,21 +156,31 @@ export function usePermissions() {
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const [pendingId, setPendingId] = useState<PermissionId | null>(null);
+ const [setupProgress, setSetupProgress] = useState<SetupProgress | null>(null);
+ const setupCancelled = useRef(false);
+
+ const fetchSnapshot = useCallback(async (): Promise<PermissionSnapshot> => {
+ const next = normalizeSnapshot(await readJson(await fetch("/api/permissions/status")));
+ setSnapshot(next);
+ return next;
+ }, []);
const refetch = useCallback(async () => {
try {
- const payload = await readJson(await fetch("/api/permissions/status"));
- setSnapshot(normalizeSnapshot(payload));
+ await fetchSnapshot();
setError(null);
} catch (exc) {
setError(exc instanceof Error ? exc.message : String(exc));
} finally {
setLoading(false);
}
- }, []);
+ }, [fetchSnapshot]);
const mutate = useCallback(
- async (id: PermissionId, action: "request" | "open-settings" | "reset") => {
+ async (
+ id: PermissionId,
+ action: "request" | "open-settings" | "reset",
+ ): Promise<PermissionSnapshot> => {
setPendingId(id);
try {
const payload = await readJson(
@@ -136,8 +188,10 @@ export function usePermissions() {
method: "POST",
}),
);
- setSnapshot(normalizeSnapshot(payload));
+ const next = normalizeSnapshot(payload);
+ setSnapshot(next);
setError(null);
+ return next;
} catch (exc) {
setError(exc instanceof Error ? exc.message : String(exc));
throw exc;
@@ -148,6 +202,72 @@ export function usePermissions() {
[],
);
+ /**
+ * The one-click flow: walk every missing row, fire its dialog (or open its
+ * Settings pane) and wait for macOS to report the grant before moving on.
+ * Ends with one automatic restart when a granted row only applies to a
+ * fresh process (Screen Recording, Input Monitoring, Accessibility) and
+ * `autoRestart` is set — onboarding owns its own final restart instead.
+ */
+ const setupAll = useCallback(
+ async (options: { autoRestart?: boolean; pollMs?: number; rowTimeoutMs?: number } = {}) => {
+ const { autoRestart = false, pollMs = 1500, rowTimeoutMs = 180_000 } = options;
+ setupCancelled.current = false;
+ let latest = await fetchSnapshot();
+ const queue = SETUP_ORDER.filter((id) =>
+ latest.permissions.some((item) => item.id === id && needsSetup(item)),
+ );
+ let outcome: SetupOutcome = "complete";
+ try {
+ for (const [index, id] of queue.entries()) {
+ const item = latest.permissions.find((entry) => entry.id === id);
+ if (settled(item)) continue;
+ setSetupProgress({ id, index: index + 1, total: queue.length, phase: "prompt" });
+ if (item?.can_request) {
+ latest = await mutate(id, "request");
+ } else if (item?.can_open_settings) {
+ latest = await mutate(id, "open-settings");
+ } else {
+ continue;
+ }
+ const deadline = Date.now() + rowTimeoutMs;
+ let current = latest.permissions.find((entry) => entry.id === id);
+ while (!settled(current)) {
+ if (setupCancelled.current) {
+ outcome = "cancelled";
+ return outcome;
+ }
+ if (Date.now() > deadline) {
+ outcome = "timeout";
+ return outcome;
+ }
+ setSetupProgress({ id, index: index + 1, total: queue.length, phase: "settings" });
+ await new Promise((resolve) => window.setTimeout(resolve, pollMs));
+ latest = await fetchSnapshot();
+ current = latest.permissions.find((entry) => entry.id === id);
+ }
+ }
+ if (autoRestart && latest.restart_required) {
+ outcome = "restart";
+ const response = await fetch("/api/settings/restart-app", { method: "POST" });
+ if (!response.ok) {
+ throw new Error(
+ response.status === 409 ? "restart-missions-running" : `restart-failed:${response.status}`,
+ );
+ }
+ }
+ return outcome;
+ } finally {
+ setSetupProgress(null);
+ }
+ },
+ [fetchSnapshot, mutate],
+ );
+
+ const cancelSetup = useCallback(() => {
+ setupCancelled.current = true;
+ }, []);
+
useEffect(() => {
// Non-critical: the banner can appear a few seconds late; the first-mount
// burst must not spend a connection on it (see bootStagger).
@@ -184,14 +304,29 @@ export function usePermissions() {
return () => window.clearInterval(timer);
}, [refetch, waitingForSystemSettings]);
+ const setupNeeded = useMemo(
+ () => snapshot?.permissions.some(needsSetup) ?? false,
+ [snapshot],
+ );
+
return {
snapshot,
loading,
error,
pendingId,
refetch,
- request: (id: PermissionId) => mutate(id, "request"),
- openSettings: (id: PermissionId) => mutate(id, "open-settings"),
- reset: (id: PermissionId) => mutate(id, "reset"),
+ request: async (id: PermissionId) => {
+ await mutate(id, "request");
+ },
+ openSettings: async (id: PermissionId) => {
+ await mutate(id, "open-settings");
+ },
+ reset: async (id: PermissionId) => {
+ await mutate(id, "reset");
+ },
+ setupAll,
+ cancelSetup,
+ setupProgress,
+ setupNeeded,
};
}
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index a340b685cb..9303137985 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -2222,6 +2222,14 @@
"api_keys": "Sichere API-Key-Ablage"
},
"restart_deferred": "Neu erteilte Freigaben werden mit dem automatischen Neustart am Ende der Einrichtung aktiv - jetzt ist nichts zu tun.",
+ "setup_all": "Alles einrichten",
+ "setup_all_hint": "Ein Klick führt dich durch alle fehlenden Berechtigungen und übernimmt sie am Ende.",
+ "setup_running": "Schritt {0} von {1}: {2}",
+ "setup_wait_prompt": "Beantworte den macOS-Dialog — es geht automatisch weiter.",
+ "setup_wait_settings": "Schalte Personal Jarvis in der gerade geöffneten Systemeinstellungen-Seite ein und komm zurück — es geht automatisch weiter.",
+ "setup_cancel": "Abbrechen",
+ "setup_restarting": "Fertig — Personal Jarvis startet einmal neu, um den neuen Zugriff zu übernehmen.",
+ "setup_timeout": "Einrichtung pausiert: Eine Berechtigung wurde nicht rechtzeitig erteilt. Nutze „Alles einrichten“ jederzeit erneut.",
"ask_again": "Erneut fragen",
"stale_grant_hint": "macOS fragt für diesen Zugriff nicht mehr nach. Steht der Haken in den Systemeinstellungen schon, gehört er zu einer älteren Version der App — tippe auf „Erneut fragen“ und erlaube den Zugriff danach neu.",
"identity_reset": "macOS sieht Personal Jarvis seit dem letzten Neuaufbau der App als neue App an und hat dabei alle erteilten Zugriffe verworfen. Bitte einmal neu erlauben — danach bleiben sie erhalten."
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 17ef5e000f..2b576841bc 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -2255,6 +2255,14 @@
"api_keys": "Secure API-key storage"
},
"restart_deferred": "Newly granted access turns on with the automatic restart at the end of setup - nothing to do now.",
+ "setup_all": "Set up everything",
+ "setup_all_hint": "One click walks you through every remaining permission and applies them at the end.",
+ "setup_running": "Step {0} of {1}: {2}",
+ "setup_wait_prompt": "Answer the macOS dialog — this continues on its own.",
+ "setup_wait_settings": "Turn on Personal Jarvis in the System Settings pane that just opened, then come back — this continues on its own.",
+ "setup_cancel": "Stop",
+ "setup_restarting": "All set — Personal Jarvis restarts once to apply the new access.",
+ "setup_timeout": "Setup paused: a permission was not granted in time. Use “Set up everything” again whenever you like.",
"ask_again": "Ask again",
"stale_grant_hint": "macOS will not ask for this access again. If System Settings already shows it as enabled, that record belongs to an older version of the app — tap “Ask again” and allow access once more.",
"identity_reset": "Since the app was last rebuilt, macOS treats Personal Jarvis as a new app and discarded every access you had granted. Please allow them once more — they will stick from then on."
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 94cfe3b22c..413a1845d4 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -2222,6 +2222,14 @@
"api_keys": "Almacenamiento seguro de claves API"
},
"restart_deferred": "Los permisos recién concedidos se activan con el reinicio automático al final de la configuración; no hay nada que hacer ahora.",
+ "setup_all": "Configurar todo",
+ "setup_all_hint": "Un clic te guía por todos los permisos que faltan y los aplica al final.",
+ "setup_running": "Paso {0} de {1}: {2}",
+ "setup_wait_prompt": "Responde al diálogo de macOS — continúa solo.",
+ "setup_wait_settings": "Activa Personal Jarvis en el panel de Ajustes del Sistema que se acaba de abrir y vuelve — continúa solo.",
+ "setup_cancel": "Detener",
+ "setup_restarting": "Listo — Personal Jarvis se reinicia una vez para aplicar el nuevo acceso.",
+ "setup_timeout": "Configuración en pausa: un permiso no se concedió a tiempo. Usa «Configurar todo» de nuevo cuando quieras.",
"ask_again": "Preguntar de nuevo",
"stale_grant_hint": "macOS ya no volverá a preguntar por este acceso. Si Ajustes del Sistema ya lo muestra activado, ese registro pertenece a una versión anterior de la app: pulsa «Preguntar de nuevo» y concede el acceso otra vez.",
"identity_reset": "Desde la última reconstrucción, macOS considera Personal Jarvis una app nueva y descartó todos los accesos concedidos. Vuelve a concederlos una vez; a partir de ahí se mantendrán."
diff --git a/jarvis/ui/web/frontend/src/views/settings/PermissionsPanel.test.tsx b/jarvis/ui/web/frontend/src/views/settings/PermissionsPanel.test.tsx
index f3e02b0d41..9bea225491 100644
--- a/jarvis/ui/web/frontend/src/views/settings/PermissionsPanel.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/settings/PermissionsPanel.test.tsx
@@ -5,8 +5,11 @@ import type { PermissionItem, PermissionSnapshot } from "@/hooks/usePermissions"
const request = vi.fn();
const openSettings = vi.fn();
const reset = vi.fn();
+const setupAll = vi.fn().mockResolvedValue("complete");
+const cancelSetup = vi.fn();
let mockSnapshot: PermissionSnapshot | null = null;
+let mockSetupNeeded = false;
vi.mock("@/i18n", () => ({
useT: () => (key: string) => key,
@@ -27,10 +30,14 @@ vi.mock("@/hooks/usePermissions", () => ({
request,
openSettings,
reset,
+ setupAll,
+ cancelSetup,
+ setupProgress: null,
+ setupNeeded: mockSetupNeeded,
}),
}));
-import { PermissionRows } from "./PermissionsPanel";
+import { PermissionRows, SetupAllControl } from "./PermissionsPanel";
function snapshotWith(row: Partial<PermissionItem>): PermissionSnapshot {
return {
@@ -91,3 +98,65 @@ describe("PermissionRows", () => {
expect(screen.queryByRole("button", { name: "permissions.ask_again" })).toBeNull();
});
});
+
+describe("Set up everything", () => {
+ afterEach(() => {
+ mockSetupNeeded = false;
+ });
+
+ it("offers the one-click flow only while a row still needs setup", () => {
+ mockSnapshot = snapshotWith({});
+ mockSetupNeeded = true;
+ render(<PermissionRows />);
+
+ fireEvent.click(screen.getByTestId("permissions-setup-all"));
+
+ // Settings/banner mode applies the grants itself; onboarding (deferred
+ // restart note) leaves the restart to its own final step.
+ expect(setupAll).toHaveBeenCalledWith({ autoRestart: true });
+ });
+
+ it("leaves the final restart to onboarding", () => {
+ mockSnapshot = snapshotWith({});
+ mockSetupNeeded = true;
+ render(<PermissionRows compact deferRestartNote />);
+
+ fireEvent.click(screen.getByTestId("permissions-setup-all"));
+
+ expect(setupAll).toHaveBeenCalledWith({ autoRestart: false });
+ });
+
+ it("hides the flow once everything is granted or the app runs outside its bundle", () => {
+ mockSnapshot = snapshotWith({ status: "granted" });
+ mockSetupNeeded = false;
+ const { unmount } = render(<PermissionRows />);
+ expect(screen.queryByTestId("permissions-setup-all")).toBeNull();
+ unmount();
+
+ mockSnapshot = { ...snapshotWith({}), app_identity: { stable: false } };
+ mockSetupNeeded = true;
+ render(<PermissionRows />);
+ expect(screen.queryByTestId("permissions-setup-all")).toBeNull();
+ });
+
+ it("names the step and the waiting phase while running, with a way out", () => {
+ const onCancel = vi.fn();
+ render(
+ <SetupAllControl
+ progress={{ id: "accessibility", index: 2, total: 5, phase: "settings" }}
+ onStart={vi.fn()}
+ onCancel={onCancel}
+ />,
+ );
+
+ // The i18n stub echoes keys, so the step line is the bare template key;
+ // the phase line tells the user what macOS is waiting for.
+ expect(screen.getByTestId("permissions-setup-progress").textContent).toContain(
+ "permissions.setup_running",
+ );
+ expect(screen.getByText("permissions.setup_wait_settings")).toBeDefined();
+ expect(screen.queryByTestId("permissions-setup-all")).toBeNull();
+ fireEvent.click(screen.getByRole("button", { name: "permissions.setup_cancel" }));
+ expect(onCancel).toHaveBeenCalledTimes(1);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/views/settings/PermissionsPanel.tsx b/jarvis/ui/web/frontend/src/views/settings/PermissionsPanel.tsx
index 6c216f98d8..5af835bd05 100644
--- a/jarvis/ui/web/frontend/src/views/settings/PermissionsPanel.tsx
+++ b/jarvis/ui/web/frontend/src/views/settings/PermissionsPanel.tsx
@@ -8,8 +8,10 @@ import {
Mic,
Monitor,
MousePointer2,
+ Music,
RefreshCw,
ShieldCheck,
+ Wand2,
} from "lucide-react";
import { useEffect, useState } from "react";
import { Button } from "@/components/ui/button";
@@ -20,6 +22,7 @@ import {
type PermissionId,
type PermissionItem,
type PermissionSnapshot,
+ type SetupProgress,
} from "@/hooks/usePermissions";
import { SettingsBlock } from "@/views/settings/SettingsBlock";
@@ -29,6 +32,7 @@ const ICONS = {
accessibility: Accessibility,
input_monitoring: Keyboard,
event_posting: MousePointer2,
+ automation: Music,
credential_store: KeyRound,
} satisfies Record<PermissionId, typeof Mic>;
@@ -51,8 +55,20 @@ export function PermissionRows({
const t = useT();
const pushToast = useEventStore((state) => state.pushToast);
const [restarting, setRestarting] = useState(false);
- const { snapshot, loading, error, pendingId, refetch, request, openSettings, reset } =
- usePermissions();
+ const {
+ snapshot,
+ loading,
+ error,
+ pendingId,
+ refetch,
+ request,
+ openSettings,
+ reset,
+ setupAll,
+ cancelSetup,
+ setupProgress,
+ setupNeeded,
+ } = usePermissions();
useEffect(() => {
onSnapshot?.(snapshot);
@@ -66,6 +82,27 @@ export function PermissionRows({
}
}
+ async function runSetup() {
+ try {
+ // Onboarding ends with its own unconditional restart; everywhere else
+ // the flow applies the new access itself so nothing is left to click.
+ const outcome = await setupAll({ autoRestart: !deferRestartNote });
+ if (outcome === "restart") {
+ pushToast("info", t("permissions.setup_restarting"));
+ } else if (outcome === "timeout") {
+ pushToast("warning", t("permissions.setup_timeout"));
+ }
+ } catch (exc) {
+ const message = exc instanceof Error ? exc.message : String(exc);
+ pushToast(
+ "error",
+ message === "restart-missions-running"
+ ? t("topbar.restart_missions_running")
+ : message,
+ );
+ }
+ }
+
async function restartApp() {
if (restarting) return;
setRestarting(true);
@@ -132,6 +169,16 @@ export function PermissionRows({
{t("permissions.identity_reset")}
</div>
)}
+ {/* One click for the whole list: every dialog in turn, the Settings
+ pane for the rows macOS only grants there, then the restart that
+ applies them — instead of six buttons and a restart to find. */}
+ {setupNeeded && snapshot?.app_identity.stable !== false && (
+ <SetupAllControl
+ progress={setupProgress}
+ onStart={() => void runSetup()}
+ onCancel={cancelSetup}
+ />
+ )}
{items.map((permission) => (
<PermissionRow
key={permission.id}
@@ -162,6 +209,57 @@ export function PermissionRows({
);
}
+export function SetupAllControl({
+ progress,
+ onStart,
+ onCancel,
+}: {
+ progress: SetupProgress | null;
+ onStart: () => void;
+ onCancel: () => void;
+}) {
+ const t = useT();
+ if (!progress) {
+ return (
+ <div className="flex flex-wrap items-center justify-between gap-2 rounded-lg bg-secondary p-3">
+ <p className="text-xs text-foreground">{t("permissions.setup_all_hint")}</p>
+ <Button size="sm" data-testid="permissions-setup-all" onClick={onStart}>
+ <Wand2 className="mr-1.5 h-3.5 w-3.5" aria-hidden />
+ {t("permissions.setup_all")}
+ </Button>
+ </div>
+ );
+ }
+ const step = t("permissions.setup_running")
+ .replace("{0}", String(progress.index))
+ .replace("{1}", String(progress.total))
+ .replace("{2}", t(`permissions.items.${progress.id}.title`));
+ return (
+ <div
+ className="flex flex-wrap items-center justify-between gap-2 rounded-lg bg-secondary p-3"
+ data-testid="permissions-setup-progress"
+ aria-live="polite"
+ >
+ <div className="min-w-0 flex-1">
+ <p className="flex items-center gap-2 text-xs font-medium text-foreground">
+ <Loader2 className="h-3.5 w-3.5 shrink-0 animate-spin" aria-hidden />
+ {step}
+ </p>
+ <p className="mt-0.5 text-xs text-muted-foreground">
+ {t(
+ progress.phase === "settings"
+ ? "permissions.setup_wait_settings"
+ : "permissions.setup_wait_prompt",
+ )}
+ </p>
+ </div>
+ <Button size="sm" variant="outline" onClick={onCancel}>
+ {t("permissions.setup_cancel")}
+ </Button>
+ </div>
+ );
+}
+
function PermissionRow({
item,
busy,