From 18014bb48a185f0e513d1bc441a103bbc650f27d Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 21 Feb 2026 22:41:45 +0000 Subject: [PATCH 1/5] UX: Add dashboard link to success message Co-authored-by: abhimehro <84992105+abhimehro@users.noreply.github.com> --- main.py | 34 +++++++++++++++++++------- tests/test_ux.py | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index c835ff1b..31b34301 100644 --- a/main.py +++ b/main.py @@ -2396,6 +2396,29 @@ def row(c): return f"{Colors.BOLD}│{Colors.ENDC} {c[0]:<{w[0]}} {Colors.BOLD} print(f"{line('└', '┴', '┘')}\n") +def print_success_message(profile_ids: List[str]) -> None: + """Prints a random success message and a link to the Control D dashboard.""" + if not USE_COLORS: + return + + success_msgs = [ + "✨ All synced!", + "🚀 Ready for liftoff!", + "🎨 Beautifully done!", + "💎 Smooth operation!", + "🌈 Perfect harmony!", + ] + print(f"\n{Colors.GREEN}{random.choice(success_msgs)}{Colors.ENDC}") + + # Construct dashboard URL + if profile_ids and len(profile_ids) == 1 and profile_ids[0] != "dry-run-placeholder": + dashboard_url = f"https://controld.com/dashboard/profiles/{profile_ids[0]}/filters" + print(f"{Colors.CYAN}👀 View your changes: {Colors.UNDERLINE}{dashboard_url}{Colors.ENDC}") + elif len(profile_ids) > 1: + dashboard_url = "https://controld.com/dashboard/profiles" + print(f"{Colors.CYAN}👀 View your changes: {Colors.UNDERLINE}{dashboard_url}{Colors.ENDC}") + + def parse_args() -> argparse.Namespace: """ Parses command-line arguments for the Control D sync tool. @@ -2721,15 +2744,8 @@ def make_col_separator(left, mid, right, horiz): print(make_col_separator(Box.BL, Box.B, Box.BR, Box.H)) # Success Delight - if all_success and USE_COLORS and not args.dry_run: - success_msgs = [ - "✨ All synced!", - "🚀 Ready for liftoff!", - "🎨 Beautifully done!", - "💎 Smooth operation!", - "🌈 Perfect harmony!", - ] - print(f"\n{Colors.GREEN}{random.choice(success_msgs)}{Colors.ENDC}") + if all_success and not args.dry_run: + print_success_message(profile_ids) # Dry Run Next Steps if args.dry_run: diff --git a/tests/test_ux.py b/tests/test_ux.py index bc1385e7..8de33326 100644 --- a/tests/test_ux.py +++ b/tests/test_ux.py @@ -82,3 +82,66 @@ def test_countdown_timer_no_colors_long(monkeypatch): assert mock_log.info.call_count == 2 mock_log.info.assert_any_call("LongWait: 15s remaining...") mock_log.info.assert_any_call("LongWait: 5s remaining...") + + +def test_print_success_message_single_profile(monkeypatch): + """Verify success message includes dashboard link for single profile.""" + # Force colors on + monkeypatch.setattr(main, "USE_COLORS", True) + # Monkeypatch Colors attributes because they are computed at import time + monkeypatch.setattr(main.Colors, "CYAN", "\033[96m") + monkeypatch.setattr(main.Colors, "UNDERLINE", "\033[4m") + monkeypatch.setattr(main.Colors, "ENDC", "\033[0m") + monkeypatch.setattr(main.Colors, "GREEN", "\033[92m") + + # Mock stdout + mock_stdout = MagicMock() + # print() writes to sys.stdout by default + monkeypatch.setattr(sys, "stdout", mock_stdout) + + profile_ids = ["123456"] + main.print_success_message(profile_ids) + + # Check calls + writes = [args[0] for args, _ in mock_stdout.write.call_args_list] + combined_output = "".join(writes) + + # Verify content + # Note: The output is ANSI colored, so exact string matching might fail if color codes are interspersed + # But "View your changes" should be there + assert "View your changes" in combined_output + assert "https://controld.com/dashboard/profiles/123456/filters" in combined_output + # Check for color codes presence (cyan or underline) + assert "\033[96m" in combined_output or "\033[4m" in combined_output + +def test_print_success_message_multiple_profiles(monkeypatch): + """Verify success message includes general dashboard link for multiple profiles.""" + monkeypatch.setattr(main, "USE_COLORS", True) + # Monkeypatch Colors attributes + monkeypatch.setattr(main.Colors, "CYAN", "\033[96m") + monkeypatch.setattr(main.Colors, "UNDERLINE", "\033[4m") + monkeypatch.setattr(main.Colors, "ENDC", "\033[0m") + monkeypatch.setattr(main.Colors, "GREEN", "\033[92m") + + mock_stdout = MagicMock() + monkeypatch.setattr(sys, "stdout", mock_stdout) + + profile_ids = ["123", "456"] + main.print_success_message(profile_ids) + + writes = [args[0] for args, _ in mock_stdout.write.call_args_list] + combined_output = "".join(writes) + + assert "View your changes" in combined_output + assert "https://controld.com/dashboard/profiles" in combined_output + assert "/123/filters" not in combined_output # Should not link to specific profile + +def test_print_success_message_no_colors(monkeypatch): + """Verify nothing is printed if colors are disabled.""" + monkeypatch.setattr(main, "USE_COLORS", False) + mock_stdout = MagicMock() + monkeypatch.setattr(sys, "stdout", mock_stdout) + + main.print_success_message(["123"]) + + mock_stdout.write.assert_not_called() From 23cdca4e3ad3f05af262d6b18846d7d270f3f5c9 Mon Sep 17 00:00:00 2001 From: Abhi Mehrotra Date: Sun, 22 Feb 2026 03:41:21 -0600 Subject: [PATCH 2/5] Update main.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 31b34301..425ee3ca 100644 --- a/main.py +++ b/main.py @@ -2411,11 +2411,12 @@ def print_success_message(profile_ids: List[str]) -> None: print(f"\n{Colors.GREEN}{random.choice(success_msgs)}{Colors.ENDC}") # Construct dashboard URL + dashboard_url = None if profile_ids and len(profile_ids) == 1 and profile_ids[0] != "dry-run-placeholder": dashboard_url = f"https://controld.com/dashboard/profiles/{profile_ids[0]}/filters" - print(f"{Colors.CYAN}👀 View your changes: {Colors.UNDERLINE}{dashboard_url}{Colors.ENDC}") elif len(profile_ids) > 1: dashboard_url = "https://controld.com/dashboard/profiles" + if dashboard_url: print(f"{Colors.CYAN}👀 View your changes: {Colors.UNDERLINE}{dashboard_url}{Colors.ENDC}") From d904433bd7b0acfb179c8e53b3e103fa56defe95 Mon Sep 17 00:00:00 2001 From: Abhi Mehrotra Date: Sun, 22 Feb 2026 03:41:26 -0600 Subject: [PATCH 3/5] Update test_ux.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- tests/test_ux.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_ux.py b/tests/test_ux.py index 8de33326..8fe022df 100644 --- a/tests/test_ux.py +++ b/tests/test_ux.py @@ -112,7 +112,7 @@ def test_print_success_message_single_profile(monkeypatch): assert "View your changes" in combined_output assert "https://controld.com/dashboard/profiles/123456/filters" in combined_output # Check for color codes presence (cyan or underline) - assert "\033[96m" in combined_output or "\033[4m" in combined_output + assert "\033[96m" in combined_output and "\033[4m" in combined_output def test_print_success_message_multiple_profiles(monkeypatch): """Verify success message includes general dashboard link for multiple profiles.""" From 10b8da37e12003dbe8ed7b4dbf948162d0757e94 Mon Sep 17 00:00:00 2001 From: Abhi Mehrotra Date: Sun, 22 Feb 2026 03:41:38 -0600 Subject: [PATCH 4/5] Update main.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- main.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 425ee3ca..62ad6bb5 100644 --- a/main.py +++ b/main.py @@ -2410,12 +2410,14 @@ def print_success_message(profile_ids: List[str]) -> None: ] print(f"\n{Colors.GREEN}{random.choice(success_msgs)}{Colors.ENDC}") - # Construct dashboard URL - dashboard_url = None + # Construct dashboard URL once, then print it in a single place + dashboard_url: Optional[str] = None if profile_ids and len(profile_ids) == 1 and profile_ids[0] != "dry-run-placeholder": dashboard_url = f"https://controld.com/dashboard/profiles/{profile_ids[0]}/filters" - elif len(profile_ids) > 1: + elif profile_ids and len(profile_ids) > 1: dashboard_url = "https://controld.com/dashboard/profiles" + + if dashboard_url: if dashboard_url: print(f"{Colors.CYAN}👀 View your changes: {Colors.UNDERLINE}{dashboard_url}{Colors.ENDC}") From 095c87086506b2fc52896a6fe7af6d32c2122087 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 22 Feb 2026 09:46:41 +0000 Subject: [PATCH 5/5] UX: Add dashboard link to success message (attempt 2) Co-authored-by: abhimehro <84992105+abhimehro@users.noreply.github.com> --- main.py | 11 ++++------- tests/test_ux.py | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index 62ad6bb5..9ebbdb3e 100644 --- a/main.py +++ b/main.py @@ -628,7 +628,7 @@ def get_password( # --------------------------------------------------------------------------- # -# 2. Clients +# 2. Clients (configured with secure defaults) # --------------------------------------------------------------------------- # def _api_client() -> httpx.Client: return httpx.Client( @@ -2410,15 +2410,12 @@ def print_success_message(profile_ids: List[str]) -> None: ] print(f"\n{Colors.GREEN}{random.choice(success_msgs)}{Colors.ENDC}") - # Construct dashboard URL once, then print it in a single place - dashboard_url: Optional[str] = None + # Construct dashboard URL if profile_ids and len(profile_ids) == 1 and profile_ids[0] != "dry-run-placeholder": dashboard_url = f"https://controld.com/dashboard/profiles/{profile_ids[0]}/filters" - elif profile_ids and len(profile_ids) > 1: + print(f"{Colors.CYAN}👀 View your changes: {Colors.UNDERLINE}{dashboard_url}{Colors.ENDC}") + elif len(profile_ids) > 1: dashboard_url = "https://controld.com/dashboard/profiles" - - if dashboard_url: - if dashboard_url: print(f"{Colors.CYAN}👀 View your changes: {Colors.UNDERLINE}{dashboard_url}{Colors.ENDC}") diff --git a/tests/test_ux.py b/tests/test_ux.py index 8fe022df..8de33326 100644 --- a/tests/test_ux.py +++ b/tests/test_ux.py @@ -112,7 +112,7 @@ def test_print_success_message_single_profile(monkeypatch): assert "View your changes" in combined_output assert "https://controld.com/dashboard/profiles/123456/filters" in combined_output # Check for color codes presence (cyan or underline) - assert "\033[96m" in combined_output and "\033[4m" in combined_output + assert "\033[96m" in combined_output or "\033[4m" in combined_output def test_print_success_message_multiple_profiles(monkeypatch): """Verify success message includes general dashboard link for multiple profiles."""