fix(workspaces): await lifecycle agent lookups#676
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
There was a problem hiding this comment.
No issues found across 2 files
Auto-approved: Fixes missing awaits on agent lifecycle lookups that caused runtime errors; removes unsafe casts. A focused, bounded bug fix with no new behavior or tradeoffs.
Re-trigger cubic
Greptile SummaryThis PR corrects asynchronous Durable Object agent resolution.
Confidence Score: 5/5The PR appears safe to merge, with the changed lifecycle paths now resolving agent stubs before invoking their methods. The awaited lookups match the asynchronous getAgentByName contract while preserving existing purge aggregation, failure recording, and account-link transfer ordering.
What T-Rex did
|
| Filename | Overview |
|---|---|
| src/features/workspaces/ai/user-ai-agents.ts | Correctly awaits the anonymous UserAIStore lookup before exporting, importing, and purging linked-account resources. |
| src/features/workspaces/durable-object-lifecycle.ts | Correctly makes lifecycle lookups asynchronous and awaits their resolved RPC stubs at all affected deletion and transfer call sites. |
Reviews (1): Last reviewed commit: "fix(workspaces): await lifecycle agent l..." | Re-trigger Greptile
Summary
getAgentByName()before invoking user and workspace lifecycle methods.as unknown ascasts that hid Promise/stub type mismatches.Why
getAgentByName()returns a Promise and has done so since the repository's original Agents 0.17.x integration. The lifecycle helpers cast that Promise to narrow agent interfaces, so deletion attempted to callpurgeForDeletion()on the Promise itself.Those calls threw before Durable Object or R2 cleanup began. The purge wrappers recorded the failure and returned a failed result, allowing the database deletion to complete while backing storage could remain orphaned.
The workspace regression was introduced when commit
f4d1022breplaced the previously awaitedgetWorkspaceKernel()path with the unawaited lifecycle helper. It was not caused by the later Agents 0.18.0 upgrade.Changes
UserAIStorelookup insidemergeLinkedAnonymousUser().Testing
pnpm vp checkpnpm test -- --run— 29 files, 102 tests passedgit diff --checkReview Notes
The important review boundary is the removal of all three unsafe lifecycle casts. With explicit awaited assignments, TypeScript will reject the same missing-await pattern in these paths.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit