Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .Jules/palette.md
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.
18 changes: 16 additions & 2 deletions archwiz/archwiz.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ def banner():
β•šβ•β• β•šβ•β•β•šβ•β• β•šβ•β• β•šβ•β•β•β•β•β•β•šβ•β• β•šβ•β• β•šβ•β•β•β•šβ•β•β• β•šβ•β•β•šβ•β•β•β•β•β•β•
""" + N)
print(f"{G}\u26a1 ARCHWIZ DASHBOARD \u26a1{N} {time.strftime('%c')}")
print(f"{W}session: {os.getlogin()}@{os.uname().nodename}{N}")
try:
username = os.getlogin()
except Exception:
import getpass
username = getpass.getuser()
print(f"{W}session: {username}@{os.uname().nodename}{N}")
print(C + "\u2500" * 60 + N)

def get_pipeline_status():
Expand Down Expand Up @@ -94,6 +99,7 @@ def main():
try:
choice = input(f"{C}>> {N}").strip().lower()
except (EOFError, KeyboardInterrupt):
print() # Ensure clean line alignment on interrupt exit
break

if choice == '1':
Expand Down Expand Up @@ -376,8 +382,16 @@ def main():
elif choice == 'p':
toggle_pipeline()
elif choice == '0':
print(G + random.choice(["ArchWiz signing off. Forge well.", "Until next cycle. Stay l33T.", "Dashboard closed. The Forge awaits.", "ArchWiz out. Happy hacking.", "Systems stable. ArchWiz offline."]) + N)
break

# Uniform, delightful exit signature for all exits (choice '0', Ctrl+C, Ctrl+D)
print(G + random.choice([
"ArchWiz signing off. Forge well.",
"Until next cycle. Stay l33T.",
"Dashboard closed. The Forge awaits.",
"ArchWiz out. Happy hacking.",
"Systems stable. ArchWiz offline."
]) + N)
Comment on lines +387 to +394

Copy link
Copy Markdown
Contributor

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 break paths, but the staged-block restore branch does return from main() mid-loop (archwiz/archwiz.py:211), so that exit path prints no farewell. Also, if main() is imported/called elsewhere, the message now prints on every loop exit rather than only on explicit quit.

Open in Devin Review

Was this helpful? React with πŸ‘ or πŸ‘Ž to provide feedback.


if __name__ == '__main__':
main()
51 changes: 20 additions & 31 deletions deepcli-tui/tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,38 +270,27 @@ def prompt_session_id():

def show_commands():
"""Display available commands with descriptions."""
console.print(Panel("""
[bold cyan]/branches[/] List root messages (conversation branches)
[bold cyan]/branchpoints[/] Show fork points (messages with multiple children)
[bold cyan]/more[/] Toggle full tree (uncapped)
[bold cyan]/flat[/] Toggle flat/tree view
[bold cyan]/continue[/] Pick an assistant message to continue from
[bold cyan]/edit[/] Branch from a user message
[bold cyan]/back[/] Return to session selection
[bold cyan]/new[/] Create a new session
[bold cyan]/refresh[/] Clear cache and reload
[bold cyan]/bookmark[/] Save current position
[bold cyan]/bookmarks[/] List saved bookmarks
[bold cyan]/thinking on|off[/] Toggle DeepThink
[bold cyan]/search on|off[/] Toggle web search
[bold cyan]/model instant|expert[/] Switch model
help_text = """[bold cyan]/branches[/] List root messages (conversation branches)
[bold cyan]/branchpoints[/] Show fork points (messages with multiple children)
[bold cyan]/more[/] Toggle full tree (uncapped)
[bold cyan]/flat[/] Toggle flat/tree view
[bold cyan]/continue[/] Pick an assistant message to continue from
[bold cyan]/edit[/] Branch from a user message
[bold cyan]/back[/] Return to session selection
[bold cyan]/new[/] Create a new session
[bold cyan]/refresh[/] Clear cache and reload conversation
[bold cyan]/bookmark[/] Save current position
[bold cyan]/bookmarks[/] List saved bookmarks
[bold cyan]/thinking on|off[/] Toggle DeepThink
[bold cyan]/search on|off[/] Toggle web search
[bold cyan]/model instant|expert[/] Switch model
[bold cyan]/attach <files> | <prompt>[/] Attach files
[bold cyan]/reset[/] Reset to latest assistant
[bold cyan]/cmd[/] Show this reference
""", title="Commands", expand=False))
input("\nPress Enter to continue...")
help_text = """
[bold]Commands:[/]
/new, /continue, /edit, /reset, /thinking on|off, /search on|off
/model expert|instant, /attach <file>, /clear-attach
/flat – toggle flat list view
/refresh – clear cache and reload conversation
/more – show full tree (uncapped)
/branches – list conversation branches
/help – this help
exit/quit – leave
"""
console.print(Panel(help_text, title="Help"))
[bold cyan]/clear-attach[/] Clear current attachments
[bold cyan]/reset[/] Reset to latest assistant
[bold cyan]/cmd[/] Show this reference
[bold cyan]/help[/] Show this help menu
[bold cyan]exit / quit[/] Leave the TUI"""
console.print(Panel(help_text, title="πŸ“– DeepCLI TUI Commands Guide", expand=False, border_style="cyan"))
input("\nPress Enter to continue...")

def main():
Expand Down
159 changes: 127 additions & 32 deletions termux-multi-agent/dashboard.py
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 sys.exit(1) if rich is missing, but no requirements file in the repo (e.g. requirements-base.txt) was updated to declare it. On a fresh Termux install the dashboard becomes unusable until the user reads the error and installs manually.

Open in Devin Review

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):
Expand All @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 target can raise during parsing. Lines 38-39 then stop the whole read, so later valid telemetry records do not appear.

Validate the record type and target before using them. Add a regression test with an invalid record followed by a valid record.

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
try:
entry = json.loads(line)
target = entry.get("target") or "System"
active_jobs[target] = entry
except json.JSONDecodeError:
continue
except Exception:
pass
try:
entry = json.loads(line)
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
except Exception:
pass
🧰 Tools
πŸͺ› Ruff (0.16.0)

[error] 38-39: try-except-pass detected, consider logging the exception

(S110)


[warning] 38-38: Do not catch blind exception: Exception

(BLE001)

πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@termux-multi-agent/dashboard.py` around lines 32 - 39, Update the telemetry
parsing loop around json.loads and the target assignment to accept only
dictionary records with a string target (or no target, using β€œSystem”); skip
invalid shapes and continue processing subsequent lines instead of allowing them
to abort the read. Add a regression test covering an invalid record followed by
a valid record and verify the valid record is retained.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

πŸ“ Info: Sorting by timestamp assumes the field is always a string

sorted(..., key=lambda x: x.get("timestamp", "")) returns None when a log line contains an explicit "timestamp": null, and comparing None with str raises TypeError, which the surrounding try/except no longer covers (the sort happens after it). The current writer always sets a strftime string, so this is not reachable today, but key=lambda x: str(x.get("timestamp") or "") would make it robust against hand-edited or third-party log lines.

Open in Devin Review

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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

TELEMETRY_LOG remains a bare relative filename while the actual stream file lives at the repo root, not in termux-multi-agent/. The new empty-state panel tells the user to run ./run_agent.sh, but if the dashboard is launched from a different directory than the agent, the panel will keep showing 'waiting' forever even though events are being written. Resolving the path relative to the script location (or surfacing the absolute path in the header) would avoid the confusing dead-end.

Open in Devin Review

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

πŸ“ Info: Table cell strings are parsed as Rich markup

message, agent, and target are passed to table.add_row as plain strings, which Rich renders with console markup enabled. Telemetry messages currently emitted by termux-multi-agent/src/telemetry.py and provision_agent.py:318-369 are static literals with no square brackets, so this is safe today. However, any future message containing bracketed text (e.g. an exception string or [INFO] prefix) would be silently swallowed as a style tag or, if malformed, raise MarkupError inside the Live loop and terminate the dashboard. Wrapping these values in Text(...) would make cell rendering literal.

Open in Devin Review

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 (console.clear() at termux-multi-agent/dashboard.py:155) right after the previous screen contents were restored, so the user's earlier terminal output disappears.
Impact: Users lose the commands and output that were visible before launching the dashboard, contradicting the intended clean restore.

Alternate-screen restore followed by an explicit clear

Live(..., screen=True) at termux-multi-agent/dashboard.py:149 renders into the terminal's alternate screen buffer. When KeyboardInterrupt propagates out of the with block, Live's __exit__ leaves the alternate screen and the user's original screen contents are restored. The handler then calls console.clear(), which emits a clear-screen/home sequence against that restored primary screen, destroying the content that was just brought back before printing the goodbye panel. Simply printing the panel (without clearing) achieves the intended "clean restore + warm parting message".

Suggested change
console.clear()
console.print(Panel(
# Live(screen=True) already restored the previous terminal contents
console.print()
Open in Devin Review

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()