Skip to content

feat: add quota usage display and rate limit warnings (fixes #691)#745

Merged
PureWeen merged 2 commits intomainfrom
fix/issue-691-quota-display
Apr 23, 2026
Merged

feat: add quota usage display and rate limit warnings (fixes #691)#745
PureWeen merged 2 commits intomainfrom
fix/issue-691-quota-display

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Summary

Adds a quota usage display and rate limit warnings to the PolyPilot dashboard, addressing issue #691.

Changes

Quota Indicator (Dashboard Header)

  • Color-coded pill in the dashboard header showing remaining premium quota percentage
  • Green (>50%): healthy usage
  • Yellow (20-50%): approaching limit
  • Red (≤20%): critical, with pulsing dot animation
  • Tooltip shows compact summary with reset countdown
  • Shows "Unlimited" for unlimited plans

Warning Banner

  • Appears when quota drops below 20% (critical threshold)
  • Shows remaining requests count, percentage, and reset countdown (e.g., "Resets in 5 days")
  • Dismissable — auto-resets when quota recovers above threshold

Enhanced Session View

  • Expanded session view now shows color-coded quota info with percentage
  • Added "Resets in X days" countdown alongside reset date

Enhanced /usage Command

  • Reset date now includes human-friendly countdown (e.g., 2026-05-01 (Resets in 8 days))

Service Layer

  • CopilotService.LatestQuotaInfo — tracks latest account-level quota from any session
  • CopilotService.OnQuotaChanged — event fired when quota info updates
  • QuotaDisplayHelper — static helper with level classification, reset countdown, compact summary, CSS class mapping

Files Changed

File Change
PolyPilot/Models/QuotaDisplayHelper.cs New: quota display helper with level/countdown/summary logic
PolyPilot/Services/CopilotService.cs Add LatestQuotaInfo property and OnQuotaChanged event
PolyPilot/Services/CopilotService.Events.cs Fire OnQuotaChanged from AssistantUsageEvent handler
PolyPilot/Components/Pages/Dashboard.razor Quota indicator, warning banner, event subscription
PolyPilot/Components/Pages/Dashboard.razor.css Styles for indicator pill, color variants, warning banner
PolyPilot/Components/ExpandedSessionView.razor Color-coded quota with reset countdown
PolyPilot/Components/ExpandedSessionView.razor.css Quota color styles
PolyPilot.Tests/QuotaDisplayTests.cs 22 new unit tests
PolyPilot.Tests/UsageCommandTests.cs Updated format mirror for reset countdown
PolyPilot.IntegrationTests/QuotaDisplayTests.cs Integration test stubs

Test Results

Warning

⚠️ Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • 192.0.2.1

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "192.0.2.1"

See Network Configuration for more information.

Generated by Agent Fix for issue #691 · ● 72.1M ·

Add a quota indicator pill in the dashboard header that shows remaining
premium quota percentage with color coding:
- Green (>50%): healthy usage
- Yellow (20-50%): approaching limit
- Red (≤20%): critical, with pulsing animation

Add a warning banner that appears when quota drops below 20%, showing
remaining requests and reset countdown (e.g., 'Resets in 5 days').

Enhance the expanded session view to show color-coded quota with reset
countdown. Enhance /usage command output with reset countdown info.

Implementation:
- QuotaDisplayHelper: static helper with level classification, reset
  countdown formatting, compact summary, and CSS class mapping
- CopilotService: LatestQuotaInfo property and OnQuotaChanged event
  fired from AssistantUsageEvent handler
- Dashboard: quota indicator in header-meta, warning banner with dismiss
- ExpandedSessionView: color-coded quota info with reset countdown

Tests: 22 new unit tests for QuotaDisplayHelper (level thresholds, reset
countdown parsing, compact summary formatting). Integration test stubs
for quota indicator and warning banner rendering.

Fixes #691

Co-authored-by: copilot-agentic-workflow[bot] <224017+copilot-agentic-workflow[bot]@users.noreply.github.com>

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@PureWeen
Copy link
Copy Markdown
Owner

CI Screenshots (Mac Catalyst Integration Test)

Screenshots from integration run #24815950280:

Note: The quota indicator requires live Copilot API quota data to render. In CI (Demo mode), no quota events fire so the indicator is not visible in these screenshots. The quota display logic is covered by 24 unit tests including edge cases (negative numbers, reset countdown, thread safety).

App startup (Dashboard):
Download artifacts from the CI runpolypilot-maccatalyst to see:

  • polypilot-ci-screenshot.png — Initial app state
  • polypilot-after-create-form.png — Session creation
  • polypilot-after-session.png — Active session with messages

To see the quota indicator locally, run the app with a real Copilot connection and send a few messages — the indicator appears in the header bar after the first AssistantUsageEvent with quota data.

@PureWeen
Copy link
Copy Markdown
Owner

Screenshots

The quota indicator requires live Copilot API data to render (the SDK fires AssistantUsageEvent with quota info after each API call). In CI Demo mode, no quota events fire so the indicator isn't visible in automated screenshots.

CI artifacts (app launch + smoke tests): Integration run artifacts → download polypilot-maccatalyst

To see the quota feature locally:

  1. Run PolyPilot with a real Copilot connection
  2. Send a few messages to generate AssistantUsageEvents
  3. The quota pill appears in the Dashboard header bar (green/yellow/red based on remaining %)
  4. When <20%, a warning banner appears

What the quota UI shows:

  • Header pill: colored dot + remaining percentage
  • Hover: compact usage summary ("X/Y requests used")
  • Warning banner at <20% (dismissible, auto-resets on recovery)
  • Enhanced /usage command with reset countdown

The logic is covered by 24 unit tests including edge cases (negative numbers from overage, reset countdown at boundary, thread safety).

@PureWeen
Copy link
Copy Markdown
Owner

📸 CI Screenshots

Download from the integration test run artifacts:

Contents: polypilot-ci-screenshot.png, polypilot-after-create-form.png, polypilot-after-session.png

Creates a session, sends a message to trigger AssistantUsageEvent,
waits for quota indicator to appear, then screenshots it.
Also tests /usage command output.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
PureWeen added a commit that referenced this pull request Apr 23, 2026
## Summary

Fixes two bugs in `polypilot-integration.yml` that caused the
integration test run dispatched by PR #745 to fail:

### Bug 1: Linux/GTK binary not found
The `find-binary` step searched for `PolyPilot.Gtk` /
`PolyPilot.Gtk.dll`, but the GTK csproj has
`<AssemblyName>PolyPilot</AssemblyName>`. The build output is named
`PolyPilot` / `PolyPilot.dll`, so the search always failed.

### Bug 2: Report job — 'not a git repository'
The report job runs `gh pr comment` without an `actions/checkout` step.
The `gh` CLI can't determine the repo without a git context. Fixed by
adding `--repo ${{ github.repository }}`.

### Evidence
Integration test run
[#24815950280](https://github.com/PureWeen/PolyPilot/actions/runs/24815950280)
— dispatched by agent-fix for PR #745 — failed on both of these.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor Author

🧪 Integration Test Report — PR #745

Platform Build Launch DevFlow Smoke
Linux/GTK (xvfb)
Mac Catalyst
Windows ⚠️ ⚠️

✅ All platforms passed

View full run

PureWeen added a commit that referenced this pull request Apr 23, 2026
)

## Summary

The auto-fix feedback loop (`auto-fix-on-failure.yml`) has **never
triggered** (0 runs) because two bugs prevented it from working with
`workflow_dispatch`-based integration tests.

### Bug 1: `branches-ignore: main`
Integration tests dispatched by the agent-fix workflow use
`workflow_dispatch`, which always runs on `main` (the `ref` input only
controls which code is checked out). The `branches-ignore: main` filter
excluded all such runs.

### Bug 2: PR lookup by `head_branch`  
For `workflow_dispatch` runs, `head_branch` is `main`, not the PR
branch. The original code searched for a PR with `--head main`, finding
nothing.

**Fix:** Read `pr_number` from the failed run's inputs via the API
first, fall back to branch-based lookup for push/PR-triggered runs. Also
resolve the actual PR branch name for the comment.

### Bug 3: Insufficient permissions
`pull-requests: read` → `pull-requests: write` (needed for `gh pr
comment`).

### Testing
This was discovered while validating the end-to-end agent-fix pipeline
for PR #745. The agent correctly dispatched integration tests, but when
they failed (due to workflow YAML bugs fixed in #755), the auto-fix loop
never fired.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@PureWeen PureWeen marked this pull request as ready for review April 23, 2026 19:29
@PureWeen PureWeen merged commit a269556 into main Apr 23, 2026
6 checks passed
@PureWeen PureWeen deleted the fix/issue-691-quota-display branch April 23, 2026 19:45
PureWeen pushed a commit that referenced this pull request Apr 23, 2026
)

feat: add quota usage display and rate limit warnings

- Color-coded quota indicator pill in dashboard header (green/yellow/red)
- Warning banner when quota drops below 20%
- Enhanced /usage command with reset countdown
- 22 new unit tests

Fixes #691

Generated by agent-fix workflow. Passed integration tests + expert code review.
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.

Add Quota usage display and rate limit warnings

1 participant