Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion webviews/scripts/design-tokens-baseline.jsonl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
{"file":"agent-session/acpmux/composerControls.css","kind":"height","property":"height","values":{"1px":1,"calc(23.5px * var(--cmux-interface-scale, 1))":1,"calc(15px * var(--cmux-interface-scale, 1))":1,"3px":1,"16px":1}}
{"file":"agent-session/acpmux/composerControls.css","kind":"spacing","property":"gap","values":{"6px":1}}
{"file":"agent-session/acpmux/composerControls.css","kind":"spacing","property":"padding","values":{"0 8px 6px":1,"6px 10px 4px":1,"0 6px 0 8px":1}}
{"file":"agent-session/acpmux/composerLocation.css","kind":"height","property":"height","values":{"46px":1,"calc(46px + var(--acpmux-strip-gap, 4px))":2,"22px":4,"1px":3,"12px":1,"16px":3,"6px":1}}
{"file":"agent-session/acpmux/composerLocation.css","kind":"height","property":"height","values":{"46px":1,"calc(46px + var(--acpmux-strip-gap, 4px))":2,"22px":3,"1px":3,"12px":1,"16px":3,"6px":1}}
{"file":"agent-session/acpmux/composerLocation.css","kind":"height","property":"min-height","values":{"52px":1,"16px":1}}
{"file":"agent-session/acpmux/composerLocation.css","kind":"spacing","property":"gap","values":{"1px":1,"6px":1,"3px":1}}
{"file":"agent-session/acpmux/composerLocation.css","kind":"spacing","property":"padding","values":{"0 var(--acpmux-strip-inset, 3px)":1,"0 6px":2,"0 3px":1,"5px 4px":1,"4px 4px 2px":1,"0 5px":1,"0 calc(var(--acpmux-top-strip-edge) - var(--acpmux-tray-inset) - 6px) var(--acpmux-tray-tuck)":1,"0 0 calc(2px + var(--acpmux-tray-tuck)) calc(var(--acpmux-top-strip-edge) - var(--acpmux-tray-inset))":1,"6px 8px":1,"1px 4px":1,"calc(11px * var(--cmux-interface-scale, 1)) max(0px, calc(8px * var(--cmux-interface-scale, 1) - var(--cmux-scroller-size, 8px))) calc(11px * var(--cmux-interface-scale, 1)) calc(7px * var(--cmux-interface-scale, 1))":1}}
Expand Down
71 changes: 30 additions & 41 deletions webviews/src/agent-session/acpmux/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ import {
remoteRecordingAttachment,
} from "./attachments";
import type { KeptAttachments } from "./composer/keptAttachments";
import { ComposerPickers, PICKER_LABELS, type ComposerPermissionAccess } from "./ComposerPickers";
import { ComposerPickers, PICKER_LABELS } from "./ComposerPickers";
import { chatAccessGrants, revokeAccessRows } from "./header/grantsMenu";
import { openPicker } from "./pickerOpeners";
import { EmptyState, type EmptyStateProjects, isNewChat, projectName } from "./EmptyState";
import { ChatUnavailableState } from "./ChatUnavailableState";
Expand Down Expand Up @@ -4502,14 +4503,12 @@ const NEW_TAB_CLOSE_EVENT = "acpmux-newtab-close";
function DefaultComposerChips({
snapshot,
cwd,
permissionAccess,
onAddAgent,
startsChat = false,
}: {
snapshot: AcpmuxSnapshot;
/// The folder a chat the chips start opens in (the New Tab page's project).
cwd?: string;
permissionAccess?: ComposerPermissionAccess;
onAddAgent?(): void;
/// The chips belong to a page with no chat yet: a model, mode or effort pick starts one first.
startsChat?: boolean;
Expand Down Expand Up @@ -4557,7 +4556,6 @@ function DefaultComposerChips({
snapshot.switching !== undefined ||
(startsChat && !!snapshot.summary?.harness && window.cmuxAcpmuxActions?.["chat.new"] !== undefined)
}
permissionAccess={permissionAccess}
onModel={(modelId) => {
start();
void callNative("chat.model", { modelId });
Expand Down Expand Up @@ -6745,11 +6743,36 @@ function AcpmuxPane() {
workflows.length > 0 ? { list: workflows, onStop: stopSubagent, onOpenAgent: showWorkflowAgent } : undefined,
[workflows, stopSubagent, showWorkflowAgent],
);
// What the chat was granted (header/grantsMenu.ts): revoked from the chat menu's Revoke Granted
// Access, always there, and from Session Info's Environment when it shows; never from the
// composer's mode menu, which lists the modes alone (Leo, 2026-10-29). The trusted grant names
// where the answer lives (the repository, a worktree's root, the folder), from the answer just
// given or the last read.
const trustScope =
trustAsk.ask?.state === "decided" && trustAsk.ask.level === "trusted" ? trustAsk.ask : trustAsk.scope;
const trustLabel = trustScope
? isAgentHome(trustScope.cwd)
? t("trust.trustedPrivate")
: trustedLabel(t, trustScope)
: undefined;
const accessGrants = chatAccessGrants(
{
trusted: trustAsk.trusted,
trustLabel,
untrust: trustAsk.undo,
chatAllowance: Boolean(snapshot.permissionGroups?.chatAllowance),
// A grant shown from the chat's last read until its refresh lands: removable once it is read.
allowanceUnread: snapshot.permissionGroups?.ready === false,
revokeAllowance: () => void callNative("chat.permission_chat.revoke", {}),
},
t,
);
const inspector = useChatInspector({
snapshot,
machineName,
repository: githubRepository,
shell,
grants: accessGrants,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Read-only subagent panes still receive accessGrants in Session Info and the chat menu. Guard both surfaces with readOnlySubagent so a subagent cannot display or revoke the parent chat's grants.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At webviews/src/agent-session/acpmux/App.tsx, line 7660:

<comment>Read-only subagent panes still receive `accessGrants` in Session Info and the chat menu. Guard both surfaces with `readOnlySubagent` so a subagent cannot display or revoke the parent chat's grants.</comment>

<file context>
@@ -7635,6 +7657,7 @@ function AcpmuxPane() {
     machineName,
     repository: githubRepository,
     shell,
+    grants: accessGrants,
     onOpenOutput: quick ? undefined : inspectorSubagent ? openSubagentOutput : openOutput,
     onOpenSourceFile: quick || !inspectorLocal ? undefined : (path) => openSourceFile(path, callNative),
</file context>

onOpenOutput: quick ? undefined : inspectorSubagent ? openSubagentOutput : openOutput,
onOpenSourceFile: quick || !inspectorLocal ? undefined : (path) => openSourceFile(path, callNative),
onOpenUrl: quick
Expand Down Expand Up @@ -8966,7 +8989,7 @@ function AcpmuxPane() {
// the early New Tab flag, one object from a useState initializer).
}, [harnessSwitch, newChatPrewarm, queryClient, toggleInspector, earlyNewTab, restartGate, sandbox]);
const registryChips = (window.cmuxAcpmuxRegistry as unknown as Record<string, unknown> | undefined)?.composerChips as
| React.ComponentType<{ snapshot: AcpmuxSnapshot; permissionAccess?: ComposerPermissionAccess }>
| React.ComponentType<{ snapshot: AcpmuxSnapshot }>
| undefined;
const ComposerChips = registryChips ?? DefaultComposerChips;
// The catalog arrives through the query cache, which composerSnapshot carries.
Expand Down Expand Up @@ -9428,6 +9451,8 @@ function AcpmuxPane() {
},
]
: []),
// Revoke Granted Access: the chat's grants, revocable with default settings (header/grantsMenu.ts).
...revokeAccessRows(accessGrants, t),
];
// Quick Chat's panel is not a tab: only the chat's own actions.
if (quick) return menuGroups(fork, continueIn, copy ? [copy] : [], tools);
Expand Down Expand Up @@ -10122,41 +10147,6 @@ function AcpmuxPane() {
)}
</div>
) : null;
// The trusted grant names where the answer lives (the repository, a worktree's root, the
// folder), from the answer just given or the last read; its × forgets it there.
const trustScope =
trustAsk.ask?.state === "decided" && trustAsk.ask.level === "trusted" ? trustAsk.ask : trustAsk.scope;
const trustLabel = trustScope
? isAgentHome(trustScope.cwd)
? t("trust.trustedPrivate")
: trustedLabel(t, trustScope)
: undefined;
const permissionAccess: ComposerPermissionAccess = {
grants: [
...(trustAsk.trusted
? [
{
id: "folder-trust",
label: trustLabel ?? t("trust.trustedPrivate"),
onRemove: trustAsk.undo,
},
]
: []),
...(snapshot.permissionGroups?.chatAllowance
? [
{
id: "chat-permission",
label: t("permission.allowChat"),
// A grant shown from the chat's last read until its refresh lands: removable once it is read.
onRemove: () =>
snapshot.permissionGroups?.ready === false
? undefined
: void callNative("chat.permission_chat.revoke", {}),
},
]
: []),
],
};
// A failed start of a folder harness says what it waits for, in place of the switch's Retry
// card: Enable (sent from the button's click, then the chat starts again), or the Trust answer.
const block =
Expand Down Expand Up @@ -10402,7 +10392,6 @@ function AcpmuxPane() {
placeholder={isSideSession ? t("sideSession.placeholder") : undefined}
switching={Boolean(switchView.intent)}
chips={ComposerChips}
permissionAccess={permissionAccess}
onOpenContext={inspector.reveal ? () => inspector.reveal?.("context") : undefined}
draft={draft}
onUnsentDraft={quick ? undefined : onNewChatDraft}
Expand Down
8 changes: 2 additions & 6 deletions webviews/src/agent-session/acpmux/Composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
SlashIcon,
ReturnIcon,
StopIcon,
type ComposerPermissionAccess,
} from "./ComposerPickers";
import { FileSearch } from "./FileSearch";
import { PromptFocus } from "./promptFocus";
Expand Down Expand Up @@ -237,7 +236,7 @@ type Props = {
/// (`projectDraft`) moves `snapshot`'s cwd but not the tab's until the chat starts, so the
/// header's PR belongs to another folder then.
headerCwd?: string;
chips: React.ComponentType<{ snapshot: AcpmuxSnapshot; permissionAccess?: ComposerPermissionAccess }>;
chips: React.ComponentType<{ snapshot: AcpmuxSnapshot }>;
/// Sends a prompt. False when nothing can take it yet (no acpmux), so the prompt keeps it. A
/// promise holds the prompt in the composer until the host takes it: it clears when the promise
/// resolves and stays (for the user to send again) when it rejects, so a refusal loses nothing.
Expand Down Expand Up @@ -268,8 +267,6 @@ type Props = {
switching?: boolean;
/// The bar's left button, such as attach; by default + opens the agent's commands. `null` leaves the slot empty.
leading?: React.ReactNode;
/// Granted folder trust and chat-wide permission state, rendered inside Access.
permissionAccess?: ComposerPermissionAccess;
/// Buttons before Send, such as the dictation mic.
accessory?: React.ReactNode;
/// A dictation session is waiting for words: the empty prompt reads "Listening…" in italic.
Expand Down Expand Up @@ -394,7 +391,6 @@ export function Composer({
queueImage,
draft,
leading,
permissionAccess,
accessory,
dictating = false,
prompt,
Expand Down Expand Up @@ -2117,7 +2113,7 @@ export function Composer({
}
chips={
<PromptFocus value={focusPrompt}>
<Chips snapshot={snapshot} permissionAccess={permissionAccess} />
<Chips snapshot={snapshot} />
</PromptFocus>
}
// Claude Code ends the quiet row on the context ring. It keeps its place before the chat
Expand Down
2 changes: 1 addition & 1 deletion webviews/src/agent-session/acpmux/ComposerBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export function ComposerBox({
>
{leading}
{/* The granted-permission status gets no slot of its own in this row (hq#1957 item 15
compact row): grants live in the permission mode's Access menu, one lock. */}
compact row): grants are revoked from the chat menu (header/grantsMenu.ts). */}
{!quietRow && shownChips}
{/* Codex's look: the context ring before the model, where Codex shows its own. */}
{!quietRow && plainFooter && ring}
Expand Down
32 changes: 10 additions & 22 deletions webviews/src/agent-session/acpmux/ComposerPickers.gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useEffect, useMemo, useState } from "react";
import { componentEntry } from "../../gallery/format";
import type { Play } from "../../gallery/play";
import type { AcpmuxSnapshot } from "./model";
import { ComposerPickers, type ComposerPermissionGrant } from "./ComposerPickers";
import { ComposerPickers } from "./ComposerPickers";
import { BUNDLED_MODEL_CATALOG, buildPickerCatalog } from "./modelCatalogData";
import { ChatAccountsContext, readChatAccounts, type ChatAccounts } from "./chatAccounts";
import { rememberFullAccess } from "./startMode";
Expand Down Expand Up @@ -198,10 +198,6 @@ function GalleryComposerPickers({ claude, accounts, managed }: Props) {
const [mode, setMode] = useState(initialSnapshot.summary!.modes!.currentModeId!);
const [effort, setEffort] = useState("medium");
const [fast, setFast] = useState("off");
const [grants, setGrants] = useState<ComposerPermissionGrant[]>([
{ id: "folder", label: "Trusted cmux-tui", onRemove: () => setGrants((current) => current.slice(1)) },
{ id: "git-grep", label: "Allow git grep in cmux for this session", onRemove: () => setGrants([]) },
]);
const snapshot = useMemo<AcpmuxSnapshot>(
() => ({
...initialSnapshot,
Expand Down Expand Up @@ -243,7 +239,6 @@ function GalleryComposerPickers({ claude, accounts, managed }: Props) {
<ComposerPickers
snapshot={snapshot}
{...(pickerCatalog ? { pickerCatalog } : {})}
permissionAccess={{ grants }}
onModel={setModel}
onMode={setMode}
onEffort={(id, value) => (id === "fast-mode" ? setFast(value) : setEffort(value))}
Expand Down Expand Up @@ -415,20 +410,13 @@ const managedMode: Play = async (ctx) => {
throw new Error("Full access must say it is managed by the organization");
};

const accessGrants: Play = async (ctx) => {
const trigger = ctx.find({ role: "button", name: "Mode" });
if (trigger.textContent?.includes("Trusted")) throw new Error("Trust state leaked into the Access trigger");
// The allowed rules live in the menu only; the trigger shows no count beside the mode.
if (trigger.querySelector(".acpmux-access-grant-count") || /\d/.test(trigger.textContent ?? ""))
throw new Error("Access trigger shows an allowed-rule count");
// The mode menu lists the modes alone (Leo, 2026-10-29): granted access is revoked from the chat
// menu's Revoke Granted Access (header/grantsMenu.ts), never from this menu.
const modesOnly: Play = async (ctx) => {
await ctx.click({ role: "button", name: "Mode" });
await ctx.waitFor(() => ctx.document.querySelector(".acpmux-access-grants") !== null);
const grants = [...ctx.document.querySelectorAll<HTMLElement>(".acpmux-access-grant")];
if (grants.length !== 2) throw new Error(`Expected two allowed rules, found ${grants.length}`);
if (!grants.every((row) => row.querySelector(".acpmux-access-grant-remove")))
throw new Error("Allowed rules must each have a remove button");
await ctx.click({ selector: ".acpmux-access-grant-remove" });
await ctx.waitFor(() => ctx.document.querySelectorAll(".acpmux-access-grant").length === 1);
await ctx.waitFor(() => ctx.document.querySelector('[role="menuitemradio"]') !== null);
if (ctx.document.querySelector(".acpmux-access-grants, .acpmux-access-grant"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: modesOnly can't catch a regression: this variant no longer seeds any grants, so the absence check passes even if the mode menu starts rendering grants. Give the variant a seeded grant source again, or drop the play's grant-absence check in favor of a stronger assertion.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At webviews/src/agent-session/acpmux/ComposerPickers.gallery.tsx, line 425:

<comment>`modesOnly` can't catch a regression: this variant no longer seeds any grants, so the absence check passes even if the mode menu starts rendering grants. Give the variant a seeded grant source again, or drop the play's grant-absence check in favor of a stronger assertion.</comment>

<file context>
@@ -422,20 +417,13 @@ const managedMode: Play = async (ctx) => {
-  await ctx.click({ selector: ".acpmux-access-grant-remove" });
-  await ctx.waitFor(() => ctx.document.querySelectorAll(".acpmux-access-grant").length === 1);
+  await ctx.waitFor(() => ctx.document.querySelector('[role="menuitemradio"]') !== null);
+  if (ctx.document.querySelector(".acpmux-access-grants, .acpmux-access-grant"))
+    throw new Error("The mode menu shows granted access");
   await ctx.press("Escape");
</file context>

throw new Error("The mode menu shows granted access");
await ctx.press("Escape");
};

Expand Down Expand Up @@ -542,10 +530,10 @@ export default componentEntry<Props>({
props: { managed: true },
play: managedMode,
},
"access-grants": {
note: "Allowed folder and chat rules stay inside Access; the footer shows only a compact count and the menu offers removal.",
"modes-only": {
note: "The mode menu lists the modes alone: no Granted access section (Leo, 2026-10-29); grants are revoked from the chat menu's Revoke Granted Access.",
props: {},
play: accessGrants,
play: modesOnly,
},
"permission-focus": {
note: "The numeric mode shortcut picks Full access; Escape from a reopen returns focus to Mode.",
Expand Down
Loading