平时做技术实践时,很多问题不是概念不会,而是细节没串起来。拿“Claude Code 对话框/弹窗 UI 样式汇总小结”来说,它看着像小点,放到项目里常会牵出环境、配置、兼容性和维护成本。下面按实际采用顺序,把思路、关键写法和容易踩坑的地方讲清楚,便于大家直接对照操作。
会话过程中,所有对话框由 focusedInputDialog 控制,按优先级依次弹出。以下是完整列表。
触发时机: 工具(Bash、Write、Read 等)需用户批准时
UI 描述:
根据工具类型分发到不同的权限子组件:
$ 开头的命令预览+11/-22 颜色标记)通用结构:
<Select> 选项:"Allow"、"Allow and don't ask again"、"Deny"
组件: PermissionRequest.tsx → 分发到 BashPermissionRequest / FileEditPermissionRequest 等
触发时机: 工具(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) │
└──────────────────────────────────────────────────────────────────┘
<PermissionDialog> 中组件: SandboxPermissionRequest.tsx
触发时机: Swarm worker 子代理请求网络访问,等待 leader 审批
UI 描述: 与 sandbox-permission 结构相同,但借助 mailbox 协议跨进程响应。选项借助 sendSandboxPermissionResponseViaMailbox 发送回 worker。
组件: SandboxPermissionRequest.tsx(同一组件)
触发时机: Sub-agent 正在等待 leader 批准权限时显示
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 │
└──────────────────────────────────────────────────────────────────┘
borderStyle="round", borderColor="warning")组件: WorkerPendingPermission.tsx
触发时机: Hook 得到 type: "prompt" 需用户选择
UI 描述:
┌──────────────────────────────────────────────────────────────────┐
│ [title] [info] │
│ │
│ Request message here... │
│ [tool summary] │ (dim)
│ │
│ > Option 1 │
│ Option 2 │
│ Option 3 │
└──────────────────────────────────────────────────────────────────┘
<PermissionDialog> 中<Select> 选项列表,映射自 hook 得到的 request.optionsapp:interrupt 快捷键中止组件: PromptDialog.tsx
触发时机: MCP 服务器请求用户输入(表单、URL 确认、等待完成)
UI 描述: 三种模式:
表单模式:
┌──────────────────────────────────────────────────────────────────┐
│ MCP server "serverName" requests your input │
│ │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ Text input field... │ │
│ └──────────────────────────────────────────────────────────┘ │
│ ○ Option A ○ Option B ○ Option C │
│ ☑ Checkbox option │
│ │
│ [Accept] [Decline] │
└──────────────────────────────────────────────────────────────────┘
等待模式: 域名 + Spinner + "Reload / Open in Browser / Close"
URL 确认: "MCP server wants to open a URL" + Accept/Decline
组件: ElicitationDialog.tsx(~1169 行,大型表单引擎)
触发时机: 当前会话 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! │
└──────────────────────────────────────────────────────────────────┘
<Dialog> 中hasAcknowledgedCostThreshold: true组件: CostThresholdDialog.tsx
触发时机: 用户长时间离开后得到时
UI 描述:
┌──────────────────────────────────────────────────────────────────┐
│ You've been away 25m and this conversation is 45K tokens. │
│ │
│ If this is a new task, clearing context will save usage and │
│ be faster. │
│ │
│ > Continue this conversation │
│ Send message as a new conversation │
│ Don't ask me again │
└──────────────────────────────────────────────────────────────────┘
<Dialog> 中组件: IdleReturnDialog.tsx
触发时机: 首次检测到 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 │
└──────────────────────────────────────────────────────────────────┘
<Dialog> 颜色 theme "ide"组件: IdeOnboardingDialog.tsx
触发时机: 首次采用 Opus 模型时(新功能引导)
UI 描述:
┌──────────────────────────────────────────────────────────────────┐
│ Choose your effort level │
│ │
│ Description text explaining what effort level means... │
│ │
│ low · medium · high │ (effort indicators)
│ │
│ > ● Medium (recommended) │
│ ●●● High │
│ ○ Low │
└──────────────────────────────────────────────────────────────────┘
<PermissionDialog> 中组件: EffortCallout.tsx
触发时机: 首次启用 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 │
└──────────────────────────────────────────────────────────────────┘
<PermissionDialog> 中组件: RemoteCallout.tsx
触发时机: 生成执行计划后,询问用户是否继续
UI 描述: 理解这一步时,显示远程执行计划内容供用户审查/批准。内置独立滚动(不与主 ScrollBox 联动)。接收 plan、sessionId、taskId 等回调。
组件: UltraplanChoiceDialog(非独立组件文件,REPL.tsx 内联采用)
触发时机: 用户确认后,启动 Ultraplan 远程执行前
UI 描述: 从实现思路看,触发 ultraplan 命令,回声显示公告行,传递断开连接桥接选项,远程会话就绪时附加状态更新。
组件: UltraplanLaunchDialog(非独立组件文件,REPL.tsx 内联采用)
触发时机: 检测到未安装 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 │
└──────────────────────────────────────────────────────────────────┘
<PermissionDialog> 中组件: LspRecommendationMenu.tsx
触发时机: 外部命令建议安装插件时
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 │
└──────────────────────────────────────────────────────────────────┘
<PermissionDialog> 中组件: PluginHintMenu.tsx
触发时机: 最多 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 │
└──────────────────────────────────────────────────────────────────┘
<PermissionDialog> 中<DesktopHandoff> 子组件组件: DesktopUpsellStartup.tsx
触发时机: 用户按 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
──────────────────────────────────────────────────────────────────────
color="suggestion")组件: MessageSelector.tsx
条件编译: "external" === 'ant' 时存在
onDone(selection, modelAlias?) 回调可用来切换 mainLoopModel组件: AntModelSwitchCallout
条件编译: "external" === 'ant' 时存在
组件: 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),输入完成后恢复。
落到代码里,到此这篇关于Claude Code 对话框/弹窗 UI 样式汇总小结的文章就介绍到这了,更多相关Claude Code 对话框/弹窗 内容请搜索脚本之家以前的文章或继续浏览下面的相关文章,希望大家以后多多兼容脚本之家!