agent-console 1.3.1: 全部自动同意 (Auto-approve all), split out of #727 (#747)

Auto-approve all (全部自动同意) ships in agent-console 1.3.1, split out of #727 (qingnian108).

The mode is off by default. In it, Codex runs with its sandbox off and Claude Code skips its checks. Cursor, OpenCode and dsh requests are answered allow-once by the console, never allow_always or acceptForSession. Each auto answer is saved with `auto: true` before the Agent goes on, and a banner shows while the mode is on. Plan confirmations and questions still ask. A 1.2 默认 of 全部放行 is not silently upgraded to real auto-approve. Pi keeps the `default` mode id ("Pi never asks"), so switching Agents before the first message never carries auto-approve into an Agent the user didn't pick.

Reviewed at 7e55c87ca merged onto main 20b89389:
- Linux (WSL2 Ubuntu 24.04): root `bun test packages/agent-console` 6/6; `bun scripts/check.mjs` OK; `npm run check` OK; vitest 461 passed / 17 skipped; `verify:build` 5/5 identical.
- Windows 11 (Edge): `e2e:v1` 29/29.
- Linux e2e stops at scenario 5 (steer timeout). It does the same on main 1.3.0, so it was filed as #753.
- Broken by hand:
  - Pi's modeMap back to bypassPermissions: 2 tests red.
  - The keeps line shown for every Agent: 1 test red.
  - Pi's label branch removed: 1 test red.
- An earlier round at 049449612 on macOS checked the daemon behaviour with probes. This version is published from the dist branch; the package isn't on npm.
This commit is contained in:
qingnian108
2026-11-05 14:02:29 +08:00
committed by GitHub
parent 20b893893f
commit 2c4e76dbba
38 changed files with 1378 additions and 136 deletions
@@ -0,0 +1,25 @@
// 1.3 全部自动同意 (#727 review 1): a persistent indicator for as long as the conversation is in auto-approve.
// One slim line (Nolan): amber shield + 全部自动同意已开启 on the left, the way back to 每次询问 on the right, nothing in
// between. What the mode does for this Agent (Codex: sandbox off, Claude: skips all permission checks …) is the left
// label's tooltip and its accessible description; the permission menu shows the same wording. Not dismissible.
import { useId } from "react";
import { Icon } from "./Icons";
import { autoApproveBannerDesc } from "../i18n/modes.js";
import { t } from "../i18n/index.js";
export function AutoApproveBanner({ providerId, onBack }: { providerId?: string; onBack?: () => void }) {
const desc = autoApproveBannerDesc(providerId);
const descId = useId();
return (
<div className="cp-auto-on" role="status" aria-live="polite" data-testid="auto-on">
<span className="cp-auto-t" title={desc} aria-describedby={descId} tabIndex={0}>
<span className="cp-auto-ic" aria-hidden><Icon name="shieldCheck" size={13} /></span>
<b>{t("composer.autoOn.title")}</b>
</span>
<span id={descId} className="sr-only">{desc}</span>
{onBack && (
<button type="button" className="cp-auto-back" onClick={onBack}>{t("composer.autoOn.back")}</button>
)}
</div>
);
}
@@ -0,0 +1,73 @@
// 1.3 全部自动同意 (#727 review): the approvals the daemon gave by itself, one quiet row per run of tool calls.
// Collapsed: "已自动同意 3 项 · npm test · git status …"; expanded: each request's title, command / file and the answer.
import { useState } from "react";
import type { DisplayItem } from "../timeline/reducer";
import { approvalChoice, approvalTarget } from "../timeline/autoApproved";
import { Icon } from "./Icons";
import { t, tf } from "../i18n/index.js";
import { ws } from "../main";
export function AutoApprovedItem({ it }: { it: Extract<DisplayItem, { kind: "autoperm" }> }) {
// Same flat one-line rows as the 1.3 tool steps: icon slot · text · right-edge meta; the shield keeps the amber of the
// 全部自动同意 chip so the row reads "approved for you", not "you approved"
const [open, setOpen] = useState(false);
const peek = it.items.map(approvalTarget).filter(Boolean).join(" · ");
return (
<div className={`apv${open ? " open" : ""}`} data-testid="auto-approved">
<button className="apv-head" aria-expanded={open} onClick={() => setOpen(!open)}
title={t("timeline.autoApproved.title")}>
<span className="apv-ic" aria-hidden><Icon name="shieldCheck" size={13} /></span>
<span className="apv-n">{tf("timeline.autoApproved.count", { n: it.items.length })}</span>
{!open && peek && <span className="apv-peek">{peek}</span>}
<span className={`caret${open ? " open" : ""}`} aria-hidden>›</span>
</button>
{open && (
<div className="apv-list">
{it.items.map((p) => {
const d = (p.detail ?? {}) as { command?: unknown; path?: unknown };
const choice = approvalChoice(p);
const cmd = typeof d.command === "string" && d.command.trim() ? d.command.trim() : "";
const path = !cmd && typeof d.path === "string" && d.path.trim() ? d.path.trim() : "";
const answer = p.status === "pending"
? t("timeline.autoApproved.pending")
: tf("timeline.autoApproved.answer", { opt: choice ?? t("timeline.permAllowed") });
return (
<div key={p.requestId} className="apv-row" title={[p.title, cmd || path, answer].filter(Boolean).join("\n")}>
<span className="ts-ic" aria-hidden><Icon name={p.status === "pending" ? "hourglass" : "check"} size={13} /></span>
{cmd ? <span className="apv-cmd">{cmd}</span>
: path ? <span className="apv-path">{path}</span>
: <span className="apv-title">{p.title}</span>}
<span className="apv-meta">{answer}</span>
</div>
);
})}
</div>
)}
</div>
);
}
/** 1.3 upgrade (#727 review 3): a 1.2 全部放行 that did nothing for this Agent was not turned into real auto-approval */
export const AUTO_UPGRADE_CODES = new Set(["auto_approve_upgrade", "auto_approve_migrated"]);
export function AutoUpgradeNotice({ it, threadId }: { it: Extract<DisplayItem, { kind: "notice" }>; threadId: string }) {
const [busy, setBusy] = useState(false);
const migrated = it.code === "auto_approve_migrated";
const turnOn = () => {
setBusy(true);
void ws.call("thread.setMode", { id: threadId, mode: "bypassPermissions" }).catch(() => {}).finally(() => setBusy(false));
};
return (
<div className="nt nt-auto" data-testid="auto-upgrade-notice" role="note">
<div className="nt-auto-h">
<span className="apv-ic"><Icon name="shieldCheck" size={14} /></span>
<b>{t("timeline.autoUpgrade.title")}</b>
</div>
<div>{t(migrated ? "timeline.autoUpgrade.migrated" : "timeline.autoUpgrade.body")}</div>
<div className="nt-actions">
<button type="button" className="btn" disabled={busy} onClick={turnOn}>{t("timeline.autoUpgrade.turnOn")}</button>
<button type="button" className="btn" onClick={() => window.dispatchEvent(new Event("open-settings"))}>{t("timeline.autoUpgrade.settings")}</button>
</div>
</div>
);
}
@@ -7,6 +7,7 @@ import { useData, pickDefaultProvider } from "../stores/data";
import { useTimeline } from "../stores/timeline";
import { TimelineRow } from "./Timeline";
import { foldTimeline, TOOL_COLLAPSE_AT } from "../timeline/fold";
import { collectAutoApproved } from "../timeline/autoApproved";
import { Composer } from "./Composer";
import { QuoteSelect } from "./QuoteSelect";
import { Icon } from "./Icons";
@@ -23,7 +24,8 @@ export function Chat() {
const prefs = useLiveSettings();
// 1.3: runs of tool calls (and short thinking between them) fold into one summary row
// (tl.items is a fresh array after every timeline change, so the memo follows the stream)
const items = useMemo(() => foldTimeline(tl.items, { showThinking: prefs.showThinking }), [tl.items, prefs.showThinking]);
// 1.3 全部自动同意: the daemon's own approvals become one quiet row after their run (collectAutoApproved)
const items = useMemo(() => foldTimeline(collectAutoApproved(tl.items), { showThinking: prefs.showThinking }), [tl.items, prefs.showThinking]);
const scrollRef = useRef<HTMLDivElement>(null);
const [stick, setStick] = useState(true);
const [hasNew, setHasNew] = useState(false);
@@ -19,6 +19,7 @@ import { composerModeOptions, effortLabel } from "../i18n/modes.js";
import { Logo } from "./Logo";
import { currentChecklist, todoProgress } from "../timeline/fold";
import { SelectMenu } from "./SelectMenu";
import { AutoApproveBanner } from "./AutoApproveBanner";
import { errMsg, t as tr, tf } from "../i18n/index.js";
import {
applySlashPick,
@@ -397,8 +398,12 @@ export function Composer() {
};
const setMode = (m: Mode) => {
if (thread) void ws.call("thread.setMode", { id: thread.id, mode: m });
if (!thread) return;
void ws.call("thread.setMode", { id: thread.id, mode: m }).catch((e) => toast(errMsg(e), true));
};
// 1.3 (#727 review 1): while the mode this Agent really uses is 全部自动同意, a persistent banner + warning-coloured chip
const autoOn = !!(modes.find((m) => m.id === mode) ?? modes[0])?.auto;
const canAsk = modes.some((m) => m.id === "default" && !m.auto);
const setEffort = (effort: string | null) => {
if (thread) void ws.call("thread.setEffort", { id: thread.id, effort });
};
@@ -469,10 +474,8 @@ export function Composer() {
))}
</div>
)}
{mode === "bypassPermissions" && (
<div className="cp-danger">{tr("composer.bypassWarn")}</div>
)}
<div className={`cp-card${waiting ? " waiting" : ""}${mode === "bypassPermissions" ? " danger" : ""}${dropHint ? " drop-on" : ""}`}>
{autoOn && <AutoApproveBanner providerId={thread?.provider} onBack={canAsk ? () => setMode("default") : undefined} />}
<div className={`cp-card${waiting ? " waiting" : ""}${autoOn ? " auto-on" : ""}${dropHint ? " drop-on" : ""}`}>
{dropHint && <div className="cp-drop-hint">{tr("mention.drop")}</div>}
{imagesByPath && attachments.some((a) => a.mime.startsWith("image/")) && (
<div className="att-note">{tf("composer.imagesByPath", { agent: provider?.name ?? "" })}</div>
@@ -728,13 +731,19 @@ export function Composer() {
<ChipCaret />
</SelectMenu>
)}
{/* permission mode: list only the modes this Agent really has; hidden when there is only one (e.g. Pi has no modes) */}
{/* permission mode: list only the modes this Agent really has; one mode only (Pi: always auto) = a plain label */}
{modes.length === 1 && (
<span className={`pill ipill mode-chip static${modes[0]!.auto ? " auto" : ""}`} title={modes[0]!.desc} data-mode={modes[0]!.id}>
<Icon name={modes[0]!.auto ? "shieldCheck" : "shield"} size={14} />
<span className="ip-l">{modes[0]!.label}</span>
</span>
)}
{modes.length > 1 && (() => {
// The mode stored on the conversation doesn't exist for this Agent → show the one it will actually use
const shown = modes.find((m) => m.id === mode) ?? modes[0]!;
return (
<SelectMenu
className={`pill ipill${shown.danger ? " danger" : ""}`}
className={`pill ipill mode-chip${shown.danger ? " danger" : ""}${shown.auto ? " auto" : ""}`}
title={shown.desc}
ariaLabel={tr("composer.modeTitle")}
prefer="up"
@@ -742,9 +751,9 @@ export function Composer() {
menuClassName="mode-menu"
value={shown.id}
onChange={(v) => setMode(v as Mode)}
options={modes.map((m) => ({ value: m.id, label: m.label, hint: m.desc, danger: m.danger }))}
options={modes.map((m) => ({ value: m.id, label: m.label, hint: m.desc, danger: m.danger, warn: m.auto, icon: m.auto ? "shieldCheck" : undefined }))}
>
<Icon name="shield" size={14} />
<Icon name={shown.auto ? "shieldCheck" : "shield"} size={14} />
<span className="ip-l">{shown.label}</span>
<ChipCaret />
</SelectMenu>
@@ -29,6 +29,7 @@ const PATHS: Record<string, string> = {
shield: "M12 3l8 3v6c0 5-3.5 9-8 11-4.5-2-8-6-8-11V6l8-3z",
quote: "M5 7h5v5H7c0 2 1 3 3 4M14 7h5v5h-3c0 2 1 3 3 4",
pencil: "M4 20h4L19 9a2.1 2.1 0 0 0-3-3L5 17v3zM14 7l3 3",
shieldCheck: "M12 3l8 3v6c0 5-3.5 9-8 11-4.5-2-8-6-8-11V6l8-3zM8.5 12.2l2.4 2.4 4.6-4.8",
zap: "M13 2L4 14h7l-1 8 9-12h-7l1-8z",
// 1.3 timeline rows / footer / code blocks
prompt: "M5 7l5 5-5 5M12 17h7",
@@ -3,6 +3,7 @@
// Enter/Space pick, Esc/Tab close (Esc returns focus to the trigger). Click outside closes. The menu is portaled to <body> with
// fixed positioning, opens below the trigger or flips above it when there's no room (the composer sits at the bottom), and is
// kept inside the window; no browser popup is involved, so it behaves the same inside Magpie's sandboxed iframe.
import { Icon } from "./Icons";
import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState, type ReactNode } from "react";
import { createPortal } from "react-dom";
@@ -12,6 +13,10 @@ export type SelectOption<T extends string = string> = {
hint?: string;
disabled?: boolean;
danger?: boolean;
/** Warning colour (1.3: 全部自动同意, #727 review 1) */
warn?: boolean;
/** Small icon before the label (1.3: the 全部自动同意 shield) */
icon?: string;
};
const GAP = 4;
@@ -186,12 +191,12 @@ export function SelectMenu<T extends string>({
role="option"
aria-selected={o.value === value}
aria-disabled={o.disabled || undefined}
className={`mi sm-opt${i === active ? " on" : ""}${o.disabled ? " off" : ""}${o.danger ? " danger" : ""}${o.hint ? " has-hint" : ""}`}
className={`mi sm-opt${i === active ? " on" : ""}${o.disabled ? " off" : ""}${o.danger ? " danger" : ""}${o.warn ? " warn" : ""}${o.hint ? " has-hint" : ""}`}
onPointerMove={() => { if (!o.disabled && active !== i) setActive(i); }}
onClick={() => pick(i)}
>
<span className="sm-text">
<span className="sm-label">{o.label}</span>
<span className="sm-label">{o.icon && <Icon name={o.icon} size={13} />}{o.label}</span>
{o.hint && <span className="sm-hint">{o.hint}</span>}
</span>
<span className="sm-check" aria-hidden="true">{o.value === value ? (
@@ -225,10 +225,10 @@ export function SettingsDialog({ onClose, providers }: { onClose: () => void; pr
{row(t("settings.defaultMode"), (
<SelectMenu className="tinput sm-field" matchWidth ariaLabel={t("settings.defaultMode")}
value={s.defaultMode ?? "default"} onChange={(v) => void set({ defaultMode: v })}
options={modes.map((m) => ({ value: m.id, label: m.label, hint: m.desc }))}>
options={modes.map((m) => ({ value: m.id, label: m.label, hint: m.desc, icon: m.auto ? "shieldCheck" : undefined }))}>
<span className="sm-val">{(() => { const m = modes.find((x) => x.id === (s.defaultMode ?? "default")); return m ? `${m.label} — ${m.desc}` : ""; })()}</span>
</SelectMenu>
), t("settings.defaultModeHint"))}
), s.defaultMode === "bypassPermissions" ? `${t("settings.defaultModeHint")} ${t("composer.autoWarn")}` : t("settings.defaultModeHint"))}
{row(t("settings.theme"), (
<SelectMenu className="tinput sm-field" matchWidth ariaLabel={t("settings.theme")}
value={normalizeThemeSetting(s.theme)} onChange={(v) => void set({ theme: v })}
@@ -17,6 +17,7 @@ import { splitLocalLinks } from "../util/localLinks";
import { onChatLinkClick, openExternal } from "../preview/open";
import { splitQuotes } from "../composer/quotes";
import { localClientIds, useTimeline } from "../stores/timeline";
import { AUTO_UPGRADE_CODES, AutoApprovedItem, AutoUpgradeNotice } from "./AutoApproved";
export const GIT_FOR_WINDOWS_URL = "https://git-scm.com/download/win";
@@ -409,7 +410,8 @@ export function PermissionItem({ it, threadId }: { it: Extract<DisplayItem, { ki
const detail = it.detail as { command?: string; path?: string; plan?: string; hunks?: DiffHunk[]; diff?: { path?: string; hunks?: DiffHunk[] } } | undefined;
const hunks = detail?.hunks ?? detail?.diff?.hunks;
const label = it.status === "resolved"
? it.choice === "allow_always" || it.choice === "acceptForSession" ? t("timeline.permAllowSession")
? it.auto ? t("timeline.permAutoAllowed")
: it.choice === "allow_always" || it.choice === "acceptForSession" ? t("timeline.permAllowSession")
: it.choice === "deny" || it.choice === "reject" || it.choice === "decline" ? t("timeline.permDenied")
: it.choice === "implement" ? t("timeline.permAllowed") : t("timeline.permAllowed")
: t("timeline.permCancelled");
@@ -567,9 +569,11 @@ export function TimelineRow({ it, threadId, onEditResend, onRetryLast, replyText
case "plan": return <PlanItem it={it} />;
case "todo": return <TodoItem it={it} />;
case "permission": return <PermissionItem it={it} threadId={threadId} />;
case "autoperm": return <AutoApprovedItem it={it} />;
case "question": return <QuestionItem it={it} threadId={threadId} />;
case "notice":
if (it.code === "bash_missing") return <BashMissingNotice it={it} />;
if (it.code && AUTO_UPGRADE_CODES.has(it.code)) return <AutoUpgradeNotice it={it} threadId={threadId} />;
return <div className={`nt ${it.level}`}>{localizeDaemonMessage(it.message)}</div>;
case "turnend": return <TurnEndItem it={it} onRetry={onRetryLast} replyText={replyText} />;
case "gone": return null;
@@ -61,7 +61,25 @@ export const messages: Record<LocaleId, MessageTree> = {
queuePlaceholderNoSteer: "继续补充要求,回车排队发送…",
steerUnsupported: "{agent} 不支持插话:运行中发的消息会排队,本回合结束后再发送。",
queuedToast: "已排队:本回合结束后发送", steeredToast: "已插话",
inputPlaceholder: "输入消息,/ 使用命令…", bypassWarn: "Bypass:Agent 的所有操作不会再问你。",
inputPlaceholder: "输入消息,/ 使用命令…",
autoWarn: "全部自动同意会让 Agent 不经询问直接运行命令、修改文件:Codex 关闭沙箱(danger-full-access),Claude Code 跳过所有权限检查,其他 Agent 的授权请求由控制台自动「允许一次」。请谨慎使用。",
// 1.3 (#727 review 1): shown for as long as the conversation is in 全部自动同意, above the composer
autoOn: {
title: "全部自动同意已开启",
back: "改回每次询问",
keeps: "计划确认和提问仍会问你;每次只同意当前这一个请求,不会写入永久规则。",
},
// What 全部自动同意 really does for each Agent (menu hint, banner, tooltip)
autoDesc: {
claude: "Claude Code 以 bypassPermissions 运行:跳过所有权限检查,命令和改文件都不再询问(请谨慎使用)",
codex: "Codex 沙箱关闭(danger-full-access)且从不询问:命令可读写整台电脑、可联网(请谨慎使用)",
copilot: "Copilot Allow All:所有工具调用都不再确认(请谨慎使用)",
devin: "Devin Bypass Permissions:跳过所有权限检查(请谨慎使用)",
cursor: "Agent 模式,每个授权请求都由控制台自动「允许一次」:命令和改文件直接执行(请谨慎使用)",
opencode: "Build 模式,每个授权请求都由控制台自动「允许一次」:命令和改文件直接执行(请谨慎使用)",
generic: "每个授权请求都由控制台自动「允许一次」:命令和改文件直接执行,不再询问(请谨慎使用)",
pi: "Pi 本身从不询问:命令和改文件直接执行(扩展发起的确认仍会问你)",
},
imagesByPath: "{agent} 不能直接看图片:会把图片的文件路径发给它(它能用文件工具打开)。",
agentModel: "Agent & model", agentLocked: "Agent (locked)", agent: "Agent",
model: "Model", searchModel: "Search", searchAllModels: "Search models…", providers: "Agent",
@@ -82,10 +100,12 @@ export const messages: Record<LocaleId, MessageTree> = {
plan: { label: "规划", desc: "只分析代码库,不执行工具或修改" },
default: { label: "每次询问", desc: "首次使用工具时会请求授权" },
acceptEdits: { label: "接受编辑", desc: "自动批准编辑类工具,不再逐项询问" },
bypass: { label: "全部放行", desc: "跳过所有授权提示(请谨慎使用)" },
bypass: { label: "全部自动同意", desc: "不再询问:Codex 关闭沙箱,Claude Code 跳过所有权限检查,其他 Agent 的请求自动「允许一次」(请谨慎使用)" },
cursorBypass: { label: "全部自动同意", desc: "Agent 模式,每个授权请求都由控制台自动「允许一次」(请谨慎使用)" },
cursorAgent: { label: "Agent", desc: "完整 Agent:可读写、执行工具" },
cursorPlan: { label: "规划", desc: "只读规划:分析并提出方案,不改文件" },
cursorAsk: { label: "问答", desc: "问答模式:解释与讨论,只读" },
pi: { label: "Pi 本身从不询问", desc: "Pi 本身从不询问:命令和改文件直接执行(扩展发起的确认仍会问你)" },
},
// Agent-specific mode names reported by the daemon
agentMode: {
@@ -109,7 +129,7 @@ export const messages: Record<LocaleId, MessageTree> = {
sendKey: "发送键", sendEnter: "Enter 发送 / Shift+Enter 换行", sendCtrl: "Ctrl+Enter 发送 / Enter 换行",
runningSend: "运行中再发送", queue: "排队(发完自动继续)", steer: "插话(立即打断当前思路)",
steerHint: "插话只对支持的 Agent 生效(目前是 Codex);其他 Agent 仍会排队,输入框下方会提示。",
defaultModeHint: "新对话使用;每个 Agent 会换成自己最接近的模式(例如 OpenCode 只有 Plan / Build,Build 会直接改文件)。",
defaultModeHint: "新对话使用;每个 Agent 会换成自己最接近的模式(例如 OpenCode 只有 Plan / Build,Build 会直接改文件)。选「全部自动同意」后,所有 Agent 都不再弹授权。",
thinking: "思考过程", showThinking: "显示 Agent 的思考/推理内容",
idleClose: "空闲回收", idleMinutes: "分钟后自动关闭空闲会话(5–240;最多保留 3 个空闲 Agent 进程)",
idleInvalid: "请输入 5 到 240 之间的整数",
@@ -155,7 +175,14 @@ export const messages: Record<LocaleId, MessageTree> = {
timeline: {
thinking: "思考 {s}s", todo: "待办 {done}/{total}", steer: "插话", tasks: "任务", tasksPill: "{done}/{total} 个任务", tasksPillTitle: "查看任务清单",
codeWrap: "自动换行",
permAllowSession: "本对话都允许", permDenied: "已拒绝", permAllowed: "已允许", permCancelled: "已取消",
permAllowSession: "本对话都允许", permDenied: "已拒绝", permAllowed: "已允许", permAutoAllowed: "已自动同意(全部自动同意)", permCancelled: "已取消",
autoUpgrade: {
title: "1.3 新增:全部自动同意",
body: "现在「全部自动同意」对 Cursor、OpenCode、dsh 也会真正生效:授权请求由控制台自动「允许一次」,命令和改文件直接执行。1.2 的「全部放行」对它们不生效(仍会询问)。你之前把默认权限模式设成了它,为安全起见,这个对话仍从「每次询问」开始。在设置里重新选择一次默认权限模式后,新对话就按你的选择来。",
migrated: "这个对话在 1.2 里设成了「全部放行」,当时这个 Agent 实际仍会询问。1.3 起「全部自动同意」会真正自动同意(命令和改文件直接执行),所以已改回「每次询问」。",
turnOn: "在此对话开启全部自动同意", settings: "打开设置",
},
autoApproved: { count: "已自动同意 {n} 项", title: "全部自动同意替你同意了这些请求(点开查看)", answer: "{opt} · 全部自动同意", pending: "正在自动同意…" },
submitted: "已提交:{ans}", turnError: "出错:{err}", unknownError: "未知错误",
interrupted: "已打断", filesChanged: "改动 {n} 个文件 ›", editMsg: "编辑(填回输入框,不会马上发送)", sendFailed: "发送失败", sendRetry: "重新发送", sendDismiss: "移除这条没发出的消息", resend: "重新发送这条消息", retryHint: "重试:重新发送上一条消息", msgActions: "消息操作", editBusy: "输入框里还有没发送的内容:先发送或清空,再点编辑",
tool: {
@@ -256,7 +283,23 @@ export const messages: Record<LocaleId, MessageTree> = {
queuePlaceholderNoSteer: "Add to the task — Enter queues it…",
steerUnsupported: "{agent} can't steer: messages sent while it runs are queued and sent after this turn.",
queuedToast: "Queued — sends after this turn", steeredToast: "Steered",
inputPlaceholder: "Message the agent, / for commands…", bypassWarn: "Bypass: the agent will not ask for permission.",
inputPlaceholder: "Message the agent, / for commands…",
autoWarn: "Auto-approve all lets the agent run commands and edit files without asking: Codex turns its sandbox off (danger-full-access), Claude Code skips all permission checks, and every other agent's approval requests are answered \"allow once\" by the console. Use with care.",
autoOn: {
title: "Auto-approve all is on",
back: "Back to Always Ask",
keeps: "Plan approvals and questions still ask you; each approval covers only that one request and never saves a lasting rule.",
},
autoDesc: {
claude: "Claude Code runs with bypassPermissions: skips all permission checks, commands and edits never ask (use with care)",
codex: "Codex sandbox off (danger-full-access) and never asks: commands can read and write your whole machine and use the network (use with care)",
copilot: "Copilot Allow All: no tool call asks for confirmation (use with care)",
devin: "Devin Bypass Permissions: skips all permission checks (use with care)",
cursor: "Agent mode, every approval request answered \"allow once\" by the console: commands and edits run without asking (use with care)",
opencode: "Build mode, every approval request answered \"allow once\" by the console: commands and edits run without asking (use with care)",
generic: "Every approval request is answered \"allow once\" by the console: commands and edits run without asking (use with care)",
pi: "Pi itself never asks: commands and edits run directly (dialogs from Pi extensions still ask you)",
},
imagesByPath: "{agent} can't see images directly: it gets the image's file path instead (it can open it with its file tools).",
agentModel: "Agent & model", agentLocked: "Agent (locked after first message)", agent: "Agent",
model: "Model", searchModel: "Search", searchAllModels: "Search all models…", providers: "Providers",
@@ -276,10 +319,12 @@ export const messages: Record<LocaleId, MessageTree> = {
plan: { label: "Plan Mode", desc: "Analyze the codebase without running tools or edits" },
default: { label: "Always Ask", desc: "Ask permission the first time a tool is used" },
acceptEdits: { label: "Accept File Edits", desc: "Auto-approve edit tools without prompting" },
bypass: { label: "Bypass", desc: "Skip all permission prompts (use with caution)" },
bypass: { label: "Auto-approve all", desc: "Never asks: Codex turns its sandbox off, Claude Code skips all permission checks, other agents' requests are answered \"allow once\" (use with care)" },
cursorBypass: { label: "Auto-approve all", desc: "Agent mode, every approval request answered \"allow once\" by the console (use with care)" },
cursorAgent: { label: "Agent", desc: "Full agent: tools and edits" },
cursorPlan: { label: "Plan", desc: "Read-only planning and analysis" },
cursorAsk: { label: "Ask", desc: "Q&A style explanations (read-only)" },
pi: { label: "Pi never asks", desc: "Pi itself never asks: commands and edits run directly (dialogs from Pi extensions still ask you)" },
},
agentMode: {},
effort: { low: "Low", medium: "Medium", high: "High", xhigh: "Extra high", max: "Max", minimal: "Minimal", none: "Off" },
@@ -300,7 +345,7 @@ export const messages: Record<LocaleId, MessageTree> = {
sendCtrl: "Ctrl+Enter sends / Enter newline",
runningSend: "While running", queue: "Queue (run after current turn)", steer: "Steer (interrupt now)",
steerHint: "Steer only works for agents that support it (Codex today); other agents still queue, and the composer says so.",
defaultModeHint: "For new conversations. Each agent maps it to its own nearest mode (OpenCode only has Plan / Build, and Build edits without asking).",
defaultModeHint: "For new conversations. Each agent maps it to its own nearest mode (OpenCode only has Plan / Build, and Build edits without asking). With Auto-approve all, no agent asks for approval.",
thinking: "Reasoning", showThinking: "Show agent reasoning/thinking",
idleClose: "Idle cleanup", idleMinutes: "minutes before closing idle sessions (5–240; at most 3 idle agent processes are kept)",
idleInvalid: "Enter a whole number from 5 to 240",
@@ -346,7 +391,14 @@ export const messages: Record<LocaleId, MessageTree> = {
timeline: {
thinking: "Thinking {s}s", todo: "Todos {done}/{total}", steer: "Steer", tasks: "tasks", tasksPill: "{done}/{total} tasks", tasksPillTitle: "Show the task list",
codeWrap: "Wrap lines",
permAllowSession: "Allowed for this chat", permDenied: "Denied", permAllowed: "Allowed", permCancelled: "Cancelled",
permAllowSession: "Allowed for this chat", permDenied: "Denied", permAllowed: "Allowed", permAutoAllowed: "Auto-approved (Auto-approve all)", permCancelled: "Cancelled",
autoUpgrade: {
title: "New in 1.3: Auto-approve all",
body: "Auto-approve all now really works for Cursor, OpenCode and dsh: the console answers their approval requests \"allow once\", so commands and edits run without asking. 1.2's bypass mode did nothing for them (they still asked). Your default permission mode was set to it, so to be safe this conversation starts in Always Ask. Pick the default permission mode again in Settings and new conversations follow your choice.",
migrated: "This conversation was set to bypass permissions in 1.2, where this agent still asked anyway. From 1.3 Auto-approve all really auto-approves (commands and edits run without asking), so it was put back to Always Ask.",
turnOn: "Turn on Auto-approve all here", settings: "Open Settings",
},
autoApproved: { count: "Auto-approved {n}", title: "Requests Auto-approve all approved for you (click to see them)", answer: "{opt} · Auto-approve all", pending: "Auto-approving…" },
submitted: "Submitted: {ans}", turnError: "Error: {err}", unknownError: "Unknown error",
interrupted: "Interrupted", filesChanged: "{n} file(s) changed ›", editMsg: "Edit (puts it back in the input; nothing is sent yet)", sendFailed: "Not sent", sendRetry: "Send again", sendDismiss: "Remove this unsent message", resend: "Send this message again", retryHint: "Retry: send the last message again", msgActions: "Message actions", editBusy: "The input still has unsent text: send or clear it first, then click Edit",
tool: {
@@ -0,0 +1,57 @@
// 1.3: per-Agent permission options and hints; Pi keeps the default id but clearly says it never asks.
import { describe, it, expect, beforeEach } from "vitest";
import { setLocale } from "./index.js";
import { autoApproveBannerDesc, composerModeOptions, permissionModes } from "./modes.js";
describe("composerModeOptions", () => {
beforeEach(() => { setLocale("zh"); });
it("keeps 每次询问 and adds 全部自动同意 with the shield flag", () => {
const all = permissionModes();
expect(all.find((m) => m.id === "default")?.label).toBe("每次询问");
const auto = all.find((m) => m.id === "bypassPermissions")!;
expect(auto.label).toBe("全部自动同意");
expect(auto.auto).toBe(true);
expect(auto.danger).toBeFalsy(); // grayscale, not the red danger style
});
it("Cursor: Agent, 全部自动同意, 规划, 问答", () => {
const m = composerModeOptions("cursor", ["default", "bypassPermissions", "plan", "ask"]);
expect(m.map((x) => x.label)).toEqual(["Agent", "全部自动同意", "规划", "问答"]);
});
it("the hint says plainly what full-auto does for the Agent (#727 review 1); the label stays 全部自动同意", () => {
const m = composerModeOptions("codex", ["default", "acceptEdits", "bypassPermissions"], { default: "Read Only", acceptEdits: "Auto", bypassPermissions: "Full Access" });
const auto = m.find((x) => x.id === "bypassPermissions")!;
expect(auto.label).toBe("全部自动同意");
expect(auto.desc).toContain("沙箱关闭");
expect(auto.desc).toContain("danger-full-access");
expect(m.find((x) => x.id === "default")?.label).toBe("只读");
const claude = composerModeOptions("claude", ["plan", "default", "acceptEdits", "bypassPermissions"]).find((x) => x.auto)!;
expect(claude.desc).toContain("跳过所有权限检查");
for (const p of ["cursor", "opencode", "dsh", "mock"]) {
expect(composerModeOptions(p, ["default", "bypassPermissions"]).find((x) => x.auto)!.desc).toContain("允许一次");
}
setLocale("en");
expect(composerModeOptions("codex", ["bypassPermissions"])[0]!.desc).toMatch(/sandbox off/i);
expect(composerModeOptions("claude", ["bypassPermissions"])[0]!.desc).toMatch(/skips all permission checks/i);
});
it("Pi: one default-id mode labelled as never asking in both locales", () => {
const m = composerModeOptions("pi", ["default"]);
expect(m).toHaveLength(1);
expect(m[0]).toMatchObject({ id: "default", label: "Pi 本身从不询问", auto: true });
expect(m[0]!.desc).toContain("Pi 本身从不询问");
setLocale("en");
expect(composerModeOptions("pi", ["default"])[0]).toMatchObject({ id: "default", label: "Pi never asks", auto: true });
});
it("the banner's per-request explanation is limited to Agents that answer individual requests", () => {
const phrase = "每次只同意当前这一个请求";
for (const p of ["cursor", "opencode", "dsh", undefined, "mock"]) {
expect(autoApproveBannerDesc(p), p).toContain(phrase);
}
for (const p of ["codex", "claude", "pi", "copilot", "devin"]) {
expect(autoApproveBannerDesc(p), p).not.toContain(phrase);
}
});
it("English", () => {
setLocale("en");
expect(permissionModes().find((m) => m.id === "bypassPermissions")?.label).toBe("Auto-approve all");
});
});
+32 -4
View File
@@ -1,14 +1,32 @@
import type { Mode } from "../types/models.js";
import { t } from "./index.js";
export type PermissionModeOption = { id: Mode; label: string; desc: string; danger?: boolean };
/** auto: 全部自动同意 (bypassPermissions), drawn with the shield-check in the warning colour (#727 review 1) */
export type PermissionModeOption = { id: Mode; label: string; desc: string; danger?: boolean; auto?: boolean };
const AUTO_DESC_IDS = new Set(["claude", "codex", "copilot", "devin", "cursor", "opencode", "pi"]);
const PER_REQUEST_AUTO_IDS = new Set(["cursor", "opencode", "dsh"]);
/** What 全部自动同意 really does for this Agent: sandbox off / skips all permission checks / the console answers allow-once */
export function autoModeDesc(providerId: string | undefined): string {
return t(`composer.autoDesc.${providerId && AUTO_DESC_IDS.has(providerId) ? providerId : "generic"}`);
}
export function autoApproveBannerDesc(providerId: string | undefined): string {
const desc = autoModeDesc(providerId);
return !providerId || !AUTO_DESC_IDS.has(providerId) || PER_REQUEST_AUTO_IDS.has(providerId)
? `${desc}\n${t("composer.autoOn.keeps")}`
: desc;
}
export const FULL_AUTO: Mode = "bypassPermissions";
export function permissionModes(): PermissionModeOption[] {
return [
{ id: "plan", label: t("composer.mode.plan.label"), desc: t("composer.mode.plan.desc") },
{ id: "default", label: t("composer.mode.default.label"), desc: t("composer.mode.default.desc") },
{ id: "acceptEdits", label: t("composer.mode.acceptEdits.label"), desc: t("composer.mode.acceptEdits.desc") },
{ id: "bypassPermissions", label: t("composer.mode.bypass.label"), desc: t("composer.mode.bypass.desc"), danger: true },
{ id: "bypassPermissions", label: t("composer.mode.bypass.label"), desc: t("composer.mode.bypass.desc"), auto: true },
];
}
@@ -16,6 +34,7 @@ export function permissionModes(): PermissionModeOption[] {
export function cursorExecutionModes(): PermissionModeOption[] {
return [
{ id: "default", label: t("composer.mode.cursorAgent.label"), desc: t("composer.mode.cursorAgent.desc") },
{ id: "bypassPermissions", label: t("composer.mode.cursorBypass.label"), desc: t("composer.mode.cursorBypass.desc"), auto: true },
{ id: "plan", label: t("composer.mode.cursorPlan.label"), desc: t("composer.mode.cursorPlan.desc") },
{ id: "ask", label: t("composer.mode.cursorAsk.label"), desc: t("composer.mode.cursorAsk.desc") },
];
@@ -27,10 +46,19 @@ export function composerModeOptions(
labels?: Partial<Record<Mode, string>>,
): PermissionModeOption[] {
const base = providerId === "cursor" ? cursorExecutionModes() : permissionModes();
// As in Paseo: when an Agent has its own mode names, use them (Copilot shows Agent rather than Always Ask)
// As in Paseo: when an Agent has its own mode names, use them (Copilot shows Agent rather than Always Ask).
// 1.3: 全部自动同意 keeps one name for every Agent; the description says what it does for that Agent.
return base
.filter((m) => allowed.includes(m.id))
.map((m) => (labels?.[m.id] ? { ...m, label: agentModeLabel(labels[m.id]!) } : m));
.map((m) => {
// Pi still runs without tool approvals, but its persisted id stays default so it cannot arm another Agent.
if (providerId === "pi" && m.id === "default") {
return { ...m, label: t("composer.mode.pi.label"), desc: t("composer.mode.pi.desc"), auto: true };
}
// #727 review 1: the hint says plainly what the Agent's own switch does (Codex: sandbox off; Claude: skips all checks)
if (m.id === FULL_AUTO) return { ...m, desc: autoModeDesc(providerId) };
return labels?.[m.id] ? { ...m, label: agentModeLabel(labels[m.id]!) } : m;
});
}
/** An Agent's own mode name (from the daemon, English) in the UI language when we know it */
@@ -152,6 +152,7 @@ textarea.tinput { height: auto; min-height: 60px; padding: 6px 10px; resize: ver
.sm-opt.off:hover { background: none; }
.sm-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.sm-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-label > svg { vertical-align: -2px; margin-right: 5px; }
.sm-hint { font-size: var(--fs-s); color: var(--muted); white-space: normal; line-height: 1.4; }
.sm-check { flex: none; width: 14px; display: inline-flex; color: var(--accent); }
.sm-opt[aria-selected="true"] .sm-label { font-weight: 500; }
@@ -268,3 +268,32 @@ a.ac-local { cursor: pointer; }
display: block; margin: 2px 0 6px; padding-left: 8px; border-left: 2px solid color-mix(in oklab, var(--fg) 30%, transparent);
color: var(--muted); font-size: var(--chat-fs-s); max-height: 7.5em; overflow: hidden;
}
/* 1.3 全部自动同意 (#727 review): the daemon's own approvals, one foldable row per run of tool calls, in the same flat
one-line style as the tool rows (icon slot · text · right-edge meta; clip, never wrap). Only the shield is amber. */
.apv { margin: 0 0 8px; min-width: 0; }
.apv-head {
display: flex; align-items: center; gap: 8px; width: 100%; min-height: 26px; padding: 0 6px; overflow: hidden; border-radius: var(--r-s);
color: var(--muted); font-size: var(--chat-fs-s); text-align: left; white-space: nowrap;
}
.apv-head:hover, .apv.open > .apv-head { color: var(--fg); background: var(--surface-hover); }
.apv-head .caret { flex: none; color: var(--meta); transition: transform var(--dur-1); }
.apv-head .caret.open { transform: rotate(90deg); }
.apv-ic { width: 14px; flex: none; display: inline-flex; justify-content: center; color: var(--auto-fg, var(--warn)); }
.apv-n { flex: none; }
.apv-peek { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--meta); font-family: var(--font-mono); font-size: var(--chat-code-fs); }
.apv-peek::before { content: "·"; margin-right: 8px; font-family: var(--font-ui); }
.apv-list { margin: 2px 0 0 13px; padding-left: 6px; border-left: 1px solid var(--line); }
.apv-row {
display: flex; align-items: center; gap: 8px; min-height: 26px; padding: 0 6px; min-width: 0; overflow: hidden; white-space: nowrap;
border-radius: var(--r-s); color: var(--muted); font-size: var(--chat-fs-s);
}
.apv-row:hover { background: var(--surface-hover); color: var(--fg); }
.apv-cmd, .apv-path, .apv-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apv-cmd, .apv-path { font-family: var(--font-mono); font-size: var(--chat-code-fs); }
.apv-meta { flex: none; margin-left: auto; color: var(--meta); font-size: var(--fs-xs); }
/* 1.3 upgrade notice (#727 review 3): told once that 全部自动同意 now really applies to Cursor / OpenCode / dsh */
.nt-auto {
text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-m); line-height: 1.6; color: var(--text);
}
.nt-auto-h { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
@@ -8,11 +8,29 @@
}
.cp-card:focus-within { border-color: var(--cp-focus); box-shadow: 0 0 0 3px var(--cp-ring), 0 1px 2px rgb(0 0 0 / .04); }
.cp-card.waiting { border-color: color-mix(in oklab, var(--warn) 45%, var(--bg)); }
.cp-card.danger { border-color: color-mix(in oklab, var(--danger) 40%, var(--bg)); }
.cp-danger {
max-width: var(--col); margin: 0 auto 6px; display: flex; align-items: center; gap: 6px;
color: var(--danger); font-size: var(--fs-s); padding: 0 2px;
/* 1.3 全部自动同意 (#727 review 1): a persistent one-line strip above the card (Nolan: one slim line is enough) for as long as the conversation is in it, plus a
warning-tinted card border and chip. The one exception to the grayscale accent: the semantic warning colour, darker in
light mode so small text stays readable (≥4.5:1 on the page background), lighter in dark mode. */
:root { --auto-fg: #b45309; --auto-bg: color-mix(in oklab, #f59e0b 10%, var(--bg)); --auto-line: color-mix(in oklab, #d97706 40%, var(--bg)); }
:root[data-theme="dark"] { --auto-fg: #fbbf24; --auto-bg: color-mix(in oklab, #f59e0b 13%, var(--bg)); --auto-line: color-mix(in oklab, #f59e0b 42%, var(--bg)); }
.cp-auto-on {
max-width: var(--col); margin: 0 auto 4px; display: flex; align-items: center; gap: 6px; min-width: 0;
height: 22px; padding: 0 4px; white-space: nowrap; overflow: hidden;
color: var(--muted); font-size: var(--fs-s); line-height: 22px;
}
.cp-auto-ic { flex: none; display: inline-flex; color: var(--auto-fg); }
.cp-auto-t { flex: 0 1 auto; min-width: 0; display: inline-flex; align-items: center; gap: 6px; overflow: hidden; cursor: help; border-radius: var(--r-s); }
.cp-auto-t:focus-visible { outline: 2px solid var(--auto-line); outline-offset: 1px; }
.cp-auto-t b { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--auto-fg); font-weight: 600; }
.cp-auto-on .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.cp-auto-back {
flex: none; margin-left: auto; padding: 0 2px; border: 0; background: none; white-space: nowrap;
color: var(--fg); font-size: var(--fs-s); text-decoration: underline; text-underline-offset: 2px;
text-decoration-color: color-mix(in oklab, var(--fg) 35%, transparent); cursor: pointer;
}
.cp-auto-back:hover { text-decoration-color: currentColor; }
.cp-card.auto-on { border-color: var(--auto-line); }
.cp-card.auto-on:focus-within { border-color: var(--auto-fg); }
.cp-hint { max-width: var(--col); margin: 6px auto 0; font-size: var(--fs-xs); color: var(--meta); text-align: center; }
.att-note { padding: 6px 10px 0; color: var(--muted); font-size: var(--fs-s); }
.cp-ta-wrap { position: relative; }
@@ -82,6 +100,12 @@
}
.tasks-pill:hover { color: var(--fg); background: var(--surface-hover); }
.tasks-pill svg { flex: none; color: var(--meta); }
/* 1.3 全部自动同意: Cursor's shield idea, a filled chip with a shield-check, in the warning colour (#727 review 1) */
.ipill.auto, .cp-bar .ipill.auto { color: var(--auto-fg); background: var(--auto-bg); border-color: var(--auto-line); font-weight: 600; }
.ipill.auto:hover, .ipill.auto[aria-expanded="true"], .cp-bar .ipill.auto:hover, .cp-bar .ipill.auto[aria-expanded="true"] { background: color-mix(in oklab, var(--auto-fg) 16%, var(--bg)); }
.ipill.auto svg { color: var(--auto-fg); }
.mi.warn .sm-label { color: var(--auto-fg); }
.ipill.static { cursor: default; }
.mode-menu { max-width: 300px; }
.cp-div { width: 1px; height: 14px; background: var(--line); margin: 0 4px; flex: none; }
.cp-bar > .ibtn { flex: none; }
@@ -0,0 +1,56 @@
// 1.3 全部自动同意 (#727 review): every approval the daemon answers by itself is in the timeline (permission_request +
// permission_resolved, both marked auto), so the user can always look up what was approved. Shown quietly: the auto
// approvals of one run of tool calls become one foldable row ("已自动同意 3 项") placed after that run, so they neither
// break the folded tool summary nor show up as cards with buttons. Pure: the reducer's items are not changed.
import type { DisplayItem } from "./reducer.js";
import { isShortThinking } from "./fold.js";
type Perm = Extract<DisplayItem, { kind: "permission" }>;
type AutoPerm = Extract<DisplayItem, { kind: "autoperm" }>;
export function isAutoApproved(it: DisplayItem): it is Perm {
return it.kind === "permission" && !!it.auto && it.status !== "cancelled";
}
/** Items a tool run is made of (what foldTimeline merges); anything else ends the run */
function inRun(it: DisplayItem): boolean {
return it.kind === "toolgroup" || it.kind === "gone" || isShortThinking(it);
}
/** Run before foldTimeline: pull auto-approved permissions out and put one "autoperm" row at the end of their run */
export function collectAutoApproved(items: DisplayItem[]): DisplayItem[] {
if (!items.some(isAutoApproved)) return items;
const out: DisplayItem[] = [];
let bucket: AutoPerm | null = null;
const flush = () => {
if (bucket) out.push(bucket);
bucket = null;
};
for (const it of items) {
if (isAutoApproved(it)) {
if (!bucket) bucket = { kind: "autoperm", key: `autoperm:${it.requestId}`, items: [] };
bucket.items.push(it);
continue;
}
if (bucket && !inRun(it)) flush();
out.push(it);
}
flush();
return out;
}
/** What one approval was for, on one line: the command, else the file, else the Agent's title */
export function approvalTarget(p: Perm): string {
const d = (p.detail ?? {}) as { command?: unknown; path?: unknown; diff?: { path?: unknown } };
const s = typeof d.command === "string" && d.command.trim() ? d.command
: typeof d.path === "string" && d.path.trim() ? d.path
: typeof d.diff?.path === "string" && d.diff.path.trim() ? d.diff.path
: p.title;
return s.replace(/\s+/g, " ").trim();
}
/** The label of the option the daemon picked ("Allow once" …), or its id */
export function approvalChoice(p: Perm): string | null {
if (!p.choice) return null;
return p.options.find((o) => o.id === p.choice)?.label ?? p.choice;
}
@@ -25,9 +25,11 @@ export type DisplayItem =
| { kind: "toolgroup"; key: string; steps: ToolStep[] }
| { kind: "plan"; key: string; itemId: string; markdown: string }
| { kind: "todo"; key: string; items: { text: string; status: string }[] }
| { kind: "permission"; key: string; requestId: string; title: string; kindStr: string; detail?: unknown; options: { id: string; label: string; kind: string }[]; status: "pending" | "resolved" | "cancelled"; choice?: string }
| { kind: "permission"; key: string; requestId: string; title: string; kindStr: string; detail?: unknown; options: { id: string; label: string; kind: string }[]; status: "pending" | "resolved" | "cancelled"; choice?: string; auto?: boolean }
| { kind: "question"; key: string; requestId: string; questions: unknown[]; answers?: Record<string, string>; status: "pending" | "answered" | "cancelled" }
| { kind: "notice"; key: string; level: string; message: string; code?: string }
/** 1.3 全部自动同意: the approvals the daemon gave in one run of tool calls, as one quiet foldable row (autoApproved.ts) */
| { kind: "autoperm"; key: string; items: Extract<DisplayItem, { kind: "permission" }>[] }
| { kind: "gone"; key: string } // placeholder: duplicate delta items cleared by sweepSiblings; skipped when rendering
| { kind: "turnend"; key: string; status: string; durationMs?: number; error?: string; filesChanged?: number; usage?: TurnUsage;
/** 1.3: the model the turn ran on (turn_started; null = the Agent's default) and when it ended, for the reply footer */
@@ -224,6 +226,8 @@ export function applyEvent(st: State, ev: TimelineEvent): void {
st.items.push({
kind: "permission", key: `perm:${ev.requestId}`, requestId: ev.requestId,
title: ev.title, kindStr: ev.kind, detail: ev.detail, options: ev.options, status: "pending",
// 1.3 全部自动同意: the daemon answered it itself (never a card with buttons; see timeline/autoApproved.ts)
...(ev.auto ? { auto: true } : {}),
});
return;
case "permission_resolved": {
@@ -232,6 +236,7 @@ export function applyEvent(st: State, ev: TimelineEvent): void {
if (it?.kind === "permission") {
it.status = ev.cancelled ? "cancelled" : "resolved";
it.choice = ev.optionId;
if (ev.auto) it.auto = true;
}
return;
}
@@ -16,8 +16,8 @@ export type TimelineEvent =
| { seq: number; ts: number; threadId: string; turnId?: string; type: "tool_call"; itemId: string; kind: ToolKind; title: string; status: "running" | "ok" | "failed"; input?: unknown; detail?: unknown; output?: string; exitCode?: number; durationMs?: number }
| { seq: number; ts: number; threadId: string; turnId?: string; type: "plan"; itemId: string; markdown: string; entries?: { step: string; status: string }[] }
| { seq: number; ts: number; threadId: string; turnId?: string; type: "todo"; items: { text: string; status: string }[] }
| { seq: number; ts: number; threadId: string; turnId?: string; type: "permission_request"; requestId: string; title: string; kind: string; detail?: unknown; options: { id: string; label: string; kind: string }[] }
| { seq: number; ts: number; threadId: string; turnId?: string; type: "permission_resolved"; requestId: string; optionId?: string; cancelled?: boolean }
| { seq: number; ts: number; threadId: string; turnId?: string; type: "permission_request"; requestId: string; title: string; kind: string; detail?: unknown; options: { id: string; label: string; kind: string }[]; auto?: boolean }
| { seq: number; ts: number; threadId: string; turnId?: string; type: "permission_resolved"; requestId: string; optionId?: string; cancelled?: boolean; auto?: boolean }
| { seq: number; ts: number; threadId: string; turnId?: string; type: "question"; requestId: string; questions: unknown[] }
| { seq: number; ts: number; threadId: string; turnId?: string; type: "question_answered"; requestId: string; answers: Record<string, string> }
| { seq: number; ts: number; threadId: string; turnId?: string; type: "usage"; inputTokens: number; outputTokens: number; cacheReadTokens: number; costUsd: number; contextWindow?: number }