Skip to content

Canvas - Update canvas node titles when changed/deleted/merged remotely #284

@mdroidian

Description

@mdroidian

remotely = using Roam's UI to update title/delete page, merging pages, other plugins changing page title, etc

Use cases

Canvas is loaded
Canvas is not loaded

Title Changes
Merges
Deletions

Title Changes

For Canvas is loaded and Canvas is not loaded, this is straight forward

Canvas is loaded

addPullWatch to all custom node uid's should would cover page title changes.

Canvas is not loaded

On load, query all node uid's and compare

const nodeUids = ["UID1", "UID2", "UID3"]
window.roamAlphaAPI.q(`
  [:find (pull ?page [:node/title :block/uid])
   :in $ [?uid ...]
   :where [?page :block/uid ?uid]]
`, nodeUids);

Merged / Deleted Pages

  • [[Page 1]] and [[Page 2]]
  • [[Page 2]] exists on [[Canvas/someCanvas]]
  • [[Page 2]] gets merged into [[Page 1]]

In both cases, merged/deleted pages is a problem.

merged/deleted both return null so strictly deleting the node from the canvas would be a false positive when pages are merged.

Canvas is loaded

With addPullWatch while Canvas is loaded, after state is null

image

Canvas is not loaded

[[Page 2]]'s uid no longer exists.

Solutions

Possible Solution 1 - Dialog

Show a Dialog when it happens or when canvas is loaded.
This feels way too intrusive, especially if another user deleted/merged the node.

Possible Solution 2 - Update Node / Toast

Changing the canvas node to display something like "This page no longer exists" with some details on what is was and ways to update it. This comes with a host of UX issues. When they encounter this shape the user would have to remember if they deleted it or merged it, what they merged it to, or if it was another user in the graph that deleted/merged it.

Adding a native tldraw toast when it happens will help mitigate some of this when canvas is loaded.

Possible Solution 3

Store a tree of custom shapes on [Canvas/someCanvas]]:

- shapes
  - shape:ahghf96Ze6Q8abcyPf5o6
    - [[Page 2]]
  - shape:4cfOg96Ze6Q8MmmyPf5o6
    - [[this shape's page title]]

In this case, any changes to [[Page 2]] by native Roam functions should be reflected.

So while canvas is loaded, we get null from addPullWatch, wait a beat, then check the tree to see if page has been merged or deleted.

In the case of canvas is not loaded, same thing. If uid no longer exists, check tree to see if the page was merged or deleted.

I don't love it. It feels brittle. But I'm not sure how else to handle it gracefully from a UX perspective.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions