Skip to content

A comment on a read-only example canvas looks saved and is gone on reload #125

Description

@Jing-yilin

Found by the Codex review on #116.

What happens

In the desktop app, and under sp start with an examples directory, the bundled example canvases are read-only. POST /__sp/comments answers 403 for one (canvas/server/sp.ts, the isExample(slug) guard).

The client does not look at the answer. flush() in canvas/src/canvasComments.ts records the body in written, sends the request with void fetch(...), and moves on. So a comment typed on an example stays on screen as if it were saved, and is gone on the next load, because no comments.json was written.

Smallest fix

The hosted canvas already has a place for a comment that cannot go to disk: localFiles in localStorage, which commentFiles lays over the committed files on every load, whether or not a server is behind the page. When the POST answers 403, keep that board's file there, the same lines the served === false branch runs. A comment on an example then stays in this browser, which is what a read-only canvas can offer.

Not part of #116: that PR leaves canvas/src/ alone.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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