feat(cli): add theme option for interactive shell and enhance configuration#2519
feat(cli): add theme option for interactive shell and enhance configuration#2519Devesh36 wants to merge 8 commits into
Conversation
Greptile code reviewThis repo uses Greptile for automated review. Before merge, aim for Confidence Score: 5/5 with zero unresolved review threads — see CONTRIBUTING.md. Run a review — add a PR comment with: Give it ~5-10 minutes (sometimes longer) for results, then fix feedback and re-trigger until you reach Confidence Score: 5/5. Optional: automate with the greploop skill. |
Greptile SummaryThis PR introduces a comprehensive interactive-shell theming system: a
Confidence Score: 5/5Safe to merge; all changes are additive theming infrastructure with no effect on the agent/investigation execution path. The theming system is well-isolated and the previous blocking issues (double config load, private import, TTY-guard placement, stale active_theme_name) are all resolved. The two remaining findings are cosmetic: the placeholder colour won't update live when the theme changes mid-session, and the _LazyRichStyle empty-string base is a latent trap for future authors. Neither affects current functionality. app/cli/interactive_shell/prompting/prompt_surface.py — refresh_prompt_theme has the no-op placeholder assignment; app/cli/interactive_shell/ui/theme.py — _LazyRichStyle empty-string base warrants a code comment warning future authors. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["CLI --theme / OPENSRE_THEME / config.yml"] --> B["ReplConfig.load(cli_theme=...)"]
B --> C["set_active_theme(name)"]
C --> D["_ACTIVE_THEME global updated\n_apply_theme() → ANSI/Markdown constants"]
D --> E["_LazyRichStyle proxies resolve at render time"]
F["User runs /theme"] --> G{args provided?}
G -- "yes (/theme blue)" --> H["Validate against THEME_REGISTRY"]
G -- "no" --> I{repl_tty_interactive?}
I -- "no" --> J["Print error, return"]
I -- "yes" --> K["repl_choose_one TTY picker\n(pre-selects current theme)"]
K --> L["User picks theme"]
H --> M["_persist_and_report_theme"]
L --> M
M --> N["set_active_theme(selected)"]
M --> O["session.active_theme_name = name"]
M --> P["_save_config (interactive.theme)"]
M --> Q["call_soon_threadsafe(refresh_prompt_theme)"]
M --> R["refresh_welcome_poster (clear + redraw)"]
Q --> S["app.style = _build_prompt_style()\napp.invalidate()"]
Reviews (4): Last reviewed commit: "refactor(theme): streamline theme choice..." | Re-trigger Greptile |
| active_theme_name: str = "green" | ||
| """Interactive shell palette name for this REPL session (``/theme``, prompts).""" |
There was a problem hiding this comment.
active_theme_name not initialized from the configured theme
The field defaults to the hardcoded string "green" regardless of what theme was resolved during ReplConfig.load(). If the user has configured interactive.theme: blue (or OPENSRE_THEME=blue), any code reading session.active_theme_name before /theme is first invoked will see "green" instead of "blue". Since set_active_theme() is called during config load, the module-level global in ui/theme.py is already correct — the session field just needs to be initialized with get_active_theme_name() either at session creation or in the REPL startup path.
|
@greptile-apps review again |
|
@greptile-apps review again |
|
@greptile-apps review again |
This pull request introduces a comprehensive theming system for the interactive shell, allowing users to select and persist a color palette via CLI options, environment variables, configuration files, or a new
/themeslash command. It also improves configuration validation and enhances the user experience for theme selection and application. Additionally, there are minor improvements to code clarity and command output formatting.Interactive shell theming system:
--themeCLI option,OPENSRE_THEMEenvironment variable, andinteractive.themeconfig key, allowing users to select the shell color palette. Theme selection is validated and persisted, with a default of"green"if unset or invalid (app/cli/__main__.py,app/cli/interactive_shell/config/repl_config.py,app/cli/commands/config.py). [1] [2] [3] [4] [5] [6] [7] [8] [9]/themeslash command for interactive theme selection and persistence, including a TTY picker, tab-completion, and help integration (app/cli/interactive_shell/command_registry/theme.py,app/cli/interactive_shell/command_registry/__init__.py,app/cli/interactive_shell/command_registry/help.py,app/cli/interactive_shell/command_registry/slash_catalog.py). [1] [2] [3] [4] [5] [6]app/cli/interactive_shell/prompting/prompt_surface.py). [1] [2] [3] [4]Configuration and validation improvements:
interactive.theme, providing user-friendly error messages and fallback to defaults if invalid values are detected (app/cli/commands/config.py,app/cli/interactive_shell/config/repl_config.py). [1] [2]Minor improvements and refactoring:
app/cli/interactive_shell/command_registry/session_cmds.py). [1] [2] [3] [4] [5] [6]These changes provide a more customizable and user-friendly interactive shell experience.
