Repository navigation
π¨ Palette: Improve termux-multi-agent telemetry dashboard UX #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ## 2026-08-01 - Flicker-Free Real-Time CLI Dashboards with Rich Live | ||
| **Learning:** Terminal dashboards that clear the screen using raw ANSI escape codes (`\033[H\033[J`) or `clear` commands create severe flicker and redraw lag. This harms cognitive accessibility and visual appeal. Using `rich.live.Live` with high-level structural layout (`Table`, `Panel`, `Text`) ensures updates are drawn to the screen differential/flicker-free, and handles terminal exits cleanly. | ||
| **Action:** Always prefer `rich.live.Live` (or similar differential-updating curses-like tools) for terminal UI dashboards that require frequent, real-time telemetry updates. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,11 +1,24 @@ | ||||||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env python3 | ||||||||||||||||||||||||||||||||||||||||||
| import time | ||||||||||||||||||||||||||||||||||||||||||
| import os | ||||||||||||||||||||||||||||||||||||||||||
| import json | ||||||||||||||||||||||||||||||||||||||||||
| import sys | ||||||||||||||||||||||||||||||||||||||||||
| from datetime import datetime | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| TELEMETRY_LOG = "agent_telemetry_stream.json" | ||||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||||
| from rich.console import Console, Group | ||||||||||||||||||||||||||||||||||||||||||
| from rich.table import Table | ||||||||||||||||||||||||||||||||||||||||||
| from rich.panel import Panel | ||||||||||||||||||||||||||||||||||||||||||
| from rich.live import Live | ||||||||||||||||||||||||||||||||||||||||||
| from rich.text import Text | ||||||||||||||||||||||||||||||||||||||||||
| from rich.box import ROUNDED | ||||||||||||||||||||||||||||||||||||||||||
| except ImportError: | ||||||||||||||||||||||||||||||||||||||||||
| # Clean fallback warning | ||||||||||||||||||||||||||||||||||||||||||
| print("[ERROR] 'rich' library is required. Please run: pip install rich") | ||||||||||||||||||||||||||||||||||||||||||
| sys.exit(1) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+9
to
19
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π New runtime dependency on rich is not declared The dashboard now hard-fails with Was this helpful? React with π or π to provide feedback. |
||||||||||||||||||||||||||||||||||||||||||
| def clear_screen(): | ||||||||||||||||||||||||||||||||||||||||||
| print("\033[H\033[J", end="") | ||||||||||||||||||||||||||||||||||||||||||
| TELEMETRY_LOG = "agent_telemetry_stream.json" | ||||||||||||||||||||||||||||||||||||||||||
| console = Console() | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| def read_latest_telemetry(): | ||||||||||||||||||||||||||||||||||||||||||
| if not os.path.exists(TELEMETRY_LOG): | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -16,54 +29,136 @@ def read_latest_telemetry(): | |||||||||||||||||||||||||||||||||||||||||
| for line in f: | ||||||||||||||||||||||||||||||||||||||||||
| if not line.strip(): | ||||||||||||||||||||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||||||||||||||||||||
| entry = json.loads(line) | ||||||||||||||||||||||||||||||||||||||||||
| target = entry.get("target") or "System" | ||||||||||||||||||||||||||||||||||||||||||
| active_jobs[target] = entry | ||||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||||
| entry = json.loads(line) | ||||||||||||||||||||||||||||||||||||||||||
| target = entry.get("target") or "System" | ||||||||||||||||||||||||||||||||||||||||||
| active_jobs[target] = entry | ||||||||||||||||||||||||||||||||||||||||||
| except json.JSONDecodeError: | ||||||||||||||||||||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||||||||||||||||||||
| except Exception: | ||||||||||||||||||||||||||||||||||||||||||
| pass | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+32
to
39
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π― Functional Correctness | π‘ Minor | β‘ Quick win Skip telemetry records with an invalid JSON shape. Line 34 assumes that every valid JSON value is an object. A JSON array, scalar, or object with a non-string Validate the record type and Proposed fix try:
entry = json.loads(line)
- target = entry.get("target") or "System"
+ if not isinstance(entry, dict):
+ continue
+ target = entry.get("target")
+ if not isinstance(target, str) or not target:
+ target = "System"
active_jobs[target] = entry
except json.JSONDecodeError:
continueπ Committable suggestion
Suggested change
π§° Toolsπͺ Ruff (0.16.0)[error] 38-39: (S110) [warning] 38-38: Do not catch blind exception: (BLE001) π€ Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
| return list(active_jobs.values()) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| def render_dashboard(): | ||||||||||||||||||||||||||||||||||||||||||
| clear_screen() | ||||||||||||||||||||||||||||||||||||||||||
| print("=" * 65) | ||||||||||||||||||||||||||||||||||||||||||
| print(" β‘ TERMUX MULTI-AGENT PARALLEL TELEMETRY DASHBOARD β‘ ") | ||||||||||||||||||||||||||||||||||||||||||
| print("=" * 65) | ||||||||||||||||||||||||||||||||||||||||||
| print(f" Last Sync: {time.strftime('%Y-%m-%d %H:%M:%S')}") | ||||||||||||||||||||||||||||||||||||||||||
| print("-" * 65) | ||||||||||||||||||||||||||||||||||||||||||
| print(f"{'TARGET FILE':<20} | {'AGENT':<16} | {'TRY':<4} | {'STATUS':<15}") | ||||||||||||||||||||||||||||||||||||||||||
| print("-" * 65) | ||||||||||||||||||||||||||||||||||||||||||
| # Sort by timestamp so the list ordering is consistent/predictable | ||||||||||||||||||||||||||||||||||||||||||
| return sorted(active_jobs.values(), key=lambda x: x.get("timestamp", "")) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+41
to
42
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π Info: Sorting by timestamp assumes the field is always a string
Was this helpful? React with π or π to provide feedback. |
||||||||||||||||||||||||||||||||||||||||||
| def make_dashboard(): | ||||||||||||||||||||||||||||||||||||||||||
| # Read data | ||||||||||||||||||||||||||||||||||||||||||
| jobs = read_latest_telemetry() | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| # Header info | ||||||||||||||||||||||||||||||||||||||||||
| now_str = datetime.now().strftime("%Y-%m-%d %H:%M:%S") | ||||||||||||||||||||||||||||||||||||||||||
| header_text = Text() | ||||||||||||||||||||||||||||||||||||||||||
| header_text.append("β‘ TERMUX MULTI-AGENT PARALLEL TELEMETRY β‘\n", style="bold yellow") | ||||||||||||||||||||||||||||||||||||||||||
| header_text.append(f"Last Sync: {now_str} | File: {TELEMETRY_LOG}", style="dim") | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| header_panel = Panel( | ||||||||||||||||||||||||||||||||||||||||||
| header_text, | ||||||||||||||||||||||||||||||||||||||||||
| box=ROUNDED, | ||||||||||||||||||||||||||||||||||||||||||
| border_style="yellow", | ||||||||||||||||||||||||||||||||||||||||||
| expand=True, | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if not jobs: | ||||||||||||||||||||||||||||||||||||||||||
| print(" [ Waiting for background agent pipelines to initialize... ]") | ||||||||||||||||||||||||||||||||||||||||||
| # Beautiful empty state | ||||||||||||||||||||||||||||||||||||||||||
| empty_text = Text() | ||||||||||||||||||||||||||||||||||||||||||
| empty_text.append("\n[ Waiting for background agent pipelines to initialize... ]\n\n", style="italic cyan") | ||||||||||||||||||||||||||||||||||||||||||
| empty_text.append("To start the multi-agent orchestration pipeline, run:\n", style="dim") | ||||||||||||||||||||||||||||||||||||||||||
| empty_text.append(" ./run_agent.sh\n", style="bold green") | ||||||||||||||||||||||||||||||||||||||||||
| empty_text.append("\nThis dashboard will automatically update once events are received.\n", style="dim") | ||||||||||||||||||||||||||||||||||||||||||
| empty_text.append("Press Ctrl+C to exit.", style="dim red") | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+62
to
+68
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π Log path is relative to the process CWD, and empty-state guidance may mislead
Was this helpful? React with π or π to provide feedback. |
||||||||||||||||||||||||||||||||||||||||||
| body_panel = Panel( | ||||||||||||||||||||||||||||||||||||||||||
| empty_text, | ||||||||||||||||||||||||||||||||||||||||||
| title="System Status", | ||||||||||||||||||||||||||||||||||||||||||
| box=ROUNDED, | ||||||||||||||||||||||||||||||||||||||||||
| border_style="cyan", | ||||||||||||||||||||||||||||||||||||||||||
| expand=True | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
| return Panel( | ||||||||||||||||||||||||||||||||||||||||||
| Group( | ||||||||||||||||||||||||||||||||||||||||||
| header_panel, | ||||||||||||||||||||||||||||||||||||||||||
| body_panel | ||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||
| box=ROUNDED, | ||||||||||||||||||||||||||||||||||||||||||
| border_style="dim" | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| # Beautiful table | ||||||||||||||||||||||||||||||||||||||||||
| table = Table(box=ROUNDED, border_style="dim", expand=True) | ||||||||||||||||||||||||||||||||||||||||||
| table.add_column("Target File", style="bold cyan", no_wrap=True) | ||||||||||||||||||||||||||||||||||||||||||
| table.add_column("Agent", style="bold magenta") | ||||||||||||||||||||||||||||||||||||||||||
| table.add_column("Try", justify="center", style="yellow") | ||||||||||||||||||||||||||||||||||||||||||
| table.add_column("Status", justify="center") | ||||||||||||||||||||||||||||||||||||||||||
| table.add_column("Last Message", style="white") | ||||||||||||||||||||||||||||||||||||||||||
| table.add_column("Timestamp", style="dim", justify="right") | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| for job in jobs: | ||||||||||||||||||||||||||||||||||||||||||
| target = job.get("target") or "Global" | ||||||||||||||||||||||||||||||||||||||||||
| if len(target) > 18: | ||||||||||||||||||||||||||||||||||||||||||
| target = "..." + target[-15:] | ||||||||||||||||||||||||||||||||||||||||||
| # truncate long targets cleanly | ||||||||||||||||||||||||||||||||||||||||||
| if len(target) > 25: | ||||||||||||||||||||||||||||||||||||||||||
| target = "..." + target[-22:] | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| agent = job.get("agent", "Unknown") | ||||||||||||||||||||||||||||||||||||||||||
| attempt = str(job.get("attempt") or "-") | ||||||||||||||||||||||||||||||||||||||||||
| level = job.get("level", "INFO") | ||||||||||||||||||||||||||||||||||||||||||
| message = job.get("message", "") | ||||||||||||||||||||||||||||||||||||||||||
| timestamp = job.get("timestamp", "") | ||||||||||||||||||||||||||||||||||||||||||
| if timestamp: | ||||||||||||||||||||||||||||||||||||||||||
| # Format time if it has full date/time | ||||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||||
| dt = datetime.strptime(timestamp, "%Y-%m-%d %H:%M:%S") | ||||||||||||||||||||||||||||||||||||||||||
| timestamp = dt.strftime("%H:%M:%S") | ||||||||||||||||||||||||||||||||||||||||||
| except ValueError: | ||||||||||||||||||||||||||||||||||||||||||
| pass | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| # Beautiful styled status tag | ||||||||||||||||||||||||||||||||||||||||||
| if level == "SUCCESS": | ||||||||||||||||||||||||||||||||||||||||||
| status_str = "\033[92mSUCCESS\033[0m" | ||||||||||||||||||||||||||||||||||||||||||
| status_str = Text("SUCCESS", style="bold green") | ||||||||||||||||||||||||||||||||||||||||||
| elif level == "RETRY": | ||||||||||||||||||||||||||||||||||||||||||
| status_str = "\033[93mRETRYING\033[0m" | ||||||||||||||||||||||||||||||||||||||||||
| status_str = Text("RETRYING", style="bold yellow") | ||||||||||||||||||||||||||||||||||||||||||
| elif level == "CRITICAL": | ||||||||||||||||||||||||||||||||||||||||||
| status_str = "\033[91mCRITICAL\033[0m" | ||||||||||||||||||||||||||||||||||||||||||
| status_str = Text("CRITICAL", style="bold red") | ||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||
| status_str = "\033[94mPROCESSING\033[0m" | ||||||||||||||||||||||||||||||||||||||||||
| status_str = Text("PROCESSING", style="bold blue") | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| table.add_row( | ||||||||||||||||||||||||||||||||||||||||||
| target, | ||||||||||||||||||||||||||||||||||||||||||
| agent, | ||||||||||||||||||||||||||||||||||||||||||
| attempt, | ||||||||||||||||||||||||||||||||||||||||||
| status_str, | ||||||||||||||||||||||||||||||||||||||||||
| message, | ||||||||||||||||||||||||||||||||||||||||||
| timestamp | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+124
to
+131
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π Info: Table cell strings are parsed as Rich markup
Was this helpful? React with π or π to provide feedback. |
||||||||||||||||||||||||||||||||||||||||||
| footer_text = Text("\nPress Ctrl+C to exit Dashboard Viewer.", style="dim italic red") | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| print(f"{target:<20} | {agent:<16} | {attempt:<4} | {status_str:<15}") | ||||||||||||||||||||||||||||||||||||||||||
| print(f" β³ Msg: {job.get('message', '')[:60]}") | ||||||||||||||||||||||||||||||||||||||||||
| print("-" * 65) | ||||||||||||||||||||||||||||||||||||||||||
| return Panel( | ||||||||||||||||||||||||||||||||||||||||||
| Group( | ||||||||||||||||||||||||||||||||||||||||||
| header_panel, | ||||||||||||||||||||||||||||||||||||||||||
| table, | ||||||||||||||||||||||||||||||||||||||||||
| footer_text | ||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||
| box=ROUNDED, | ||||||||||||||||||||||||||||||||||||||||||
| border_style="blue", | ||||||||||||||||||||||||||||||||||||||||||
| title="Agent Live Monitor" | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| def main(): | ||||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||||
| while True: | ||||||||||||||||||||||||||||||||||||||||||
| render_dashboard() | ||||||||||||||||||||||||||||||||||||||||||
| time.sleep(1.0) | ||||||||||||||||||||||||||||||||||||||||||
| # Use Live rendering for smooth, flicker-free updates | ||||||||||||||||||||||||||||||||||||||||||
| with Live(make_dashboard(), refresh_per_second=1, screen=True) as live: | ||||||||||||||||||||||||||||||||||||||||||
| while True: | ||||||||||||||||||||||||||||||||||||||||||
| time.sleep(1.0) | ||||||||||||||||||||||||||||||||||||||||||
| live.update(make_dashboard()) | ||||||||||||||||||||||||||||||||||||||||||
| except KeyboardInterrupt: | ||||||||||||||||||||||||||||||||||||||||||
| print("\nExiting Dashboard Viewer.") | ||||||||||||||||||||||||||||||||||||||||||
| # Clear screen and say goodbye gracefully | ||||||||||||||||||||||||||||||||||||||||||
| console.clear() | ||||||||||||||||||||||||||||||||||||||||||
| console.print(Panel( | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+154
to
+155
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π‘ Exiting the dashboard wipes whatever was on the terminal before it started On exit the whole terminal display is erased ( Alternate-screen restore followed by an explicit clear
Suggested change
Was this helpful? React with π or π to provide feedback. |
||||||||||||||||||||||||||||||||||||||||||
| "[bold green]Thank you for using Termux Multi-Agent Dashboard![/bold green]\n" | ||||||||||||||||||||||||||||||||||||||||||
| "Stay productive and keep building! β‘π", | ||||||||||||||||||||||||||||||||||||||||||
| title="Exiting Dashboard", | ||||||||||||||||||||||||||||||||||||||||||
| border_style="green", | ||||||||||||||||||||||||||||||||||||||||||
| expand=False | ||||||||||||||||||||||||||||||||||||||||||
| )) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if __name__ == '__main__': | ||||||||||||||||||||||||||||||||||||||||||
| main() | ||||||||||||||||||||||||||||||||||||||||||
| main() | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π Info: "Uniform exit signature" is bypassed by an early return inside the menu loop
The new unconditional farewell after the loop covers
breakpaths, but the staged-block restore branch doesreturnfrommain()mid-loop (archwiz/archwiz.py:211), so that exit path prints no farewell. Also, ifmain()is imported/called elsewhere, the message now prints on every loop exit rather than only on explicit quit.Was this helpful? React with π or π to provide feedback.