Skip to content

Conversation

@mdroidian
Copy link
Contributor

@mdroidian mdroidian commented Jul 20, 2025

When a canvas has been upgraded by someone using the alpha branch, a there is no error handling for a user viewing that canvas in the current version. This adds a message to let the user know what happened.

image

Summary by CodeRabbit

  • New Features

    • Added a message to inform users when the canvas has already been upgraded, with instructions to upgrade the Discourse Graph extension to view the canvas.
  • Bug Fixes

    • Prevented the canvas editor from rendering for already upgraded canvases, improving clarity and user experience.

…amStore and updating TldrawCanvas to display upgrade message. This improves user experience by informing users about the latest canvas version.
@linear
Copy link

linear bot commented Jul 20, 2025

@supabase
Copy link

supabase bot commented Jul 20, 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
Copy link
Contributor Author

@CodeRabbit full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 20, 2025

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 20, 2025

📝 Walkthrough

Walkthrough

A new boolean property, isAlreadyUpgraded, is introduced in the useRoamStore hook to detect if the canvas data has already been upgraded. The Tldraw component now conditionally renders a message instructing users to upgrade their extension if this flag is true, instead of rendering the editor. Store initialization and synchronization logic are also gated by this flag.

Changes

File(s) Change Summary
apps/roam/src/utils/useRoamStore.ts Added isAlreadyUpgraded flag to hook logic and return value; updated store creation and effect logic to exit early if upgraded.
apps/roam/src/components/canvas/Tldraw.tsx Consumes isAlreadyUpgraded from hook; conditionally renders upgrade message instead of editor when applicable.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Tldraw
    participant useRoamStore

    User->>Tldraw: Render component
    Tldraw->>useRoamStore: Call hook
    useRoamStore-->>Tldraw: Return { store, isAlreadyUpgraded, ... }
    alt isAlreadyUpgraded is true or store is null
        Tldraw-->>User: Show "already upgraded" message
    else store is available
        Tldraw-->>User: Render TldrawEditor
    end
Loading

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0dffc97 and e84914e.

📒 Files selected for processing (2)
  • apps/roam/src/components/canvas/Tldraw.tsx (2 hunks)
  • apps/roam/src/utils/useRoamStore.ts (3 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/roam.mdc:0-0
Timestamp: 2025-07-19T22:34:23.610Z
Learning: Applies to apps/roam/**/*.{js,jsx,ts,tsx} : Use Roam Depot/Extension API documentation from https://roamresearch.com/#/app/developer-documentation/page/y31lhjIqU when working with the Roam Extension API
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/roam.mdc:0-0
Timestamp: 2025-07-19T22:34:23.610Z
Learning: Applies to apps/roam/**/*.{js,jsx,ts,tsx} : Use BlueprintJS 3 components and Tailwind CSS for platform-native UI in the Roam Research extension
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/roam.mdc:0-0
Timestamp: 2025-07-19T22:34:23.610Z
Learning: Applies to apps/roam/package.json : Prefer existing dependencies from package.json when adding or using dependencies in the Roam Research extension
apps/roam/src/utils/useRoamStore.ts (5)
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/roam.mdc:0-0
Timestamp: 2025-07-19T22:34:23.610Z
Learning: Applies to apps/roam/**/*.{js,jsx,ts,tsx} : Use the roamAlphaApi documentation from https://roamresearch.com/#/app/developer-documentation/page/tIaOPdXCj when working with the Roam API
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/roam.mdc:0-0
Timestamp: 2025-07-19T22:34:23.610Z
Learning: Applies to apps/roam/**/*.{js,jsx,ts,tsx} : Use Roam Depot/Extension API documentation from https://roamresearch.com/#/app/developer-documentation/page/y31lhjIqU when working with the Roam Extension API
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/roam.mdc:0-0
Timestamp: 2025-07-19T22:34:23.610Z
Learning: Applies to apps/roam/package.json : Prefer existing dependencies from package.json when adding or using dependencies in the Roam Research extension
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.
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/roam.mdc:0-0
Timestamp: 2025-07-19T22:34:23.610Z
Learning: Applies to apps/roam/**/*.{js,jsx,ts,tsx} : Use BlueprintJS 3 components and Tailwind CSS for platform-native UI in the Roam Research extension
apps/roam/src/components/canvas/Tldraw.tsx (5)
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/roam.mdc:0-0
Timestamp: 2025-07-19T22:34:23.610Z
Learning: Applies to apps/roam/**/*.{js,jsx,ts,tsx} : Use Roam Depot/Extension API documentation from https://roamresearch.com/#/app/developer-documentation/page/y31lhjIqU when working with the Roam Extension API
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/roam.mdc:0-0
Timestamp: 2025-07-19T22:34:23.610Z
Learning: Applies to apps/roam/**/*.{js,jsx,ts,tsx} : Use BlueprintJS 3 components and Tailwind CSS for platform-native UI in the Roam Research extension
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/roam.mdc:0-0
Timestamp: 2025-07-19T22:34:23.610Z
Learning: Applies to apps/roam/**/*.{js,jsx,ts,tsx} : Use the roamAlphaApi documentation from https://roamresearch.com/#/app/developer-documentation/page/tIaOPdXCj when working with the Roam API
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.
Learnt from: CR
PR: DiscourseGraphs/discourse-graph#0
File: .cursor/rules/roam.mdc:0-0
Timestamp: 2025-07-19T22:34:23.610Z
Learning: Applies to apps/roam/package.json : Prefer existing dependencies from package.json when adding or using dependencies in the Roam Research extension
🧬 Code Graph Analysis (1)
apps/roam/src/components/canvas/Tldraw.tsx (1)
apps/roam/src/utils/useRoamStore.ts (1)
  • useRoamStore (17-231)
🔇 Additional comments (6)
apps/roam/src/utils/useRoamStore.ts (4)

48-55: LGTM: Clean detection logic for upgraded canvases.

The detection logic correctly identifies upgraded canvases by checking for the presence of legacyTldraw in the block properties. The boolean coercion using !! is appropriate and the flag is properly included in the returned data structure.


59-59: LGTM: Appropriate early return for upgraded canvases.

Returning null for the store when the canvas is already upgraded prevents unnecessary store initialization and resource usage. This aligns well with the conditional rendering logic in the UI component.


194-194: LGTM: Proper guard condition for effect.

The effect guard correctly prevents the pull watch setup when the canvas is already upgraded or when the store is null. This prevents unnecessary event listeners and potential errors.


229-229: LGTM: Proper exposure of upgrade state.

The isAlreadyUpgraded flag is correctly exposed in the hook's return object, enabling the consuming component to conditionally render the appropriate UI.

apps/roam/src/components/canvas/Tldraw.tsx (2)

692-692: LGTM: Proper consumption of upgrade state.

The destructuring correctly extracts the isAlreadyUpgraded flag from the useRoamStore hook, making it available for conditional rendering logic.


876-886: LGTM: Clear user messaging for upgraded canvases.

The conditional rendering logic correctly handles both the isAlreadyUpgraded flag and null store scenarios. The user message is clear and provides appropriate guidance for users encountering an upgraded canvas. The centered layout and styling are appropriate for this informational state.


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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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.

@mdroidian mdroidian merged commit ebd3b49 into main Jul 20, 2025
4 checks passed
@github-project-automation github-project-automation bot moved this to Done in General Jul 20, 2025
@mdroidian mdroidian deleted the eng-607-handle-canvas-already-upgraded branch July 20, 2025 04:52
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