🎨 Palette: Show Block/Allow actions in dry-run output#433
Conversation
Updates the `print_plan_details` function to visually indicate whether a folder will be configured to "Block" or "Allow" traffic. - Adds `[Block]`, `[Allow]`, or `[Mixed]` labels next to folder names. - Uses color coding (Red for Block, Green for Allow, Yellow for Mixed) when colors are enabled. - Ensures transparency for users before they execute live syncs. - Includes unit tests covering all action scenarios. This micro-UX improvement addresses user uncertainty about what action a sync operation will actually apply. 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. |
|
Merging to
|
Summary of ChangesHello, 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 significantly enhances the user experience for dry-run operations by providing explicit and visually distinct labels for 'Block' or 'Allow' actions within the output. This change ensures that users can immediately understand the intended configuration of folders without needing to infer it, making the dry-run more informative and actionable. Additionally, it includes a refactoring of the summary table printing logic and general cleanup of test file imports. 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
|
There was a problem hiding this comment.
Code Review
This pull request is a nice UX improvement, adding visibility to the 'Block' and 'Allow' actions in the dry-run output. The implementation is solid, and the tests are well-updated to cover the new functionality. I've found a small opportunity to refactor the new logic in main.py to improve maintainability by reducing code duplication. The removal of numerous unused imports throughout the test suite is also a good cleanup.
| # Determine action (Block/Allow) | ||
| action_text = "" | ||
| action_color = "" | ||
| action_label = "" | ||
|
|
||
| # Check for multiple rule groups first | ||
| if "rule_groups" in folder and folder["rule_groups"]: | ||
| actions = {rg.get("action") for rg in folder["rule_groups"]} | ||
| if len(actions) > 1: | ||
| action_label = "Mixed" | ||
| action_color = Colors.WARNING | ||
| action_text = f"({action_color}⚠️ {action_label}{Colors.ENDC})" if USE_COLORS else f"[{action_label}]" | ||
| else: | ||
| # All groups have same action | ||
| action_val = list(actions)[0] | ||
| if action_val == 0: | ||
| action_label = "Block" | ||
| action_color = Colors.FAIL | ||
| action_text = f"({action_color}⛔ {action_label}{Colors.ENDC})" if USE_COLORS else f"[{action_label}]" | ||
| elif action_val == 1: | ||
| action_label = "Allow" | ||
| action_color = Colors.GREEN | ||
| action_text = f"({action_color}✅ {action_label}{Colors.ENDC})" if USE_COLORS else f"[{action_label}]" | ||
|
|
||
| # Fallback to single action if not set | ||
| if not action_text and "action" in folder: | ||
| action_val = folder["action"] | ||
| if action_val == 0: | ||
| action_label = "Block" | ||
| action_color = Colors.FAIL | ||
| action_text = f"({action_color}⛔ {action_label}{Colors.ENDC})" if USE_COLORS else f"[{action_label}]" | ||
| elif action_val == 1: | ||
| action_label = "Allow" | ||
| action_color = Colors.GREEN | ||
| action_text = f"({action_color}✅ {action_label}{Colors.ENDC})" if USE_COLORS else f"[{action_label}]" | ||
|
|
There was a problem hiding this comment.
The logic to determine the action text for 'Block' and 'Allow' is duplicated for handling rule_groups and the fallback action. This can be refactored to reduce duplication and improve maintainability by using a more data-driven approach.
By consolidating the logic to determine action_val first and then using a map to generate the display text, you can make the code more concise and easier to extend in the future.
# Determine action (Block/Allow)
action_text = ""
action_color = ""
action_label = ""
action_map = {
0: ("Block", Colors.FAIL, "⛔"),
1: ("Allow", Colors.GREEN, "✅"),
}
action_val = None
# Check for multiple rule groups first
if "rule_groups" in folder and folder["rule_groups"]:
actions = {rg.get("action") for rg in folder["rule_groups"]}
if len(actions) > 1:
action_label = "Mixed"
action_color = Colors.WARNING
action_text = f"({action_color}⚠️ {action_label}{Colors.ENDC})" if USE_COLORS else f"[{action_label}]"
elif actions:
action_val = list(actions)[0]
# Fallback to single action if not set
elif "action" in folder:
action_val = folder.get("action")
if action_val in action_map:
action_label, action_color, icon = action_map[action_val]
action_text = f"({action_color}{icon} {action_label}{Colors.ENDC})" if USE_COLORS else f"[{action_label}]"
UX Improvement: Explicit Action Visibility in Dry Run
Users running
--dry-runcould see what folders would be synced, but not how they would be configured (Block vs. Allow). This change adds explicit labels to the output plan.Before:
After:
(Colors are used in terminals that support them: Red for Block, Green for Allow)
Changes:
print_plan_detailsinmain.pyto inspectactionorrule_groupsfields.tests/test_plan_details.pyto verify the new output format and cover edge cases (mixed actions).uv run python main.py --dry-run.PR created automatically by Jules for task 5324149634390965004 started by @abhimehro