Skip to content

🎨 Palette: Enhance Dry Run Output#153

Closed
abhimehro wants to merge 3 commits intomainfrom
palette-ux-dry-run-plan-16898864247899382848
Closed

🎨 Palette: Enhance Dry Run Output#153
abhimehro wants to merge 3 commits intomainfrom
palette-ux-dry-run-plan-16898864247899382848

Conversation

@abhimehro
Copy link
Copy Markdown
Owner

This PR enhances the UX of the --dry-run mode by printing a detailed plan of the folders and rules that would be created. This allows users to verify the configuration before running the actual sync. Additionally, it cleans up the codebase by removing a duplicate function definition.


PR created automatically by Jules for task 16898864247899382848 started by @abhimehro

- Added detailed plan output to `sync_profile` when running in dry-run mode.
- It now lists the folders that would be created and their rule counts.
- Removed a duplicate definition of `render_progress_bar`.
- Improved UX by providing clear feedback on what the script will do.

Co-authored-by: abhimehro <84992105+abhimehro@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings February 1, 2026 23:05
@trunk-io
Copy link
Copy Markdown

trunk-io Bot commented Feb 1, 2026

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

@github-actions github-actions Bot added the python label Feb 1, 2026
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @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 significantly improves the user experience of the dry-run functionality by introducing a comprehensive output that details the planned operations, including folder structures and rule counts. This enhancement empowers users to thoroughly review and validate their configurations without performing any actual modifications. Concurrently, the PR contributes to code quality by eliminating a redundant function definition.

Highlights

  • Enhanced Dry Run Output: The --dry-run mode now provides a detailed plan, listing folders and the number of rules associated with each, allowing users to verify configurations before actual execution. This output includes conditional color formatting for improved readability.
  • Codebase Cleanup: A duplicate render_progress_bar function has been removed from main.py, improving code maintainability and removing redundant code.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Comment thread main.py Fixed
Comment thread main.py Fixed
Comment thread main.py Fixed
Comment thread main.py Fixed
Comment thread main.py Fixed
Comment thread main.py Fixed
Comment thread main.py Fixed
Comment thread main.py Fixed
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the dry-run output and removes a duplicated function, which is a good cleanup. I've found an opportunity to further improve the dry-run output by making its behavior more consistent and reducing some code duplication in the process. My suggestion ensures the plan is always printed to standard output, which improves usability, especially for command-line redirection.

Comment thread main.py Outdated
Comment on lines +1113 to +1125
if USE_COLORS:
print(f"\n{Colors.CYAN}🔍 Plan for profile {profile_id}:{Colors.ENDC}")
for folder in plan_entry["folders"]:
f_name = folder["name"]
f_rules = folder["rules"]
print(f" • {f_name} ({f_rules:,} rules)")
print("")
else:
log.info(f"Plan for profile {profile_id}:")
for folder in plan_entry["folders"]:
f_name = folder["name"]
f_rules = folder["rules"]
log.info(f" - {f_name} ({f_rules:,} rules)")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The dry-run plan output is user-facing information and should consistently be printed to standard output (stdout). Currently, the colored output goes to stdout via print(), but the non-colored output is sent to standard error (stderr) via log.info(). This is inconsistent and can be confusing for users who might want to redirect the plan to a file (e.g., ... > plan.txt).

By using print() for both cases, we can ensure consistent behavior and also simplify the code by removing the duplicated loop.

Suggested change
if USE_COLORS:
print(f"\n{Colors.CYAN}🔍 Plan for profile {profile_id}:{Colors.ENDC}")
for folder in plan_entry["folders"]:
f_name = folder["name"]
f_rules = folder["rules"]
print(f" • {f_name} ({f_rules:,} rules)")
print("")
else:
log.info(f"Plan for profile {profile_id}:")
for folder in plan_entry["folders"]:
f_name = folder["name"]
f_rules = folder["rules"]
log.info(f" - {f_name} ({f_rules:,} rules)")
if USE_COLORS:
print(f"\n{Colors.CYAN}🔍 Plan for profile {profile_id}:{Colors.ENDC}")
line_prefix = " • "
else:
print(f"Plan for profile {profile_id}:")
line_prefix = " - "
for folder in plan_entry["folders"]:
f_name = folder["name"]
f_rules = folder["rules"]
print(f"{line_prefix}{f_name} ({f_rules:,} rules)")
if USE_COLORS:
print("")

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the user experience of the --dry-run mode by displaying a detailed plan of folders and rules that would be created, allowing users to verify configuration before execution. It also removes a duplicate render_progress_bar function definition.

Changes:

  • Removed duplicate render_progress_bar function (lines 162-180) that had width=20 instead of width=15
  • Added detailed dry-run output showing folder names and rule counts per profile (lines 1113-1126)
  • Output respects USE_COLORS flag, providing colored output for TTY and plain log messages otherwise

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Added detailed plan output to `sync_profile` when running in dry-run mode.
- It now lists the folders that would be created and their rule counts.
- Removed a duplicate definition of `render_progress_bar`.
- Improved UX by providing clear feedback on what the script will do.
- Sanitized `profile_id` and folder names in log output to address CodeQL security alert.

Co-authored-by: abhimehro <84992105+abhimehro@users.noreply.github.com>
Comment thread main.py Fixed
Comment thread main.py Fixed
Comment thread main.py Fixed
- Added detailed plan output to `sync_profile` when running in dry-run mode.
- It now lists the folders that would be created and their rule counts.
- Removed a duplicate definition of `render_progress_bar`.
- Improved UX by providing clear feedback on what the script will do.
- Addressed CodeQL security alerts by ensuring `profile_id` and folder names are explicitly sanitized and assigned to safe variables before logging.

Co-authored-by: abhimehro <84992105+abhimehro@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 1, 2026 23:14
Comment thread main.py
print(f" • {safe_name} ({rule_count:,} rules)")
print("")
else:
log.info(f"Plan for profile {safe_profile_id}:")

Check notice

Code scanning / Pylintpython3 (reported by Codacy)

Use lazy % formatting in logging functions Note

Use lazy % formatting in logging functions
Comment thread main.py
raw_name = folder.get("name", "Unknown")
safe_name = sanitize_for_log(raw_name)
rule_count = int(folder.get("rules", 0))
log.info(f" - {safe_name} ({rule_count:,} rules)")

Check notice

Code scanning / Pylintpython3 (reported by Codacy)

Use lazy % formatting in logging functions Note

Use lazy % formatting in logging functions
Comment thread main.py
print(f" • {safe_name} ({rule_count:,} rules)")
print("")
else:
log.info(f"Plan for profile {safe_profile_id}:")

Check warning

Code scanning / Prospector (reported by Codacy)

Use lazy % formatting in logging functions (logging-fstring-interpolation) Warning

Use lazy % formatting in logging functions (logging-fstring-interpolation)
Comment thread main.py
raw_name = folder.get("name", "Unknown")
safe_name = sanitize_for_log(raw_name)
rule_count = int(folder.get("rules", 0))
log.info(f" - {safe_name} ({rule_count:,} rules)")

Check warning

Code scanning / Prospector (reported by Codacy)

Use lazy % formatting in logging functions (logging-fstring-interpolation) Warning

Use lazy % formatting in logging functions (logging-fstring-interpolation)
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread main.py
Comment on lines +1116 to +1131
for folder in plan_entry["folders"]:
# Sanitize folder name and ensure rule count is an integer
raw_name = folder.get("name", "Unknown")
safe_name = sanitize_for_log(raw_name)
rule_count = int(folder.get("rules", 0))
print(f" • {safe_name} ({rule_count:,} rules)")
print("")
else:
log.info(f"Plan for profile {safe_profile_id}:")
for folder in plan_entry["folders"]:
# Sanitize folder name and ensure rule count is an integer
raw_name = folder.get("name", "Unknown")
safe_name = sanitize_for_log(raw_name)
rule_count = int(folder.get("rules", 0))
log.info(f" - {safe_name} ({rule_count:,} rules)")

Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code for printing folder information is duplicated between the USE_COLORS and non-USE_COLORS branches. The only differences are the output function (print vs log.info) and bullet character (• vs -). Consider extracting this logic into a helper function or loop through the folders once and format the output based on USE_COLORS inside the loop to reduce duplication and improve maintainability.

Suggested change
for folder in plan_entry["folders"]:
# Sanitize folder name and ensure rule count is an integer
raw_name = folder.get("name", "Unknown")
safe_name = sanitize_for_log(raw_name)
rule_count = int(folder.get("rules", 0))
print(f" • {safe_name} ({rule_count:,} rules)")
print("")
else:
log.info(f"Plan for profile {safe_profile_id}:")
for folder in plan_entry["folders"]:
# Sanitize folder name and ensure rule count is an integer
raw_name = folder.get("name", "Unknown")
safe_name = sanitize_for_log(raw_name)
rule_count = int(folder.get("rules", 0))
log.info(f" - {safe_name} ({rule_count:,} rules)")
output_func = print
bullet = "•"
else:
log.info(f"Plan for profile {safe_profile_id}:")
output_func = log.info
bullet = "-"
for folder in plan_entry["folders"]:
# Sanitize folder name and ensure rule count is an integer
raw_name = folder.get("name", "Unknown")
safe_name = sanitize_for_log(raw_name)
rule_count = int(folder.get("rules", 0))
output_func(f" {bullet} {safe_name} ({rule_count:,} rules)")
if USE_COLORS:
print("")

Copilot uses AI. Check for mistakes.
Comment thread main.py
Comment on lines +1113 to +1131
safe_profile_id = sanitize_for_log(profile_id)
if USE_COLORS:
print(f"\n{Colors.CYAN}🔍 Plan for profile {safe_profile_id}:{Colors.ENDC}")
for folder in plan_entry["folders"]:
# Sanitize folder name and ensure rule count is an integer
raw_name = folder.get("name", "Unknown")
safe_name = sanitize_for_log(raw_name)
rule_count = int(folder.get("rules", 0))
print(f" • {safe_name} ({rule_count:,} rules)")
print("")
else:
log.info(f"Plan for profile {safe_profile_id}:")
for folder in plan_entry["folders"]:
# Sanitize folder name and ensure rule count is an integer
raw_name = folder.get("name", "Unknown")
safe_name = sanitize_for_log(raw_name)
rule_count = int(folder.get("rules", 0))
log.info(f" - {safe_name} ({rule_count:,} rules)")

Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new dry-run output functionality lacks test coverage. Consider adding tests that verify the dry-run output is printed correctly for both USE_COLORS=True and USE_COLORS=False scenarios, including proper sanitization of profile IDs and folder names.

Copilot uses AI. Check for mistakes.
Copilot AI added a commit that referenced this pull request Feb 8, 2026
…itization, add dry-run plan details

Incorporates the best changes from 36 Jules PRs, addressing review feedback:

Bolt (Performance) - from PR #173:
- Pre-compile PROFILE_ID_PATTERN and RULE_PATTERN at module level
- Use compiled patterns in is_valid_profile_id_format, validate_profile_id, and is_valid_rule
- Supersedes PRs: #140, #143, #152, #155, #158, #161, #167, #170, #173

Sentinel (Security) - from PR #172 with review feedback:
- Enhance sanitize_for_log to redact Basic Auth credentials in URLs
- Redact sensitive query parameters (token, key, secret, password, etc.)
- Handle fragment separators (#) per Gemini Code Assist review
- Use [^&#\s]* pattern per Copilot reviewer suggestion
- Update docstring per reviewer suggestion
- Supersedes PRs: #142, #145, #148, #151, #154, #157, #160, #169, #172

Palette (UX) - from PR #174 with lint fixes:
- Add print_plan_details function for dry-run visibility
- Fix duplicate render_progress_bar definition bug
- Supersedes PRs: #139, #141, #144, #147, #150, #153, #156, #159, #162, #165, #168, #171, #174

Also: #146, #149, #164 (parallel folder deletion) and #166 (auto-fix .env perms) are independent features not consolidated here.

Co-authored-by: abhimehro <84992105+abhimehro@users.noreply.github.com>
@abhimehro abhimehro closed this Feb 9, 2026
@abhimehro abhimehro deleted the palette-ux-dry-run-plan-16898864247899382848 branch February 9, 2026 00:22
abhimehro added a commit that referenced this pull request Feb 9, 2026
…itization, add dry-run plan details

Incorporates the best changes from 36 Jules PRs, addressing review feedback:

Bolt (Performance) - from PR #173:
- Pre-compile PROFILE_ID_PATTERN and RULE_PATTERN at module level
- Use compiled patterns in is_valid_profile_id_format, validate_profile_id, and is_valid_rule
- Supersedes PRs: #140, #143, #152, #155, #158, #161, #167, #170, #173

Sentinel (Security) - from PR #172 with review feedback:
- Enhance sanitize_for_log to redact Basic Auth credentials in URLs
- Redact sensitive query parameters (token, key, secret, password, etc.)
- Handle fragment separators (#) per Gemini Code Assist review
- Use [^&#\s]* pattern per Copilot reviewer suggestion
- Update docstring per reviewer suggestion
- Supersedes PRs: #142, #145, #148, #151, #154, #157, #160, #169, #172

Palette (UX) - from PR #174 with lint fixes:
- Add print_plan_details function for dry-run visibility
- Fix duplicate render_progress_bar definition bug
- Supersedes PRs: #139, #141, #144, #147, #150, #153, #156, #159, #162, #165, #168, #171, #174

Also: #146, #149, #164 (parallel folder deletion) and #166 (auto-fix .env perms) are independent features not consolidated here.

Co-authored-by: abhimehro <84992105+abhimehro@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants