feat: add provider-specific terminal button - #452
Merged
Conversation
Add a terminal button next to each provider card that opens a new terminal window with that provider's specific API configuration. This allows using different providers independently without changing the global setting. Changes: - Backend: Add `open_provider_terminal` command that extracts provider config and creates a temporary claude settings file - Frontend: Add terminal button to provider cards with proper callback propagation through component hierarchy - Support macOS (Terminal.app), Linux (gnome-terminal, konsole, etc.), and Windows (cmd) Each provider gets a unique config file named `claude_<providerId>_<pid>.json` in the temp directory, containing the provider's API configuration. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Author
|
ping @farion1231 :) |
farion1231
self-requested a review
December 27, 2025 15:16
farion1231
requested changes
Dec 28, 2025
farion1231
left a comment
Owner
There was a problem hiding this comment.
感谢您的贡献,review 了一下存在一些问题,另外还有格式化和未使用变量问题,请修复一下
Contributor
Author
|
好滴 我来修改 😊 |
Resolved conflicts in src-tauri/src/lib.rs: - Kept both: open_provider_terminal (my feature) and universal provider commands (upstream) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…loses 在 open_provider_terminal 功能中添加了临时配置文件的自动清理逻辑, 确保在用户关闭终端窗口时自动删除创建的临时配置文件。 修改内容: - Linux: 使用 bash -c 嵌套包装脚本,通过 trap EXIT 信号在 shell 退出时清理配置文件 - macOS: 同样使用嵌套 bash + trap 机制来处理清理 - Windows: 保持原有的批处理文件自删除逻辑(del 命令) 技术细节: - 之前使用 sh -c "...; exec $SHELL" 会导致 trap 失效 - 现在使用 bash -c 'trap ... EXIT; ...; exec bash --norc --noprofile' - exec 会替换进程但保留 trap 信号处理器 - 当用户关闭终端时,EXIT 信号触发清理操作 影响范围: - src-tauri/src/commands/misc.rs (launch_terminal_with_env 函数) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
open_provider_terminal 功能仅支持 Claude Code,因此只在 Claude 应用中显示终端按钮。 修改内容: - 在 ProviderList 组件调用时,根据 activeApp 条件传递 onOpenTerminal - 仅当 activeApp === "claude" 时传递 handleOpenTerminal 回调 - Codex 和 Gemini 不会显示终端按钮(onOpenTerminal 为 undefined) 影响范围: - src/App.tsx 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Author
|
…v vars 重构 open_provider_terminal 相关代码,提升可维护性和可读性。 主要改进: - 将 launch_terminal_with_env 拆分为多个职责单一的小函数 * write_claude_config: 写入配置文件 * escape_shell_path: 转义 shell 路径 * generate_wrapper_script: 生成包装脚本 * launch_macos_terminal / launch_linux_terminal / launch_windows_terminal: 平台特定启动逻辑 - 使用 let Some else 提前返回模式,减少嵌套 - 修复 Gemini 环境变量名为 GEMINI_API_KEY(而非 GOOGLE_API_KEY) - 完善临时文件清理逻辑: * macOS/Linux: 使用 trap EXIT 自动清理 * Windows: 批处理文件自删除 - 代码格式化和 import 排序优化 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This was referenced Dec 31, 2025
Resolved conflict in src-tauri/src/commands/misc.rs by combining imports from both sides. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Author
|
ping @farion1231 |
Owner
|
非常感谢您的贡献! |
|
这个 release 新版本了吗?话说有没有预览的版本呀,一旦构建成功,尝鲜用户可以直接用 master 功能呢 |
hpsoar
pushed a commit
to hpsoar/cc-switch
that referenced
this pull request
Jan 30, 2026
Merged PR farion1231#452 which adds: - Terminal button for Claude providers to launch with provider-specific config - Cross-platform support (macOS/Linux/Windows) - Auto-cleanup of temporary config files
dfbb
pushed a commit
to dfbb/cc-switch
that referenced
this pull request
May 20, 2026
Merged PR farion1231#452 which adds: - Terminal button for Claude providers to launch with provider-specific config - Cross-platform support (macOS/Linux/Windows) - Auto-cleanup of temporary config files
delta-lo
pushed a commit
to delta-lo/cc-switch-mod
that referenced
this pull request
May 31, 2026
Merged PR farion1231#452 which adds: - Terminal button for Claude providers to launch with provider-specific config - Cross-platform support (macOS/Linux/Windows) - Auto-cleanup of temporary config files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a terminal button next to each provider card that opens a new terminal window with that provider's specific API configuration. This allows using different providers independently without changing the global setting.
Changes:
open_provider_terminalcommand that extracts provider config and creates a temporary claude settings fileEach provider gets a unique config file named
claude_<providerId>_<pid>.jsonin the temp directory, containing the provider's API configuration.🤖 Generated with Claude Code