Skip to content

feat(terminal): add bypass permissions option to open terminal dialog / 打开终端时增加跳过权限检查选项#2509

Open
yuanxiaoye1031 wants to merge 2 commits intofarion1231:mainfrom
yuanxiaoye1031:feat/bypass-permissions-open-terminal
Open

feat(terminal): add bypass permissions option to open terminal dialog / 打开终端时增加跳过权限检查选项#2509
yuanxiaoye1031 wants to merge 2 commits intofarion1231:mainfrom
yuanxiaoye1031:feat/bypass-permissions-open-terminal

Conversation

@yuanxiaoye1031
Copy link
Copy Markdown

Summary / 概述

在使用特定供应商配置打开终端时,增加一个确认对话框,允许用户选择是否以 --dangerously-skip-permissions 模式启动 Claude Code。

  • 新增启动确认对话框,包含"跳过权限检查"复选框
  • 启用 bypass 时显示红色警告提示
  • 在 macOS、Linux、Windows 三个平台上传递 --dangerously-skip-permissions 标志
  • 更新三种语言的国际化文件(en/zh/ja)

Related Issue / 关联 Issue

Fixes #2508

Screenshots / 截图

Before / 修改前 After / 修改后
cc-switch-bypass-dialog

Checklist / 检查清单

  • pnpm typecheck passes / 通过 TypeScript 类型检查
  • pnpm format:check passes / 通过代码格式检查
  • cargo clippy passes (if Rust code changed) / 通过 Clippy 检查(如修改了 Rust 代码)
  • Updated i18n files if user-facing text changed / 如修改了用户可见文本,已更新国际化文件
yuanxiaoye1031 and others added 2 commits May 1, 2026 18:55
The /MANIFESTINPUT: and /MANIFEST:EMBED linker flags are MSVC-specific.
On the GNU toolchain these flags cause build failures. Gate the entire
manifest block behind `target_env = "msvc"` so non-MSVC builds succeed.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add a confirmation dialog when opening a terminal that lets users
optionally enable --dangerously-skip-permissions mode. The dialog
closes immediately on launch and shows success/error via toast.

Backend changes:
- Add bypassPermissions param to open_provider_terminal command
- Thread bypass flag through all platform-specific launchers
- Set env vars directly in launch scripts alongside --settings

Frontend changes:
- Confirmation dialog with checkbox and conditional warning
- i18n translations for en/zh/ja

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@yuanxiaoye1031 yuanxiaoye1031 marked this pull request as draft May 1, 2026 11:19
@yuanxiaoye1031 yuanxiaoye1031 marked this pull request as ready for review May 1, 2026 11:19
@yuanxiaoye1031 yuanxiaoye1031 changed the title 打开终端时增加跳过权限检查选项 / add bypass permissions option to open terminal dialo May 1, 2026
@farion1231
Copy link
Copy Markdown
Owner

@claude review

@claude
Copy link
Copy Markdown

claude Bot commented May 1, 2026

Claude finished @farion1231's task in 2m 1s —— View job


PR Review: feat(terminal): add bypass permissions option to open terminal dialog

  • Read changed files
  • Review Rust backend changes (misc.rs, build.rs)
  • Review frontend changes (App.tsx, providers.ts)
  • Review i18n changes
  • Compile and post final review

The PR cleanly adds the --dangerously-skip-permissions option to the open-terminal dialog. The overall approach is sound — the flag flows from a frontend checkbox through the Tauri command to platform-specific shell script generators. Here are my findings:


Rust Backend (src-tauri/src/commands/misc.rs)

launch_macos_terminal / launch_linux_terminal — line-length violations

Both platform-specific launcher functions have extremely long signatures that will fail rustfmt / cargo fmt:

// Line 916 — too long
fn launch_macos_terminal(config_file: &std::path::Path, cwd: Option<&Path>, bypass_permissions: bool, env_vars: &[(String, String)]) -> Result<(), String> {

// Line 1163 — too long
fn launch_linux_terminal(config_file: &std::path::Path, cwd: Option<&Path>, bypass_permissions: bool, env_vars: &[(String, String)]) -> Result<(), String> {

Should be broken across lines like the existing launch_windows_terminal signature at line 1283.

Fix this →

open_provider_terminal — long call site on line 761

launch_terminal_with_env(env_vars, &providerId, launch_cwd.as_deref(), bypassPermissions.unwrap_or(false))

This exceeds the standard line length. Minor, but worth splitting for consistency.

bypass_flag interpolation — no security concern ✓

The bypass_flag is always either " --dangerously-skip-permissions" or "" — a hardcoded literal, never derived from user input. No injection risk.


Frontend (src/App.tsx)

bypassPermissions not reset on dialog onOpenChange close (line 1667–1669)

onOpenChange={(open) => {
  if (!open) setTerminalLaunchOptions(null);
}}

When the dialog is dismissed by clicking outside or pressing Escape, bypassPermissions is not reset to false. It is reset in handleOpenTerminal (line 829) before the dialog opens the next time, so no user-visible bug occurs. But it leaves stale state between the close and next open. Adding setBypassPermissions(false) here would make the logic self-contained.

Fix this →

The same gap exists on the Cancel button (line 1709–1711)

<Button
  variant="outline"
  onClick={() => setTerminalLaunchOptions(null)}
>

Should also call setBypassPermissions(false).

bypass || undefined pattern (line 851)

bypassPermissions: bypass || undefined,

This converts falseundefined so the key is omitted from serialization. The backend handles None as false via bypassPermissions.unwrap_or(false), so it's functionally correct. However, it is mildly confusing — passing bypass directly would be cleaner and the backend would accept Some(false) identically.


src/lib/api/providers.ts

The OpenTerminalOptions interface and the updated openTerminal function are well-structured. ✓


i18n (en.json, zh.json, ja.json)

All three locales add the four new keys consistently. Japanese translation is accurate. ✓


build.rs (+1/-1)

Scopes the Windows manifest embedding to target_env = "msvc" to avoid failures with MinGW toolchains. Good improvement. ✓


Summary

Severity Finding
⚠️ Style / CI Long function signatures in launch_macos_terminal and launch_linux_terminal — will likely fail cargo fmt check
🔵 Minor bypassPermissions not reset in onOpenChange and Cancel button handler
🔵 Minor bypass || undefined pattern is correct but unclear

The core feature — passing --dangerously-skip-permissions through the terminal launch scripts — is correctly implemented on all three platforms with appropriate UI warning text. The main actionable item before merge is fixing the Rust formatting to pass CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants