Adopt lifecycle transitions in app clients#348
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 30 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?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 reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. 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, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughAdds a Jotai-based lifecycle transition store ( ChangesProject Lifecycle Transition Recording
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant ActionComponent as Action Component (e.g. AgentActions)
participant API as Backend API
participant RecordAtom as recordProjectLifecycleTransitionAtom
participant DesktopStateStore as desktopStateFamily
User->>ActionComponent: trigger action (resume, spawn, rename, remove)
ActionComponent->>API: call mutation (e.g. spawnAgent)
API-->>ActionComponent: response with transition data
ActionComponent->>RecordAtom: recordTransition(projectPath, transition, metadata)
RecordAtom->>DesktopStateStore: overlay transition onto projected state
DesktopStateStore-->>User: render optimistic state
Note over API,DesktopStateStore: fresh API-backed state later arrives
API->>DesktopStateStore: applyDesktopStateSuccessAtom
DesktopStateStore->>RecordAtom: settle matching transitions
DesktopStateStore-->>User: render settled state
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (3)
app/stores/lifecycleTransitions.test.ts (1)
44-196: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for
graveyard.worktree.resurrectandservice.createoverlay behavior.The suite covers agent resume/spawn overlays, the full settle lifecycle for agent resume, worktree create/remove, and service stop, but doesn't exercise
graveyard.worktree.resurrectorservice.create/service.resumeoptimistic-creation. Both of these turned out to have gaps inoverlayWorktreeTransition/overlayServiceTransition(see review onlifecycleTransitions.ts); a test mirroring the existing "adds optimistic agent rows" case for these operations would have caught this and prevents regression once fixed.🤖 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 `@app/stores/lifecycleTransitions.test.ts` around lines 44 - 196, Add test coverage in lifecycleTransitions.test.ts for the missing optimistic overlay paths in applyProjectLifecycleTransitionsToDesktopState, specifically graveyard.worktree.resurrect and service.create/service.resume. Mirror the existing “adds optimistic agent rows” and “overlays service transitions” cases by asserting overlayWorktreeTransition and overlayServiceTransition project the expected optimistic state onto stale desktopState, including pending/optimistic flags and the correct created/resurrected worktree or service fields.app/stores/lifecycleTransitions.ts (1)
130-145: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win
overlayServiceTransitionnever creates an optimistic row for new services.Unlike
overlayAgentTransition(which pushes an optimistic session viashouldCreateOptimisticAgent) andoverlayWorktreeTransition(which pushes an optimistic worktree forworktree.create), this function early-returns whenindex < 0(Line 138) for every operation, includingservice.create. A newly created service that hasn't yet appeared in a freshdesktop-statefetch gets no optimistic/pending row at all, unlike agents and worktrees.🔧 Proposed fix: add optimistic creation for service.create
function overlayServiceTransition( services: DesktopService[], record: AppLifecycleTransitionRecord, ): void { const serviceId = record.transition.targetId; if (!serviceId) return; const index = services.findIndex((service) => service.id === serviceId); const pendingAction = servicePendingAction(record.transition.operation); - if (!pendingAction || index < 0) return; - services[index] = { - ...services[index], - status: "offline", - pendingAction, - optimistic: true, - }; + if (!pendingAction) return; + if (index >= 0) { + services[index] = { + ...services[index], + status: "offline", + pendingAction, + optimistic: true, + }; + return; + } + if (record.transition.operation !== "service.create") return; + services.push({ + id: serviceId, + label: record.label ?? serviceId, + worktreePath: record.worktreePath, + status: "offline", + pendingAction, + optimistic: true, + }); }🤖 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 `@app/stores/lifecycleTransitions.ts` around lines 130 - 145, `overlayServiceTransition` currently only updates existing entries in `services` and returns when the service is missing, so `service.create` never shows an optimistic row. Update the logic in `overlayServiceTransition` to mirror `overlayAgentTransition`/`overlayWorktreeTransition`: detect when `record.transition.operation` is `service.create`, and if `findIndex` returns `-1`, append a new optimistic `DesktopService` entry with the pending action and offline status instead of returning early.app/components/agent-actions.tsx (1)
65-93: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftConsider extracting the shared
runAction/transition-recording wrapper.The same busy/error/
recordTransitionpattern is repeated near-verbatim inservice-actions.tsx,agent-management-panel.tsx(asrunLifecycleAction), andworktree-management-panel.tsx. A shared hook (e.g.useLifecycleAction(projectPath)) would reduce duplication and centralize fixes (such as label/worktreePath overlay semantics) in one place instead of four.🤖 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 `@app/components/agent-actions.tsx` around lines 65 - 93, The busy/error handling and recordTransition wrapper in runAction is duplicated across multiple components, so centralize it into a shared hook or helper such as useLifecycleAction(projectPath). Move the common async action flow, transition recording, and refresh logic out of agent-actions.tsx and reuse it from the matching implementations in service-actions.tsx, agent-management-panel.tsx (runLifecycleAction), and worktree-management-panel.tsx, keeping the existing opts and onKilled behavior configurable.
🤖 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 `@app/components/agent-management-panel.tsx`:
- Around line 81-97: In the optimistic overlay path for existing sessions, the
agent.rename handling in lifecycleTransitions should also update the session
label, not just mark it pending. Adjust the existing-session branch so the
renamed value from record.label is copied onto the session immediately, using
the existing recordTransition flow and the session/record handling in
lifecycleTransitions to keep the UI in sync before the next desktop-state
refresh.
In `@app/stores/lifecycleTransitions.ts`:
- Around line 147-167: overlayWorktreeTransition currently treats only
"worktree.create" as an optimistic pending update, so
"graveyard.worktree.resurrect" falls into the removing path or no-ops when
absent. Update overlayWorktreeTransition to handle
"graveyard.worktree.resurrect" the same way as creation by marking the matching
DesktopWorktree as pending or creating a pending entry when missing, and keep
the default branch for true removals only. Use the existing
overlayWorktreeTransition and isWorktreeTransitionSettled behavior as the guide,
similar to how overlayAgentTransition handles "graveyard.agent.resurrect".
- Around line 35-59: recordProjectLifecycleTransitionAtom currently ignores
terminal phases like succeeded/failed, which leaves stale optimistic entries
behind for the same operationId. Update the atom to remove any existing record
matching input.transition.operationId when a terminal update arrives, while
keeping the current behavior for ACTIVE_PHASES. Also add a timeout-based
fallback using startedAt/updatedAt in the lifecycle record or transition data so
entries can be pruned even when isTransitionSettled never becomes true.
---
Nitpick comments:
In `@app/components/agent-actions.tsx`:
- Around line 65-93: The busy/error handling and recordTransition wrapper in
runAction is duplicated across multiple components, so centralize it into a
shared hook or helper such as useLifecycleAction(projectPath). Move the common
async action flow, transition recording, and refresh logic out of
agent-actions.tsx and reuse it from the matching implementations in
service-actions.tsx, agent-management-panel.tsx (runLifecycleAction), and
worktree-management-panel.tsx, keeping the existing opts and onKilled behavior
configurable.
In `@app/stores/lifecycleTransitions.test.ts`:
- Around line 44-196: Add test coverage in lifecycleTransitions.test.ts for the
missing optimistic overlay paths in
applyProjectLifecycleTransitionsToDesktopState, specifically
graveyard.worktree.resurrect and service.create/service.resume. Mirror the
existing “adds optimistic agent rows” and “overlays service transitions” cases
by asserting overlayWorktreeTransition and overlayServiceTransition project the
expected optimistic state onto stale desktopState, including pending/optimistic
flags and the correct created/resurrected worktree or service fields.
In `@app/stores/lifecycleTransitions.ts`:
- Around line 130-145: `overlayServiceTransition` currently only updates
existing entries in `services` and returns when the service is missing, so
`service.create` never shows an optimistic row. Update the logic in
`overlayServiceTransition` to mirror
`overlayAgentTransition`/`overlayWorktreeTransition`: detect when
`record.transition.operation` is `service.create`, and if `findIndex` returns
`-1`, append a new optimistic `DesktopService` entry with the pending action and
offline status instead of returning early.
🪄 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: b3ef27b0-2251-4356-9b15-c5506e228f10
📒 Files selected for processing (16)
app/app/(main)/(tabs)/(dashboard)/graveyard.tsxapp/components/ProjectSidebar.tsxapp/components/WorktreeDashboard.tsxapp/components/agent-actions.tsxapp/components/agent-create-panel.tsxapp/components/agent-management-panel.tsxapp/components/screens/AgentChatScreen.tsxapp/components/screens/ServiceDetailScreen.tsxapp/components/service-actions.tsxapp/components/teammate-panel.tsxapp/components/worktree-management-panel.tsxapp/stores/desktopState.tsapp/stores/lifecycleTransitions.test.tsapp/stores/lifecycleTransitions.tsdocs/core-sidecar-north-star.mddocs/north-star-completion-tracker.md
|
Independent review follow-up fixed in af4e298:
|
Summary
Verification
Summary by CodeRabbit
New Features
Bug Fixes