Skip to content

Lifecycle-scope dashboard mutation settlement - #229

Merged
TraderSamwise merged 2 commits into
masterfrom
chore/next-20260622-tui-connection-adapter-4
Jun 23, 2026
Merged

Lifecycle-scope dashboard mutation settlement#229
TraderSamwise merged 2 commits into
masterfrom
chore/next-20260622-tui-connection-adapter-4

Conversation

@TraderSamwise

@TraderSamwise TraderSamwise commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • pass dashboard lifecycle tokens through session/service/worktree mutation settlement refreshes
  • scope rename, failure-dismiss, repair/reload, and pending-action refresh callbacks
  • update tests to assert lifecycle-scoped dashboard model refreshes

Verification

  • yarn vitest run src/multiplexer/dashboard-ops.test.ts src/multiplexer/worktrees.test.ts src/multiplexer/dashboard-model-service.test.ts src/multiplexer/dashboard-control.test.ts
  • yarn vitest run src/multiplexer/dashboard-interaction.test.ts src/multiplexer/session-runtime-core.test.ts
  • yarn typecheck
  • yarn lint
  • yarn vitest run
  • yarn build

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an issue where stale dashboard state could be rendered after subsequent user actions or state changes, ensuring only current state is displayed.
  • Tests

    • Updated tests to verify lifecycle-aware dashboard refresh behavior across multiple operations.

@vercel

vercel Bot commented Jun 23, 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 23, 2026 4:30am

@coderabbitai

coderabbitai Bot commented Jun 23, 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 28 minutes and 52 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: 3f437555-94f2-4733-9a42-215d78440d83

📥 Commits

Reviewing files that changed from the base of the PR and between b205ae1 and bc8f46f.

📒 Files selected for processing (7)
  • src/multiplexer/dashboard-ops.test.ts
  • src/multiplexer/dashboard-ops.ts
  • src/multiplexer/dashboard-view-methods.ts
  • src/multiplexer/session-runtime-core.test.ts
  • src/multiplexer/session-runtime-core.ts
  • src/multiplexer/worktrees.test.ts
  • src/multiplexer/worktrees.ts
📝 Walkthrough

Walkthrough

Threads an optional DashboardLifecycleToken into every refreshDashboardModelFromService callsite across the multiplexer. Mutation option types gain a lifecycle-parameterized onError, settlement helpers and wait/poll loops accept and forward the token, and action helpers pass the captured lifecycle into both error and settle paths. Tests are updated to assert the new two-argument call shape.

Changes

Lifecycle-aware dashboard refresh threading

Layer / File(s) Summary
Mutation option contracts and settlement refresh helpers
src/multiplexer/dashboard-ops.ts, src/multiplexer/worktrees.ts
DashboardSessionMutationOptions.onError and DashboardServiceMutationOptions.onError now accept a DashboardLifecycleToken. DashboardWorktreeMutationOptions.settle now requires a lifecycle argument. Adds refreshDashboardModelAfterAuthoritativeMutation and updates refreshDashboardModelForSettlement and refreshDashboardModelForWorktreeSettlement to conditionally forward { lifecycle } to the host refresh call.
Wait/poll helpers and mutation runners
src/multiplexer/dashboard-ops.ts
waitForStableDashboardSessionAbsence, waitForDashboardSessionResumeSettle, waitForRenderedDashboardServiceState, and waitForStableDashboardServiceAbsence accept an optional renderLifecycle and forward it into settlement refreshes. runDashboardSessionMutation and runDashboardServiceMutation error handlers call opts.onError(lifecycle).
Dashboard action helpers lifecycle threading
src/multiplexer/dashboard-ops.ts
All action helpers (spawn/fork agent, stop-to-offline, graveyard, resume offline session/service, create/stop/remove service, migrate session) pass the captured lifecycle token into refreshDashboardModelFromService and updated settlement wait helpers.
Worktree lifecycle threading
src/multiplexer/worktrees.ts
waitForRenderedDashboardWorktreeState, runDashboardWorktreeMutation, the create polling loop, refreshDashboardWorktreeCreateFailure, the creation key handler, and the graveyard settle callback all propagate the lifecycle token.
Individual callsite updates
src/multiplexer/dashboard-interaction.ts, src/multiplexer/dashboard-view-methods.ts, src/multiplexer/session-runtime-core.ts, src/multiplexer/index.ts
dashboard-interaction.ts worktree-failure dismiss, dashboard-view-methods.ts isSettled, and session-runtime-core.ts updateSessionLabel pass { lifecycle } into the refresh. index.ts dashboardPendingActions captures a lifecycle token with inputEpoch: true, passes it into the refresh, and gates rendering on isDashboardLifecycleCurrent.
Test assertion updates
src/multiplexer/dashboard-interaction.test.ts, src/multiplexer/dashboard-ops.test.ts, src/multiplexer/session-runtime-core.test.ts, src/multiplexer/worktrees.test.ts
Assertions for refreshDashboardModelFromService calls are updated to verify the new two-argument shape including the nested lifecycle object.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • TraderSamwise/aimux#222: Introduced captureDashboardLifecycle/isDashboardLifecycleCurrent to harden dashboard lifecycle races — the same utilities this PR now applies to refresh callsites.
  • TraderSamwise/aimux#224: Added the core DashboardLifecycleToken infrastructure (startDashboardLifecycleTask, captureDashboardLifecycle) that this PR threads into refreshDashboardModelFromService.
  • TraderSamwise/aimux#225: Propagated DashboardLifecycleToken through dashboard interaction and ops flows, directly overlapping the same callsite patterns changed here.

Poem

🐇 Hop, hop through the async maze,
Each refresh now wears a lifecycle badge,
No stale tokens shall clutter our stage,
The epoch stands guard, a little sage.
With { lifecycle } tucked in every call,
The dashboard stays fresh — no old ghosts at all! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

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.
✅ 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 clearly and specifically describes the main change: threading dashboard lifecycle tokens through mutation settlement operations.
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-connection-adapter-4

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

@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/dashboard-ops.ts`:
- Around line 138-153: The source code changes to the
refreshDashboardModelAfterAuthoritativeMutation and
refreshDashboardModelForSettlement functions that thread the lifecycle token
into the settlement/refresh path have not been compiled into the dist/
directory. Run yarn build to regenerate the dist/ directory with the updated
artifacts that include these changes, ensuring the compiled output reflects the
modifications made to the source.
🪄 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: 6c369285-f655-491b-8803-e5fdcada41d3

📥 Commits

Reviewing files that changed from the base of the PR and between 63401e6 and b205ae1.

📒 Files selected for processing (10)
  • src/multiplexer/dashboard-interaction.test.ts
  • src/multiplexer/dashboard-interaction.ts
  • src/multiplexer/dashboard-ops.test.ts
  • src/multiplexer/dashboard-ops.ts
  • src/multiplexer/dashboard-view-methods.ts
  • src/multiplexer/index.ts
  • src/multiplexer/session-runtime-core.test.ts
  • src/multiplexer/session-runtime-core.ts
  • src/multiplexer/worktrees.test.ts
  • src/multiplexer/worktrees.ts

Comment on lines +138 to 153
async function refreshDashboardModelAfterAuthoritativeMutation(
host: DashboardOpsHost,
lifecycle?: DashboardLifecycleToken,
): Promise<boolean> {
return refreshDashboardModelForSettlement(host, lifecycle);
}

async function refreshDashboardModelForSettlement(host: DashboardOpsHost): Promise<boolean> {
async function refreshDashboardModelForSettlement(
host: DashboardOpsHost,
lifecycle?: DashboardLifecycleToken,
): Promise<boolean> {
if (typeof host.refreshDashboardModelFromService !== "function") return false;
const beforeRefresh = host.dashboardModelServiceRefreshedAt ?? 0;
const result = await host.refreshDashboardModelFromService(true);
const result = await host.refreshDashboardModelFromService(true, lifecycle ? { lifecycle } : undefined);
if (host.dashboardModelServiceRefreshError) return false;
return result !== false || (host.dashboardModelServiceRefreshedAt ?? 0) > beforeRefresh;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check whether dist artifacts for the changed modules exist and reference the new threading.
fd -t f 'dashboard-ops*' dist 2>/dev/null
fd -t f 'worktrees*' dist 2>/dev/null
# Look for lifecycle threading in built output (presence indicates dist was rebuilt)
rg -n 'refreshDashboardModelAfterAuthoritativeMutation|renderLifecycle' dist 2>/dev/null | head

Repository: TraderSamwise/aimux

Length of output: 157


🏁 Script executed:

# Check if dist/ directory exists and its contents
ls -la dist/ 2>/dev/null | head -20

# Check the source file exists and has the changes
cat -n src/multiplexer/dashboard-ops.ts | sed -n '138,153p'

# Check if there's a build process or dist folder structure
ls -la dist/multiplexer/ 2>/dev/null || echo "dist/multiplexer not found"

# Look for package.json to understand build configuration
grep -A 5 '"build"' package.json 2>/dev/null || echo "no build script found"

Repository: TraderSamwise/aimux

Length of output: 1351


🏁 Script executed:

# Check if dist/ directory exists at all
ls -la dist/ 2>/dev/null || echo "dist/ directory does not exist"

# Count files in dist/ to see if it's populated
find dist -type f 2>/dev/null | wc -l

# Check if there are any compiled .js files
find dist -name "*.js" -type f 2>/dev/null | head -10

# Verify the source actually has lifecycle parameter being passed
rg -A 2 -B 2 'refreshDashboardModelForSettlement.*lifecycle' src/multiplexer/dashboard-ops.ts

Repository: TraderSamwise/aimux

Length of output: 316


The dist/ directory is missing and must be rebuilt.

The source changes thread the lifecycle token into the settlement/refresh path (lines 138–153 and beyond), which modifies aimux runtime behavior. Per the coding guidelines, this requires running yarn build to regenerate dist/. Currently, dist/ does not exist, so the compiled output does not include these changes.

Run yarn build to generate the updated artifacts.

🤖 Prompt for 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.

In `@src/multiplexer/dashboard-ops.ts` around lines 138 - 153, The source code
changes to the refreshDashboardModelAfterAuthoritativeMutation and
refreshDashboardModelForSettlement functions that thread the lifecycle token
into the settlement/refresh path have not been compiled into the dist/
directory. Run yarn build to regenerate the dist/ directory with the updated
artifacts that include these changes, ensuring the compiled output reflects the
modifications made to the source.

Source: Coding guidelines

@TraderSamwise

Copy link
Copy Markdown
Owner Author

CodeRabbit stale-dist note is not applicable here: dist/ is not tracked in this repo, and the branch has already passed yarn build locally. There are no dist changes to commit.

@TraderSamwise
TraderSamwise merged commit 9cb2be0 into master Jun 23, 2026
3 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.

1 participant