Skip to content

web: weekly usage chips and popover in the sidebar footer #153

Closed

Description

@yansfil

Why

The Swift shell shows each provider's weekly usage in the sidebar footer: a chip per provider between the device picker and Settings, and a Weekly Usage popover above them.
The web shell shows nothing, although the core already computes the numbers.
Usage display is on the umbrella PRD's deferred list (agents/prd/web-shell-pivot/prd.md D-04).

What exists

  • herdr-core/src/usage.rs fills navigator.provider_usage: one row per provider (claude read through claude -p /usage, codex through its usage endpoint with a session-JSONL fallback), each with state, used_percent, resets_at_unix_seconds, message, and buckets (per-model rows such as Fable under Claude Code).
  • The refresh timer reads two hints that ride ui_state_update: usage_window_visible (a 5-minute refresh while the window is visible) and usage_popover_open (opening the popover refreshes a row older than 60 s).
  • Swift draws it in macos/Sources/HerdrMacOS/HideSidebar.swift (HideUsagePopover).

Gap

  • contracts/hided-ws.schema.json declares neither navigator.provider_usage nor the two hint fields, so web/src/generated/hided-ws.ts has no type for them.
  • The web never sends the hints, so a web-only session gets the first read and never refreshes.
  • web/src/sidebar.tsx has no chip or popover.

Scope

  • Contract: declare provider_usage (with buckets) on the navigator and usage_window_visible / usage_popover_open on ui_state_update, then regenerate the web types.
  • Footer chips: provider mark and percent, colored by the same thresholds as Swift, muted when state is not available, stale or fallback.
  • Popover: Weekly Usage with 7 days, one row per provider (label, reset countdown such as in 5d 4h, percent, bar) and indented bucket rows under it.
  • Hints: usage_window_visible follows document visibility, usage_popover_open follows the popover.
  • States: loading and unavailable read as a muted chip with the row's message inside the popover, never a banner (design principle Move live and remote Herdr parsing to the typed boundary #13).
  • Pen: draw the chip and popover as a Component sheet and update the sidebar screen sheet in the same PR (docs/DESIGN_WORKFLOW.md).

Done when

  • For one core, the web chips and popover show the same percents and resets as the Swift shell.
  • Opening the popover after 60 s triggers a read, and a hidden tab stops the 5-minute refresh.
  • Web e2e covers an available, a loading and an unavailable row from the fixture.
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions