Skip to content

Conversation

@mdroidian
Copy link
Contributor

@mdroidian mdroidian commented Aug 15, 2025

Introduced in #288

Summary by CodeRabbit

  • New Features
    • None
  • Bug Fixes
    • Configuration now loads immediately on startup, preventing brief mismatches after opening the app or config page.
    • Discourse-related content and styling initialize earlier, reducing flicker and delayed rendering.
  • Refactor
    • Streamlined startup sequence to perform configuration and data initialization once, earlier in the load process, improving consistency and responsiveness.

…ndListeners.ts to ensure config tree refresh occurs after relevant setup steps.
@linear
Copy link

linear bot commented Aug 15, 2025

@supabase
Copy link

supabase bot commented Aug 15, 2025

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 ↗︎.

@mdroidian mdroidian requested a review from sid597 August 15, 2025 23:50
@mdroidian
Copy link
Contributor Author

@CodeRabbit full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 15, 2025

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 15, 2025

📝 Walkthrough

Walkthrough

Moved initializeDiscourseNodes() and refreshConfigTree() earlier in the Roam app onload sequence and removed their later duplicate call. In observers/listeners setup, added an immediate refreshConfigTree() after creating the Discourse config observer. No public API changes.

Changes

Cohort / File(s) Summary
Roam app onload sequencing
apps/roam/src/index.ts
Reordered initialization: call initializeDiscourseNodes() and refreshConfigTree() immediately after the dev toast; removed subsequent duplicate invocation; retained remaining setup sequence.
Observers and listeners init
apps/roam/src/utils/initializeObserversAndListeners.ts
After creating the Discourse config observer, immediately call refreshConfigTree() before hash-change handling; no other flow or signatures changed.

Sequence Diagram(s)

sequenceDiagram
  participant App as Roam App
  participant Discourse as Discourse Init
  participant Config as Config Tree
  participant UI as Graph View Styling
  participant Obs as Observers/Listeners

  App->>App: onload()
  App->>App: showDevToast()
  App->>Discourse: initializeDiscourseNodes()
  App->>Config: refreshConfigTree()
  App->>UI: addGraphViewNodeStyling()
  App->>Obs: initializeObserversAndListeners()
Loading
sequenceDiagram
  participant Init as initializeObserversAndListeners()
  participant CObs as Config Observer
  participant Config as Config Tree
  participant Router as Hash-change Handler

  Init->>CObs: create Discourse config observer
  Init->>Config: refreshConfigTree() (immediate)
  Init->>Router: setup hash-change handling
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/roam/src/index.ts (1)

89-91: Optional: await refreshConfigTree for future-proofing
Looking at apps/roam/src/utils/refreshConfigTree.ts, refreshConfigTree is currently a synchronous function (const refreshConfigTree = () => { … }). Adding await today is a no-op, but it’s safe and ensures the correct ordering if it ever becomes async in the future.

Recommended change in apps/roam/src/index.ts:

   await initializeDiscourseNodes();
-  refreshConfigTree();
+  await refreshConfigTree();

[optional_refactors_recommended]

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between db34eb8 and 6dc73c9.

📒 Files selected for processing (2)
  • apps/roam/src/index.ts (1 hunks)
  • apps/roam/src/utils/initializeObserversAndListeners.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-06-23T11:49:45.457Z
Learnt from: maparent
PR: DiscourseGraphs/discourse-graph#220
File: apps/roam/src/utils/conceptConversion.ts:11-40
Timestamp: 2025-06-23T11:49:45.457Z
Learning: In the DiscourseGraphs/discourse-graph codebase, direct access to `window.roamAlphaAPI` is the established pattern throughout the codebase. The team prefers to maintain this pattern consistently rather than making piecemeal changes, and plans to address dependency injection as a global refactor when scheduled.

Applied to files:

  • apps/roam/src/index.ts
📚 Learning: 2025-06-22T10:40:21.679Z
Learnt from: sid597
PR: DiscourseGraphs/discourse-graph#232
File: apps/roam/src/utils/getAllDiscourseNodesSince.ts:15-16
Timestamp: 2025-06-22T10:40:21.679Z
Learning: In the getAllDiscourseNodesSince function in apps/roam/src/utils/getAllDiscourseNodesSince.ts, date validation is performed before the function is called, so additional date validation within the function is not needed.

Applied to files:

  • apps/roam/src/index.ts
🔇 Additional comments (2)
apps/roam/src/utils/initializeObserversAndListeners.ts (1)

149-150: No changes needed: refreshConfigTree is synchronous

The refreshConfigTree function is declared as a plain arrow function (no async keyword or Promise return) and contains only synchronous operations. There’s no need to await it—leaving the calls as-is is correct.

apps/roam/src/index.ts (1)

89-91: Moving initialization earlier addresses the overlay init race

Initializing discourse nodes and refreshing config before wiring observers/listeners is the right direction for fixing the overlay init bug; removing the later duplicate call reduces redundant work. No API surface changes—LGTM.

@mdroidian mdroidian merged commit 91c4ea6 into main Aug 23, 2025
5 checks passed
@github-project-automation github-project-automation bot moved this to Done in General Aug 23, 2025
@mdroidian mdroidian deleted the eng-744-overlay-init-bug-fix branch August 23, 2025 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants