Refactor/Zero shell-only mutators#396
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro 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 |
Greptile SummaryThis PR introduces a
Confidence Score: 4/5Safe to merge with one minor inconsistency: All core optimizations are correctly applied. The single finding is a P2 inefficiency (redundant DB work) that contradicts the PR's stated goal but does not break correctness or cause data loss. src/lib/zero/server-mutators.ts — the Important Files Changed
|
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/lib/zero/mutators.ts">
<violation number="1" location="src/lib/zero/mutators.ts:385">
P2: `updateShellOnly` performs a blind `update` without verifying the item exists. Because Zero `update` is a no-op for missing PKs, move/layout operations can now silently succeed on nonexistent items instead of returning a not-found error.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| updates.lastModified = params.shellChanges.lastModified; | ||
| } | ||
|
|
||
| await tx.mutate.workspace_items.update(updates); |
There was a problem hiding this comment.
P2: updateShellOnly performs a blind update without verifying the item exists. Because Zero update is a no-op for missing PKs, move/layout operations can now silently succeed on nonexistent items instead of returning a not-found error.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/lib/zero/mutators.ts, line 385:
<comment>`updateShellOnly` performs a blind `update` without verifying the item exists. Because Zero `update` is a no-op for missing PKs, move/layout operations can now silently succeed on nonexistent items instead of returning a not-found error.</comment>
<file context>
@@ -353,6 +353,38 @@ async function upsertItem(
+ updates.lastModified = params.shellChanges.lastModified;
+ }
+
+ await tx.mutate.workspace_items.update(updates);
+}
+
</file context>
| await tx.mutate.workspace_items.update(updates); | |
| const existing = await tx.run( | |
| zql.workspace_items | |
| .where("workspaceId", params.workspaceId) | |
| .where("itemId", params.itemId) | |
| .one(), | |
| ); | |
| if (!existing) { | |
| throw new ApplicationError(`Workspace item ${params.itemId} was not found.`); | |
| } | |
| await tx.mutate.workspace_items.update(updates); |
This PR optimizes Zero mutators by introducing a shell-only update path to avoid unnecessary writes to
workspace_item_contentduring layout and move operations. Additionally, it fixes theupdateManyserver mutator to only sync extracted rows for content-affecting operations.updateShellOnly()helper for targetedworkspace_itemsupdates.updateMany.layoutUpdates,move,moveMany, andfolder.createWithItemsto useupdateShellOnly().deleteItemByIdfolder child promotion to useupdateShellOnly().withAuthwrapper foritem.updateManywith customdefineMutatorto conditionally sync extracted rows.workspaceSnapshotstable definition.