Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

revert: revert the inline execution switches

vastsa591d659ae264
diff --git a/apps/desktop/src/components/Composer.tsx b/apps/desktop/src/components/Composer.tsx
index 7294104d9..bebc1d609 100644
--- a/apps/desktop/src/components/Composer.tsx
+++ b/apps/desktop/src/components/Composer.tsx
@@ -151,6 +151,7 @@ export function Composer({
: EMPTY_QUEUED_PROMPTS,
);
+ const [permissionOpen, setPermissionOpen] = useState(false);
const composerTransformInvalidateRef = useRef<() => void>(() => {});
const composerShellRef = useRef<HTMLDivElement>(null);
const dockRef = useRef<HTMLDivElement>(null);
@@ -414,6 +415,7 @@ export function Composer({
useEffect(() => {
if (!controlsBlocked) return;
+ setPermissionOpen(false);
}, [controlsBlocked]);
const composerTransformController = useComposerTransforms({
@@ -607,6 +609,8 @@ export function Composer({
modelId={modelId}
thinkingLevel={thinkingLevel}
composerPermissionMode={composerPermissionMode}
+ permissionOpen={permissionOpen}
+ setPermissionOpen={setPermissionOpen}
controlsBlocked={controlsBlocked}
localToolsAllowed={localToolsAllowed}
attachmentsAllowed={attachmentsAllowed}
diff --git a/apps/desktop/src/features/chat/composer/ComposerModelPicker.tsx b/apps/desktop/src/features/chat/composer/ComposerModelPicker.tsx
index e55a5593b..05a89f815 100644
--- a/apps/desktop/src/features/chat/composer/ComposerModelPicker.tsx
+++ b/apps/desktop/src/features/chat/composer/ComposerModelPicker.tsx
@@ -18,6 +18,7 @@ export type ComposerModelPickerProps = {
selectedProviderId?: string;
selectedModelId?: string;
controlsBlocked: boolean;
+ onCloseOtherMenus: () => void;
rootActions?: ReactNode;
};
@@ -31,6 +32,7 @@ export function ComposerModelPicker({
selectedProviderId,
selectedModelId,
controlsBlocked,
+ onCloseOtherMenus,
rootActions,
}: ComposerModelPickerProps) {
const {
@@ -76,6 +78,7 @@ export function ComposerModelPicker({
aria-expanded={open}
disabled={controlsBlocked}
onClick={() => {
+ onCloseOtherMenus();
if (!open) {
setOtherModelsExpanded(false);
setQuery("");
diff --git a/apps/desktop/src/features/chat/composer/ComposerPermissionPicker.tsx b/apps/desktop/src/features/chat/composer/ComposerPermissionPicker.tsx
new file mode 100644
index 000000000..6ee6fa036
--- /dev/null
+++ b/apps/desktop/src/features/chat/composer/ComposerPermissionPicker.tsx
@@ -0,0 +1,87 @@
+import type { Dispatch, SetStateAction } from "react";
+import type { TFunction } from "i18next";
+import type { GlobalPermissionMode, Mode } from "@pi-desktop/shared";
+import { AnchoredMenu } from "../../../components/settings/AnchoredMenu";
+import { TooltipButton } from "../../../components/ui";
+import { IconCheck, IconChevronDown } from "../../../components/icons";
+import { PERMISSION_MODE_I18N_KEYS } from "../../../lib/permission-mode-labels";
+
+/** Controlled permission UI shared by conversations and task drafts. */
+export function ComposerPermissionPicker({t, mode, composerPermissionMode,
+ permissionOpen, setPermissionOpen, controlsBlocked, onCloseOtherMenus, onSelect,
+}: {
+ t: TFunction;
+ mode: Mode;
+ composerPermissionMode: GlobalPermissionMode;
+ permissionOpen: boolean;
+ setPermissionOpen: Dispatch<SetStateAction<boolean>>;
+ controlsBlocked: boolean;
+ onCloseOtherMenus: () => void;
+ onSelect: (mode: GlobalPermissionMode) => void | Promise<void>;
+}) {
+ return (
+ <AnchoredMenu
+ className="composer-permission"
+ open={permissionOpen && mode !== "goal"}
+ onClose={() => setPermissionOpen(false)}
+ menuClassName="composer-permission-menu"
+ label={t("chat.permissionMode")}
+ role="menu"
+ align="start"
+ side="top"
+ trigger={(ref) => (
+ <TooltipButton
+ ref={ref}
+ type="button"
+ className={`icon-btn mode-chip ${permissionOpen ? "active" : ""}`}
+ tooltip={
+ mode === "goal"
+ ? `${t("chat.permissionMode")} · ${t("goal.autoWarning")}`
+ : mode === "plan" && composerPermissionMode === "auto"
+ ? `${t("chat.permissionMode")} · ${t("plan.autoWarning")}`
+ : t("chat.permissionMode")
+ }
+ ariaLabel={
+ mode === "goal"
+ ? `${t("chat.permissionMode")} · ${t("goal.autoWarning")}`
+ : mode === "plan" && composerPermissionMode === "auto"
+ ? `${t("chat.permissionMode")} · ${t("plan.autoWarning")}`
+ : t("chat.permissionMode")
+ }
+ aria-haspopup={mode === "goal" ? undefined : "menu"}
+ aria-expanded={mode === "goal" ? false : permissionOpen}
+ disabled={controlsBlocked || mode === "goal"}
+ onClick={() => {
+ onCloseOtherMenus();
+ setPermissionOpen((open) => !open);
+ }}
+ >
+ <span className="text-sm">
+ {t(PERMISSION_MODE_I18N_KEYS[composerPermissionMode])}
+ </span>
+ <IconChevronDown size={12} />
+ </TooltipButton>
+ )}
+ >
+ {(["ask", "accept-edits", "auto"] as const).map((candidate) => (
+ <button
+ key={candidate}
+ type="button"
+ role="menuitemradio"
+ aria-checked={composerPermissionMode === candidate}
+ disabled={controlsBlocked}
+ className={`composer-plus-item ${composerPermissionMode === candidate ? "active" : ""}`}
+ onClick={async () => {
+ setPermissionOpen(false);
+ await onSelect(candidate);
+ }}
+ >
+ <span className="flex-1 text-left">
+ {t(PERMISSION_MODE_I18N_KEYS[candidate])}
+ </span>
+ {composerPermissionMode === candidate ? <IconCheck size={13} /> : null}
+ </button>
+ ))}
+ </AnchoredMenu>
+ );
+}
diff --git a/apps/desktop/src/features/chat/composer/ComposerSwitches.tsx b/apps/desktop/src/features/chat/composer/ComposerSwitches.tsx
deleted file mode 100644
index c796930d9..000000000
--- a/apps/desktop/src/features/chat/composer/ComposerSwitches.tsx
+++ /dev/null
@@ -1,213 +0,0 @@
-import type { KeyboardEvent, ReactNode } from "react";
-import type { TFunction } from "i18next";
-import type { Mode, PermissionMode } from "@pi-desktop/shared";
-import {
- IconPencil,
- IconShield,
- IconSparkles,
-} from "../../../components/icons";
-import { PERMISSION_MODE_I18N_KEYS } from "../../../lib/permission-mode-labels";
-import { ModeIcon } from "./ComposerModeIcon";
-import { MODE_CYCLE, MODE_LABEL_KEYS } from "./model";
-
-type SelectablePermission = Exclude<PermissionMode, "inherit">;
-
-type Segment<Value extends string> = {
- value: Value;
- label: string;
- icon: ReactNode;
-};
-
-const SELECT_KEYS = new Set(["ArrowLeft", "ArrowRight", "Home", "End"]);
-const SELECTABLE_PERMISSIONS: readonly SelectablePermission[] = [
- "ask",
- "accept-edits",
- "auto",
-];
-const PERMISSION_ICONS: Record<SelectablePermission, ReactNode> = {
- ask: <IconShield size={13} />,
- "accept-edits": <IconPencil size={13} />,
- auto: <IconSparkles size={13} />,
-};
-
-/**
- * Mutually exclusive choices as one segmented control.
- *
- * Every option is a real click target: any state is one pointer action away.
- * The alternatives in this toolbar used to need a menu round-trip (permission)
- * or repeated clicks on a cycling chip (mode). Selection follows focus like a
- * native radio group, so arrow keys move to and commit the neighbouring option.
- */
-function SegmentedControl<Value extends string>({
- className,
- ariaLabel,
- value,
- segments,
- disabled = false,
- planning = false,
- onSelect,
-}: {
- className: string;
- ariaLabel: string;
- value: Value;
- segments: readonly Segment<Value>[];
- disabled?: boolean;
- planning?: boolean;
- onSelect: (value: Value) => void;
-}) {
- const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
- if (!SELECT_KEYS.has(event.key)) return;
- const radios = [
- ...event.currentTarget.querySelectorAll<HTMLButtonElement>(
- '[role="radio"]:not(:disabled)',
- ),
- ];
- if (radios.length === 0) return;
- event.preventDefault();
- const active = radios.indexOf(document.activeElement as HTMLButtonElement);
- const last = radios.length - 1;
- const next =
- event.key === "Home"
- ? 0
- : event.key === "End"
- ? last
- : event.key === "ArrowLeft"
- ? (active <= 0 ? last : active - 1)
- : active >= last
- ? 0
- : active + 1;
- const target = radios[next];
- if (!target) return;
- target.focus();
- // Selecting on arrow navigation keeps focus and the committed state equal.
- target.click();
- };
-
- return (
- <div
- className={`composer-segment-group ${className}`}
- role="radiogroup"
- aria-label={ariaLabel}
- data-planning={planning ? "true" : undefined}
- onKeyDown={handleKeyDown}
- >
- {segments.map((segment) => {
- const active = segment.value === value;
- return (
- <button
- key={segment.value}
- type="button"
- role="radio"
- aria-checked={active}
- aria-label={segment.label}
- // The glyph-only options carry their name on hover; the committed
- // one spells it out in the row itself.
- title={active ? undefined : segment.label}
- className={`composer-segment${active ? " is-active" : ""}`}
- data-value={segment.value}
- tabIndex={active ? 0 : -1}
- disabled={disabled}
- onClick={() => {
- if (!active) onSelect(segment.value);
- }}
- >
- <span className="composer-segment-icon" aria-hidden="true">
- {segment.icon}
- </span>
- <span className="composer-segment-label">{segment.label}</span>
- </button>
- );
- })}
- </div>
- );
-}
-
-/**
- * Approval level as a standalone switch. Scheduled task drafts show it without
- * a mode switch, because a task always runs in the agent mode.
- */
-export function ComposerPermissionSwitch({
- t,
- permissionMode,
- locked = false,
- controlsBlocked,
- onSelect,
-}: {
- t: TFunction;
- permissionMode: PermissionMode;
- locked?: boolean;
- controlsBlocked: boolean;
- onSelect: (mode: SelectablePermission) => void;
-}) {
- const effectivePermission: SelectablePermission = locked
- ? "auto"
- : (permissionMode as SelectablePermission);
- return (
- <SegmentedControl
- className="composer-permission-switch"
- ariaLabel={
- locked
- ? `${t("chat.permissionMode")} · ${t("goal.autoWarning")}`
- : t("chat.permissionMode")
- }
- value={effectivePermission}
- segments={SELECTABLE_PERMISSIONS.map((candidate) => ({
- value: candidate,
- label: t(PERMISSION_MODE_I18N_KEYS[candidate]),
- icon: PERMISSION_ICONS[candidate],
- }))}
- disabled={controlsBlocked || locked}
- onSelect={onSelect}
- />
- );
-}
-
-/**
- * Composer-left execution switches: how the agent works (mode) and how much it
- * may do unattended (approval level), side by side in one capsule.
- */
-export function ComposerSwitches({
- t,
- mode,
- planningLive,
- permissionMode,
- controlsBlocked,
- onSelectMode,
- onSelectPermission,
-}: {
- t: TFunction;
- mode: Mode;
- planningLive: boolean;
- permissionMode: PermissionMode;
- controlsBlocked: boolean;
- onSelectMode: (mode: Mode) => void;
- onSelectPermission: (mode: SelectablePermission) => void;
-}) {
- return (
- <div className="composer-switches">
- <SegmentedControl
- className="composer-mode-switch"
- ariaLabel={t("settings.mode")}
- value={mode}
- planning={planningLive}
- segments={MODE_CYCLE.map((candidate) => ({
- value: candidate,
- label: t(MODE_LABEL_KEYS[candidate]),
- icon: <ModeIcon mode={candidate} />,
- }))}
- disabled={controlsBlocked}
- onSelect={onSelectMode}
- />
- <span className="composer-switch-divider" aria-hidden="true" />
- {/* Goal runs fully automated, so the approval switch reports that state
- instead of offering choices the mode would override. */}
- <ComposerPermissionSwitch
- t={t}
- permissionMode={permissionMode}
- locked={mode === "goal"}
- controlsBlocked={controlsBlocked}
- onSelect={onSelectPermission}
- />
- </div>
- );
-}
diff --git a/apps/desktop/src/features/chat/composer/ComposerToolbar.tsx b/apps/desktop/src/features/chat/composer/ComposerToolbar.tsx
index ae74a95a4..dea7eee18 100644
--- a/apps/desktop/src/features/chat/composer/ComposerToolbar.tsx
+++ b/apps/desktop/src/features/chat/composer/ComposerToolbar.tsx
@@ -1,3 +1,4 @@
+import type { Dispatch, SetStateAction } from "react";
import type { TFunction } from "i18next";
import {
keybindingDisplayParts,
@@ -8,7 +9,7 @@ import {
type PluginComposerTransformMeta,
} from "@pi-desktop/shared";
import type { AppState } from "../../../stores/app-store";
-import { ComposerSwitches } from "./ComposerSwitches";
+import { ComposerPermissionPicker } from "./ComposerPermissionPicker";
import { ContextUsageInspector } from "../../../components/ContextUsageInspector";
import { ComposerControlSlots } from "./ComposerControlSlots";
import { TooltipButton } from "../../../components/ui";
@@ -19,8 +20,13 @@ import {
IconStop,
IconUndo2,
} from "../../../components/icons";
+import { ModeIcon } from "./ComposerModeIcon";
import { LiveVoiceControls } from "../../voice/live/LiveVoiceControls";
import { ComposerModelPicker } from "./ComposerModelPicker";
+import {
+ MODE_LABEL_KEYS,
+ nextMode,
+} from "./model";
import type { useComposerModelMenu } from "./hooks/useComposerModelMenu";
type ModelMenuController = ReturnType<typeof useComposerModelMenu>;
@@ -34,6 +40,8 @@ export type ComposerToolbarProps = {
modelId?: string;
thinkingLevel: SessionThinkingLevel;
composerPermissionMode: Exclude<PermissionMode, "inherit">;
+ permissionOpen: boolean;
+ setPermissionOpen: Dispatch<SetStateAction<boolean>>;
controlsBlocked: boolean;
localToolsAllowed?: boolean;
attachmentsAllowed?: boolean;
@@ -71,6 +79,8 @@ export function ComposerToolbar({
modelId,
thinkingLevel,
composerPermissionMode,
+ permissionOpen,
+ setPermissionOpen,
controlsBlocked,
localToolsAllowed = true,
attachmentsAllowed = true,
@@ -111,6 +121,7 @@ export function ComposerToolbar({
ariaLabel={t("chat.addFiles")}
disabled={controlsBlocked || pasting || !attachmentsAllowed}
onClick={() => {
+ setPermissionOpen(false);
void pickAndAttach();
}}
>
@@ -118,14 +129,18 @@ export function ComposerToolbar({
</TooltipButton>
</div>
{localToolsAllowed ? <LiveVoiceControls t={t} workSessionId={workSessionId} /> : null}
- <ComposerSwitches
- t={t}
- mode={mode}
- planningLive={planningLive}
- permissionMode={composerPermissionMode}
- controlsBlocked={controlsBlocked}
- onSelectMode={async (next) => {
+ <TooltipButton
+ type="button"
+ className="icon-btn mode-chip composer-mode-chip"
+ data-mode={mode}
+ data-planning={planningLive ? "true" : undefined}
+ tooltip={planningLive ? t(`${mode}.planning`) : t("settings.mode")}
+ ariaLabel={planningLive ? t(`${mode}.planning`) : t("settings.mode")}
+ disabled={controlsBlocked}
+ onClick={async () => {
modelMenu.setOpen(false);
+ setPermissionOpen(false);
+ const next: Mode = nextMode(mode);
try {
await configureActiveSession({
mode: next,
@@ -139,23 +154,33 @@ export function ComposerToolbar({
});
}
}}
- onSelectPermission={async (candidate) => {
- modelMenu.setOpen(false);
- try {
- await configureActiveSession({
- mode,
- providerId,
- modelId,
- thinkingLevel,
- permissionMode: candidate,
- });
- } catch (error) {
- showToast(error instanceof Error ? error.message : String(error), {
- variant: "error",
- });
- }
- }}
- />
+ >
+ <span className="composer-mode-chip-face" key={mode}>
+ <ModeIcon mode={mode} />
+ <span className="composer-mode-chip-label text-sm">
+ {t(MODE_LABEL_KEYS[mode])}
+ </span>
+ </span>
+ </TooltipButton>
+ <ComposerPermissionPicker t={t} mode={mode}
+ composerPermissionMode={composerPermissionMode}
+ permissionOpen={permissionOpen} setPermissionOpen={setPermissionOpen}
+ controlsBlocked={controlsBlocked} onCloseOtherMenus={() => modelMenu.setOpen(false)}
+ onSelect={async (candidate) => {
+ try {
+ await configureActiveSession({
+ mode,
+ providerId,
+ modelId,
+ thinkingLevel,
+ permissionMode: candidate,
+ });
+ } catch (error) {
+ showToast(error instanceof Error ? error.message : String(error), {
+ variant: "error",
+ });
+ }
+ }} />
{localToolsAllowed ? <ComposerControlSlots side="left" /> : null}
</div>
@@ -171,6 +196,7 @@ export function ComposerToolbar({
selectedProviderId={providerId}
selectedModelId={modelId}
controlsBlocked={controlsBlocked}
+ onCloseOtherMenus={() => setPermissionOpen(false)}
/>
{composerTransforms.map((transform) => {
const key = `${transform.pluginId}/${transform.id}`;
diff --git a/apps/desktop/src/features/chat/composer/model.ts b/apps/desktop/src/features/chat/composer/model.ts
index 787283b91..cd6c1e63b 100644
--- a/apps/desktop/src/features/chat/composer/model.ts
+++ b/apps/desktop/src/features/chat/composer/model.ts
@@ -68,6 +68,11 @@ export type ComposerFileReference = {
};
+export function nextMode(mode: Mode): Mode {
+ const index = MODE_CYCLE.indexOf(mode);
+ return MODE_CYCLE[(index + 1) % MODE_CYCLE.length] ?? "agent";
+}
+
export function isThinkingLevel(value: unknown): value is SessionThinkingLevel {
return isSessionThinkingLevel(value);
}
diff --git a/apps/desktop/src/features/scheduled/ScheduledExecutionSettings.tsx b/apps/desktop/src/features/scheduled/ScheduledExecutionSettings.tsx
index b0542f635..bddb8648a 100644
--- a/apps/desktop/src/features/scheduled/ScheduledExecutionSettings.tsx
+++ b/apps/desktop/src/features/scheduled/ScheduledExecutionSettings.tsx
@@ -1,4 +1,4 @@
-import { useMemo } from "react";
+import { useEffect, useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import {
type GlobalPermissionMode,
@@ -10,7 +10,7 @@ import { IconChat, IconFolder } from "../../components/icons";
import { SettingsMenuSelect } from "../../components/settings/SettingsMenuSelect";
import { useAppStore } from "../../stores/app-store";
import { ScheduledModelPicker } from "./ScheduledModelPicker";
-import { ComposerPermissionSwitch } from "../chat/composer/ComposerSwitches";
+import { ComposerPermissionPicker } from "../chat/composer/ComposerPermissionPicker";
export type ScheduledModelSelection = {
@@ -49,6 +49,8 @@ export function ScheduledExecutionSettings({
onSessionModeChange: (mode: ScheduledSessionMode) => void;
}) {
const { t } = useTranslation();
+ const [permissionOpen, setPermissionOpen] = useState(false);
+ useEffect(() => { if (busy) setPermissionOpen(false); }, [busy]);
const currentWorkspacePath = useAppStore((state) => state.workspace?.path ?? "");
const projectOptions = useMemo(() => {
const seen = new Set<string>();
@@ -84,10 +86,10 @@ export function ScheduledExecutionSettings({
}
onChange={onWorkspaceChange}
/>
- <ComposerPermissionSwitch
- t={t}
- permissionMode={permissionMode}
- controlsBlocked={busy}
+ <ComposerPermissionPicker t={t} mode="agent"
+ composerPermissionMode={permissionMode}
+ permissionOpen={permissionOpen} setPermissionOpen={setPermissionOpen}
+ controlsBlocked={busy} onCloseOtherMenus={() => {}}
onSelect={onPermissionChange} />
<SettingsMenuSelect
className="scheduled-execution-session"
diff --git a/apps/desktop/src/features/scheduled/ScheduledModelPicker.tsx b/apps/desktop/src/features/scheduled/ScheduledModelPicker.tsx
index 58dcf7d15..4e210031e 100644
--- a/apps/desktop/src/features/scheduled/ScheduledModelPicker.tsx
+++ b/apps/desktop/src/features/scheduled/ScheduledModelPicker.tsx
@@ -52,7 +52,7 @@ export function ScheduledModelPicker({ value, disabled, onChange }: {
return <ComposerModelPicker t={t} controller={controller} modelLabel={label}
thinkingLabel={thinkingLevel} thinkingLevel={thinkingLevel}
selectedProviderId={value.providerId} selectedModelId={value.modelId}
- controlsBlocked={disabled}
+ controlsBlocked={disabled} onCloseOtherMenus={() => {}}
rootActions={value.providerId ? <button type="button" className="composer-plus-item"
role="menuitem" disabled={disabled} onClick={() => {onChange({}); controller.setOpen(false);}}>
{t("settings.defaultModel")}
diff --git a/apps/desktop/src/styles/composer-menus.css b/apps/desktop/src/styles/composer-menus.css
index 35bbe1cdb..150670417 100644
--- a/apps/desktop/src/styles/composer-menus.css
+++ b/apps/desktop/src/styles/composer-menus.css
@@ -43,6 +43,32 @@
flex: 0 1 auto;
}
+/* Permission-mode chip menu (D115): anchored left above the mode chips. */
+.composer-permission {
+ position: relative;
+}
+
+.composer-permission-menu {
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: auto;
+ bottom: auto;
+ z-index: 40;
+ width: min(120px, calc(100vw - 24px));
+ max-height: min(520px, calc(100vh - 92px));
+ overflow-y: auto;
+ padding: 6px;
+ border-radius: var(--radius-lg);
+ background: var(--ds-bg-elevated-opaque);
+ box-shadow: var(--ds-shadow-dialog);
+ border: 1px solid var(--ds-border-subtle);
+ color: var(--ds-text-primary);
+ opacity: 0;
+ pointer-events: none;
+ visibility: hidden;
+}
+
.composer-model-menu {
position: fixed;
top: 0;
@@ -68,6 +94,7 @@
visibility: hidden;
}
+.composer-permission-menu.is-open,
.composer-model-menu.is-open {
opacity: 1;
pointer-events: auto;
diff --git a/apps/desktop/src/styles/composer-switches.css b/apps/desktop/src/styles/composer-switches.css
deleted file mode 100644
index caf594d1b..000000000
--- a/apps/desktop/src/styles/composer-switches.css
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- Composer execution switches: how the agent works (Agent / Plan / Goal) and
- how much it may do unattended (Ask / Accept edits / Auto).
-
- Both are always-visible segmented controls. Every option is one click away,
- and the committed pair is readable without opening anything — the previous
- mode chip cycled on click and the approval chip hid its choices behind a
- menu, so reaching a specific state took repeated actions.
-*/
-.composer-switches {
- display: inline-flex;
- flex: 0 1 auto;
- min-width: 0;
- align-items: center;
- gap: 5px;
- height: 28px;
- padding: 2px;
- border-radius: var(--radius-full);
- background: var(--ds-tile);
-}
-
-.composer-switch-divider {
- flex: 0 0 auto;
- width: 1px;
- height: 12px;
- background: var(--ds-border-default);
-}
-
-.composer-segment-group {
- display: inline-flex;
- flex: 0 1 auto;
- min-width: 0;
- align-items: center;
- gap: 2px;
-}
-
-.composer-segment {
- display: inline-flex;
- flex: 0 1 auto;
- min-width: 0;
- height: 24px;
- align-items: center;
- gap: 5px;
- padding: 0 9px;
- border-radius: var(--radius-full);
- color: var(--ds-text-secondary);
- font-size: var(--text-sm);
- line-height: var(--leading-compact);
- white-space: nowrap;
- cursor: pointer;
- transition:
- background var(--motion-duration-fast) var(--motion-ease-out),
- color var(--motion-duration-fast) var(--motion-ease-out);
-}
-
-.composer-segment:hover:not(:disabled) {
- color: var(--ds-text-primary);
- background: var(--ds-tile-hover);
-}
-
-.composer-segment:focus-visible {
- outline: 2px solid var(--ds-accent);
- outline-offset: 1px;
-}
-
-/* The committed option sits on a raised plate, so the row reads as a choice
- rather than three equal buttons. */
-.composer-segment.is-active {
- color: var(--ds-text-primary);
- background: var(--ds-raised);
- box-shadow: var(--ds-raised-shadow);
- font-weight: var(--font-weight-medium);
-}
-
-.composer-segment-icon {
- display: inline-flex;
- flex: 0 0 auto;
- align-items: center;
-}
-
-/*
- Only the committed option spells itself out; the other options stay glyphs
- with their names one hover away. Six spelled-out choices made the cluster
- wider than the controls it replaced.
-*/
-.composer-segment:not(.is-active) {
- padding: 0 7px;
-}
-
-.composer-segment:not(.is-active) .composer-segment-label {
- display: none;
-}
-
-.composer-segment-label {
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.composer-segment:disabled {
- cursor: default;
- opacity: 0.45;
-}
-
-/* Goal pins the approval level to Auto: the locked chip still reports it. */
-.composer-segment.is-active:disabled {
- background: var(--ds-tile);
- box-shadow: none;
- opacity: 1;
-}
diff --git a/apps/desktop/src/styles/composer.css b/apps/desktop/src/styles/composer.css
index 414d5af19..a3742d225 100644
--- a/apps/desktop/src/styles/composer.css
+++ b/apps/desktop/src/styles/composer.css
@@ -224,18 +224,38 @@
}
}
-/* A live planning turn pulses the committed mode's glyph instead of parking a
- second status row above the composer. */
-.composer-mode-switch[data-planning="true"] .composer-segment.is-active {
- color: var(--ds-text-primary);
+.composer-mode-chip-face {
+ display: inline-flex;
+ min-width: 0;
+ max-width: 100%;
+ align-items: center;
+ gap: 6px;
+ animation: composer-mode-face-in var(--motion-duration-fast)
+ var(--motion-ease-out) both;
+}
+
+.composer-mode-chip[data-planning="true"] {
+ color: var(--ds-text-primary) !important;
}
-.composer-mode-switch[data-planning="true"] .composer-segment.is-active svg {
- color: var(--ds-purple);
+.composer-mode-chip[data-planning="true"] svg {
+ color: var(--ds-purple) !important;
animation: composer-mode-planning-pulse 1.2s var(--motion-ease-standard)
2;
}
+@keyframes composer-mode-face-in {
+ from {
+ opacity: 0;
+ transform: translateX(4px);
+ }
+
+ to {
+ opacity: 1;
+ transform: none;
+ }
+}
+
@keyframes composer-mode-planning-pulse {
0%,
100% {
@@ -919,7 +939,7 @@
}
@media (prefers-reduced-motion: reduce) {
- .composer-mode-switch[data-planning="true"] .composer-segment.is-active svg {
+ .composer-mode-chip[data-planning="true"] svg {
animation: none;
}
diff --git a/apps/desktop/src/styles/globals.css b/apps/desktop/src/styles/globals.css
index 962e02b8f..b37ad23b5 100644
--- a/apps/desktop/src/styles/globals.css
+++ b/apps/desktop/src/styles/globals.css
@@ -14,7 +14,6 @@
@import "./chrome.css";
@import "./chat-shell.css";
@import "./composer.css";
-@import "./composer-switches.css";
@import "./sidebar-threads.css";
@import "./messages.css";
@import "./prose.css";
diff --git a/apps/desktop/src/styles/responsive.css b/apps/desktop/src/styles/responsive.css
index f6c4bc469..bc2ff2c7d 100644
--- a/apps/desktop/src/styles/responsive.css
+++ b/apps/desktop/src/styles/responsive.css
@@ -75,16 +75,6 @@
display: none;
}
- /* At the floor even the committed option drops its label; the switches keep
- the same three options and the same one-click reach. */
- .composer-segment {
- padding: 0 6px;
- }
-
- .composer-segment-label {
- display: none;
- }
-
.composer-right .context-inspector-trigger {
gap: 0;
padding-inline: 3px;
@@ -157,7 +147,8 @@
}
.composer-placeholder,
- .composer-mode-switch[data-planning="true"] .composer-segment.is-active svg {
+ .composer-mode-chip-face,
+ .composer-mode-chip[data-planning="true"] svg {
animation: none;
}
diff --git a/apps/desktop/src/styles/theme-overrides.css b/apps/desktop/src/styles/theme-overrides.css
index 5ddf4d4a5..8ef838815 100644
--- a/apps/desktop/src/styles/theme-overrides.css
+++ b/apps/desktop/src/styles/theme-overrides.css
@@ -215,6 +215,23 @@
white-space: nowrap;
}
+/* Keep the Agent/Plan/Goal control stable while its localized label changes. */
+.composer-mode-chip {
+ width: 88px;
+ min-width: 88px;
+ max-width: 88px;
+ flex: 0 0 88px;
+ justify-content: flex-start;
+}
+
+.composer-mode-chip-label {
+ min-width: 0;
+ overflow: hidden;
+ text-align: start;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
.mode-chip > span {
min-width: 0;
overflow: hidden;
@@ -223,6 +240,7 @@
}
.mode-chip > span,
+.composer-mode-chip-label,
.composer-model-thinking-model,
.composer-model-thinking-level {
line-height: var(--leading-compact);
@@ -233,6 +251,17 @@
color: var(--ds-text-primary) !important;
}
+/* Goal keeps the same chip geometry while presenting a non-editable Auto state. */
+.composer-permission .mode-chip:disabled {
+ cursor: default;
+ opacity: 1;
+}
+
+.composer-permission .mode-chip:disabled:hover {
+ background: transparent !important;
+ color: var(--ds-text-secondary) !important;
+}
+
/* Tone and truncation only. The label-driven chip sets its own padding with
`!important`, so the inline padding that used to sit here only ever widened
the icon-only controls in this row. */
diff --git a/apps/desktop/test/composer-chip-descenders.test.mjs b/apps/desktop/test/composer-chip-descenders.test.mjs
index 60d6e2e6f..d8ae43646 100644
--- a/apps/desktop/test/composer-chip-descenders.test.mjs
+++ b/apps/desktop/test/composer-chip-descenders.test.mjs
@@ -58,33 +58,37 @@ test("composer runtime chips keep compact line-height for descenders", () => {
);
});
-test("mode switch labels stay single-line and ellipsize instead of reflowing", () => {
- // Options render from the canonical mode order, so the row no longer depends
- // on one fixed chip width sized for the longest built-in label.
- assert.match(composerSource, /MODE_CYCLE\.map\(\(candidate\) => \(\{/);
- assert.doesNotMatch(styles, /\.composer-mode-chip\s*\{/);
+test("mode selector reserves the longest localized label width", () => {
assert.match(
- styles,
- /\.composer-segment-label\s*\{[\s\S]*?text-overflow:\s*ellipsis;/,
+ composerSource,
+ /className="icon-btn mode-chip composer-mode-chip"/,
);
+
+ const block = styles.match(/\.composer-mode-chip\s*\{[^}]+\}/)?.[0] ?? "";
+ assert.match(block, /width:\s*88px;/);
+ assert.match(block, /min-width:\s*88px;/);
+ assert.match(block, /max-width:\s*88px;/);
+ assert.match(block, /flex:\s*0 0 88px;/);
+ assert.match(styles, /\.composer-mode-chip-label\s*\{[\s\S]*?text-overflow:\s*ellipsis;/);
});
-test("the committed mode pulses while planning is live", () => {
- assert.match(composerSource, /planning=\{planningLive\}/);
+test("mode chip cross-fades on switch and pulses while planning is live", () => {
+ assert.match(composerSource, /data-planning=\{planningLive \? "true" : undefined\}/);
+ assert.match(composerSource, /className="composer-mode-chip-face"/);
assert.match(
composerSource,
- /data-planning=\{planning \? "true" : undefined\}/,
+ /const planningLive =\s*isRunning &&\s*planningState === "planning" &&\s*\(mode === "plan" \|\| mode === "goal"\)/,
);
assert.match(
- composerSource,
- /const planningLive =\s*isRunning &&\s*planningState === "planning" &&\s*\(mode === "plan" \|\| mode === "goal"\)/,
+ styles,
+ /\.composer-mode-chip-face\s*\{[\s\S]*?animation:\s*composer-mode-face-in/,
);
assert.match(
styles,
- /\.composer-mode-switch\[data-planning="true"\]\s*\.composer-segment\.is-active svg\s*\{[\s\S]*?animation:\s*composer-mode-planning-pulse/,
+ /\.composer-mode-chip\[data-planning="true"\] svg\s*\{[\s\S]*?animation:\s*composer-mode-planning-pulse/,
);
assert.match(
styles,
- /prefers-reduced-motion:\s*reduce[\s\S]*?\.composer-mode-switch\[data-planning="true"\]\s*\.composer-segment\.is-active svg\s*[,{]/,
+ /prefers-reduced-motion:\s*reduce[\s\S]*?\.composer-mode-chip-face,/,
);
});
diff --git a/apps/desktop/test/composer-mode-switches.test.mjs b/apps/desktop/test/composer-mode-switches.test.mjs
deleted file mode 100644
index cd67268c9..000000000
--- a/apps/desktop/test/composer-mode-switches.test.mjs
+++ /dev/null
@@ -1,116 +0,0 @@
-import assert from "node:assert/strict";
-import test from "node:test";
-import { composerToolbar } from "./helpers/composer-toolbar.mjs";
-import { readComposerModule } from "./helpers/source-contracts.mjs";
-import { slotSsr } from "./helpers/slot-ssr.mjs";
-
-/*
- * The Composer execution switches replaced two multi-step controls: a mode chip
- * that cycled Agent -> Plan -> Goal on each click, and an approval chip that hid
- * its three levels behind a menu. Both are now inline radiogroups where every
- * option is one click away, and the committed pair is readable at rest.
- */
-
-const switchesSource = await readComposerModule("ComposerSwitches.tsx");
-
-async function toolbar(t, overrides = {}) {
- const ssr = await slotSsr(t);
- return (await composerToolbar(t, ssr, overrides))();
-}
-
-/** Radios of one labelled group, in render order. */
-function radios(html, groupLabel) {
- const start = html.indexOf(`aria-label="${groupLabel}`);
- assert.ok(start >= 0, `missing group: ${groupLabel}`);
- const group = html.slice(start, html.indexOf("</div>", start));
- return [...group.matchAll(/<button[^>]*role="radio"[^>]*>/g)].map(([tag]) => ({
- label: tag.match(/aria-label="([^"]*)"/)?.[1],
- checked: /aria-checked="true"/.test(tag),
- active: /composer-segment is-active/.test(tag),
- }));
-}
-
-test("mode and approval render as two labelled radiogroups, not menus", async (t) => {
- const html = await toolbar(t, { mode: "plan", composerPermissionMode: "accept-edits" });
- assert.match(html, /role="radiogroup" aria-label="settings\.mode"/);
- assert.match(html, /role="radiogroup" aria-label="chat\.permissionMode"/);
- // Only the cluster itself: the model picker on the right still opens a menu.
- const cluster = html.slice(
- html.indexOf("composer-switches"),
- html.indexOf('<div class="composer-right">'),
- );
- assert.ok(cluster.length > 0);
- assert.doesNotMatch(cluster, /aria-haspopup|role="menu"/);
-
- const modes = radios(html, "settings.mode");
- assert.deepEqual(
- modes.map((radio) => radio.label),
- ["settings.modeAgent", "settings.modePlan", "settings.modeGoal"],
- );
- assert.deepEqual(modes.map((radio) => radio.checked), [false, true, false]);
- assert.deepEqual(modes.map((radio) => radio.active), [false, true, false]);
-
- const approvals = radios(html, "chat.permissionMode");
- assert.deepEqual(
- approvals.map((radio) => radio.label),
- ["chat.permissionAsk", "chat.permissionAcceptEdits", "chat.permissionAuto"],
- );
- // Plain markup is escaped in the attribute, so match the checked flags only.
- assert.deepEqual(approvals.map((radio) => radio.checked), [false, true, false]);
-});
-
-test("each option commits on a single click", async (t) => {
- const html = await toolbar(t, { mode: "agent", composerPermissionMode: "ask" });
- // Every option is rendered as its own target; nothing is hidden behind a
- // second surface, and no chip advances to "the next" state.
- assert.equal(radios(html, "settings.mode").length, 3);
- assert.equal(radios(html, "chat.permissionMode").length, 3);
- assert.match(
- switchesSource,
- /onClick=\{\(\) => \{\s*\n\s*if \(!active\) onSelect\(segment\.value\);/,
- );
- assert.doesNotMatch(switchesSource, /nextMode|AnchoredMenu|role="menu"/);
-});
-
-test("arrow keys move to the neighbouring option and commit it", () => {
- assert.match(
- switchesSource,
- /const SELECT_KEYS = new Set\(\["ArrowLeft", "ArrowRight", "Home", "End"\]\)/,
- );
- assert.match(switchesSource, /role="radiogroup"[\s\S]*?onKeyDown=\{handleKeyDown\}/);
- // Selection follows focus, exactly like a native radio group.
- assert.match(switchesSource, /target\.focus\(\);[\s\S]*?target\.click\(\);/);
- // Roving tabindex keeps one tab stop per group.
- assert.match(switchesSource, /tabIndex=\{active \? 0 : -1\}/);
-});
-
-test("Goal locks the approval switch to Auto and says why", async (t) => {
- const html = await toolbar(t, { mode: "goal", composerPermissionMode: "ask" });
- const start = html.indexOf('aria-label="chat.permissionMode');
- const group = html.slice(start, html.indexOf("</div>", start));
- // Every approval option is disabled, Auto is the checked one, and the group
- // still names the locked state for assistive technology.
- assert.equal([...group.matchAll(/<button[^>]*role="radio"[^>]*>/g)].length, 3);
- for (const [tag] of group.matchAll(/<button[^>]*role="radio"[^>]*>/g)) {
- assert.match(tag, /disabled=""/);
- }
- const approvals = radios(html, "chat.permissionMode");
- assert.deepEqual(approvals.map((radio) => radio.checked), [false, false, true]);
- assert.match(html, /aria-label="chat\.permissionMode · /);
-});
-
-test("the switches stay in flow while the toolbar narrows", async () => {
- const { loadStyles } = await import("./helpers/styles.mjs");
- const styles = await loadStyles();
- // The committed option keeps its label the longest, so the current pair is
- // readable at every toolbar width; the others collapse to their glyphs.
- assert.match(
- styles,
- /\.composer-segment:not\(\.is-active\) \.composer-segment-label\s*\{\s*display:\s*none;/,
- );
- assert.match(
- styles,
- /@container composer-stack \(max-width: 450px\)[\s\S]*?\.composer-segment-label\s*\{\s*display:\s*none;/,
- );
- assert.match(styles, /\.composer-switches\s*\{[\s\S]*?background:\s*var\(--ds-tile\);/);
-});
diff --git a/apps/desktop/test/composer-paste-files.test.mjs b/apps/desktop/test/composer-paste-files.test.mjs
index fdf9b529f..c3ecf5e4a 100644
--- a/apps/desktop/test/composer-paste-files.test.mjs
+++ b/apps/desktop/test/composer-paste-files.test.mjs
@@ -139,9 +139,9 @@ test("picker attachments materialize a session before importing paths", () => {
test("composer opens one unified file picker directly from the plus button", () => {
const leftStart = composer.indexOf('<div className="composer-left">');
const plusIndex = composer.indexOf('tooltip={t("chat.addFiles")}', leftStart);
- const modeIndex = composer.indexOf("<ComposerSwitches", leftStart);
+ const modeIndex = composer.indexOf("composer-mode-chip", leftStart);
assert.ok(leftStart >= 0 && plusIndex > leftStart && modeIndex > leftStart);
- assert.ok(plusIndex < modeIndex, "upload must precede the execution switches");
+ assert.ok(plusIndex < modeIndex, "upload must precede the agent mode chip");
assert.match(composer, /void pickAndAttach\(\);/);
assert.match(composer, /const pickAndAttach = async \(\) =>/);
assert.match(composer, /const result = await api\.pickFiles\(\);/);
diff --git a/apps/desktop/test/composer-permission-mode.test.mjs b/apps/desktop/test/composer-permission-mode.test.mjs
index 33ec0f9f7..f6921c49f 100644
--- a/apps/desktop/test/composer-permission-mode.test.mjs
+++ b/apps/desktop/test/composer-permission-mode.test.mjs
@@ -1,57 +1,43 @@
-import { readComposerSource, readComposerModule } from "./helpers/source-contracts.mjs";
+import { readComposerSource } from "./helpers/source-contracts.mjs";
import assert from "node:assert/strict";
-import { loadStyles } from "./helpers/styles.mjs";
+import { readFile } from "node:fs/promises";
import test from "node:test";
const composerSource = await readComposerSource();
-const switchesSource = await readComposerModule("ComposerSwitches.tsx");
-const styles = await loadStyles();
-test("Agent and Plan offer the effective approval levels as one-click options", () => {
- // The three selectable levels are rendered from one ordered list, and every
- // option is a radio the user reaches in a single action.
- assert.match(
- switchesSource,
- /const SELECTABLE_PERMISSIONS: readonly SelectablePermission\[\] = \[[\s\S]*?"ask",[\s\S]*?"accept-edits",[\s\S]*?"auto",[\s\S]*?\];/,
+test("Agent and Plan permission menus present only effective selectable modes", () => {
+ const permissionControlSource = composerSource.slice(
+ composerSource.indexOf('className="composer-permission"'),
+ composerSource.indexOf('<div className="composer-right">'),
);
- assert.match(switchesSource, /role="radiogroup"/);
- assert.match(switchesSource, /role="radio"/);
- assert.match(switchesSource, /aria-checked=\{active\}/);
- assert.match(switchesSource, /aria-label=\{segment\.label\}/);
+
assert.match(
- switchesSource,
- /label: t\(PERMISSION_MODE_I18N_KEYS\[candidate\]\)/,
+ permissionControlSource,
+ /\["ask", "accept-edits", "auto"\] as const/,
);
- // `inherit` is a task-draft default, never a Composer option.
- assert.doesNotMatch(switchesSource, /PERMISSION_MODE_I18N_KEYS\["inherit"\]/);
-});
-
-test("Goal keeps the approval switch visible but fixed to Full auto", () => {
assert.match(
- composerSource,
- /const composerPermissionMode: Exclude<PermissionMode, "inherit"> =\s*\n\s*mode === "goal" \? "auto" : effectivePermissionMode;/,
+ permissionControlSource,
+ /aria-checked=\{composerPermissionMode === candidate\}/,
);
- assert.match(switchesSource, /locked=\{mode === "goal"\}/);
assert.match(
- switchesSource,
- /const effectivePermission: SelectablePermission = locked\s*\n?\s*\? "auto"/,
+ permissionControlSource,
+ /\{t\(PERMISSION_MODE_I18N_KEYS\[candidate\]\)\}/,
);
- assert.match(switchesSource, /disabled=\{controlsBlocked \|\| locked\}/);
- // The locked group states why it cannot be changed instead of silently
- // ignoring clicks.
- assert.match(switchesSource, /`\$\{t\("chat\.permissionMode"\)\} · \$\{t\("goal\.autoWarning"\)\}`/);
+ assert.doesNotMatch(permissionControlSource, /permissionInherit/);
+ assert.doesNotMatch(permissionControlSource, /\["inherit",/);
});
-test("approval selection commits through the active-session configuration path", () => {
- const toolbar = composerSource.slice(
- composerSource.indexOf("<ComposerSwitches"),
- composerSource.indexOf("<ComposerControlSlots side=\"left\" />"),
+test("Goal keeps the permission chip visible but fixes it to Full auto", () => {
+ const permissionControlSource = composerSource.slice(
+ composerSource.indexOf('className="composer-permission"'),
+ composerSource.indexOf('<div className="composer-right">'),
+ );
+
+ assert.match(
+ composerSource,
+ /const composerPermissionMode: Exclude<PermissionMode, "inherit"> =\s*\n\s*mode === "goal" \? "auto" : effectivePermissionMode;/,
);
- assert.match(toolbar, /onSelectPermission=\{async \(candidate\) => \{/);
- assert.match(toolbar, /permissionMode: candidate,/);
- assert.match(toolbar, /onSelectMode=\{async \(next\) => \{/);
- assert.match(toolbar, /mode: next,/);
- // The old permission chip opened a menu; nothing may reintroduce it.
- assert.doesNotMatch(styles, /\.composer-permission-menu\s*\{/);
- assert.doesNotMatch(composerSource, /composer-permission-menu/);
+ assert.match(permissionControlSource, /mode === "goal" \? undefined : "menu"/);
+ assert.match(permissionControlSource, /disabled=\{controlsBlocked \|\| mode === "goal"\}/);
+ assert.match(permissionControlSource, /permissionOpen && mode !== "goal"/);
});
diff --git a/apps/desktop/test/fixed-dropdown-surfaces.test.mjs b/apps/desktop/test/fixed-dropdown-surfaces.test.mjs
index 982d5d605..21f019ea3 100644
--- a/apps/desktop/test/fixed-dropdown-surfaces.test.mjs
+++ b/apps/desktop/test/fixed-dropdown-surfaces.test.mjs
@@ -42,6 +42,7 @@ const dropdownSurfaces = [
"agent-capability-menu",
"scope-compact-menu",
"scope-popover",
+ "composer-permission-menu",
"composer-model-menu",
"plan-approval-menu",
"composer-autocomplete",
diff --git a/apps/desktop/test/helpers/composer-toolbar.mjs b/apps/desktop/test/helpers/composer-toolbar.mjs
index 043c52e1a..ba05fa743 100644
--- a/apps/desktop/test/helpers/composer-toolbar.mjs
+++ b/apps/desktop/test/helpers/composer-toolbar.mjs
@@ -21,6 +21,8 @@ export const TOOLBAR_PROPS = {
modelId: "model-1",
thinkingLevel: "off",
composerPermissionMode: "ask",
+ permissionOpen: false,
+ setPermissionOpen: noop,
controlsBlocked: false,
pasting: false,
pickAndAttach: idle,
diff --git a/apps/desktop/test/idle-status-animations.test.mjs b/apps/desktop/test/idle-status-animations.test.mjs
index b56b6cd80..23daf3c37 100644
--- a/apps/desktop/test/idle-status-animations.test.mjs
+++ b/apps/desktop/test/idle-status-animations.test.mjs
@@ -58,7 +58,7 @@ const IDLE_INDICATORS = [
".thread-item-status.running::before",
".sidebar-session-hover-card-session-link-status::before",
".thread-item-status.permission::before",
- '.composer-mode-switch[data-planning="true"] .composer-segment.is-active svg',
+ '.composer-mode-chip[data-planning="true"] svg',
".backend-banner.warn .backend-dot",
];
diff --git a/apps/desktop/test/plan-mode-source-contract.test.mjs b/apps/desktop/test/plan-mode-source-contract.test.mjs
index 06fac384e..985872561 100644
--- a/apps/desktop/test/plan-mode-source-contract.test.mjs
+++ b/apps/desktop/test/plan-mode-source-contract.test.mjs
@@ -140,7 +140,7 @@ test("the component spec assigns mode ownership to Composer", () => {
assert.doesNotMatch(topbarSpec, /model picker/);
assert.doesNotMatch(topbarSpec, /Agent \| Plan|mode toggle|mode indicator/);
assert.match(composerSpec, /combined model ×\s+reasoning-level control/);
- assert.match(composerSpec, /Composer-left Agent\/Plan\/Goal switch is the sole mode/);
+ assert.match(composerSpec, /Composer-left Agent\/Plan\/Goal chip is the sole mode/);
assert.match(composerSpec, /--ds-bg-composer/);
});
diff --git a/apps/desktop/test/plugin-composer-slots.test.mjs b/apps/desktop/test/plugin-composer-slots.test.mjs
index a2d7cfc28..bfa72803f 100644
--- a/apps/desktop/test/plugin-composer-slots.test.mjs
+++ b/apps/desktop/test/plugin-composer-slots.test.mjs
@@ -16,17 +16,7 @@ import { parseProbe, probed, propsProbe, slotMounts, slotSsr } from "./helpers/s
/** The toolbar's own controls below, by label. */
// Live Voice's idle entry is conditional on the feature setting and therefore
// is not a permanent host slot in this disabled-by-default fixture.
-// The execution switches render one radio per option, so the left row shows the
-// three modes and the three approval levels as single-click targets.
-const HOST_LEFT = [
- "chat.addFiles",
- "settings.modeAgent",
- "settings.modePlan",
- "settings.modeGoal",
- "chat.permissionAsk",
- "chat.permissionAcceptEdits",
- "chat.permissionAuto",
-];
+const HOST_LEFT = ["chat.addFiles", "settings.mode", "chat.permissionMode"];
const HOST_RIGHT = ["context", "chat.model: Model. chat.reasoningLevel: Off", "chat.send"];
async function composer(t, toolbarProps = {}) {
diff --git a/apps/desktop/test/thinking-ui.test.mjs b/apps/desktop/test/thinking-ui.test.mjs
index adabcf2ac..eed489502 100644
--- a/apps/desktop/test/thinking-ui.test.mjs
+++ b/apps/desktop/test/thinking-ui.test.mjs
@@ -15,7 +15,7 @@ import { loadStyles } from "./helpers/styles.mjs";
const composerSource = await readComposerSource();
const composerToolbarSource = await readComposerModule("ComposerToolbar.tsx");
const composerModelPickerSource = await readComposerModule("ComposerModelPicker.tsx");
-const composerSwitchesSource = await readComposerModule("ComposerSwitches.tsx");
+const composerPermissionPickerSource = await readComposerModule("ComposerPermissionPicker.tsx");
const scheduledModelPickerSource = await readFile(
new URL("../src/features/scheduled/ScheduledModelPicker.tsx", import.meta.url),
"utf8",
@@ -96,22 +96,22 @@ test("thinking levels use their canonical English values without i18n", () => {
assert.doesNotMatch(transcriptSource, /thinkingLevel\./);
assert.doesNotMatch(settingsSource, /thinkingLevel\./);
});
+
test("Composer owns the mode and model controls", () => {
const leftToolbar = composerToolbarSource.slice(
composerToolbarSource.indexOf('<div className="composer-left">'),
composerToolbarSource.indexOf('<div className="composer-right">'),
);
+ const modeControl = leftToolbar.indexOf(
+ 'className="icon-btn mode-chip composer-mode-chip"',
+ );
+ const permissionControl = leftToolbar.indexOf("<ComposerPermissionPicker");
const rightToolbar = composerToolbarSource.slice(
composerToolbarSource.indexOf('<div className="composer-right">'),
);
- // Both execution choices live in one inline switch cluster: no menu to open,
- // no chip that cycles through the remaining modes.
- assert.match(leftToolbar, /<ComposerSwitches/);
- assert.doesNotMatch(
- leftToolbar,
- /composer-mode-chip|composer-permission-menu|nextMode/,
- );
+ assert.ok(modeControl >= 0);
+ assert.ok(permissionControl > modeControl);
// The task draft has no session, so its picker must not claim one: with
// `activeSessionId` unset the menu resolves the selected model's binding
// default thinking level instead of pinning the draft to its current value.
diff --git a/docs/spec/04-ux/01-ui-ia.md b/docs/spec/04-ux/01-ui-ia.md
index 9f6e82fa7..fe40a2ce4 100644
--- a/docs/spec/04-ux/01-ui-ia.md
+++ b/docs/spec/04-ux/01-ui-ia.md
@@ -158,10 +158,10 @@ destination, chat as the home surface, tools and permissions inline.
destination — centered empty-home content above a bottom-reserved composer
(D111/D204/D206), bottom-docked in a transcript, with no project / Local / branch
rail (D095).
- Its left-of-input operating-mode switch is the sole active-session control for
+ Its left-of-input operating-mode chip is the sole active-session control for
**Agent**, **Plan**, and **Goal**. Plan shows the same Agent's planning state;
Goal shows the same approval boundary for an outcome contract. Both keep the
- approval switch and expose their host-written immutable `.pi/plan/*.md`
+ permission-mode chip and expose their host-written immutable `.pi/plan/*.md`
or `.pi/goal/*.md` artifact opener after submission. The conversation top bar
retains only the task title and window actions; the Composer owns model and
reasoning selection as well as mode control.
diff --git a/docs/spec/04-ux/07-ui-design-system.md b/docs/spec/04-ux/07-ui-design-system.md
index 4b922bf22..b372f3379 100644
--- a/docs/spec/04-ux/07-ui-design-system.md
+++ b/docs/spec/04-ux/07-ui-design-system.md
@@ -968,9 +968,8 @@ The composer renders only controls connected to the active pi session:
Settings can explicitly configure a level for an unknown or proxied model.
Unknown models do not gain reasoning automatically. Changing provider clamps
or resets the durable session value before the next turn.
-- The left-of-input Composer Agent/Plan/Goal switch is the sole active-session
- mode control, with every mode one click away. Its Ask/Accept edits/Auto
- neighbour sets the approval level the same way. The Composer-right combined
+- The left-of-input Composer Agent/Plan/Goal chip is the sole active-session mode
+ control and cycles Agent → Plan → Goal → Agent. The Composer-right combined
chip owns model and reasoning changes; the top bar has no duplicate mode or
model control. The combined Composer picker closes and is disabled while an active
`pending` Plan or Goal approval exists;
diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.md
index a54c94970..0f770f5a6 100644
--- a/docs/spec/04-ux/08-component-spec.md
+++ b/docs/spec/04-ux/08-component-spec.md
@@ -1544,7 +1544,7 @@ storage but compose into one assistant turn until the next user message.
| Turn start | Send / retry / regenerate re-pins follow mode and jumps to bottom |
| Thinking-only streaming | Transcript opens; the latest thinking disclosure opens unless the user has taken it over; no empty answer bubble; the tail status continues to identify the running turn |
| Running fallback | Compact animated-dot Working row throughout the running turn when no specific runtime phase or planning state is known, including pauses after partial output or completed tools |
-| Running planning | Compact animated-dot Planning / Goal row in that same slot throughout the planning turn; a runtime phase takes precedence, and pending user interaction or turn completion hides it. The committed Composer mode segment pulses |
+| Running planning | Compact animated-dot Planning / Goal row in that same slot throughout the planning turn; a runtime phase takes precedence, and pending user interaction or turn completion hides it. The Composer mode chip pulses |
| Idle | Scrollable; no auto-scroll |
| Permission pending | PermissionCard inserted inline; transcript continues after resolution |
| Context checkpoint | Existing transcript remains visible; compaction adds one divider row after the message it covers and one warning toast |
@@ -2862,31 +2862,22 @@ reasoning-level control.
- Padding: px-4 py-3 inner textarea
- Font: text-sm for Agent, Plan, and Goal; mode changes semantics and tool
controls, not the typography
-- Composer-left holds one inline segmented cluster with two radiogroups:
- Agent/Plan/Goal and Ask/Accept edits/Auto. Every option is its own target, so
- any mode or approval level is one click away — no menu round-trip and no chip
- that advances through the remaining states. Each segment shows its
- glyph plus label; the committed one sits on a raised plate
- (`--ds-raised` + `--ds-raised-shadow`) at medium weight, so the current pair
- reads without opening anything. A hairline divider separates the two groups.
- Segments stay single-line and ellipsize rather than reflowing, and the
- committed option keeps its label longest as the toolbar narrows (480-780px
- drops the unselected labels to glyphs; the 450px floor drops all labels and
- keeps tooltips plus accessible names).
-- Arrow keys move to the neighbouring option and commit it, Home/End jump to
- the ends, and roving `tabindex` keeps one tab stop per group — the native
- radio-group contract.
-- The approval group stays visible in Agent, Plan, and Goal for a stable
+- The Agent/Plan/Goal mode chip reserves one fixed 88px width, sized from the
+ longest built-in label in English and zh-CN ("Agent" / "智能体"). Its label
+ stays single-line and ellipsizes if a future locale exceeds that budget, so
+ switching modes never reflows the adjacent Composer controls. Cycling the
+ chip cross-fades the icon and label in place. While the live turn is
+ `planning`, the chip pulses on its icon (purple) instead of leaving a
+ second status row parked above the composer; a staged mode choice still
+ updates the chip immediately and does not start that pulse until the
+ in-flight turn actually projects `planning`.
+- The permission chip remains visible in Agent, Plan, and Goal for a stable
toolbar rhythm. Agent and Plan expose the effective selectable permission;
- Goal fixes the group to Auto and disables it, with the group's accessible
- name stating the mode's automatic warning while the approval card remains the
- separate place for choosing execution policy. The Chinese Composer short
- label for Accept edits stays `允许编辑` / `允許編輯` so the option remains
- single-line; the scheduled task draft reuses the same approval switch.
-- While the live turn is `planning`, the committed mode segment pulses on its
- icon (purple) instead of leaving a second status row parked above the
- composer; a staged mode choice still updates the switch immediately and does
- not start that pulse until the in-flight turn actually projects `planning`.
+ Goal displays the localized Auto label as a disabled, non-opening chip while
+ the approval card remains the separate place for choosing execution policy.
+ The permission menu stays 120px wide; its Chinese Composer short label for
+ Accept edits is `允许编辑` / `允許編輯` so the option remains single-line
+ beside its selection indicator.
- The right toolbar owns the remaining-capacity context inspector (when the
newest assistant turn has usage) immediately left of one combined model ×
reasoning-level chip. Explicitly installed plugins may add user-invoked
@@ -3013,7 +3004,7 @@ reasoning-level control.
| Running | textarea and mode/model × reasoning/permission controls remain editable for the next turn; the single submit slot shows Stop only with an empty draft | Send queues text or attachments; Stop when both are empty |
| Context checkpoint | Same as Running until durable checkpoint completion; intermediate `turn_end` does not reactivate controls. A retained-tail fallback remains Running and shows a warning toast | Same single-slot Stop/Send behavior as Running |
| Permission pending | textarea disabled (per [03-permission-ux.md](03-permission-ux.md) §7) | Send disabled; Stop remains active whenever the running empty-draft condition is met |
-| Plan / Goal / planning | textarea active while idle; contract badge and approval switch visible; the committed mode segment pulses while the live turn projects `planning` | inspect, send, or submit a contract |
+| Plan / Goal / planning | textarea active while idle; contract badge and permission chip visible; mode chip pulses while the live turn projects `planning` | inspect, send, or submit a contract |
| Plan / Goal / awaiting approval | approval surface shows only the title and artifact opener for the exact `.pi/<kind>/*.md` approval; draft is preserved read-only and composer controls remain blocked for that session | approve or reject |
| Plan / queued or running | Agent badge remains selected; queue/running state is visible; draft and next-turn controls remain editable | Stop; Send queues the next prompt; no replay control |
| Plan / Goal / planning after rejected, expired, or interrupted proposal | contract chip remains visible and editable | send a later prompt; submit a new contract; no execution action |
@@ -3143,8 +3134,8 @@ reasoning-level control.
an empty list), so changing a level during a turn cannot collapse the submenu
to Off-only. An active pending Plan or Goal approval still disables these
controls. Approval actions are the exception while awaiting approval. The
- Composer-left Agent/Plan/Goal switch is the sole mode
- control and commits any mode on a single click. The Composer-right
+ Composer-left Agent/Plan/Goal chip is the sole mode
+ control and cycles Agent → Plan → Goal → Agent on click. The Composer-right
model × reasoning chip owns both selections. Palette and Composer slash mode commands use the
same active-session configuration path; after host confirmation resolves an
approval, the approval surface is removed rather than remaining as a terminal
@@ -3238,12 +3229,11 @@ reasoning-level control.
- The combined menu closes on outside mousedown or Escape. In a submenu,
Up/Down moves the highlighted row, Enter selects from the model search/list,
and Left returns to the root.
-- The approval switch remains visible beside the mode switch. Agent and Plan
- show the effective Ask / Accept edits / Auto posture as three one-click
- options. Goal keeps the same geometry but is fixed to the localized Auto
- option and disabled; its approval card remains the separate place for
- choosing execution policy. The control does not imply that Write/Edit/plugin
- tools are available.
+- The permission chip remains visible beside the mode selector. Agent and Plan
+ show the effective Ask / Accept edits / Auto posture. Goal keeps the same
+ geometry but is fixed to the localized Auto label and cannot open a menu;
+ its approval card remains the separate place for choosing execution policy.
+ The control does not imply that Write/Edit/plugin tools are available.
- Goal shares the Plan approval surface (D198). The bar reads its copy from the
proposal's `kind`, so a goal contract shows the matching approval label and
artifact opener while the layout and remembered permission split-button stay
diff --git a/docs/spec/04-ux/09-interaction-patterns.md b/docs/spec/04-ux/09-interaction-patterns.md
index 2c1cd53a0..633d419be 100644
--- a/docs/spec/04-ux/09-interaction-patterns.md
+++ b/docs/spec/04-ux/09-interaction-patterns.md
@@ -1005,8 +1005,8 @@ Agent calls a permission-gated tool (including Plan/Goal Bash under Ask or Accep
matching contract mode and the renderer projects `planning`.
2. The Agent investigates with the selected contract tool set. Read/Glob/Grep and
BrowserPreview are allowed; Bash follows the visible permission mode. A
- contract-mode Bash command may mutate under Auto, so the mode switch remains visible.
- While that turn is live `planning`, the committed Composer mode segment pulses and a compact
+ contract-mode Bash command may mutate under Auto, so the mode chip remains visible.
+ While that turn is live `planning`, the Composer mode chip pulses and a compact
Planning row occupies the same reserved tail slot as Working until completion
or pending user interaction. A known runtime phase takes precedence; tool
and answer output do not hide the running status.
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 9c7589161..41b076c6d 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -11149,18 +11149,15 @@ This test plan spec is accepted when:
- **Milestone**: M5
- **Status**: Partially automated (radius token and shared-control source test)
-### US-UI-73 Composer mode and approval switches stay one click away
+### US-UI-73 Composer mode selector has stable width
- Open the empty home and a docked thread in both English and zh-CN.
-- Expect Agent, Plan, and Goal to render as three always-visible options and
- Ask / Accept edits / Auto as three more; selecting any of them is one click,
- never a cycle through the remaining modes and never a menu.
-- Expect the committed mode and approval level to keep their labels as the
- column narrows while the unselected options collapse to glyphs, and the send
- button and composer shell not to resize while switching.
-- In Goal, expect the approval switch to remain visible with the same geometry,
- show Full auto / 全自动, and stay disabled; its accessible name states the
- mode's automatic warning. The Plan/Goal approval card remains the separate
- execution-policy control.
+- Switch the Composer mode chip through Agent/Plan/Goal several times.
+- Expect the mode chip to keep one fixed width sized for the longest built-in
+ label (English "Agent" / zh-CN "智能体"); the adjacent Thinking and
+ permission controls, send button, and composer shell do not move or resize.
+- In Goal, expect the permission chip to remain visible with the same geometry,
+ show Full auto / 全自动, and stay disabled without opening a permission menu.
+ The Plan/Goal approval card remains the separate execution-policy control.
- **Specs linked**: `04-ux/08-component-spec.md` §11.3
- **Milestone**: M5
- **Status**: Partially automated (renderer style/source contract)
diff --git a/docs/zh-CN/spec/04-ux/07-ui-design-system.md b/docs/zh-CN/spec/04-ux/07-ui-design-system.md
index f9405c8a4..f50b378d4 100644
--- a/docs/zh-CN/spec/04-ux/07-ui-design-system.md
+++ b/docs/zh-CN/spec/04-ux/07-ui-design-system.md
@@ -848,9 +848,8 @@ UTF-8 写入活动会话的临时 `pasted/` 目录,并在粘贴位置显示一
模型。未知的 Custom/OpenAI-compatible 模型未暴露任何发明的推理
行动或分级阶梯。更换供应商钳位或重置耐用性
下一轮之前的会话值。
-- 左侧输入 Composer Agent/Plan/Goal 开关是唯一的活动会话模式控制,
- 每个模式只需一次点击;相邻的 Ask/接受编辑/自动开关以同样方式设置批准档位。
- 顶部栏没有重复的模式或模型控件。
+- 左侧输入 Composer Agent/Plan/Goal 芯片是唯一的活动会话模式
+ 控制和循环 Agent → Plan → Goal → Agent。顶部栏没有重复的模式或模型控件。
Composer 组合选择器当存在有效的 `pending` Plan 或 Goal 批准时将关闭并被禁用;
终端提案快照不会禁用它。批准选择器记住
该设备上最后选择的模式并将其用于下一个待处理的提案。
diff --git a/docs/zh-CN/spec/04-ux/08-component-spec.md b/docs/zh-CN/spec/04-ux/08-component-spec.md
index d5ee812be..01c073eee 100644
--- a/docs/zh-CN/spec/04-ux/08-component-spec.md
+++ b/docs/zh-CN/spec/04-ux/08-component-spec.md
@@ -2000,23 +2000,12 @@ MainChat 底部的输入区域,用于撰写和发送提示。支持多行输
- 填充:px-4 py-3 内部文本区域
- 字体:Agent、Plan 和 Goal 的 text-sm;模式改变语义和工具
控件,而不是排版
-- Composer 左侧是一个内联分段簇,包含两个 radiogroup:Agent/Plan/Goal
- 与 Ask/Accept edits/Auto。每个选项都是独立目标,任何模式或权限档位都只需
- 一次点击——不再有菜单往返,也不再有“点一下切到下一个”的芯片。每个分段显示
- 图标与标签,已选项位于抬起底板上(`--ds-raised` + `--ds-raised-shadow`,
- 中等字重),因此当前组合无需展开即可读取;两组之间由一条细分隔线隔开。
- 分段保持单行并在需要时省略,不回流相邻控件;列变窄时已选项保留标签最久
- (480-780px 时未选中项收起为图标;450px 下限时全部收起为图标,
- 保留 tooltip 与无障碍名称)。
-- 方向键移动到相邻选项并直接提交,Home/End 跳到两端;漫游 `tabindex`
- 让每组只占一个 Tab 停靠点——这就是原生 radio group 的契约。
-- 批准档位组在 Agent、Plan 和 Goal 中始终可见,保持工具栏节奏。Agent 与 Plan
- 暴露有效的可选项;Goal 将该组固定为 Auto 并禁用,其无障碍名称说明该模式
- 的自动执行警告,批准卡片仍是选择执行策略的独立位置。中文 Accept edits 短标签
- 仍为 `允许编辑` / `允許編輯`,保证单行显示;计划任务草稿复用同一个批准开关。
-- 当前回合处于实时 `planning` 时,已选模式分段的图标以紫色脉冲,而不是在输入框
- 上方再停一行状态;回合中暂存的模式选择仍会立刻更新开关,但要等进行中的回合
- 真正投影 `planning` 才开始脉冲。
+- Agent/Plan/Goal 模式芯片保留一个固定的 88px 宽度,尺寸从
+ 最长的英文和中中文内置标签(“Agent”/“智能体”)。它的标签
+ 如果未来的语言环境超出预算,则保持单行并省略,因此
+ 切换模式永远不会回流相邻的 Composer 控件。循环切换时图标和标签就地交叉淡入。
+ 当前回合处于实时 `planning` 时,芯片图标以紫色脉冲,而不是在输入框上方再停一行状态;
+ 回合中暂存的模式选择仍会立刻改芯片,但要等进行中的回合真正投影 `planning` 才开始脉冲。
- 右侧工具栏在有用量时于模型 × 推理芯片左侧放置剩余容量检查器(D347);触发器只显示圆环和百分比。模型 × 推理芯片直接显示规范思考等级值,不进行本地化;`off` 时省略等级文本。
- 空草稿高度:`.composer-input` 使用 `min-height: 3lh`,空闲输入框默认显示三行。
- 底部锚定:固定在主聊天区域的底部
@@ -2133,8 +2122,8 @@ MainChat 底部的输入区域,用于撰写和发送提示。支持多行输
(`supportsReasoning: false`、缺省或空的等级列表),Composer 就回落到
所选模型的目录/绑定等级,因此回合中改档不会把子菜单塌缩成只剩关闭思考。有效的待处理 Plan 或 Goal 批准仍会禁用这些功能
控制。等待批准期间的批准操作是例外情况。的
- Composer 左侧的 Agent/Plan/Goal 开关是唯一模式控制,每个模式只需一次点击;
- Composer 右侧的
+ Composer-左Agent/Plan/Goal芯片是唯一模式
+ 单击时控制并循环 Agent → Plan → Goal → Agent;Composer 右侧的
模型 × 推理芯片拥有这两项选择。Palette 和 Composer 斜线模式命令使用
相同的活动会话配置路径;主机确认解决后
审批,审批面被移除而不是保留为终端
@@ -2161,8 +2150,8 @@ MainChat 底部的输入区域,用于撰写和发送提示。支持多行输
- 切换提供商保留可用级别,否则使用最近的级别
支撑位(先向上,然后向下);非推理提供商
`off` 仍然存在。
-- 批准开关在模式开关旁边仍然可见,三个档位(询问/接受编辑/自动)都是一次点击
- 即可到达的选项。它显示有效的询问/接受编辑/自动姿势。在 Plan 和 Goal 中,其帮助文本
+- Plan 权限芯片在模式选择器旁边仍然可见。它显示
+ 有效的询问/接受编辑/自动姿势。在 Plan 和 Goal 中,其帮助文本
表示 Bash 在“询问”或“接受”编辑下得到确认,并且可能会在没有修改的情况下发生变异
自动下确认;这并不意味着 Write/Edit/plugin 工具是
可用。
diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
index 52a8cc31f..9bead491a 100644
--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
@@ -6624,14 +6624,12 @@ eleven-tool-round desktop paths are verified by
- **里程碑**:M5
- **状态**:部分自动化(radius 令牌和共享控制源测试)
-### US-UI-73 Composer 模式与权限开关都只需一次点击
+### US-UI-73 Composer 模式选择器具有稳定的宽度
- 以英语和中文打开空的主页和停靠的线程。
-- 期望 Agent/Plan/Goal 渲染为三个常驻选项,Ask/接受编辑/自动再三个;
- 选择任意一个都只需一次点击,不会循环切换,也不会弹出菜单。
-- 期望列变窄时已选的模式与权限档位仍保留标签,未选中项收起为图标,
- 切换过程中发送按钮与 Composer shell 不移动、不变形。
-- 在 Goal 中,期望批准开关仍可见且几何不变、显示“全自动”并保持禁用,
- 其无障碍名称说明该模式的自动执行警告。
+- 通过Agent/Plan/Goal多次切换Composer模式芯片。
+- 期望模式芯片为最长的内置保持一个固定的宽度尺寸
+ 标签(英文“Agent”/zh-CN“智能体”);相邻的思维和
+ 权限控件、发送按钮和 Composer shell 不会移动或调整大小。
- **链接规格**:`04-ux/08-component-spec.md` §11.3
- **里程碑**:M5
- **状态**:部分自动化(渲染器 style/source 合约)
diff --git a/scripts/e2e-plan-ui.mjs b/scripts/e2e-plan-ui.mjs
index c14fdf911..ca98d4674 100644
--- a/scripts/e2e-plan-ui.mjs
+++ b/scripts/e2e-plan-ui.mjs
@@ -618,16 +618,12 @@ async function inspectUi(state) {
};
const text = (node) => (node?.innerText || node?.textContent || "").replace(/\\s+/g, " ").trim();
const label = (node) => (node?.getAttribute("aria-label") || text(node)).trim();
- // The execution switches render every mode as its own radio; the checked
- // one is the session's operating mode.
- const modeButtons = [...document.querySelectorAll(".composer-shell .composer-mode-switch button[role=\"radio\"]")]
+ const modeButtons = [...document.querySelectorAll(".composer-shell button.mode-chip")]
.filter(visible)
- .map((node) => ({
- label: text(node),
- checked: node.getAttribute("aria-checked") === "true",
- disabled: Boolean(node.disabled),
- }));
- const operatingModes = modeButtons.filter((item) => item.checked);
+ .map((node) => ({ label: text(node), disabled: Boolean(node.disabled) }));
+ const operatingModes = modeButtons.filter((item) =>
+ ["Agent", "Plan", "智能体", "规划"].includes(item.label),
+ );
const bar = document.querySelector('[data-testid="plan-approval-bar"]');
const approvalMain = bar?.querySelector(".plan-approval-approve-main");
const approvalMenu = document.querySelector(".plan-approval-menu.is-open");
@@ -635,7 +631,7 @@ async function inspectUi(state) {
const prompt = document.querySelector(".composer-input");
const model = document.querySelector(".composer-model-thinking button");
const mode = operatingModes[0];
- const permission = document.querySelector('.composer-permission-switch button[role="radio"]');
+ const permission = document.querySelector(".composer-permission button");
const send = document.querySelector(".composer-shell .send-btn");
const barText = text(bar);
const bodyText = document.body?.innerText || "";
@@ -653,10 +649,9 @@ async function inspectUi(state) {
bodyText,
activeSessionId: activeRow?.getAttribute("data-sidebar-session-row") || null,
modeLabels: operatingModes.map((item) => item.label),
- modeOptionLabels: modeButtons.map((item) => item.label),
modeControlCount: operatingModes.length,
modeDisabled: mode ? mode.disabled : null,
- topbarModeControlCount: document.querySelectorAll(".conversation-topbar .composer-mode-switch").length,
+ topbarModeControlCount: document.querySelectorAll(".conversation-topbar button.mode-chip").length,
permissionVisible: visible(permission),
permissionDisabled: permission ? Boolean(permission.disabled) : null,
modelDisabled: model ? Boolean(model.disabled) : null,
@@ -1115,7 +1110,7 @@ function assertShellStructure(snapshot, expectedMode, locale) {
assert(snapshot.permissionVisible, "Composer permission control is missing");
assert(snapshot.activeSessionId, "no active rendered session row");
if (expectedMode === "plan") {
- assert(snapshot.modeOptionLabels.includes(expectedLabel), `Plan shell label missing for ${locale}`);
+ assert(snapshot.modeLabels.includes(expectedLabel), `Plan shell label missing for ${locale}`);
}
}
diff --git a/scripts/e2e-scheduled.mjs b/scripts/e2e-scheduled.mjs
index 3b35c8c4a..5043c5ada 100644
--- a/scripts/e2e-scheduled.mjs
+++ b/scripts/e2e-scheduled.mjs
@@ -229,9 +229,9 @@ try {
assert.equal(await evaluate(`document.querySelector('button[aria-label="Cadence"]').textContent.trim()`), "Manual");
await choose("Cadence", "Daily");
await choose("Select project", "project-alt");
- // The approval level is an inline switch: one click, no menu round-trip.
- await click("Auto", '.composer-permission-switch button[data-value="auto"]');
- await waitFor(() => evaluate(`document.querySelector('.composer-permission-switch button[data-value="auto"]').getAttribute('aria-checked') === 'true'`), 5000, "approval switch selects Auto");
+ await click("Permission mode", "button[aria-haspopup]", true);
+ await waitFor(() => evaluate(`!!document.querySelector('.composer-permission-menu.is-open')`), 5000, "shared permission menu");
+ await click("Auto", '.composer-permission-menu [role="menuitemradio"]');
assert.ok(await evaluate(`document.body.innerText.includes('Auto can run restricted actions')`));
await click(await evaluate(`document.querySelector('.scheduled-execution-toolbar .composer-model-thinking-chip').getAttribute('aria-label')`), 'button[aria-haspopup]', true);
await waitFor(() => evaluate(`!!document.querySelector('.composer-model-menu.is-open .composer-menu-root')`), 5000, "measured root menu");