Skip to content

Route TUI view reads through API runtime - #219

Merged
TraderSamwise merged 5 commits into
masterfrom
chore/next-20260622-tui-api-views
Jun 22, 2026
Merged

Route TUI view reads through API runtime#219
TraderSamwise merged 5 commits into
masterfrom
chore/next-20260622-tui-api-views

Conversation

@TraderSamwise

@TraderSamwise TraderSamwise commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Route Coordination, Project, Library, Topology, and Graveyard refreshes through the shared TUI API runtime
  • Preserve each screen's existing first-load/stale-state behavior while coalescing concurrent refreshes
  • Keep no-timeout transport call shape stable and add coalescing coverage for each converted screen

Verification

  • yarn vitest run src/multiplexer/tui-api-runtime.test.ts src/multiplexer/dashboard-model-service.test.ts src/multiplexer/notifications.test.ts src/multiplexer/project.test.ts src/multiplexer/library.test.ts src/multiplexer/topology.test.ts src/multiplexer/archives.test.ts
  • yarn typecheck
  • yarn lint
  • yarn vitest run
  • yarn build
  • push hook: yarn typecheck && yarn lint && yarn test

Summary by CodeRabbit

  • Improvements
    • Refreshes across notifications, project, topology, library, and graveyard now reliably deduplicate concurrent requests, reducing redundant API calls.
    • Added stronger payload validation during refresh; on failures, affected views revert to safe fallback content.
    • “Refresh” actions now trigger force-refresh behavior consistently (e.g., after dashboard updates and editor/thread actions).
  • Tests
    • Expanded concurrency-focused test coverage to ensure multiple simultaneous refresh calls coalesce correctly and resolve with the expected results.

@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview, Comment Jun 22, 2026 12:07pm

@TraderSamwise

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@TraderSamwise, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 45 minutes and 47 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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5fa17cc1-5035-4ccf-8484-75f6a3eed933

📥 Commits

Reviewing files that changed from the base of the PR and between 62aa058 and 8ec6a25.

📒 Files selected for processing (2)
  • src/multiplexer/subscreens.test.ts
  • src/multiplexer/subscreens.ts
📝 Walkthrough

Walkthrough

Five multiplexer resource refreshers (topology, project, library, archives, notifications) are migrated from direct host.getFromProjectService calls to getOrCreateTuiApiRuntime(host).refreshJson. Each gains a validate*Payload helper, a resource constant, and an optional { force: boolean } parameter. The TUI runtime's opts propagation is fixed to avoid passing { timeoutMs: undefined }. New concurrency tests verify coalescing behavior, and mutation/key-handler call sites are updated to pass { force: true } to supersede stale in-flight refreshes.

Changes

Multiplexer TUI runtime migration, coalescing tests, and force-refresh orchestration

Layer / File(s) Summary
TUI runtime opts propagation fix
src/multiplexer/tui-api-runtime.ts
refreshJson now passes undefined (not { timeoutMs: undefined }) to the request callback, and getOrCreateTuiApiRuntime calls getFromProjectService(path) without opts when opts is absent, allowing cleaner opts branching downstream.
Notifications coordination refresh migration and workflow
src/multiplexer/notifications.ts, src/multiplexer/notifications.test.ts, src/multiplexer/dashboard-actions-methods.ts, src/multiplexer/coordination.ts
Adds COORDINATION_WORKLIST_RESOURCE and validateCoordinationPayload (normalizes absent threads to []); refactors refreshCoordinationFromService to use getOrCreateTuiApiRuntime(host).refreshJson with a force option forwarded as supersede. Notification settlement path passes { force: true } for both success and error cases. Dashboard-actions-methods and coordination reload updated to accept/forward force option. Coalescing test verifies both concurrent calls resolve and service is called once.
Topology, project, library, and archives migrations
src/multiplexer/topology.ts, src/multiplexer/project.ts, src/multiplexer/library.ts, src/multiplexer/archives.ts and corresponding .test.ts files
Each module adds a resource constant (TOPOLOGY_RESOURCE, PROJECT_OBSERVABILITY_RESOURCE, LIBRARY_RESOURCE, GRAVEYARD_RESOURCE) and a validate*Payload helper (throwing on invalid shapes). Replaces direct getFromProjectService with getOrCreateTuiApiRuntime(host).refreshJson. Topology adds early guard when getFromProjectService is absent. All gain optional options parameter with force flag. New Vitest cases for all four refreshers confirm concurrent calls coalesce into a single request with both promises resolving.
Force-refresh call sites and orchestration
src/multiplexer/archives.ts, src/multiplexer/library.ts, src/multiplexer/topology.ts, src/multiplexer/project.ts, src/multiplexer/project-event-stream.ts, src/multiplexer/subscreens.ts, src/multiplexer/subscreens.test.ts, src/multiplexer/project-event-stream.test.ts
Graveyard resurrect/delete mutations and all refresh key handlers ('r' key) now invoke with { force: true }. Dashboard project-event-stream coordinates multiple resource refreshes with forced option when screen changes occur. Thread handoff and subscription-refresh workflows trigger forced coordination refresh. Test expectations updated to assert forced invocation.

Sequence Diagram(s)

None — while the changes introduce new parameter plumbing and update call sites, the core control flow remains unchanged; the { force: true } option is a semantic hint to the runtime's internal coalescing logic rather than a new observable workflow.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • TraderSamwise/aimux#218: Introduces and stabilizes TuiApiRuntime in src/multiplexer/tui-api-runtime.ts, including the refreshJson request/coalescing semantics that this PR's migrations depend on.
  • TraderSamwise/aimux#180: Originally adds refreshProjectObservability and refreshTopology to fetch from new service endpoints — the same functions this PR routes through the TUI runtime with payload validation and force-refresh support.
  • TraderSamwise/aimux#196: Updates the dashboard project-event/SSE refresh flow that coordinates the multiplexer resource refreshes; this PR's changes to refreshDashboardApiViews to pass { force: true } directly build on that orchestration.

Poem

🐇 Hoppity-hop through the runtime we go,
Five refreshers coalesced in a row!
No duplicate fetches, opts now flow clean,
Force-refresh after mutations in between.
The warren's requests are tidy and bright—
One in-flight service call, coalesced right! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.68% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Route TUI view reads through API runtime' accurately describes the main change in the pull request, which routes view refreshes for multiple screens through a shared TUI API runtime.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/next-20260622-tui-api-views

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

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@TraderSamwise

Copy link
Copy Markdown
Owner Author

Independent review findings addressed in 1ee38b3:\n\n- Fixed post-mutation Graveyard refreshes so they supersede older pending reads and cannot reapply stale pre-mutation payloads.\n- Added explicit forced refresh semantics for SSE/manual/mutation-triggered TUI view refreshes while preserving passive coalescing for screen-entry refreshes.\n\nVerification after fixes: yarn typecheck, yarn lint, yarn vitest run, yarn build, and pre-push yarn typecheck && yarn lint && yarn test.

@TraderSamwise

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@TraderSamwise

Copy link
Copy Markdown
Owner Author

Second independent review finding fixed in 62aa058: workflow/thread mutation refreshes now force Coordination reloads instead of coalescing behind older pending reads. Added regression coverage in subscreens.test.ts.\n\nVerification after this fix: yarn typecheck, yarn lint, yarn vitest run, yarn build, and pre-push yarn typecheck && yarn lint && yarn test.

@TraderSamwise

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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/subscreens.test.ts`:
- Around line 101-109: The assertion for renderCoordination being called is
outside the vi.waitFor() block, creating a race condition since
renderCoordination is invoked after refreshCoordinationFromService completes in
an unawaited async chain. Move the
expect(host.renderCoordination).toHaveBeenCalledOnce() assertion from line 108
into the vi.waitFor() callback to ensure it waits for the complete async side
effect chain to finish before checking if renderCoordination was called.
🪄 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: 8f3e23b3-8e65-4068-9605-8d9fd35bbcfa

📥 Commits

Reviewing files that changed from the base of the PR and between 3479b13 and 62aa058.

📒 Files selected for processing (12)
  • src/multiplexer/archives.test.ts
  • src/multiplexer/archives.ts
  • src/multiplexer/coordination.ts
  • src/multiplexer/dashboard-actions-methods.ts
  • src/multiplexer/library.ts
  • src/multiplexer/notifications.ts
  • src/multiplexer/project-event-stream.test.ts
  • src/multiplexer/project-event-stream.ts
  • src/multiplexer/project.ts
  • src/multiplexer/subscreens.test.ts
  • src/multiplexer/subscreens.ts
  • src/multiplexer/topology.ts
✅ Files skipped from review due to trivial changes (2)
  • src/multiplexer/project-event-stream.test.ts
  • src/multiplexer/coordination.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/multiplexer/library.ts

Comment thread src/multiplexer/subscreens.test.ts
@TraderSamwise

Copy link
Copy Markdown
Owner Author

Third independent review finding fixed in b6a99b2: relevant-thread opening now forces its preselection Coordination refresh, so it cannot pick from an older in-flight worklist. Added regression coverage in subscreens.test.ts.\n\nVerification: yarn typecheck, yarn lint, yarn vitest run, yarn build, and pre-push yarn typecheck && yarn lint && yarn test.

@TraderSamwise

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

1 participant