Skip to content

🎨 Palette: Consistently use _print_hint for UX hints#731

Closed
abhimehro wants to merge 2 commits intomainfrom
fix-print-hint-9985298205871170489
Closed

🎨 Palette: Consistently use _print_hint for UX hints#731
abhimehro wants to merge 2 commits intomainfrom
fix-print-hint-9985298205871170489

Conversation

@abhimehro
Copy link
Copy Markdown
Owner

What: Refactored direct print statements in main.py to use the custom _print_hint helper function. Also added a dedicated test in tests/test_ux.py to ensure _print_hint appropriately styles the text based on the USE_COLORS setting without losing semantic emojis.
Why: The codebase has a custom _print_hint(hint: str) function designed to handle coloring and fallback of hints securely, but it was not consistently used for many other hints such as those related to "No folders to sync", cache clearing, missing Profile ID and missing API Token. This change simplifies the logic (removes if USE_COLORS: branching at the call sites) and aligns with the UX best practices logged in .jules/palette.md to ensure emojis are preserved as uncolored text for fallback modes while keeping the CLI pretty when allowed.
Before/After: No functional changes. The output now consistently preserves emojis in NO_COLOR mode for several hints.
Accessibility: Improved fallback text mode rendering by ensuring semantic emojis are not stripped out, maintaining context and scannability.


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

Co-authored-by: abhimehro <84992105+abhimehro@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 20, 2026 18:31
@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.

@trunk-io
Copy link
Copy Markdown

trunk-io Bot commented Apr 20, 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.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

Comment thread tests/test_ux.py
monkeypatch.setattr(main, "USE_COLORS", False)
main._print_hint("💡 Hint: Just a test")
captured = capsys.readouterr()
assert "\033[2m" not in captured.out
Comment thread tests/test_ux.py
main._print_hint("💡 Hint: Just a test")
captured = capsys.readouterr()
assert "\033[2m" not in captured.out
assert "💡 Hint: Just a test" in captured.out
Comment thread tests/test_ux.py Fixed
codescene-delta-analysis[bot]

This comment was marked as outdated.

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 refactors the printing of hint messages by introducing a _print_hint helper function, which centralizes color handling and reduces manual branching. Additionally, it updates the test suite to verify the new helper and improves type safety in existing tests. A review comment suggests further simplifying the 'No folders to sync' message by removing an unnecessary if USE_COLORS check, aligning it with the logic used in the rest of the PR.

Comment thread main.py
Comment on lines 584 to 587
if USE_COLORS:
print(f" {Colors.WARNING}⚠️ No folders to sync.{Colors.ENDC}")
print(
f" {Colors.DIM}💡 Hint: Add folder URLs using --folder-url or in your config.yaml{Colors.ENDC}"
)
else:
print(" ⚠️ No folders to sync.")
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

This if USE_COLORS block can be simplified to a single print statement. Since the Colors class attributes default to empty strings when USE_COLORS is False, the colored string will gracefully degrade to plain text. This change improves maintainability and aligns with the PR's objective of removing manual color branching at call sites, as seen in other parts of this refactor (e.g., lines 2871, 2928).

        print(f"  {Colors.WARNING}⚠️  No folders to sync.{Colors.ENDC}")

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

Refactors CLI “hint” output in main.py to consistently route through the _print_hint() helper so hint styling (dim vs plain) is centralized and emoji-preserving across color/no-color modes.

Changes:

  • Replaced several inline print(... Colors.DIM ...) hint call sites with _print_hint(...) in main.py.
  • Added a dedicated test to validate _print_hint behavior under USE_COLORS=True/False.
  • Updated an existing UX test to construct PlanEntry with the correct TypedDict shape.

Reviewed changes

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

File Description
main.py Swaps scattered hint print() logic for _print_hint() to unify styling behavior.
tests/test_ux.py Adds _print_hint regression coverage and adjusts plan-entry test data to match TypedDicts.

Comment thread tests/test_ux.py
@@ -460,20 +460,46 @@ def validator(value):
assert f"\033[2m{main.EMPTY_INPUT_HINT}\033[0m" in captured.out
assert f"\033[2m{main.INVALID_INPUT_HINT}\033[0m" in captured.out

Co-authored-by: abhimehro <84992105+abhimehro@users.noreply.github.com>
Comment thread tests/test_ux.py

main._print_hint("💡 Hint: Just a test")
captured = capsys.readouterr()
assert "\033[2m💡 Hint: Just a test\033[0m" in captured.out
Copy link
Copy Markdown

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Choose a reason for hiding this comment

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

Gates Passed
6 Quality Gates Passed

See analysis details in CodeScene

Quality Gate Profile: Pay Down Tech Debt
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

abhimehro added a commit that referenced this pull request Apr 23, 2026
…ry-pick from #731)

Replaces bare print() calls with _print_hint() for:
- No folders to sync hint
- Cache clear hint
- Missing Profile ID hint
- Missing API Token hint
abhimehro added a commit that referenced this pull request Apr 23, 2026
@abhimehro
Copy link
Copy Markdown
Owner Author

Closing: #730 merged first and caused a merge conflict in tests/test_ux.py. Changes cherry-picked manually to main in commit b87e4c3 — main.py _print_hint refactors and test_print_hint_helper_usage test both applied cleanly. No functional regression.

@abhimehro abhimehro closed this Apr 23, 2026
@google-labs-jules
Copy link
Copy Markdown

Closing: #730 merged first and caused a merge conflict in tests/test_ux.py. Changes cherry-picked manually to main in commit b87e4c3 — main.py _print_hint refactors and test_print_hint_helper_usage test both applied cleanly. No functional regression.

Understood. Acknowledging that this work was closed due to a conflict and the changes have been cherry-picked manually. Stopping work on this task.

abhimehro added a commit that referenced this pull request Apr 23, 2026
@abhimehro abhimehro deleted the fix-print-hint-9985298205871170489 branch April 26, 2026 02:59
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