ENG-1291: Port discourse node specification#765
Conversation
|
@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
7a25648 to
fde2738
Compare
28d44a4 to
5a3bbba
Compare
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
ff23661 to
c704afc
Compare
7a086b1 to
433277c
Compare
433277c to
af25640
Compare
| const existingProps = getBlockProps(uid); | ||
| if (!existingProps || Object.keys(existingProps).length === 0) { | ||
| // TODO: Overwriting on safeParse failure is a temporary fix for schema shape changes | ||
| // (e.g. specification: [] -> {enabled, query}). Replace with proper versioned migrations. |
There was a problem hiding this comment.
Why do we need this already if this is our first version? As in, we don't have any other versions/migrations?
There was a problem hiding this comment.
we already have merged code in main that would have created the previous specification structure in graphs that have main version of roam plugin and so we need to migrate for those graphs.
| hideCustomSwitch, | ||
| showAlias, | ||
| discourseNodeType, | ||
| settingKey, // eslint-disable-line react/prop-types |
There was a problem hiding this comment.
Why do we need to resort to this disable? What did you try to properly fix it?
There was a problem hiding this comment.
not under scope of this pr every other key also has the same problem and in multiple places in the codebase
There was a problem hiding this comment.
fixing it properly would result in more touch points and get out of scope for this pr
3678893 to
89a82ea
Compare
af25640 to
b08670d
Compare
b08670d to
6ad633e
Compare
89a82ea to
33c45e6
Compare
d9c0d00
into
eng-1280-discourse-node-query-builder-and-specification-setting-v2
These PRs were squash-merged into parent branches instead of main due to a Graphite stack merge race condition. Their changes never landed on main despite showing as merged in Graphite. Includes: - #764 ENG-1280: Port query builder/editor for block props - #765 ENG-1291: Port discourse node specification (dual-write) - #769 ENG-1290: Port discourse node config panel - #793 ENG-1440: Port page groups settings in suggestive mode - #794 ENG-1438: Port keyboard shortcut keys/triggers - #805 ENG-1328: Port small blueprint misc settings
specification, config panel) The initial recovery commit claimed to include these but only contained Chain 2 (#793, #794, #805, #804). Chain 1 lives on separate branches that weren't in the merge source. Applied using `gh pr diff` for each PR in order (#764 → #765 → #769). init.ts required manual merge — #765 and #769 both modified it from the same base. Kept #765's safeParse checks inside #769's restructured initializeSettingsBlockProps. - #764 ENG-1280: Port query builder and editor component for block props - #765 ENG-1291: Port discourse node specification - #769 ENG-1290: Port discourse node config panel
…#826) * Land orphaned Graphite stack PRs (#764, #765, #769, #793, #794, #805) These PRs were squash-merged into parent branches instead of main due to a Graphite stack merge race condition. Their changes never landed on main despite showing as merged in Graphite. Includes: - #764 ENG-1280: Port query builder/editor for block props - #765 ENG-1291: Port discourse node specification (dual-write) - #769 ENG-1290: Port discourse node config panel - #793 ENG-1440: Port page groups settings in suggestive mode - #794 ENG-1438: Port keyboard shortcut keys/triggers - #805 ENG-1328: Port small blueprint misc settings * Add #804 ENG-1217: Port section component in left sidebar * Add #764, #765, #769 (Chain 1 orphaned PRs: query builder, specification, config panel) The initial recovery commit claimed to include these but only contained Chain 2 (#793, #794, #805, #804). Chain 1 lives on separate branches that weren't in the merge source. Applied using `gh pr diff` for each PR in order (#764 → #765 → #769). init.ts required manual merge — #765 and #769 both modified it from the same base. Kept #765's safeParse checks inside #769's restructured initializeSettingsBlockProps. - #764 ENG-1280: Port query builder and editor component for block props - #765 ENG-1291: Port discourse node specification - #769 ENG-1290: Port discourse node config panel * fix lint * prettier
These PRs were squash-merged into parent branches instead of main due to a Graphite stack merge race condition. Their changes never landed on main despite showing as merged in Graphite. Includes: - #764 ENG-1280: Port query builder/editor for block props - #765 ENG-1291: Port discourse node specification (dual-write) - #769 ENG-1290: Port discourse node config panel - #793 ENG-1440: Port page groups settings in suggestive mode - #794 ENG-1438: Port keyboard shortcut keys/triggers - #805 ENG-1328: Port small blueprint misc settings


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