-
Notifications
You must be signed in to change notification settings - Fork 4
ENG-1291: Port discourse node specification #765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: eng-1280-discourse-node-query-builder-and-specification-setting-v2
Are you sure you want to change the base?
ENG-1291: Port discourse node specification #765
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 WalkthroughWalkthroughA Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/roam/src/components/QueryEditor.tsx (1)
491-518:⚠️ Potential issue | 🔴 CriticalCritical bug confirmed:
returnNodeis excluded from the sync payload, causing it to be reset to""whenever conditions/selections/custom change.The
strippedobject (line 494–498) contains only{ conditions, selections, custom }. WhenIndexSchema.safeParsevalidates it, the missingreturnNodefield defaults to""(per the schema definition atzodSchema.ts:56). This overrides thereturnNodeinitially set by:
DiscourseNodeIndex.tsx(line 53:returnNode: DEFAULT_RETURN_NODE)DiscourseNodeSpecification.tsx(line 77:returnNode: node.text)The overwrite occurs ~250ms after mount when the sync effect fires on any change to
conditions,selections, orcustom.Since
returnNodeis not stored as state in QueryEditor (only extracted once fromparseQueryresult but not destructured), there is no way to persist it through subsequent syncs. IncludereturnNodein the state and sync payload to fix this.
🧹 Nitpick comments (3)
apps/roam/src/components/settings/utils/zodSchema.ts (1)
106-113: Consider extracting the default specification value to avoid duplication withIndexSchemadefaults.Line 113 manually spells out the full default for
query({ conditions: [], selections: [], custom: "", returnNode: "" }), which duplicates the defaults already declared inIndexSchema(lines 53–57). IfIndexSchemagains a new field with a default, this transform will silently become stale.♻️ Suggested refactor
+const DEFAULT_SPECIFICATION = { + enabled: false, + query: { conditions: [], selections: [], custom: "", returnNode: "" }, +} as const; + export const DiscourseNodeSchema = z.object({ ... specification: z .object({ enabled: z.boolean().default(false), query: IndexSchema.default({}), }) .nullable() .optional() - .transform((val) => val ?? { enabled: false, query: { conditions: [], selections: [], custom: "", returnNode: "" } }), + .transform((val) => val ?? DEFAULT_SPECIFICATION),This keeps the default in one place and shortens the line.
apps/roam/src/components/settings/DiscourseNodeSpecification.tsx (2)
96-111: Potential race: disable path deletes scratch children then resets block props — ensure ordering is safe.Lines 99–107 delete all scratch children, then in
.then()reset the block props. This ordering is fine for the happy path. However, if the user rapidly toggles enabled → disabled → enabled, the effect on line 32 will fire for both states. The cleanup function (lines 112–114) only callsrefreshConfigTree()and doesn't cancel the in-flightPromise.allorcreateBlockchains, so interleaved create/delete operations could leave inconsistent state.Consider adding a cancelled flag or using an AbortController pattern in the effect to avoid races on rapid toggles.
119-121: CSS overrides to hide the query button and restyle the checkbox are fine but fragile.These selectors (
.bp3-button.bp3-intent-primary,.bp3-checkbox,.bp3-control-indicator) are tied to BlueprintJS 3 class names. Consider adding a brief comment explaining why these overrides are needed, so future maintainers don't accidentally remove them.

https://www.loom.com/share/ec0987fd82474127ad994237104f9b9e
Summary by CodeRabbit