Skip to content

feat(web): add the comment card, opened from its passage when narrow - #306

Closed
pratikbuilds wants to merge 6 commits into
document-viewer-storybookfrom
document-comments-storybook
Closed

pratikbuilds wants to merge 6 commits into
document-viewer-storybookfrom
document-comments-storybook

Conversation

@pratikbuilds

@pratikbuilds pratikbuilds commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Fourth of four stacked PRs. Base: #305.

Storybook only; nothing in the app renders comment cards yet.

What changed

  • CommentCard: a comment beside the passage it is about. Comments collect until the person sends their next message. Then each card follows its own change: written, saved, being changed, changed in a version. A tick clears it once seen. Enter saves, Shift+Enter starts a new line and Escape cancels. An Enter that ends an input-method composition is left alone, including Safari's.
  • DocumentPage: when the margin is too narrow for cards, pressing an underlined passage opens its card under the line. Each passage has a button that only appears on keyboard focus and opens the card from the keyboard; the card then takes focus, and Escape hands it back. Scrolling closes it.

Design

Figma: #306 · Comments, with this PR's boards and masters.

Screenshots

Comment card: writing, saved, saved with edit and delete, being changed, changed in a version, changed.

comment states

A narrow page, with a passage's card opened from its underline:

narrow

How it was verified

  • Every commit passes the pre-commit checks: format, oxlint --deny-warnings, dependency boundaries, typecheck.
  • bun --conditions=intx-src test apps/web/src/pages/workspace packages/plugin-ui plugins: 251 pass, including comment-card.test.ts for the Enter/Escape/composition rules.
  • Each story checked in Storybook, light and dark; the narrow card checked at 900px.

@pratikbuilds
pratikbuilds force-pushed the document-comments-storybook branch from f182ff2 to a9d91d5 Compare November 19, 2026 10:06
@pratikbuilds
pratikbuilds added this pull request to stack #307 November 19, 2026 10:25
@pratikbuilds
pratikbuilds force-pushed the document-comments-storybook branch from a9d91d5 to e413f4b Compare November 19, 2026 12:35
@TheGreatAxios

Copy link
Copy Markdown
Contributor

A comment's stage is defined twice here, with different names for the same four stages. The page has PassageState, which is "selected" | "making" | "changed" with no value for a saved comment, and the card has CommentState, which is "writing" | "saved" | "making" | "changed". The card's "writing" is the page's "selected", and the card's "saved" is the page's missing value.

Whatever places these in the app will have to keep the two in step for every comment, so the underline and the card can disagree about the same comment. Could there be one stage type that both read? The card's four names already cover every case, so the page could take that type and pick its highlight from it, and the host would hold one value per comment.

A comment sits beside the passage it is about. Comments collect until
the person sends them with their next message, then each card follows
its own change: written, saved, being changed, changed in a version. A
tick clears a changed comment once the person has seen it.

Enter saves, Shift+Enter starts a new line and Escape cancels. An Enter
that ends an input-method composition is left alone, including Safari's,
which reports it with isComposing already false.
With no room for cards beside the page, the margin stays empty and a
press on an underlined passage opens its card under the line, or above
it where the view ends first. A hidden button per passage does the same
from the keyboard; the card then takes focus, so Escape hands it back.
Scrolling closes the card.
A comment is a draft in the browser until the person sends it, so the card
has no state for a change being made or made, no version and no tick to
clear it. The making and changed states go, with their wording, their
status line and their stories.
A passage's comment is saved or being written; nothing on the page follows
it once it is sent, so the grey dashed and green underlines go.
@pratikbuilds

Copy link
Copy Markdown
Contributor Author

Replaced by #344, the same code rebuilt as one PR with commits that read in order. The room integration is in #345, stacked on it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants