System folder picker opens on every click cc-switch
Quick fix
Remove the pickDirectory() call from handleOpenTerminal in src/App.tsx to stop the folder picker from opening whenever you click to open a terminal.
Symptom
Section titled “Symptom”每次点击都会先弹出系统文件夹选择器,选完目录才打开终端。The system folder picker opens on every click, and the terminal opens only after you select a directory.
Across multiple versions of cc-switch, the frontend interaction logic contains redundant behavior. For example, when opening a terminal, the handleOpenTerminal function in src/App.tsx calls settingsApi.pickDirectory() unconditionally before calling the backend's open_provider_terminal, forcing you to choose a directory every time. The backend's cwd parameter is an Option and defaults to opening the terminal in its working directory when omitted, so the frontend's forced dialog is unnecessary.
This version range also has similar issues with UI state and event bindings: left-clicking the tray icon opens only the menu instead of the main window (the Tauri tray event listener needs modification); tray menu provider data does not sync promptly after restoring a backup from S3; and importing SQL requires a second click to confirm after selecting a file. These are omissions in frontend state management or event binding.
Open src/App.tsx and find the handleOpenTerminal function.
Remove the settingsApi.pickDirectory() call and the related cwd parameter, then call openTerminal directly.
// src/App.tsxconst handleOpenTerminal = async (provider: Provider) => {const selectedDir = await settingsApi.pickDirectory();if (!selectedDir) return;await providersApi.openTerminal(provider.id, activeApp, { cwd: selectedDir });await providersApi.openTerminal(provider.id, activeApp);...};To also fix the issue where left-clicking the tray icon does not open the main window, set .show_menu_on_left_click(false) in the Rust backend and add TrayIconEvent::Click event handling.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 4 real issues
- Why does changing the tray icon's left-click behavior have no effect on Linux?
- This is a known limitation of Tauri and the platform. TrayIconEvent does not fire on Linux, so this change is a safe no-op there, and clicking still opens the menu.
- Can I still specify a working directory after fixing the terminal dialog?
- The cwd parameter of the backend's open_provider_terminal is an Option. If omitted, the terminal opens in its default working directory. To retain the ability to specify a working directory, consider adding it to settings or providing a separate entry point instead of forcing a dialog.
- What should I do if the tray menu does not update after restoring a backup from S3?
- This is a known sync bug: the main window shows the correct data, but the tray menu still shows old data. For now, wait for an official fix or try restarting the app to refresh the cache.
Related problems
Section titled “Related problems”This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.