diff --git a/apps/desktop/src/state/inbox.test.ts b/apps/desktop/src/state/inbox.test.ts
index 5d020939d..1677cd134 100644
--- a/apps/desktop/src/state/inbox.test.ts
+++ b/apps/desktop/src/state/inbox.test.ts
@@ -1,6 +1,14 @@
import { describe, expect, test } from "bun:test";
import type { PermissionRequest, SessionSummary } from "../acp/types";
-import { DECIDED_MAX, deriveInbox, foldDecided, groupInbox, type InboxItem, showsNeedsYou } from "./inbox";
+import {
+ DECIDED_MAX,
+ deriveInbox,
+ foldDecided,
+ groupInbox,
+ type InboxItem,
+ readOnlyApprovals,
+ showsNeedsYou,
+} from "./inbox";
import type { Link } from "./orchestration";
const NOW = 1_700_000_000_000;
@@ -287,3 +295,39 @@ describe("the decided section", () => {
expect(folded[0]!.key).toBe(gone.key);
});
});
+
+describe("allowing the read-only approvals", () => {
+ test("only plainly read-only calls count, never a write, an unknown call or a question", () => {
+ const items = deriveInbox(
+ {
+ sessions,
+ threads: {
+ one: {
+ permissions: [
+ request("one", 1, NOW - 4_000, { title: "read_file src/a.ts", toolKind: "read" }),
+ request("one", 2, NOW - 3_000, { input: { command: "rm -rf build" } }),
+ request("one", 3, NOW - 2_000, { title: "mystery_tool" }),
+ ],
+ },
+ two: {
+ permissions: [
+ request("two", 4, NOW - 1_000, { title: "grep needle", toolKind: "search" }),
+ request("two", 5, NOW - 500, {
+ title: "Pick one",
+ question: { multiple: false } as PermissionRequest["question"],
+ }),
+ ],
+ },
+ },
+ failed: {},
+ links: [],
+ },
+ NOW,
+ );
+ expect(
+ readOnlyApprovals(items)
+ .map((item) => item.request?.rpcId)
+ .sort(),
+ ).toEqual([1, 4]);
+ });
+});
diff --git a/apps/desktop/src/state/inbox.ts b/apps/desktop/src/state/inbox.ts
index 6172cf427..236393320 100644
--- a/apps/desktop/src/state/inbox.ts
+++ b/apps/desktop/src/state/inbox.ts
@@ -10,7 +10,7 @@
// (state/inboxDismissed.ts).
import type { PermissionRequest, SessionSummary } from "../acp/types";
-import { approvalSubject, commandOf } from "../lib/approval";
+import { approvalSubject, assessApproval, commandOf } from "../lib/approval";
import { type InboxDismissals, isDismissed } from "./inboxDismissed";
import type { Link } from "./orchestration";
@@ -285,3 +285,18 @@ export function foldDecided(
export function showsNeedsYou(items: readonly InboxItem[]): boolean {
return items.length > 0;
}
+
+/**
+ * The approvals waiting across every thread that only read: plainly read-only tools and commands
+ * (`assessApproval` says `safe`). Questions are not approvals, and anything unknown is not safe,
+ * so "Allow read-only" never answers a call that could change something.
+ */
+export function readOnlyApprovals(items: readonly InboxItem[]): InboxItem[] {
+ return items.filter(
+ (item) =>
+ item.kind === "approval" &&
+ !!item.request &&
+ !item.request.question &&
+ assessApproval(item.request, item.project).level === "safe",
+ );
+}
diff --git a/apps/desktop/src/ui/Inbox.tsx b/apps/desktop/src/ui/Inbox.tsx
index ce5f846c1..7fea6c8ae 100644
--- a/apps/desktop/src/ui/Inbox.tsx
+++ b/apps/desktop/src/ui/Inbox.tsx
@@ -11,7 +11,14 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { isAllow, type PermissionOption, type PermissionRequest, projectName } from "../acp/types";
import { assessApproval, grantAllowed, optionScope } from "../lib/approval";
import { useClock } from "../lib/useNow";
-import { type DecidedItem, foldDecided, groupInbox, type InboxGroup, type InboxItem } from "../state/inbox";
+import {
+ type DecidedItem,
+ foldDecided,
+ groupInbox,
+ type InboxGroup,
+ type InboxItem,
+ readOnlyApprovals,
+} from "../state/inbox";
import { useInboxItems } from "../state/inboxRead";
import { filteredNeedsCount } from "../state/sidebarGroups";
import {
@@ -411,6 +418,17 @@ export function Inbox() {
dismissInbox(items);
}, [items]);
+ const readOnly = useMemo(() => readOnlyApprovals(items), [items]);
+ const allowReadOnly = useCallback(() => {
+ for (const item of readOnly) {
+ const option =
+ item.request && orderedOptions(item.request.options).find((o) => optionScope(o) === "once");
+ if (!item.request || !option) continue;
+ labels.current[item.key] = "Approved";
+ answerPermission(item.request, option);
+ }
+ }, [readOnly]);
+
useEffect(() => {
const onKey = (e: KeyboardEvent) => {
if (e.metaKey || e.ctrlKey || e.altKey || e.isComposing) return;
@@ -469,6 +487,13 @@ export function Inbox() {
}
>
+ {readOnly.length > 1 && (
+
+
+ Allow {readOnly.length} read-only
+
+
+ )}
{items.length > 0 && (
Dismiss all