Skip to content

feat: harden OpenCode collector with robust status, mtime polling, chat/tool logs, and subagent tree#148

Closed
weby-homelab wants to merge 5 commits into
graykode:mainfrom
weby-homelab:feature/enhance-opencode-monitoring
Closed

feat: harden OpenCode collector with robust status, mtime polling, chat/tool logs, and subagent tree#148
weby-homelab wants to merge 5 commits into
graykode:mainfrom
weby-homelab:feature/enhance-opencode-monitoring

Conversation

@weby-homelab

@weby-homelab weby-homelab commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

This PR significantly hardens and refactors the OpenCode agent collector in abtop, bringing it to full feature parity with other collectors like Claude and Codex, while drastically optimizing resource usage.

Key Enhancements

  1. Dialogue History & Tool Calls Timeline:

    • Instead of returning empty vectors for chat history, abtop now queries the part table, joining with the message table.
    • Extracts and reconstructs actual ChatMessage lines (handling text and reasoning blocks, with secret redaction) and ToolCall events (calculating tool duration and extracting arguments like commands, file paths, and descriptions).
  2. Real-time Database Polling via mtime (Zero-CPU Idle):

    • Implemented dynamic database and WAL file modification time (mtime) polling.
    • Re-queries the SQLite DB immediately when modifications are detected, but falls back to the slow_tick cache (every 10s) when idle. This provides instant TUI updates during active agent runs without spawning unnecessary sqlite3 CLI processes.
  3. Precise Status Derivation (Zero Heuristics):

    • Replaced the arbitrary 30-second timestamp heuristic with precise SQL-backed status resolution.
    • Checks the role of the last message (user vs assistant) and whether the time.completed field is present. Falls back to process/descendant CPU usage only if a background tool is actively running.
  4. Robust Subagent PID Filtering:

    • Filters out child/subagent processes (descendant opencode processes) during PID-to-session mapping. This prevents subagents from being misidentified as main sessions in the list.
  5. Expanded History:

    • Increased MAX_SESSIONS limit from 20 to 50 to display a wider history of past agent runs.
  6. Git Branch & DB Path discovery:

    • Preserves dynamic .git/HEAD branch resolution (avoiding expensive git branch forks) and dynamic opencode*.db path discovery.

@weby-homelab weby-homelab changed the title feat: enhance OpenCode support with subagent tree, dynamic db discovery, and git branch tracking feat: harden OpenCode collector with robust status, mtime polling, chat/tool logs, and subagent tree Jun 30, 2026
@weby-homelab weby-homelab deleted the feature/enhance-opencode-monitoring branch June 30, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant