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 5 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 adds a comprehensive theming system to the interactive shell, allowing users to pick a color palette via
Confidence Score: 5/5Safe to merge — the theming feature is well-contained, all three config tiers resolve correctly, and the previous issues (session field initialization, TTY guard ordering, private import) are all addressed. The three-tier theme resolution path is tested end-to-end, the lazy _LazyRichStyle tokens resolve at render time so no stale colours can leak, and session.active_theme_name is now seeded from get_active_theme_name() immediately after config load. The only remaining findings are minor maintenance concerns that carry no current runtime risk. The hardcoded theme list in app/cli/main.py will require a manual update every time a theme is added to or removed from THEME_REGISTRY. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[opensre CLI invoked] --> B{subcommand?}
B -- no, TTY --> C[ReplConfig.load\ncli_theme + env + file]
B -- no, non-TTY --> D[render_landing]
B -- yes --> E[ReplConfig.load\ncli_theme only\nfor theme side-effect]
C --> F[set_active_theme\nmodule globals updated]
E --> F
F --> G[run_repl]
G --> H[repl_main]
H --> I[session.active_theme_name =\nget_active_theme_name]
I --> J[REPL loop]
J --> K{/theme command}
K -- with arg --> L[validate & apply theme]
K -- no arg + TTY --> M[interactive picker]
M --> L
L --> N[set_active_theme]
N --> O[persist to config.yml]
O --> P[call_soon_threadsafe\nrefresh_prompt_theme]
O --> Q[refresh_welcome_poster\nwith theme_notice]
Reviews (3): Last reviewed commit: "fix(cli): resolve CodeQL findings and th..." | 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 |
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.
