Skip to content

Eng 1616 add getconfigtree equivalent for block pros on init#944

Open
sid597 wants to merge 4 commits intoeng-1470-test-dual-read-with-flag-on-and-fix-gapsv2from
eng-1616-add-getconfigtree-equivalent-for-block-pros-on-init
Open

Eng 1616 add getconfigtree equivalent for block pros on init#944
sid597 wants to merge 4 commits intoeng-1470-test-dual-read-with-flag-on-and-fix-gapsv2from
eng-1616-add-getconfigtree-equivalent-for-block-pros-on-init

Conversation

@sid597
Copy link
Copy Markdown
Collaborator

@sid597 sid597 commented Apr 6, 2026

sid597 added 2 commits April 6, 2026 17:00
Cut plugin load from ~20925ms to ~1327ms (94%) on a real graph by collapsing
per-call settings accessors into a single bulk read at init and threading
that snapshot through the init chain + observer callbacks.

Key changes:
- accessors.ts: bulkReadSettings() runs ONE pull query against the settings
  page's direct children and returns { featureFlags, globalSettings,
  personalSettings } parsed via Zod. readPathValue exported.
- getDiscourseNodes / getDiscourseRelations / getAllRelations: optional
  snapshot param threaded through, no breaking changes to existing callers.
- initializeDiscourseNodes + refreshConfigTree (+ registerDiscourseDatalog-
  Translators, getDiscourseRelationLabels): accept and forward snapshot.
- index.ts: bulkReadSettings() at the top of init; snapshot threaded into
  initializeDiscourseNodes, refreshConfigTree, initObservers,
  installDiscourseFloatingMenu, setInitialQueryPages, and the 3 sync sites
  inside index.ts itself.
- initializeObserversAndListeners.ts: snapshot threaded into the sync-init
  body; pageTitleObserver + leftSidebarObserver callbacks call
  bulkReadSettings() per fire (fresh, not stale); nodeTagPopupButtonObserver
  uses per-sync-batch memoization via queueMicrotask; hashChangeListener
  and nodeCreationPopoverListener use bulkReadSettings() per fire.
- findDiscourseNode: snapshot param added; getDiscourseNodes() default-arg
  moved inside the cache-miss branch so cache hits don't waste the call.
- isQueryPage / isCanvasPage / QueryPagesPanel.getQueryPages: optional
  snapshot param.
- LeftSidebarView.buildConfig / useConfig / mountLeftSidebar: optional
  initialSnapshot threaded for the first render; emitter-driven updates
  keep using live reads for post-mount reactivity.
- DiscourseFloatingMenu.installDiscourseFloatingMenu: optional snapshot.
- posthog.initPostHog: removed redundant internal getPersonalSetting check
  (caller already guards from the snapshot).
- migrateLegacyToBlockProps.hasGraphMigrationMarker: accepts the existing
  blockMap and does an O(1) lookup instead of a getBlockUidByTextOnPage scan.

Includes per-phase timing console.logs across index.ts, refreshConfigTree,
init.ts, initSettingsPageBlocks, and initObservers. Committed as a
checkpoint so we can reference measurements later; will be removed in the
next commit.
Removes the per-phase console.log instrumentation added in the previous
commit. All the [DG Plugin] / [DG Nav] logs and their `mark()` / `markPhase()`
helpers are gone. Code behavior unchanged.

Dropped in this commit:
- index.ts: mark() closure, load start/done logs, and all phase marks.
- initializeObserversAndListeners.ts: markPhase() closure, per-observer marks,
  pageTitleObserver fire log, hashChangeListener [DG Nav] logs.
- LeftSidebarView.tsx: openTarget [DG Nav] click/resolve logs.
- refreshConfigTree.ts: mark() closure and all phase marks.
- init.ts: mark() closures in initSchema and initSettingsPageBlocks.
- accessors.ts: bulkReadSettings internal timing log.
- index.ts: unused getPluginElapsedTime import.

Previous commit (343dc11) kept as a checkpoint for future drill-downs.
@linear
Copy link
Copy Markdown

linear bot commented Apr 6, 2026

@supabase
Copy link
Copy Markdown

supabase bot commented Apr 6, 2026

This pull request has been ignored for the connected project zytfjzqyijgagqxrzbmz because there are no changes detected in packages/database/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

View 5 additional findings in Devin Review.

Open in Devin Review

Comment on lines 122 to 127
export const installDiscourseFloatingMenu = (
onLoadArgs: OnloadArgs,
snapshot?: SettingsSnapshot,
props: DiscourseFloatingMenuProps = {
position: "bottom-right",
theme: "bp3-light",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 AGENTS.md violation: installDiscourseFloatingMenu has >2 positional parameters without object destructuring

The installDiscourseFloatingMenu function was changed from 2 to 3 positional parameters (onLoadArgs, snapshot?, props), violating the AGENTS.md rule: "Use named parameters (object destructuring) when a function has more than 2 parameters." This rule is explicitly stated in the repository's style guide at AGENTS.md.

(Refers to lines 122-130)

Prompt for agents
The function installDiscourseFloatingMenu in apps/roam/src/components/DiscourseFloatingMenu.tsx now has 3 parameters (onLoadArgs, snapshot, props) which violates the AGENTS.md rule requiring object destructuring for functions with more than 2 parameters. Refactor the signature to use a single object parameter with destructuring, e.g. ({ onLoadArgs, snapshot, props }: { onLoadArgs: OnloadArgs; snapshot?: SettingsSnapshot; props?: DiscourseFloatingMenuProps }). Update the single call site in apps/roam/src/index.ts:158 to pass an object instead of positional arguments.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines 622 to 626
export const mountLeftSidebar = async (
wrapper: HTMLElement,
onloadArgs: OnloadArgs,
initialSnapshot?: SettingsSnapshot,
): Promise<void> => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 AGENTS.md violation: mountLeftSidebar has >2 positional parameters without object destructuring

The mountLeftSidebar function was changed from 2 to 3 positional parameters (wrapper, onloadArgs, initialSnapshot?), violating the AGENTS.md rule: "Use named parameters (object destructuring) when a function has more than 2 parameters." This rule is explicitly stated in the repository's style guide at AGENTS.md. Call sites at apps/roam/src/index.ts:184 and apps/roam/src/utils/initializeObserversAndListeners.ts:348 would need to be updated accordingly.

Prompt for agents
The function mountLeftSidebar in apps/roam/src/components/LeftSidebarView.tsx now has 3 parameters (wrapper, onloadArgs, initialSnapshot) which violates the AGENTS.md rule requiring object destructuring for functions with more than 2 parameters. Refactor the signature to use a single object parameter with destructuring, e.g. ({ wrapper, onloadArgs, initialSnapshot }: { wrapper: HTMLElement; onloadArgs: OnloadArgs; initialSnapshot?: SettingsSnapshot }). Update all call sites: apps/roam/src/index.ts:184, apps/roam/src/utils/initializeObserversAndListeners.ts:348.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

sid597 added 2 commits April 6, 2026 20:26
…ional snapshot

- index.ts: move initPluginTimer() back to its original position (after
  early-return checks) so timing isn't started for graphs that bail out.
- Replace readPathValue + `as T | undefined` casts with direct typed
  indexing on the Zod-derived snapshot types across:
    - index.ts (disallowDiagnostics, isStreamlineStylingEnabled)
    - initializeObserversAndListeners.ts (suggestiveModeOverlay,
      pagePreview, discourseContextOverlay, globalTrigger,
      personalTriggerCombo, customTrigger) — also drops dead `?? "\\"`
      and `?? "@"` fallbacks since Zod defaults already populate them.
    - isCanvasPage.ts (canvasPageFormat)
    - setQueryPages.ts + QueryPagesPanel.tsx (nested [Query][Query pages])
- setQueryPages.setInitialQueryPages: snapshot is now optional with a
  getPersonalSetting fallback, matching the pattern used elsewhere
  (getQueryPages, isCanvasPage, etc.).
- init.ts: restore logDualReadComparison + window.dgDualReadLog so the
  on-demand console helper is available again. NOT auto-called on init —
  invoke window.dgDualReadLog() manually to dump the comparison.
Capture performance.now() at the top of runExtension and log the
elapsed milliseconds just before the unload handler is wired, so we
have a single broad measurement of plugin init cost on each load.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant