🎨 Palette: Handle KeyboardInterrupt gracefully and improve prompt guidance#184
🎨 Palette: Handle KeyboardInterrupt gracefully and improve prompt guidance#184
Conversation
- Added a `try...except KeyboardInterrupt` block around interactive prompts and cache warmup to prevent ugly tracebacks when users cancel. - Updated the Profile ID prompt to include the direct URL to the Control D dashboard. - Fixed `tests/test_plan_details.py` to correctly patch `main.USE_COLORS` when `main` module is reloaded by other tests. Co-authored-by: abhimehro <84992105+abhimehro@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
🚫 This pull request was closed by @abhimehro, so it was removed from the merge queue. See more details here. |
Summary of ChangesHello @abhimehro, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the command-line interface's user experience by making it more robust to user interruptions and providing clearer guidance during setup. Additionally, it improves the stability of the test suite by addressing a specific flaky test. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
👋 Development Partner is reviewing this PR. Will provide feedback shortly. |
There was a problem hiding this comment.
Code Review
This pull request introduces several user experience improvements and a test stability fix. The graceful handling of KeyboardInterrupt during the initial setup and cache warming is a great addition, preventing tracebacks and providing a clear message. The updated prompt for the Profile ID now includes a clickable URL, which is a thoughtful improvement. Additionally, the fix for the flaky test in test_plan_details.py by correctly handling reloaded modules is well-implemented and enhances the reliability of the test suite. The changes are clean, correct, and well-executed.
main.py
Outdated
| if not profile_ids: | ||
| print(f"{Colors.CYAN}ℹ Profile ID is missing.{Colors.ENDC}") | ||
| print( | ||
| f"{Colors.CYAN} You can find this in the URL of your profile in the Control D Dashboard at https://controld.com/dashboard/profiles (or just paste the URL).{Colors.ENDC}" |
Check warning
Code scanning / Prospector (reported by Codacy)
line too long (190 > 159 characters) (E501)
| ) | ||
| exit(1) | ||
| if not TOKEN and not args.dry_run: | ||
| log.error( |
Check warning
Code scanning / Prospector (reported by Codacy)
Consider using sys.exit() (consider-using-sys-exit)
main.py
Outdated
| if not profile_ids: | ||
| print(f"{Colors.CYAN}ℹ Profile ID is missing.{Colors.ENDC}") | ||
| print( | ||
| f"{Colors.CYAN} You can find this in the URL of your profile in the Control D Dashboard at https://controld.com/dashboard/profiles (or just paste the URL).{Colors.ENDC}" |
Check warning
Code scanning / Pylint (reported by Codacy)
Line too long (190/100)
| print( | ||
| f"{Colors.CYAN} You can find this in the URL of your profile in the Control D Dashboard at https://controld.com/dashboard/profiles (or just paste the URL).{Colors.ENDC}" | ||
| ) | ||
|
|
Check warning
Code scanning / Pylint (reported by Codacy)
Missing function docstring
| validate_profile_id(pid, log_errors=False) for pid in ids | ||
| p_input = get_validated_input( | ||
| f"{Colors.BOLD}Enter Control D Profile ID:{Colors.ENDC} ", | ||
| validate_profile_input, |
Check warning
Code scanning / Pylint (reported by Codacy)
Line too long (127/100)
| ) | ||
| if not TOKEN: | ||
| print(f"{Colors.CYAN}ℹ API Token is missing.{Colors.ENDC}") | ||
| print( |
Check warning
Code scanning / Pylint (reported by Codacy)
Line too long (115/100)
| import main | ||
|
|
||
| # Helper to get current main module (handles reloading by other tests) | ||
| def get_main(): |
Check warning
Code scanning / Pylint (reported by Codacy)
Missing function docstring
main.py
Outdated
| if not profile_ids: | ||
| print(f"{Colors.CYAN}ℹ Profile ID is missing.{Colors.ENDC}") | ||
| print( | ||
| f"{Colors.CYAN} You can find this in the URL of your profile in the Control D Dashboard at https://controld.com/dashboard/profiles (or just paste the URL).{Colors.ENDC}" |
Check warning
Code scanning / Pylintpython3 (reported by Codacy)
Line too long (190/100)
| ) | ||
| exit(1) | ||
| if not TOKEN and not args.dry_run: | ||
| log.error( |
Check warning
Code scanning / Pylintpython3 (reported by Codacy)
Consider using sys.exit()
| import main | ||
|
|
||
| # Helper to get current main module (handles reloading by other tests) | ||
| def get_main(): |
Check warning
Code scanning / Pylintpython3 (reported by Codacy)
Missing function or method docstring
There was a problem hiding this comment.
Pull request overview
This PR improves CLI user experience by adding graceful Ctrl+C handling during the initial interactive/configuration phase and cache warm-up, improves guidance for locating Profile IDs, and stabilizes a flaky plan-details test in the presence of main module reloads across the test suite.
Changes:
- Wrap the interactive prompt +
warm_up_cache()in atry/except KeyboardInterruptto print a friendly cancellation message and exit with code 130. - Update the Profile ID hint text to include a direct dashboard URL.
- Update
tests/test_plan_details.pyto patchUSE_COLORSagainst the currently-loadedmainmodule (viasys.modules) to avoid stale module references.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
main.py |
Adds early-phase KeyboardInterrupt handling and improves prompt guidance for Profile ID discovery. |
tests/test_plan_details.py |
Adjusts patching/calls to target the active main module instance to reduce flakiness when other tests reload/delete main. |
main.py
Outdated
| except KeyboardInterrupt: | ||
| sys.stderr.write( | ||
| f"\n{Colors.WARNING}⚠️ Sync cancelled by user.{Colors.ENDC}\n" | ||
| ) | ||
| sys.exit(130) |
There was a problem hiding this comment.
The new KeyboardInterrupt handling in main() changes observable behavior (message + exit code 130) during interactive prompts and cache warm-up, but it isn't covered by tests. Consider adding a unit test that simulates KeyboardInterrupt from input() / getpass.getpass() or warm_up_cache() and asserts the friendly cancellation message and exit status.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
main.py
Outdated
| if not profile_ids: | ||
| print(f"{Colors.CYAN}ℹ Profile ID is missing.{Colors.ENDC}") | ||
| print( | ||
| f"{Colors.CYAN} You can find this in the URL of your profile in the Control D Dashboard at https://controld.com/dashboard/profiles (or just paste the URL).{Colors.ENDC}" |
There was a problem hiding this comment.
The existing test test_interactive_prompts_show_hints in test_main.py (line 247-248) should be updated to verify that the new Profile ID dashboard URL is displayed. Currently it only checks for the generic text "You can find this in the URL of your profile" and the Token URL. Consider adding an assertion like assert "https://controld.com/dashboard/profiles" in stdout to ensure the new helpful URL is properly shown to users.
Co-authored-by: abhimehro <84992105+abhimehro@users.noreply.github.com>
Pull request was closed
This PR improves the CLI UX by:
KeyboardInterrupt(Ctrl+C) gracefully during the interactive setup phase and cache warmup, displaying a friendly "Cancelled by user" message instead of a traceback.test_print_plan_details_no_colors) that failed when running the full suite due to module reloading side effects.PR created automatically by Jules for task 18017526019155954203 started by @abhimehro