2025年Claude Code对话框弹窗UI样式排行榜 2026-06-06阅读 0热度 0 Claude 好的,作为一位在该领域深耕多年的技术专家,我现在来为你重新讲述这篇关于会话对话框的深度解析。 --- 会话过程中的所有对话框都由一个叫 `focusedInputDialog` 的组件统一控制。它会根据一个严格的优先级列表,逐个弹出。下面就是这份完整的列表,也是我们这次要聊的核心。 ## 一、权限类对话框 先来看几个最常遇到的权限请求。 ### 1. 工具权限确认 (tool-permission) **什么时候会出现?** 当Bash、Write、Read这些工具需要你点头同意才行的时候。 这个对话框的UI设计得很有讲究。它实际上是一个分发器,会根据工具类型调用不同的子组件: * **BashPermissionRequest**:会展示待执行的 shell 命令、工作目录,以及一个以 `$` 开头让你一目了然的命令预览。 * **FileEditPermissionRequest**:会展示文件路径和用颜色标记的差异(`+11` 表示新增,`-22` 表示删除)。 * **WebFetchPermissionRequest**:会展示要访问的目标 URL。 它们有几个通用的结构特点:一个覆盖层阻止你与主界面交互,一个工具名称标签,一个操作描述或预览区域。底部则是一个下拉选择框,选项是 "Allow"(允许)、"Allow and don't ask again"(允许且不再询问)和 "Deny"(拒绝)。操作上,按 Escape 拒绝,按 Enter 确认。 这个功能的核心组件在 `PermissionRequest.tsx` 中,它会分发到 `BashPermissionRequest`、`FileEditPermissionRequest` 等子组件。 ### 2. Sandbox 网络权限 (sandbox-permission) **什么时候会出现?** 当 WebFetch 这样的工具想要访问外部网络时。 它的UI长这样: ``` ┌──────────────────────────────────────────────────────────────────┐ │Network request outside of sandbox │ │ │ │Host: api.example.com (dim) │ │ │ │Do you want to allow this connection? │ │ │ │> Yes │ │Yes, and don't ask again for api.example.com │ │No, and tell Claude what to do differently (esc) │ └──────────────────────────────────────────────────────────────────┘ ``` 它被包裹在 `` 组件里。主机名用 `dim` 颜色显示。选项包括允许、允许并记住该域名、拒绝并引导用户给出不同的指令。对应的组件是 `SandboxPermissionRequest.tsx`。 ### 3. Worker Sandbox 权限 (worker-sandbox-permission) **什么时候会出现?** 当 Swarm worker 子袋里的任务需要访问网络,等待主进程审批时。 它的UI结构跟 `sandbox-permission` 完全一样,唯一的区别在于响应方式:它是通过 `sendSandboxPermissionResponseViaMailbox` 协议跨进程回复给 worker 的。使用的组件同样是 `SandboxPermissionRequest.tsx`。 ### 4. Worker 等待中指示器 (非阻塞) **什么时候会出现?** 当子袋里(Sub-agent)正在等待主进程批准权限时,你会看到这个提示。 它的UI是这样的一个圆角卡片: ``` ┌──────────────────────────────────────────────────────────────────┐ │⠋ Waiting for team lead approval (warning, bold) │ │─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │ │Tool: WebFetchTool (dim) │ │Action: Fetch https://api.example.com/data (dim) │ │Permission request sent to team "my-team" leader │ └──────────────────────────────────────────────────────────────────┘ ``` 顶部有一个旋转动画(Spinner)和加粗的警告色文字,中间是工具名称和操作详情,下方还带有一个显示袋子名称和颜色的 `WorkerBadge`。对应的组件是 `WorkerPendingPermission.tsx`。 ## 二、交互输入类对话框 这类对话框需要你更主动的参与。 ### 5. Hook Prompt 对话框 (prompt) **什么时候会出现?** 当 Hook 返回 `type: "prompt"`,需要你从几个选项中选择时。 它的UI结构如下: ``` ┌──────────────────────────────────────────────────────────────────┐ │[title][info] │ │ │ │Request message here... │ │[tool summary] (dim) │ │ │ │> Option 1 │ │Option 2 │ │Option 3 │ └──────────────────────────────────────────────────────────────────┘ ``` 它被包裹在 `` 中。界面包含一个主标题和一个副标题(请求信息),右侧可能有一个用 `dim` 颜色显示的工具输入摘要。选项列表通过一个 `` 组件实现,其选项由 Hook 返回的 `request.options` 映射而来。支持通过 `app:interrupt` 快捷键中止操作。对应的核心组件是 `PromptDialog.tsx`。 ### 6. MCP Elicitation 对话框 (elicitation) **什么时候会出现?** 当 MCP 服务器需要你输入信息时。它有三种模式: **表单模式**:最复杂的一种,看起来像一个动态表单: ``` ┌──────────────────────────────────────────────────────────────────┐ │MCP server "serverName" requests your input │ │ │ │┌──────────────────────────────────────────────────────────────┐ │ ││Text input field... │ │ │└──────────────────────────────────────────────────────────────┘ │ │○ Option A ○ Option B ○ Option C │ │☑ Checkbox option │ │ │ │[Accept] [Decline] │ └──────────────────────────────────────────────────────────────────┘ ``` 它支持文本输入、单选/多选枚举、布尔值、日期/时间选择器等动态表单字段,并有验证错误提示和内联快捷键。这是一个约1169行的大型表单引擎,组件名为 `ElicitationDialog.tsx`。 **等待模式**:显示一个域名,带一个旋转动画,底部有 "Reload / Open in Browser / Close" 三个操作按钮。 **URL 确认**:显示 "MCP server wants to open a URL",并让你选择接受或拒绝。 ## 三、会话管理类对话框 ### 7. 成本阈值对话框 (cost) **什么时候会出现?** 当前会话的 API 费用达到你设定的阈值时。 UI 设计: ``` ┌──────────────────────────────────────────────────────────────────┐ │You've spent $5 on the Anthropic API this session. │ │ │ │Learn more about how to monitor your spending: │ │code.claude.com/docs/en/costs (link) │ │ │ │> Got it, thanks! │ └──────────────────────────────────────────────────────────────────┘ ``` 它被包裹在 `` 中,显示当前会话消费金额,并提供一个费用监控文档的链接。只有一个确认选项,确认后会在系统内标记为 `hasAcknowledgedCostThreshold: true`。对应的组件是 `CostThresholdDialog.tsx`。 ### 8. 闲置返回对话框 (idle-return) **什么时候会出现?** 当你离开一段时间后返回时。 UI 设计: ``` ┌──────────────────────────────────────────────────────────────────┐ │You've been away 25m and this conversation is 45K tokens. │ │ │ │If this is a new task, clearing context will sa ve usage and │ │be faster. │ │ │ │> Continue this conversation │ │Send message as a new conversation │ │Don't ask me again │ └──────────────────────────────────────────────────────────────────┘ ``` 同样包裹在 `` 中,显示离开时长和当前上下文占用的 token 数。有三个选项:继续当前对话、清除上下文后作为新对话发送、不再提示。对应的组件是 `IdleReturnDialog.tsx`。 ## 四、新功能引导类对话框 ### 9. IDE 集成引导 (ide-onboarding) **什么时候会出现?** 当系统首次检测到你安装了 IDE 扩展时。 UI 设计: ``` ┌──────────────────────────────────────────────────────────────────┐ │✻ Welcome to Claude Code for Visual Studio Code │ │ │ │installed extension v1.2.3 (dim) │ │ │ │• Claude has context about your open files and selected lines │ │• View code diffs in your IDE +11 / -22 (diff colors) │ │• Cmd+Esc to quickly launch │ │• Cmd+Option+K to send selection │ │ │ │Press Enter to continue │ └──────────────────────────────────────────────────────────────────┘ ``` 这是一个使用 `"ide"` 主题颜色的 `` 组件。用项目符号列表介绍了IDE集成的各种功能,差异标记还带有颜色展示。按Enter或Escape即可关闭。对应的组件是 `IdeOnboardingDialog.tsx`。 ### 10. Effort 选择引导 (effort-callout) **什么时候会出现?** 当你首次使用Opus模型时,用来引导你选择投入力度。 UI 设计: ``` ┌──────────────────────────────────────────────────────────────────┐ │Choose your effort level │ │ │ │Description text explaining what effort level means... │ │ │ │low · medium · high (effort indicators) │ │ │ │> ● Medium (recommended) │ │●●● High │ │○ Low │ └──────────────────────────────────────────────────────────────────┘ ``` 它被包裹在 `` 中,有一个30秒的自动消失计时器。你可以从低、中、高三个力度中选择。对应的组件是 `EffortCallout.tsx`。 ### 11. 远程控制引导 (remote-callout) **什么时候会出现?** 当你首次启用 Bridge 或远程控制功能时。 UI 设计: ``` ┌──────────────────────────────────────────────────────────────────┐ │Remote Control │ │ │ │Description text explaining how remote control works... │ │Your CLI session can be accessed from the web or other apps. │ │ │ │> Enable Remote Control for this session │ │Never mind │ └──────────────────────────────────────────────────────────────────┘ ``` 同样包裹在 `` 中,但只会显示一次,因为选择后会自动持久化。对应的组件是 `RemoteCallout.tsx`。 ### 12. Ultraplan 选择对话框 (ultraplan-choice) **什么时候会出现?** 在生成执行计划后,询问你是否要继续。 它会显示远程执行计划的内容,供你审查和批准。内置了独立的滚动功能,不和主页面的 `ScrollBox` 联动。它接收 `plan`、`sessionId`、`taskId` 等回调。该组件 `UltraplanChoiceDialog` 并非独立文件,而是在 `REPL.tsx` 中内联使用的。 ### 13. Ultraplan 启动对话框 (ultraplan-launch) **什么时候会出现?** 在你确认后,启动Ultraplan远程执行之前。 它会触发 ultraplan 命令,并回显显示公告行。同时会传递断开连接时的桥接选项,并在远程会话就绪时附加状态更新。该组件 `UltraplanLaunchDialog` 同样是在 `REPL.tsx` 中内联使用的。 ## 五、推荐/推广类对话框 ### 14. LSP 插件推荐 (lsp-recommendation) **什么时候会出现?** 当系统检测到你打开了某个未安装对应 LSP 插件的文件类型时。 UI 设计: ``` ┌──────────────────────────────────────────────────────────────────┐ │LSP Plugin Recommendation │ │ │ │LSP provides code intelligence like go-to-definition and error │ │checking. │ │ │ │Plugin: @anthropic/lsp-rust (dim) │ │Triggered by: .rs files (dim) │ │ │ │Would you like to install this LSP plugin? │ │ │ │> Yes, install @anthropic/lsp-rust (bold) │ │No, not now │ │Never for @anthropic/lsp-rust │ │Disable all LSP recommendations │ └──────────────────────────────────────────────────────────────────┘ ``` 它被包裹在 `` 中,有一个30秒的自动消失计时器,超时后视为拒绝。对应的组件是 `LspRecommendationMenu.tsx`。 ### 15. 插件提示 (plugin-hint) **什么时候会出现?** 当外部命令建议你安装某个插件时。 UI 设计: ``` ┌──────────────────────────────────────────────────────────────────┐ │Plugin Recommendation │ │ │ │The "my-command" command suggests installing a plugin. │ │ │ │Plugin: my-plugin (dim) │ │Marketplace: official (dim) │ │ │ │Would you like to install it? │ │ │ │> Yes, install my-plugin │ │No │ │No, and don't show plugin installation hints again │ └──────────────────────────────────────────────────────────────────┘ ``` 同样包裹在 `` 中,也有30秒的自动消失计时器。对应的组件是 `PluginHintMenu.tsx`。 ### 16. Desktop 升级引导 (desktop-upsell) **什么时候会出现?** 在最多3次启动时,提示你升级到桌面版。 UI 设计: ``` ┌──────────────────────────────────────────────────────────────────┐ │Try Claude Code Desktop │ │ │ │Same Claude Code with visual diffs, live app preview, parallel │ │sessions, and more. │ │ │ │> Open in Claude Code Desktop │ │Not now │ │Don't ask again │ └──────────────────────────────────────────────────────────────────┘ ``` 它被包裹在 `` 中。如果你选择了 "Open in Desktop",界面会切换到 `` 子组件。对应的组件是 `DesktopUpsellStartup.tsx`。 ## 六、消息操作类 ### 17. 消息选择器 / Rewind (message-selector) **什么时候会出现?** 当你按下 `Ctrl+O` 或选择要回退到的消息时。 UI 设计: ``` ─── Rewind ────────────────────────────────────────────────────────── (color: suggestion) > #1 "Add error handling to the login flow" +5 / -2 (file changes) #2 "Fix the bug in user authentication" +3 / -1 #3 "Refactor the database schema" (no changes) (code rollback warning) Restore code and conversation Restore conversation Summarize from here: [____________________________] Never mind ────────────────────────────────────────────────────────────────────── ``` 这不是一个传统的对话框,而是内联选择器。标题为 "Rewind",使用 `suggestion` 颜色。每条用户消息都会显示文件变更统计。底部有代码回滚警告,并提供恢复代码和对话、仅恢复对话、从此处总结等选项。在确认模式下会显示差异统计。对应的组件是 `MessageSelector.tsx`。 ## 七、Ant 内部版(外部构建不可见) ### 18. 模型切换引导 (model-switch) 这个组件的存在依赖于条件编译:只有当 `"external" === 'ant'` 时才会出现。它会提示用户切换模型,切换后可通过 `onDone(selection, modelAlias?)` 回调来更新 `mainLoopModel`。对应的组件是 `AntModelSwitchCallout`。 ### 19. Undercover 模式引导 (undercover-callout) 同样,只有当 `"external" === 'ant'` 时才会出现。它会解释 Undercover 模式自动启用的原因,并提供一个简单的解除回调。对应的组件是 `UndercoverAutoCallout`。 ## 优先级总结 最后,我们来梳理一下这些对话框的弹出优先级(从高到低): | 优先级 | 对话框 | 条件 | | :--- | :--- | :--- | | **最高** | `message-selector` | 用户主动打开 | | 1 | `sandbox-permission` | 网络权限请求 | | 2 | `tool-permission` | 工具权限请求 | | 3 | `prompt` | Hook prompt 交互 | | 4 | `worker-sandbox-permission` | Worker 网络权限 | | 5 | `elicitation` | MCP 表单输入 | | 6 | `cost` | 费用阈值提示 | | 7 | `idle-return` | 闲置返回 | | 8 | `ultraplan-choice` | Ultraplan 计划选择 | | 9 | `ultraplan-launch` | Ultraplan 启动 | | 10 | `ide-onboarding` | IDE 引导 | | 11 | `model-switch` | 模型切换(ant-only) | | 12 | `undercover-callout` | Undercover 引导(ant-only) | | 13 | `effort-callout` | Effort 选择引导 | | 14 | `remote-callout` | 远程控制引导 | | 15 | `lsp-recommendation` | LSP 插件推荐 | | 16 | `plugin-hint` | 插件建议 | | **最低** | `desktop-upsell` | 桌面版推广 | 值得注意的是,当用户正在输入时,高优先级的对话框会暂缓弹出(通过 `hasSuppressedDialogs` 标志控制),等输入完成后再恢复。这是一个非常合理的用户体验设计。