Skip to content

[P4d] Create TUI sidebar component for token-meter #33

Description

@four-bytes-robby

Purpose

TUI sidebar component showing live token usage with color-coded progress bar. Subscribes to plugin bus for real-time updates.

Scope

TUI component (src/tui.tsx)

  • @jsxImportSource @opentui/solid
  • Sidebar slot: sidebar_content
  • Auto-refresh: subscribes to tbg/+/status via BusTui
  • Progress bar: width = percentage, color:
    • Green (< 50%): tokens well within budget
    • Yellow (50-80%): approaching soft limit
    • Red (> 80%): near hard limit
  • Display: token count, percentage, status text
  • Truncated session ID

BusTui integration

  • Import BusTui from @four-bytes/opencode-plugin-lib/tui
  • On mount: connect to bus, subscribe to tbg/+/status
  • On message: update SolidJS signals
  • On unmount: unsubscribe, close connection
  • Auto-reconnect handled by BusTui

Startup message

  • If no bus running: show "plugin bus not available" for 3 seconds, then hide
  • If bus running but no TBG session: show "waiting for session..."

Files

  • src/tui.tsx (new)

Depends on

Acceptance

  • TUI sidebar renders with progress bar
  • Updates in real-time as tokens accumulate
  • Color changes at threshold crossings
  • Shows "plugin bus not available" when bus is down

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions