Skip to content

Configuration UI Flickering - cc-switch

Quick fix

Upgrade cc-switch to fix flickering from async form loading; read SQLite DB to fix env vars not updating with providers.

Error output
配置界面闪烁
English translation

Configuration UI flickering

When editing the currently active provider in cc-switch, the form initially mounts using database configuration, then asynchronously reads the real-time ~/.claude/settings.json and replaces it. This delayed replacement triggers form.reset, causing fields like API Key to reinitialize after the first screen render, resulting in UI flickering. Additionally, due to adjustments in the general configuration feature, custom environment variables configured per provider (e.g., env.CC_SWITCH_RELAY_NAME) no longer update automatically when switching providers.

  1. Upgrade cc-switch to a version containing PR #4277. This update ensures the form mounts only once after real-time configuration is ready (showing a spinner during loading), eliminating flickering caused by asynchronous replacement.

  2. To retrieve custom environment variables such as the current relay name, stop reading from settings.json and instead write a Bash wrapper script to query cc-switch's local SQLite database directly.

    $HOME/.cc-switch/cc-switch.db
    #!/usr/bin/env bash
    set -euo pipefail
    payload="$(cat)"
    DB="$HOME/.cc-switch/cc-switch.db"
    label=""
    if [[ -f "$DB" ]]; then
    label="$(sqlite3 \
    -cmd ".timeout 200" \
    -noheader -batch "$DB" \
    "SELECT name
    FROM providers
    WHERE app_type='claude' AND is_current=1
    LIMIT 1;" 2>/dev/null)" || label=""
    fi
    [[ -z "$label" ]] && label="Unknown"
    ccline_out="$(printf '%s' "$payload" | ccline 2>/dev/null | head -n1)"
    printf '⚡%s | %s\n' "$label" "$ccline_out"
ToolClaude Code
Version3.16.2 - 3.16.3
PlatformsmacOS
Why can't I find the 'Edit General Configuration' entry in the new version?
The author reverted the general configuration feature. The current logic requires manually editing Claude's settings.json to add general configurations; these non-whitelisted fields will not be overwritten when switching providers.
Will the UI flickering loop infinitely?
No. It is a one-time bounded reinitialization that occurs when opening the edit dialog, most noticeable when manual edits to settings.json cause inconsistencies between real-time data and the database.

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.