Skip to content

feat: Add pending requests count to the main dashboard#516

Merged
mostlygeek merged 10 commits intomostlygeek:mainfrom
author-brian-mendonca:Pending-Requests-Counter
Feb 16, 2026
Merged

feat: Add pending requests count to the main dashboard#516
mostlygeek merged 10 commits intomostlygeek:mainfrom
author-brian-mendonca:Pending-Requests-Counter

Conversation

@author-brian-mendonca
Copy link
Contributor

@author-brian-mendonca author-brian-mendonca commented Feb 11, 2026

This pull requests adds a "Waiting" count to the models dashboard, which I have found useful for tracking how many requests are pending to be processed if there is a lot of traffic incoming to the local server. This does not change how multiple requests are managed as that should be done in configs, but it can be useful at showing backlog versus completed requests and be a helpful metric for the overall system health. Tested compiling and usability on macOS Tahoe.

dashboard

Summary by CodeRabbit

  • New Features
    • Real-time in‑flight request counts broadcast to clients and included in initial and live updates.
    • UI stats panel now shows Completed and Waiting counts side‑by‑side.
    • Frontend store and event stream extended to receive and surface in‑flight totals for dashboards.

@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds in-flight request tracking: backend event/type, an InflightCounter and middleware that emits InFlightRequestsEvent, SSE emission of totals, frontend types and store, and UI changes to display completed vs waiting requests.

Changes

Cohort / File(s) Summary
Backend Events
proxy/events.go
Added InFlightRequestsEventID constant and InFlightRequestsEvent struct with Type() method.
Backend Proxy Manager
proxy/proxymanager.go
Added InflightCounter (mutex-protected) with Current, Increment, Decrement; added trackInflight() middleware; wired middleware into routes and initialized counter in ProxyManager.
Backend API Pipeline
proxy/proxymanager_api.go
Added internal inflight message handling and sendInFlight() helper; emits initial and event-driven in-flight totals via SSE.
Frontend Types
ui-svelte/src/lib/types.ts
Added InFlightStats interface and extended APIEventEnvelope union to include "inflight".
Frontend Store
ui-svelte/src/stores/api.ts
Added exported inFlightRequests writable store; initialize/reset on connect; handle "inflight" events to update the count.
Frontend UI
ui-svelte/src/components/StatsPanel.svelte
Imported inFlightRequests, propagated it through returned stats, and replaced the single total cell with Completed (totalRequests) and Waiting (inFlightRequests).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • mostlygeek
🚥 Pre-merge checks | ✅ 2 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (12 files):

⚔️ .github/workflows/containers.yml (content)
⚔️ docker/build-container.sh (content)
⚔️ proxy/events.go (content)
⚔️ proxy/proxymanager.go (content)
⚔️ proxy/proxymanager_api.go (content)
⚔️ ui-svelte/src/components/StatsPanel.svelte (content)
⚔️ ui-svelte/src/components/playground/ChatInterface.svelte (content)
⚔️ ui-svelte/src/components/playground/ChatMessage.svelte (content)
⚔️ ui-svelte/src/lib/markdown.test.ts (content)
⚔️ ui-svelte/src/lib/markdown.ts (content)
⚔️ ui-svelte/src/lib/types.ts (content)
⚔️ ui-svelte/src/stores/api.ts (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a pending/waiting requests counter to the dashboard UI, which is the primary user-facing feature across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@author-brian-mendonca author-brian-mendonca changed the title Add pending requests count to the main dashboard feat: Add pending requests count to the main dashboard Feb 11, 2026
@mostlygeek
Copy link
Owner

mostlygeek commented Feb 12, 2026

Neat feature. Integrating it into the events system is the right place.

I think a gin middleware in the ProxyManager would be a better place to implement it. Wrap the handlers that proxy a request.

Also, I prefer to use int instead of int32 for counters.

Move "Waiting" tracking into a Gin wrapper in ProxyManager, emitting total in‑flight events from there.

Switch in‑flight counters to int and simplify SSE payload to total only.
Move "Waiting" tracking into a Gin wrapper in ProxyManager, emitting total in‑flight events from there.

Switch in‑flight counters to int and simplify SSE payload to total only.
@author-brian-mendonca
Copy link
Contributor Author

Sure thing, I've pushed up some additional changes that should take into account your suggestions. Please let me know if you have any other change requests. Go isn't my primary language, but this has been a fun project to work on.


processGroups map[string]*ProcessGroup

inFlightMu sync.Mutex
Copy link
Owner

Choose a reason for hiding this comment

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

Having an InflightCounter struct to encapsulate the variables, locking, etc would be a better design. See metrics_monitor.go as an example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I've got this done how you've intended; if not, please let me know.

@author-brian-mendonca author-brian-mendonca marked this pull request as draft February 12, 2026 20:29
@author-brian-mendonca
Copy link
Contributor Author

Converting to draft PR for now as I follow up on the latest change requests...

@author-brian-mendonca author-brian-mendonca marked this pull request as ready for review February 12, 2026 21:18
Copy link
Owner

@mostlygeek mostlygeek left a comment

Choose a reason for hiding this comment

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

Just a couple of small changes and I think it'll be good to land.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
proxy/proxymanager.go (1)

31-34: InflightCounter is exported but its constructor newInflightCounter is unexported.

If this type is only used within the proxy package, consider making it unexported (inflightCounter) for consistency. If external access is intended, export the constructor as well.

Also, this whole struct could be replaced with atomic.Int64 from the standard library, which would eliminate the mutex and simplify the code. The floor-at-zero check in Decrement would need a CAS loop, though, so the current approach is reasonable if you prefer the explicit guard.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@proxy/proxymanager.go`:
- Around line 430-436: The in-flight counter in ProxyManager.trackInflight
currently increments before calling c.Next() but calls
pm.inFlightCounter.Decrement() after c.Next(), which will be skipped if a
downstream handler panics; change the handler to call
pm.inFlightCounter.Decrement() (and emit the corresponding
InFlightRequestsEvent) in a defer immediately after incrementing so the
decrement always runs (even on panic/recovery) while still emitting the updated
totals around c.Next().
🧹 Nitpick comments (1)
proxy/proxymanager.go (1)

31-63: InflightCounter is exported but only used internally.

The type is exported (InflightCounter) while its constructor newInflightCounter is unexported, suggesting this is internal-only. Consider making the type unexported (inflightCounter) for consistency, or export the constructor if external use is intended.

Copy link
Owner

@mostlygeek mostlygeek left a comment

Choose a reason for hiding this comment

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

Looks good!

@author-brian-mendonca
Copy link
Contributor Author

Thank you! 👍

@mostlygeek mostlygeek merged commit 1688bdd into mostlygeek:main Feb 16, 2026
4 checks passed
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.

2 participants