Skip to content

Every click first pops up the system folder picker - cc-switch

Quick fix

Edit src/App.tsx to remove the pickDirectory() call in handleOpenTerminal, so opening a terminal stops forcing a folder picker.

Error output
每次点击都会先弹出系统文件夹选择器,选完目录才打开终端。
English translation

Every click first pops up the system folder picker, and the terminal only opens once a directory is chosen.

Several cc-switch versions have redundant front-end interaction logic. For opening a terminal, the handleOpenTerminal function in src/App.tsx calls settingsApi.pickDirectory() unconditionally before invoking the backend open_provider_terminal, forcing a manual directory choice every time. The backend cwd parameter is an Option and opens in the terminal directory by default when omitted, so the forced front-end dialog is unnecessary.

The same version range also has similar UI state and event binding problems: a left click on the tray icon only opening the menu rather than the main window (needing a change to the Tauri tray event listener), tray menu provider data not syncing after restoring a backup from S3, and a SQL import needing a second click to confirm after choosing a file. All are omissions in front-end state management or event binding.

  1. Open src/App.tsx and find the handleOpenTerminal function.

  2. Remove the settingsApi.pickDirectory() call and the associated cwd parameter passing, and call openTerminal directly.

    // src/App.tsx
    const 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);
    ...
    };
  3. To also fix a left click on the tray not opening the main window, set .show_menu_on_left_click(false) in the Rust backend and add TrayIconEvent::Click handling.

Toolcc-switch
Version3.16.2 - 3.19.2
PlatformsWindowsmacOS
Why does changing the tray left-click behaviour have no effect on Linux?
A known Tauri and platform limitation: TrayIconEvent does not fire on Linux, so the change is a safe no-op there and a click still opens the menu.
After fixing the open-terminal dialog, can I still specify a working directory?
The backend open_provider_terminal cwd parameter is an Option and opens in the terminal default directory when omitted. If you want to keep the ability to specify one, put it in a setting or a separate entry point rather than a forced dialog.
The tray menu does not update after restoring a backup from S3. What now?
A known sync bug where the main window data is correct while the tray menu still shows the old data. Wait for an official fix, or restart the app to refresh the cache.

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.