Skip to content

refactor(CommentPin): uncontrolled selection, Comments' person type, and ElementSize; the host hides resolved pins, and isDimmed is removed - #13702

Open
ernestt wants to merge 2 commits into
mainfrom
feat/commentpin-api-pass
Open

ernestt wants to merge 2 commits into
mainfrom
feat/commentpin-api-pass

Conversation

@ernestt

@ernestt ernestt commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Primary intent

CommentPin's API pass before it moves to Core, as its owners decided when they voted to graduate it: selection works controlled or uncontrolled, participants share the Comments family's person type, size takes the system's element-size type, and the pin loses its isResolved and isDimmed props. The pull request adds, removes, and retypes props, so neither the bug-fix nor the feature template fits; the title says refactor. It is the first of two: the move to Core stacks on it.

User or maintainer impact

  • Keyboard and screen-reader users. On main, a pin with isResolved renders nothing once it is not selected. A reader who resolves a thread and then presses Enter on its selected pin is left on a removed button, and focus drops to the page body (the Component Audit Rubric's A5 check: focus never drops to the page). Now the pin never removes itself. The host decides which pins render, and the docs say where it moves focus first.
  • Low-vision users. On main, isDimmed sets opacity: 0.4 on a pin that stays operable. Its thread count falls to 2.06:1 in dark mode and 2.48:1 in light mode (the rubric's D7 check: operable content keeps its contrast). The prop and its style are gone.
  • Builders. A pin works without host state: it keeps its own selection, and activation flips it. A host that keeps one pin selected among its siblings passes isSelected and updates it from onSelectedChange. A participant is the same CommentUser record the Comments family takes, so one person object feeds both. size takes ElementSize, the shared sm | md | lg type that Core's SizeContext exports.

Problem and solution fit

  • isResolved let the pin erase itself, but only the host knows where focus should go next. Removing pins is the host's job, so the host owns the focus hand-off too.
  • isDimmed was a boolean that only swapped visuals, at a contrast no operable control may have. A product that wants dimming styles it itself.
  • Selection was controlled only, so even a lone pin needed host state to show aria-pressed. The isSelected, defaultIsSelected, and onSelectedChange trio follows the system's naming table and CommentThread's existing isSelected and onSelectedChange.
  • CommentPin said avatarSrc and Comments said avatarUrl for the same Avatar src. Both now say src, on one type.

Every delta maps to one of these points. The Comments family changes only where its person type renames avatarUrl to src (types.ts, the one place that reads it, and a test fixture).

Before and after:

// Before
<CommentPin
  label="Open 6 grouped annotations from Ada, Lin, and 3 others, 2 unread"
  participants={[{id: 'ada', name: 'Ada Lovelace', avatarSrc: adaAvatar}, lin, mira]}
  size="md"
  threadCount={6}
  unreadCount={2}
  isSelected={selectedId === 'cluster-1'}
  isDimmed={selectedId != null && selectedId !== 'cluster-1'}
  isResolved={cluster.isResolved}
  onClick={() => setSelectedId(id => (id === 'cluster-1' ? null : 'cluster-1'))}
/>

// After
{!cluster.isResolved && (
  <CommentPin
    label="Open 6 grouped annotations from Ada, Lin, and 3 others, 2 unread"
    participants={[{id: 'ada', name: 'Ada Lovelace', src: adaAvatar}, lin, mira]}
    size="md"
    threadCount={6}
    unreadCount={2}
    isSelected={selectedId === 'cluster-1'}
    onSelectedChange={isSelected => setSelectedId(isSelected ? 'cluster-1' : null)}
  />
)}

Public delta:

Prop or type Before After
participants readonly [CommentPinParticipant, ...], item {id, name, avatarSrc?} readonly [CommentUser, ...CommentUser[]]; the pin reads id, name, and src
CommentPinParticipant, CommentPinSize exported removed
CommentUser.avatarUrl string? src?: string
size CommentPinSize ('sm' | 'md' | 'lg'), default 'sm' ElementSize, same values and default; heights and circles unchanged
isSelected controlled only, default false controlled when passed
defaultIsSelected — boolean, default false
onSelectedChange — (isSelected: boolean) => void; runs after onClick on a click, Enter, or Space; a disabled pin does not call it
isDimmed boolean, opacity 0.4, theme state dimmed removed, with its style and theme state
isResolved boolean; an unselected resolved pin returns null; theme state resolved removed, with its theme state

Theme authors: astryx-comment-pin no longer reflects data-dimmed or data-resolved. Lab is private and unreleased, so no Changeset or codemod is owed.

Authority

  • The owners' graduation decisions for CommentPin: drop isResolved (the host stops rendering resolved pins, and the docs say where it moves focus), drop isDimmed with its 0.4 opacity, take isSelected + defaultIsSelected + onSelectedChange, share {id, name, src} with Comments, and size on the element-size scale.
  • architecture:public-component-api DEC-1 (a prop uses the word the system already has: Avatar takes src), INV3 (a prop never silently suppresses another, as isResolved erased the pin), INV7 (a consumer cancels built-in behavior only where the API promises it, so onClick does not cancel the selection request), INV20 (no boolean that only swaps visuals), and INV21 (one API per job: one person type).
  • architecture:component-size-cascade INV1 (the standard size axis is the shared sm | md | lg) and INV2 (a component joins the cascade only when its own contract says so; this one does not).
  • The API conventions naming table: an uncontrolled default is defaultIs<Name>.
  • component:CommentPin is a draft record. This pull request amends it to match (below), so it needs a spec owner's /approve-spec. That approval decides two things:
    1. The record's new requirements: FR5's selection source and that the pin never removes or hides itself, FR12's activation order, AR2's deselection request, and AR7's host focus move.
    2. A behavior change on desktop: a pin rendered without isSelected now selects itself on a mouse click (aria-pressed and the 2px outline).

Change and evidence

  • CommentPin.tsx: the props above. Activation runs onClick, then requests the opposite selection; a pin without isSelected also takes it. The dimmed style and the opacity: 1 that only beat it are gone.
  • CommentPin.doc.mjs (English, Chinese, dense): the new props, the theme states, an example that filters out resolved threads, and an accessibility row and a best practice that say where the host moves focus before it removes a focused pin: the thread's entry in its comments list when one shows, otherwise the next pin in reading order, or the annotated content when no pin is left.
  • Stories and blocks: the state matrix drops the dimmed and resolved rows, the placement story and the showcase select through onSelectedChange, and the margin block keeps its own selection.
  • component:CommentPin record: every dimmed and resolved clause is gone (glance table, compatibility, ownership, concept rows, FR5, ORD4, AR6, DD6, DD9, states, verification map). The size row names ElementSize, FR5 and the ownership section say the pin keeps an uncontrolled selection, the new FR12 states the activation order, AR2 says that activating the selected pin requests deselection, and the new AR7 says the host moves focus before it removes a focused pin.

Real Chromium, Storybook's placement story after the margin pin is selected. On main the grouped pin dims to opacity 0.4; on this branch it keeps full contrast:

Before After
Light before after
Dark before after

State matrix: the dimmed and the resolved-selected rows are gone, and every other row renders as before.

Before After
before after

Unchanged path, the placement story at rest: before, after. Avatar images were blocked in the capture, so the circles show initials in both builds.

Focus (A5): on main, a throwaway test focused a selected isResolved pin and pressed Enter while its host cleared the selection; the pin disconnected and document.activeElement was BODY. The new test "keeps a focused pin mounted and focused when activation clears its selection" covers the same path on this branch.

Open, not in this pull request

These need an owner's decision that neither the records nor the graduation decisions settle, so the code keeps today's behavior and the record lists them as open questions:

  • Size cascade (OQ2). Should size join the size cascade (its own size, then the nearest SizeProvider, then sm)? The pin only reuses the ElementSize type for now.
  • Agents on a pin (OQ3). Comments draws a CommentUser whose kind is agent with a square-cornered avatar. The pin ignores kind and draws a circle.

Writing rubric results

docs/specs/components/CommentPin/CommentPin.spec.md:

  • R1, R2, R3, R4, R5: none.
  • R6: OQ2 and OQ3 are unanswered, so they keep their options.
  • R7: two sentences that predate this change say the record is still a draft (the Compatibility/readiness row and the decision log). This pull request does not change them; the move to Core rewrites the Compatibility/readiness row.

Scope

Components: CommentPin, Comments (person type only)

  • This PR has one primary intent.
  • Independently removable deltas were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm vitest run packages/lab/src/CommentPin packages/lab/src/Comments: 136 passed. New cases cover uncontrolled flips, defaultIsSelected, a controlled pin that requests a change and waits for the host, Enter and Space, a disabled pin that neither calls its handlers nor flips, src reaching Avatar, and the focused pin that stays mounted and focused when activation clears its selection.

  • tsc --noEmit for @astryxdesign/lab

  • eslint and prettier --check on the changed files; pnpm check:repo (includes pnpm check:knowledge)

  • pnpm review:pre: 0 findings

  • pnpm storybook:build, then the captures above in real Chromium

  • The docs' row on where focus goes when a host removes a focused pin uses the Keyboard accessibility category, since the docs check accepts no Focus category.

  • Rebased onto main at 2608fe4, with no change to its own diff (the same patch ID as before the rebase). Repeated on this head: vitest run packages/lab/src/CommentPin packages/lab/src/Comments: 136 passed. tsc for Lab: pass. pnpm review:pre: 0 findings. pnpm check:knowledge: clean.

@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Dec 2, 2026 6:18pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 24, 2026
@astracat-bot

astracat-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Dec 2, 2026, 6:39 PM UTC

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 2ce97d4

Storybook · Sandbox · built from this PR's head

Current run: Heavy CI deferred: runs when review passes and before merge. Lint, typecheck and any path-filtered checks ran on this push.


Generated by PR Enrichment workflow | View current CI run

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review can't approve yet: an engineering owner has to decide on the CommentPin record changes, and two fixes are needed.

Owner decision needed. The pull request writes new requirements into the draft CommentPin record (FR5's selection source and "never removes or hides itself", FR12's activation order, AR2's deselection request and AR7's host focus order), and it makes a pin rendered without isSelected select itself on a mouse click, a desktop behavior change that also needs an explicit owner decision. An engineering owner records the decision by commenting /approve-spec with the full head SHA, which the author may do if they are an engineering owner.

Required fixes:

  • packages/lab/src/CommentPin/CommentPin.doc.mjs:168 uses category: 'Focus', which the doc type does not allow ('Color contrast' | 'Keyboard' | 'Semantics' | 'Content'), so the Lab typecheck job fails; 'Keyboard' matches the repository's other 2.4.3 rows.
  • The description says ElementSize is "the type every Core component's sm | md | lg uses", but most sized Core components keep their own alias (for example DropdownMenuSize and InputSize), so please reword it to describe Core's shared sm | md | lg type from SizeContext.

Also worth a look: the "Single thread" docs example now toggles off on a second click while its thread stays open, and the "Resolved threads leave the content" example leaves out the focus move that the new accessibility row asks for.

Claims and files checked

Review mode: full; reason: no-earlier-review

Claims:

  • On main, an unselected resolved pin renders nothing, so a focused pin the host deselects drops focus: verified (base CommentPin.tsx:464-466).
  • On main, dimmed pins paint at 0.4 opacity: verified (base CommentPin.tsx:196-201); the quoted contrast ratios were not measured.
  • A pin without isSelected flips on activation, onSelectedChange runs after onClick on click, Enter or Space, and a disabled pin calls neither: verified (CommentPin.tsx:470-486 and the new tests).
  • Participants share the Comments person type with src, and Comments changes only its type, its one reader and a test fixture: verified (no other avatarUrl reader remains).
  • size takes ElementSize with the same values and default: verified (CommentPin.tsx:392-393).
  • ElementSize is the type every Core component's sm | md | lg uses: false (most sized Core components export their own alias).
  • The selection props follow the naming table and CommentThread: verified.
  • The theme target no longer reflects data-dimmed or data-resolved: verified.
  • Lab is private, so no changeset is owed: verified (packages/lab/package.json).
  • Stories, blocks and the record were updated as described: verified.
  • New tests cover the listed cases: verified by reading; not run here.
  • tsc --noEmit for the Lab package passes: false for the package typecheck (CI fails in its docs step at CommentPin.doc.mjs:168).
  • Vitest run, eslint/prettier, repository checks, pre-review checklist and Storybook captures: not verified here; CI lint passed and the tests are deferred until review passes.

Files:

  • apps/storybook/stories/CommentPin.stories.tsx: clear
  • docs/specs/components/CommentPin/CommentPin.spec.md: owner approval needed; FR1 now reads against FR5/FR12 (non-blocking)
  • packages/lab/blocks/CommentPinInMargin.doc.mjs: clear
  • packages/lab/blocks/CommentPinInMargin.tsx: clear
  • packages/lab/blocks/CommentPinShowcase.doc.mjs: clear
  • packages/lab/blocks/CommentPinShowcase.tsx: clear
  • packages/lab/src/CommentPin/CommentPin.doc.mjs: typecheck failure at line 168; two example notes
  • packages/lab/src/CommentPin/CommentPin.test.tsx: clear
  • packages/lab/src/CommentPin/CommentPin.tsx: clear
  • packages/lab/src/CommentPin/index.ts: clear
  • packages/lab/src/Comments/CommentParts.tsx: clear
  • packages/lab/src/Comments/Comments.test.tsx: clear
  • packages/lab/src/Comments/types.ts: clear
  • packages/lab/src/index.ts: clear

Automated review (maintainer link)

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review can't approve yet: an engineering owner has to decide on the CommentPin record changes, and two sentences in the title and description need rewording (the ElementSize wording from the last round is fixed).

Owner decision needed. The pull request writes new requirements into the draft CommentPin record (FR5's selection source and "never removes or hides itself", FR12's activation order, AR2's deselection request and AR7's host focus order), and it makes a pin rendered without isSelected select itself on a mouse click, a desktop behavior change that also needs an explicit owner decision. An engineering owner records the record decision by commenting /approve-spec with the full head SHA; the author may do so if they are an engineering owner.

Required fixes:

  • Miss: The title ends "and nothing dims", but a disabled pin still paints at 0.45 opacity (CommentPin.tsx:186-191), so please narrow it, for example to "and siblings no longer dim".
  • Miss: The description's "A pin works with no state of its own" says the opposite of the change, because the pin now keeps its own selection when isSelected is left out (CommentPin.tsx:394-397); "A pin works without host state: it keeps its own selection, and activation flips it" would fit.

Still worth a look, non-blocking: the "Single thread" example now toggles off on a second click while its thread stays open, the "Resolved threads leave the content" example leaves out the focus move the new accessibility row asks for, and FR1 still says the pin never mutates selection.

Claims and files checked

Review mode: full; reason: recipe-changed (many rules)

Title: refactor(CommentPin): uncontrolled selection, Comments' person type, and ElementSize; the host hides resolved pins, and nothing dims

Claims:

  • Selection works controlled or uncontrolled: verified (CommentPin.tsx:394-397; the uncontrolled-flip and controlled-request tests pass, run here).
  • Participants share the Comments person type and read src: verified (CommentPin.tsx:76, types.ts src?: string).
  • size takes ElementSize, the shared sm | md | lg type Core's SizeContext exports: verified (SizeContext.ts:22 and Core's ./SizeContext export).
  • The pin loses isResolved and isDimmed, with their style and theme states: verified (CommentPin.tsx:497-504 reflects only size, grouped, unread, selected and disabled).
  • Title, "nothing dims": false (a disabled pin still paints at 0.45 opacity, CommentPin.tsx:186-191).
  • Title, the host hides resolved pins: verified (the pin has no resolved state; the docs example and best practice tell the host to stop rendering them).
  • On main a resolved pin renders nothing once unselected, and a focused one drops focus to the page: the early return is verified (base CommentPin.tsx:464-466); the focus drop is reported from the author's own run.
  • On main a dimmed pin paints at 0.4 opacity while it stays operable: verified (base capture, run here); the quoted contrast ratios are reported.
  • Now the pin never removes itself: verified (no early return remains; the focused-pin test passes, run here).
  • "A pin works with no state of its own": false (the pin keeps its own selection when isSelected is left out, CommentPin.tsx:394-397).
  • Activation flips a pin without isSelected, onSelectedChange runs after onClick on click, Enter or Space, and a disabled pin calls neither: verified (CommentPin.tsx:470-496; the click, keyboard and disabled tests pass, run here).
  • One person object feeds both components, and both now say src: verified.
  • The selection props follow the naming table and CommentThread's isSelected and onSelectedChange: verified (the conventions table's defaultIs<Name>; CommentThread.tsx:57-59).
  • Every delta maps to one of the stated problems: verified (no tag-along found).
  • Comments changes only the avatarUrl rename, in its type, its one reader and a test fixture: verified (a whole-tree search for avatarUrl at the head finds only unrelated CLI export docs; at the base its only reader was CommentParts.tsx:618).
  • CommentPinParticipant and CommentPinSize are no longer exported: verified (packages/lab/src/index.ts:50, CommentPin/index.ts:13).
  • The theme target no longer reflects dimmed or resolved: verified, and no theme selects on either state.
  • Lab is private and unreleased, so no Changeset is owed: verified (packages/lab/package.json is private).
  • The owners decided these changes when they voted to graduate the pin: unverified (no committed record or quoted decision).
  • The cited current architecture claims say what the description says: verified against the current records.
  • The CommentPin record is a draft that needs a spec owner's approval: verified.
  • The docs add the new props, the theme states, a resolved-threads example, and a focus row and best practice: verified (CommentPin.doc.mjs:101-119, 143, 167-171, 210, 287-301).
  • The story and blocks select through onSelectedChange, the state matrix drops the dimmed and resolved rows, and the margin block keeps its own selection: verified (code and Storybook captures, run here).
  • Every dimmed and resolved clause is gone from the record: verified (searched the head record; the remaining hits are the host's resolved state, value resolution and AR7).
  • Every other state-matrix row renders as before: verified (base and head captures, run here).
  • The before and after screenshots and the main-branch focus run: reported.
  • The new focus test covers the same path on this branch: verified (present and passing, run here).
  • OQ2 and OQ3 stay open, and the pin ignores kind and draws a circle: verified.
  • 136 tests pass: verified (run here: 136 passed in 5 files).
  • Type check, lint and formatting pass: type check and lint verified (CI's typecheck and lint jobs pass at this head); the repository checks, pre-review checklist and Storybook build are reported.
  • Rebased onto the base, then validated against a later main without conflict: the base is verified, and the head also merges cleanly with today's main; the earlier validation is reported.

Files:

  • apps/storybook/stories/CommentPin.stories.tsx: clear
  • docs/specs/components/CommentPin/CommentPin.spec.md: owner approval needed for FR5, FR12, AR2 and AR7; FR1 reads against FR5 and FR12 (non-blocking)
  • packages/lab/blocks/CommentPinInMargin.doc.mjs: clear
  • packages/lab/blocks/CommentPinInMargin.tsx: clear
  • packages/lab/blocks/CommentPinShowcase.doc.mjs: clear
  • packages/lab/blocks/CommentPinShowcase.tsx: clear
  • packages/lab/src/CommentPin/CommentPin.doc.mjs: two example notes (non-blocking)
  • packages/lab/src/CommentPin/CommentPin.test.tsx: clear
  • packages/lab/src/CommentPin/CommentPin.tsx: new click-to-select default needs an owner decision; the disabled opacity makes the title claim false
  • packages/lab/src/CommentPin/index.ts: clear
  • packages/lab/src/Comments/CommentParts.tsx: clear
  • packages/lab/src/Comments/Comments.test.tsx: clear
  • packages/lab/src/Comments/types.ts: clear
  • packages/lab/src/index.ts: clear

Automated review (maintainer link)

label="Open annotation from Ada"
participants={[{id: 'ada', name: 'Ada Lovelace', avatarSrc: '/ada.jpg'}]}
participants={[{id: 'ada', name: 'Ada Lovelace', src: '/ada.jpg'}]}
onClick={() => openThread('thread-1')}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: this pin passes only onClick, so it now keeps its own selection. A second click turns aria-pressed off and calls openThread again while the thread stays open. Pass isSelected from the open thread, as the grouped examples do, or say that the pin's own state is decorative here.

{
label: 'Resolved threads leave the content',
code: `{threads
.filter(thread => !thread.isResolved)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: this example filters resolved threads but leaves out the focus move that the new "Focus when a pin goes away" row asks for. A host that copies it drops focus to the page when the focused pin's thread resolves. A line that moves focus before the filter removes the pin, or a comment that points to the row, keeps the two in step.

| FR11 | `size` MUST set the root height and minimum width to `--size-element-sm`, `--size-element-md`, or `--size-element-lg` and draw 22, 24, or 28px participant circles, and the reflected size MUST match. Padding MUST be equal on every side and equal to the inset that centers one participant circle in that height; a grouped marker MUST sit its first AvatarGroup ring inside the start padding, so participant circles keep that inset from the start edge. The trailing total or unread dot MUST add `--spacing-1` of end padding, so neither crowds the edge. | product visual direction | product direction; rendered visual review pending |
| ID | Candidate invariant | Basis | Draft review state |
| ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | ----------------------------------------------------------- |
| FR1 | CommentPin MUST render one button and MUST NOT accept, derive, or mutate anchor coordinates, grouping membership, thread selection, or collision layout. | product ownership boundary | product direction; pending owner approval |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: FR1 still says the pin MUST NOT "accept, derive, or mutate ... thread selection", while FR5 and FR12 now let it keep and flip its own selection. Consider "which thread is selected among its siblings" so FR1 and FR5 read together.

@ernestt

ernestt commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Reworded the description: size takes ElementSize, the shared sm | md | lg type that Core's SizeContext exports.

build, test and docsite-test are the held heavy-CI placeholders, not failures in this change: each stops after about ten seconds with "Heavy CI deferred: runs when review passes and before merge (spec:AST-030 FR20)".

The record changes wait for an engineering owner's /approve-spec. The three non-blocking notes (the "Single thread" example, the focus move in the resolved-threads example, and FR1's wording) are still open; they touch the record and its examples, so they can go with that decision.

…and ElementSize; the host hides resolved pins, and nothing dims

CommentPin's API pass before it moves to Core:

- Selection takes `isSelected`, `defaultIsSelected`, and
  `onSelectedChange`. Activation by click, Enter, or Space runs `onClick`,
  then requests the opposite selection; a pin without `isSelected` also
  flips itself. A disabled pin does neither.
- Participants are the Comments family's `CommentUser` records, read as
  `{id, name, src}`. `CommentUser.avatarUrl` becomes `src`, Avatar's word,
  and `CommentPinParticipant` and its `avatarSrc` go away.
- `size` takes `ElementSize`; `CommentPinSize` goes away. Values, default,
  and geometry stay the same.
- `isResolved` and its `resolved` theme state go away: a pin never removes
  itself, and the host stops rendering the pins it hides. The docs say where
  the host moves focus when it removes a focused pin.
- `isDimmed`, its 0.4 opacity, and its `dimmed` theme state go away.

The draft component record, docs, stories, and blocks follow.
@ernestt
ernestt force-pushed the feat/commentpin-api-pass branch from c4542db to d45a025 Compare December 2, 2026 04:56
@ernestt

ernestt commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main at 2608fe4 with the rest of the stack. This pull request's own diff is unchanged: its patch ID is the same as before the rebase, and it applied without conflicts. In the stack, only #13737 changed in content; #13702, #13735, #13736, #13738, #13739, #13740 and #13741 are unchanged apart from the rebase.

Repeated on this head: vitest run packages/lab/src/CommentPin packages/lab/src/Comments: 136 passed. tsc for Lab: pass. pnpm review:pre: 0 findings. pnpm check:knowledge: clean.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review can't approve yet: an engineering owner has to decide on the CommentPin record changes, and two sentences in the title and description need rewording.

  • Owner decision: the pull request writes new requirements into the draft CommentPin record (FR5's selection source and "never removes or hides itself", FR12's activation order, AR2's deselection request and AR7's host focus move); an engineering owner records the decision by commenting /approve-spec d45a0254251e1d261aee482819c47fa6711ef5fa on this pull request, and the author may do so only if they are an engineering owner.
  • Owner decision: a pin rendered without isSelected now selects itself (aria-pressed and the 2px outline) on a mouse click, a change to what a click does on a default pin that needs an explicit owner decision.
  • Title: "nothing dims" is not true, because a disabled pin still paints at opacity 0.45 (CommentPin.tsx:186-191); say that pins no longer dim their siblings, or that isDimmed is removed.
  • Description: "A pin works with no state of its own" is not true, because a pin without isSelected keeps its own selection (CommentPin.tsx:394-397); say it works without host state and keeps its own selection.

The three earlier non-blocking notes on the docs examples and FR1's wording still apply. The CommentPin and Comments tests (136) pass when reproduced locally, and CI's typecheck and lint pass on this head.

Claims and files checked

Review mode: full; reason: author-not-engowner

Claims:

  • Title, selection works uncontrolled: verified (CommentPin.tsx:392-397; test "flips its own selection when isSelected is left out").
  • Title, participants use the Comments person type: verified (CommentPin.tsx:76).
  • Title, size uses ElementSize: verified (CommentPin.tsx:82; Core's SizeContext.ts:22).
  • Title, the host hides resolved pins: verified (no self-removal remains; the docs' example and focus row say the host does it).
  • Title, nothing dims: false (a disabled pin paints at opacity 0.45, CommentPin.tsx:186-191).
  • The pin never removes itself: verified (no early return; test "keeps a focused pin mounted and focused when activation clears its selection").
  • On main a resolved pin vanished when unselected and focus fell to the page: reported (the base code's early return confirms the mechanism).
  • The dimmed state's 0.4 opacity and its contrast figures: reported (the 0.4 opacity reproduced in the base Storybook capture).
  • The dimmed prop and its style are gone: verified (CommentPin.tsx and the head capture).
  • A pin works with no state of its own: false (the pin keeps its own selection, CommentPin.tsx:394-397).
  • One person record feeds both families, and the size type is the one Core's size context exports: verified (CommentPin.tsx:54, :76; SizeContext.ts:22).
  • The new selection trio follows the naming table and CommentThread: verified (API conventions' defaultIs<Name> row; CommentThread.tsx:57-59).
  • Both families now say src on one type: verified (types.ts:63; CommentParts.tsx:618).
  • Comments changes only its type, its one reader and a test fixture: verified (repository search; the base's only reader was CommentParts.tsx:618).
  • The public delta table (props added, changed and removed, defaults, onSelectedChange after onClick, never on a disabled pin): verified (CommentPin.tsx:471-486; tests "requests a change but keeps a controlled selection until the host passes it" and "neither calls its handlers nor flips its selection when disabled").
  • The theme target no longer reflects the dimmed and resolved states: verified (CommentPin.tsx:497-503; head capture).
  • Lab is private, so no Changeset or codemod is owed: verified (Lab's package is private and canary-only; the release record exempts private-package-only changes).
  • The cited architecture claims (existing vocabulary, one prop per concept, handler composition, no visual-only booleans, one API per job, the shared size axis, explicit cascade participation): verified against the current records.
  • The CommentPin record is a draft that needs an owner's approval: verified (draft, no approver).
  • The listed code, docs, story, block and record edits, including every dimmed and resolved record clause removed: verified (record search finds no dimmed clause; the remaining "resolved" words are count normalisation or host-owned statements).
  • Screenshots and the base focus-loss check: reported.
  • The new focus test covers the same path: verified (passes, reproduced locally).
  • The two open questions, and the pin ignoring kind: verified (record OQ2 and OQ3; the pin's Avatar takes no shape).
  • Writing-rubric self-check: reported.
  • Test, typecheck, lint, repository-check and Storybook-build results: reported; the 136 tests reproduced locally, and CI's typecheck and lint pass on this head.
  • The focus row uses the Keyboard category because the docs type has no Focus category: verified (doc type union).
  • The rebase left this pull request's own diff unchanged: verified (identical patch ID).

Files:

  • docs/specs/components/CommentPin/CommentPin.spec.md: draft FR5, FR12, AR2 and AR7 wait on an owner; FR1 wording (non-blocking).
  • packages/lab/src/CommentPin/CommentPin.tsx: clear; its disabled style is what makes the title's "nothing dims" false.
  • packages/lab/src/CommentPin/CommentPin.doc.mjs: two examples drift from the contract (non-blocking).
  • packages/lab/src/CommentPin/CommentPin.test.tsx: clear.
  • packages/lab/src/CommentPin/index.ts: clear.
  • packages/lab/src/index.ts: clear.
  • packages/lab/src/Comments/types.ts: clear.
  • packages/lab/src/Comments/CommentParts.tsx: clear.
  • packages/lab/src/Comments/Comments.test.tsx: clear.
  • apps/storybook/stories/CommentPin.stories.tsx: clear.
  • packages/lab/blocks/CommentPinShowcase.tsx: clear.
  • packages/lab/blocks/CommentPinShowcase.doc.mjs: clear.
  • packages/lab/blocks/CommentPinInMargin.tsx: clear.
  • packages/lab/blocks/CommentPinInMargin.doc.mjs: clear.

Automated review (maintainer link)

@ernestt ernestt changed the title refactor(CommentPin): uncontrolled selection, Comments' person type, and ElementSize; the host hides resolved pins, and nothing dims refactor(CommentPin): uncontrolled selection, Comments' person type, and ElementSize; the host hides resolved pins, and isDimmed is removed Dec 2, 2026
…ption

No file changes. The pull request title now says that isDimmed is removed, and the description says that a pin keeps its own selection without host state.
@ernestt

ernestt commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Both sentences are reworded:

  • Title: "nothing dims" is now "isDimmed is removed". A disabled pin still paints at reduced opacity.
  • Description: a pin works without host state; it keeps its own selection, and activation flips it.

The description's Authority section now lists both owner decisions for the spec owner's /approve-spec: the record's new requirements (FR5, FR12, AR2, AR7), and the desktop behavior change that a pin without isSelected selects itself on a mouse click.

The new head adds one empty commit so this review runs again; its tree is the same as the last head, which passed 136 tests, the Lab typecheck, review:pre with 0 findings, and check:knowledge. The three non-blocking notes on the docs examples and FR1's wording stay open; they change the record and its examples, so they can go with the owner's decision.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review can't approve yet: an engineering owner has to decide on the CommentPin record changes and on the new click-to-select default. The title and description sentences flagged last time now match the code, and no code changes are needed.

  • Owner decision (record): the pull request writes new requirements into the draft CommentPin record (FR5's selection source and "never removes or hides itself", FR12's activation order, AR2's deselection request and AR7's host focus move); an engineering owner records the decision by commenting /approve-spec 2ce97d4fe1ba7931b8e7e7cea81ce33a828d0f94 on this pull request, and the author may do so only if they are an engineering owner.
  • Owner decision (desktop behavior): a pin rendered without isSelected now selects itself (aria-pressed and the 2px outline) on a mouse click, a change to what a click does on a default pin that needs an explicit owner decision beyond the spec approval.

The three earlier non-blocking notes on the "Single thread" and resolved-threads docs examples and on FR1's wording still apply. The CommentPin and Comments tests (136) pass when reproduced locally, and CI's typecheck and lint pass on this head.

Claims and files checked

Review mode: full; reason: author-not-engowner

Claims:

  • Title, selection works uncontrolled: verified (CommentPin.tsx:394-397; test "flips its own selection when isSelected is left out").
  • Title, participants use the Comments person type: verified (CommentPin.tsx participants: readonly [CommentUser, ...CommentUser[]]).
  • Title, size uses ElementSize: verified (CommentPin.tsx:35; Core's SizeContext.ts:22).
  • Title, the host hides resolved pins: verified (no self-removal remains; the docs' example and focus row say the host does it).
  • Title, isDimmed is removed: verified (prop, style and theme state gone; a repository search finds no remaining use).
  • On main a resolved pin vanished when unselected and focus fell to the page: reported (the base code's early return confirms the mechanism).
  • The pin never removes itself: verified (its one return always renders the button, CommentPin.tsx:568-573; test "keeps a focused pin mounted and focused when activation clears its selection").
  • The dimmed state's 0.4 opacity: verified (base style, and a browser probe of the base placement story); its contrast figures: reported.
  • A pin works without host state, keeps its own selection, and activation flips it: verified (CommentPin.tsx:394-397, :480-485; tests for click, Enter and Space).
  • A host keeps one pin selected through isSelected and onSelectedChange: verified (story and showcase hosts; docs examples).
  • One person record feeds both families, and the size type is the one Core's size context exports: verified.
  • The selection trio follows the naming table and CommentThread: verified (API conventions' defaultIs<Name> row; CommentThread.tsx:57-59).
  • Both families now say src on one type: verified (types.ts:63; CommentParts.tsx:618).
  • Comments changes only its type, its one reader and a test fixture: verified (repository search on the base and head).
  • The public delta table (props added, changed and removed, defaults, onSelectedChange after onClick on click, Enter or Space, never on a disabled pin): verified (CommentPin.tsx:471-485 is the only call site; tests "requests a change but keeps a controlled selection until the host passes it", "flips its selection from Enter and Space" and "neither calls its handlers nor flips its selection when disabled").
  • The theme target no longer reflects the dimmed and resolved states: verified (CommentPin.tsx:497-504; docs theming targets).
  • Lab is private, so no Changeset or codemod is owed: verified (Lab's package is private and canary-only; the release record exempts private-package-only changes).
  • The cited architecture claims (existing vocabulary, one prop per concept, handler composition, no visual-only booleans, one API per job, the shared size axis, explicit cascade participation): verified against the current records.
  • The owners' graduation decisions: unverified (not in any committed record); they are what the owner decisions above settle.
  • The CommentPin record is a draft that needs an owner's approval: verified (draft, no approver).
  • An owner's spec approval also decides the desktop click change: unverified (the desktop default needs its own explicit owner decision).
  • The listed code, docs, story, block and record edits, including every dimmed and resolved record clause removed: verified (no dimmed clause remains; the remaining "resolved" words are count normalisation or host-owned statements).
  • Screenshots and the base focus-loss check: reported; the opacity change reproduced in a browser here.
  • The new focus test covers the same path: verified (passes, reproduced locally).
  • The two open questions, and the pin ignoring kind: verified (record OQ2 and OQ3; the pin's Avatar takes no shape).
  • Writing-rubric self-check: reported.
  • Public text carries no internal context: verified (added lines, title, body, branch and commit messages checked).
  • Test, typecheck, lint, repository-check and Storybook-build results: reported; the 136 tests reproduced locally, and CI's typecheck and lint pass on this head.
  • The focus row uses the Keyboard category because the docs type has no Focus category: verified (doc type union).
  • The rebase left this pull request's own diff unchanged: verified (identical patch ID).
  • The new head is an empty commit with the same tree as the last one: verified.

Files:

  • docs/specs/components/CommentPin/CommentPin.spec.md: draft FR5, FR12, AR2 and AR7 wait on an owner; FR1 wording (non-blocking).
  • packages/lab/src/CommentPin/CommentPin.tsx: the click-to-select default waits on an owner decision; otherwise clear.
  • packages/lab/src/CommentPin/CommentPin.doc.mjs: two examples drift from the contract (non-blocking).
  • packages/lab/src/CommentPin/CommentPin.test.tsx: clear.
  • packages/lab/src/CommentPin/index.ts: clear.
  • packages/lab/src/index.ts: clear.
  • packages/lab/src/Comments/types.ts: clear.
  • packages/lab/src/Comments/CommentParts.tsx: clear.
  • packages/lab/src/Comments/Comments.test.tsx: clear.
  • apps/storybook/stories/CommentPin.stories.tsx: clear.
  • packages/lab/blocks/CommentPinShowcase.tsx: clear.
  • packages/lab/blocks/CommentPinShowcase.doc.mjs: clear.
  • packages/lab/blocks/CommentPinInMargin.tsx: clear.
  • packages/lab/blocks/CommentPinInMargin.doc.mjs: clear.

Automated review (maintainer link)

This branch was successfully deployed

1 active deployment
Preview — 2ce97d4f Deployed Dec 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant