Add viewer comments for private projects#27
Open
koomen wants to merge 1 commit into
Open
Conversation
Authenticated viewers of a private, comments-enabled project can leave
Google-Docs-style comments on any page: add (pinned to a click point via a
selector+offset anchor chain with a body-relative fallback), resolve/reopen,
edit, and delete. Anyone with read access may comment and resolve; only the
author or a writer+ may edit or delete. Comments live in a new PrimitiveDb
namespace keyed {project}/{page}/{creation-ordered id}, so all deploy targets
work unchanged, and are purged before a project's name is released.
The API is a content-origin route family under /:project/__scratchwork/comments
(a newly reserved site-path prefix), authenticated by the existing path-scoped
project-access cookie and guarded by the same origin/Referer gates as private
content, with its own typed policy registry and matrix test. The UI is a
self-contained widget (generated string module, renderer-style) injected into
HTML responses of comments-enabled projects.
Publish gains a commentsEnabled toggle end to end (shared contract, site
record, CLI --comments/--no-comments); comments on a public project fail the
deploy on both client and server, and flipping the toggle requires admin.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Authenticated viewers of a private, comments-enabled project can leave Google-Docs-style comments on any page: add (pinned to a click point), resolve/reopen, edit, and delete. Anyone with read access may comment and resolve; only the author or a writer+ may edit or delete. Enabled per project with
scratchwork publish --comments; comments on a public project fail the deploy on both client and server, and flipping the toggle requires admin (like public/private).Live demo (private, owner koomen@gmail.com): https://pages.sndbx.sh/comments-demo/ — sndbx.sh is already running this branch.
Design
{selector, x, y}candidates — the clicked element, then its ancestors, ending body-relative. Pins render at the first selector that still matches, so republished/dynamic pages degrade gracefully instead of losing comments (verified live: a republish that shifted the layout kept the pin on its element)./:project/__scratchwork/comments(prefix now reserved at publish time), authenticated by the existing path-scoped project-access cookie — which always exists because comment-enabled projects are always private. Same origin/Referer guards as private-content serving, applied before auth; own typed policy registry + matrix test in the spirit of invariant 4.commentsPrimitiveDb namespace keyed{project}/{page}/{creation-ordered id}— no storage-contract changes, so all three deploy targets work unchanged. Comments are purged before a deleted project's name is released.htmlTransformshook into HTML responses of private comments-enabled projects only.commentsEnabledadded to the shared publish request/response and ProjectInfo (optional fields, older CLIs unaffected).Testing
--comments/--no-comments, saved-config reuse, comments+public rejection before upload).bun run cifully green;/check-invariantspass done before commit (one finding — widget duplicating server page-normalization — fixed by making the server solely responsible for canonicalization).Notes for review
resolvedByrecorded); edit/delete stays author-or-writer+ as specified.comments-routes.ts: a project's own published JS can act as its viewer within that project's comment space only — inherent to same-origin cookie auth, scoped to a project whose author the viewer already trusts.🤖 Generated with Claude Code