fix: allow CLI theme config setter - #544
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for a new "theme" configuration option in the CLI client, allowing users to choose between auto, dark, light, or mono themes. It includes validation logic, CLI command integration, and corresponding unit tests. The feedback suggests using the existing theme_from_input helper function within parse_config_value to resolve theme aliases and uppercase inputs, preventing unexpected validation errors when configuring the theme via the CLI.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if key == "theme": | ||
| if raw not in THEMES: | ||
| raise ConfigError("theme must be auto, dark, light, or mono.") | ||
| return raw |
There was a problem hiding this comment.
parse_config_value で theme の値を検証する際、raw not in THEMES で直接チェックしているため、ダーク や 2 などの日本語・数値エイリアス(yonerai_cli/tui/themes.py の _THEME_INPUT_ALIASES で定義されているもの)や、大文字表記(DARK など)が受け入れられず、ConfigError が発生してしまいます。
インタラクティブシェルでの /テーマ コマンドや初期設定プロンプトでは theme_from_input を介してエイリアスが正常に解決されるため、CLIの config set 経路でも同様にエイリアスを解決できるように theme_from_input を使用することをお勧めします。モジュール先頭でのインポートは循環参照を引き起こすため、関数内でのローカルインポートが安全です。
if key == "theme":
from yonerai_cli.tui.themes import theme_from_input
normalized = theme_from_input(raw)
if normalized is None:
raise ConfigError("theme must be auto, dark, light, or mono.")
return normalized|
Duplicate of #545 for the CLI theme config setter lane.\n\nCurrent classification on 2026-06-28:\n- #544 and #545 touch the same files and implement the same UX fix.\n- Both have the same valid P2 review: route config set theme through the shared heme_from_input alias parser so Japanese/numeric aliases match /テーマ and onboarding.\n- This is not a current P0/P1/security blocker and should not starve the Web-to-CLI sync/security lane.\n\nKeeping #545 as the canonical tracking PR for the theme-config UX fix; closing #544 to avoid duplicate review/merge paths. |
Motivation
themeはDEFAULT_CONFIGとnormalize_config_key()で受け入れられている一方、非対話の設定経路であるparse_config_value()にtheme分岐が無く、さらにargparseの選択肢にthemeが入っていなかったため、yonerai config set theme ...や自動化経路で設定できない不整合が発生していました。Description
clients/cli/yonerai_cli/config.pyのparse_config_value()にif key == "theme":ブロックを追加してauto/dark/light/monoを検証するようにしました。clients/cli/yonerai_cli/commands/config.pyのCONFIG_KEY_CHOICESに"theme"を追加して CLI のconfig set theme ...が受け付けられるようにしました。build_config_report) と pretty 表示行にthemeを含めるようにして、config showや JSON レポートで確認できるようにしました。tests/test_cli_theme.pyに追加して、直接の設定 API 経路での永続化、無効テーマの拒否、およびyonerai config set theme ... --jsonの CLI 経路をカバーするようにしました。Testing
pytest tests/test_cli_theme.py tests/test_cli_command_display_modes.pyと選択したtests/test_cli_interactive_v030.pyの設定系テスト群を実行し、全テストが成功しました(24 passed)。PYTHONPATH=clients/cli python -m yonerai_cli config set theme dark --config-path /tmp/yonerai-theme-smoke.json --jsonを実行し、期待どおり"theme": "dark"が出力され成功しました。ruffとpython -m compileallを実行し警告・コンパイルエラーは発生しませんでした。Codex Task