diff --git a/chatbot/src/App.jsx b/chatbot/src/App.jsx index 0c1daf0fe..fc25b1329 100644 --- a/chatbot/src/App.jsx +++ b/chatbot/src/App.jsx @@ -2130,7 +2130,7 @@ export default function App() { e.target.value = ""; }} /> - {chat.executors.length > 1 && !pinnedExecutor ? ( + {chat.executors.length > 1 ? ( { @@ -2142,7 +2142,9 @@ export default function App() { : null, }; })} - value={chat.executor} + value={pinnedExecutor?.id || chat.executor} + disabled={Boolean(pinnedExecutor)} + title={pinnedExecutor ? "当前对话已绑定该 CLI,切换请新建对话" : undefined} onSelect={(id) => { chat.setExecutor(id); input.current?.focus(); diff --git a/chatbot/src/PermissionPicker.jsx b/chatbot/src/PermissionPicker.jsx index 0a37c8305..06c64303a 100644 --- a/chatbot/src/PermissionPicker.jsx +++ b/chatbot/src/PermissionPicker.jsx @@ -24,7 +24,7 @@ export function rememberApprovalMode(userId, value) { } // `glyph` is a rendered brand mark. Options that only set `icon` keep the Harness icon. -export default function PermissionPicker({ value, onSelect, open, onOpenChange, label = "操作确认方式", icon, options = modes }) { +export default function PermissionPicker({ value, onSelect, open, onOpenChange, label = "操作确认方式", icon, options = modes, disabled = false, title }) { const trigger = useRef(null); const panel = useRef(null); const initialFocus = useRef(null); @@ -136,7 +136,7 @@ export default function PermissionPicker({ value, onSelect, open, onOpenChange, close(true); } function keyDown(event) { - if (event.isComposing || event.nativeEvent?.isComposing) return; + if (disabled || event.isComposing || event.nativeEvent?.isComposing) return; if (event.key === "Escape") { event.preventDefault(); event.stopPropagation(); @@ -169,10 +169,14 @@ export default function PermissionPicker({ value, onSelect, open, onOpenChange, className="permission-selector" data-tone={current.tone} aria-label={label} - aria-haspopup="menu" - aria-expanded={open} + disabled={disabled} + title={title} + aria-haspopup={disabled ? undefined : "menu"} + aria-expanded={disabled ? false : open} aria-controls={identity} - onClick={() => onOpenChange(!open)} + onClick={() => { + if (!disabled) onOpenChange(!open); + }} onKeyDown={(event) => { if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) { if (open && presence.mounted) keyDown(event); diff --git a/chatbot/src/permission-picker.css b/chatbot/src/permission-picker.css index be12e883f..bbc6a3ec5 100644 --- a/chatbot/src/permission-picker.css +++ b/chatbot/src/permission-picker.css @@ -6,6 +6,11 @@ min-width: 0; } +.chat-shell button.permission-selector:disabled { + cursor: default; + opacity: 1; +} + /* The portal defines its own colors outside the workbench's theme scope. */ .permission-menu { --permission-surface: #fff; diff --git a/chatbot/tests/pickers-and-activity.test.jsx b/chatbot/tests/pickers-and-activity.test.jsx index a27fbdc36..efea04be0 100644 --- a/chatbot/tests/pickers-and-activity.test.jsx +++ b/chatbot/tests/pickers-and-activity.test.jsx @@ -81,6 +81,30 @@ describe("pickers and activity", () => { expect(selectPermission).toHaveBeenCalledWith("auto"); }); + test("shows a locked CLI as a disabled, readable selector", async () => { + const onOpenChange = vi.fn(); + const onSelect = vi.fn(); + render( + , + ); + const selector = screen.getByRole("button", { name: "CLI" }); + expect(selector).toBeDisabled(); + expect(selector).toHaveAttribute("title", "当前对话已绑定该 CLI,切换请新建对话"); + await userEvent.click(selector); + expect(onOpenChange).not.toHaveBeenCalled(); + expect(onSelect).not.toHaveBeenCalled(); + expect(document.querySelector(".permission-menu")).not.toBeInTheDocument(); + }); + test("remembers the approval mode and ignores unknown values", () => { expect(storedApprovalMode(1)).toBe("confirm"); rememberApprovalMode(1, "assisted");