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. |
📝 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.
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.
898a0bd to
adab8d8
Compare
1c7af7a to
6bed1ba
Compare
adab8d8 to
cc9fd40
Compare
6bed1ba to
39d97bf
Compare
cc9fd40 to
3be01d4
Compare
39d97bf to
09f158c
Compare
09f158c to
7b96a6d
Compare
72de51b to
28d44a4
Compare
7b96a6d to
09c5ec6
Compare
7a25648 to
fde2738
Compare
28d44a4 to
5a3bbba
Compare


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