Make TUI consume project-service API events#196
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
More reviews will be available in 25 minutes and 34 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis PR migrates the dashboard to service-authoritative data flows by introducing an SSE-based project event stream ( ChangesService-Driven Dashboard Refresh and Orchestration Routes
Sequence Diagram(s)sequenceDiagram
participant Dashboard as Dashboard (runDashboard)
participant SSEStream as project-event-stream
participant ProjectService as ProjectService (SSE endpoint)
participant scheduleRefresh as scheduleProjectViewRefresh
participant Notifications as notifications.ts
participant MetadataServer as MetadataServer (/orchestration/routes)
participant DashboardControl as dashboard-control.ts
rect rgba(70, 130, 180, 0.5)
Note over Dashboard, SSEStream: Stream startup
Dashboard->>SSEStream: startDashboardProjectEventStream(host)
SSEStream->>ProjectService: GET SSE endpoint (text/event-stream)
ProjectService-->>SSEStream: event: projectUpdate / alert
end
rect rgba(80, 160, 80, 0.5)
Note over SSEStream, Notifications: Debounced refresh on projectUpdate
SSEStream->>scheduleRefresh: views[] from projectUpdate event
scheduleRefresh->>scheduleRefresh: accumulate Set, 25ms debounce
scheduleRefresh->>Notifications: refreshCoordinationFromService()
Notifications->>ProjectService: GET coordination data
ProjectService-->>Notifications: updated state (no local fallback on failure)
end
rect rgba(180, 100, 60, 0.5)
Note over Dashboard, MetadataServer: Orchestration route picker
Dashboard->>DashboardControl: showOrchestrationRoutePicker()
DashboardControl->>MetadataServer: GET /orchestration/routes?selectedSessionId=...
MetadataServer->>MetadataServer: buildOrchestrationRouteOptions(sessions, teammates)
MetadataServer-->>DashboardControl: OrchestrationRouteOptionsResponse
DashboardControl->>DashboardControl: applyOrchestrationRouteOptions (open overlay or show error)
end
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/multiplexer/dashboard-control.ts`:
- Around line 411-414: The hardcoded 10 second request timeout in the service
call handling (around lines 448-472, particularly in
openProjectServiceNotificationTarget) exceeds the 3 second total deadline
imposed by the enclosing polling helpers. Replace the hardcoded timeout value
with one that respects the caller's deadline constraint, ensuring that
individual request timeouts do not exceed the overall polling deadline to
prevent UI blocking and maintain the intended wait budget.
In `@src/multiplexer/notifications.ts`:
- Around line 190-195: The validation guard before calling
applyCoordinationModel checks the shape of res.model and res.worklist but does
not validate res.threads, allowing invalid non-array thread shapes to reach
applyCoordinationModel and corrupt host.threadEntries. Add a condition to the
existing guard's if statement to ensure res.threads is either falsy (allowing
the ?? [] fallback) or is an Array before proceeding with the
applyCoordinationModel call.
In `@src/multiplexer/project-event-stream.ts`:
- Line 59: The SSE stream reconnection logic in the project-event-stream.ts file
does not implement backoff when readEventStream completes successfully on a
clean close. Currently, when the stream closes with a successful response, the
loop immediately re-fetches without waiting, which can cause rapid reconnect
attempts if the server closes 200 status streams quickly. Add a delay using
RETRY_MS after the readEventStream call completes successfully (on normal
return, not just on error) before the next iteration attempts to fetch the
stream again. This ensures proper backoff behavior for both error and
clean-close scenarios.
- Around line 212-223: The abort listener added to the signal in the sleep
function is not being removed when the timeout completes normally, causing
listener accumulation on the long-lived signal. Store a reference to the abort
event handler function, then after the Promise resolves (when the setTimeout
callback fires), manually remove the listener from the signal using
removeEventListener. This ensures the listener is cleaned up regardless of
whether the abort signal fires or the timeout completes naturally, preventing
listener leaks during repeated reconnect delays.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e5029cd6-a60c-49c1-9afb-ec6fef7394f6
📒 Files selected for processing (23)
app/lib/api.tsapp/lib/desktop-state.tssrc/dashboard/index.tssrc/dashboard/session-registry.tssrc/metadata-server.test.tssrc/metadata-server.tssrc/multiplexer/coordination.test.tssrc/multiplexer/coordination.tssrc/multiplexer/dashboard-actions-methods.tssrc/multiplexer/dashboard-control.test.tssrc/multiplexer/dashboard-control.tssrc/multiplexer/dashboard-interaction.test.tssrc/multiplexer/dashboard-interaction.tssrc/multiplexer/dashboard-model.tssrc/multiplexer/index.tssrc/multiplexer/notifications.test.tssrc/multiplexer/notifications.tssrc/multiplexer/project-event-stream.test.tssrc/multiplexer/project-event-stream.tssrc/multiplexer/runtime-lifecycle-methods.tssrc/multiplexer/session-launch.tssrc/multiplexer/subscreens.tssrc/project-api-contract.ts
💤 Files with no reviewable changes (2)
- src/multiplexer/coordination.test.ts
- src/multiplexer/index.ts
Summary
Verification
Summary by CodeRabbit
Release Notes
New Features
Improvements