fix(mobile): reply without swapping sheets, and post comments at all
Summary
- Replying to a page comment on mobile closed the list and opened a different sheet. The all-comments sheet is now the only comment surface, with a pinned composer and inline replies.
- Selecting a block opened a sheet too. It now opens a popover anchored to the block, matching web, reusing web's placement math from
packages/shared. - Commenting from mobile was broken outright —
optimisticId()calledcrypto.randomUUID(), which Hermes does not have. Fixed at the source.
Why / Context
The reply flow was the reported problem: tapping Reply did router.replace from /comments to /thread, so the list visibly closed and a second sheet opened just to type one line.
While verifying on a simulator against production, two more things surfaced that the reply work would have papered over:
Nothing posts from mobile. optimisticId() lives in packages/shared and calls crypto.randomUUID(). Hermes ships neither that nor getRandomValues, and apps/mobile polyfills only the latter via react-native-get-random-values. It threw undefined is not a function inside onMutate, before any network call, surfacing as a bare "Comment not posted" alert. Every comment and every reply from iOS has failed since #7427 moved this code into shared. The id is a local placeholder the server row replaces, so it never needed to be a UUID.
Page-level threads were unreachable. The API has always offered anchorKind: "page" with a null anchor and validates that pairing (page-comment/schema.ts:38), but no client could produce one — the store hardcoded "element" and dereferenced anchor.path.
How It Works
One sheet. /pages/[slug]/thread and /pages/[slug]/compose are deleted along with their routes. AllCommentsSheet holds a replyingTo target; Reply sets it, shows a Replying to X ✕ chip, focuses the composer and scrolls the thread into view. ✕ clears it and the composer falls back to a page-level comment. Pin taps set a focus thread and open the same sheet.
Anchored popover. Web's popoverPlacement was pure math with no DOM, so it moved to packages/shared/src/page-comments/popoverLayout.ts; packages/ui re-exports it and its existing tests still run against it unchanged, which is the evidence the move is behaviour-preserving. Two new optional params, both defaulted so web and desktop are untouched: pinSize (24 web, 28 mobile) and maxWidth (capping a 390pt phone at web's 350 clamps left to 28 against 12 on the right — visibly off-centre).
The popover anchors to the block's rect, not pinPointOf, which returns a point inside the element and put the card on top of tall headings. Passing the block's height as pinSize makes the existing flip-above branch land correctly without touching the formula.
Resolved comments sit behind a View N resolved comments disclosure at the foot of the list, expanding inline.
Manual QA Checklist
Verified on an iOS 26.3 simulator against production.
Reply flow
- Tapping Reply keeps the sheet open — no swap
- Chip names the author; ✕ returns to page-level
- Reply lands inline and the list scrolls to it
- Composer sits flush on the keyboard at full detent
Popover
- Opens anchored below the selected block
- Full width with symmetric margins
- Avatar aligns with the input pill
- Flips above a block near the bottom
- Lifts only as far as the keyboard overlap
- Quick actions (trash / lightning / thumbs-up) post
Comments
- A typed comment posts (this is the
randomUUIDfix — was failing 100%) - A comment with no reply target creates a page-level thread and draws no pin
- Long-press → Resolve/Reopen
-
View N resolved commentsexpands inline; a resolved pin auto-expands it
Web / desktop regression
- Popover placement unchanged on web
- Anchored threads still create with
anchorKind: "element"
Testing
bun run typecheck— 41/41bun run lint— cleanbun run check:i18n— all 17 locales compile under--strict; the 7 new strings are translated by hand in every catalog, matching the existing "Hide resolved" wording already there from web, with proper plural categories for ru/pl/csbun run sherif— no issuesbun testfor shared, cloud-client, ui, web, mobile, i18n — 0 fail- New tests:
createThreadsends the page-kind payload with a null anchor, the element path still sends its anchor, andoptimisticThreadreports the kind it has
Known Limitations
- The unticked QA boxes above are not verified. Building the app locally needed three throwaway workarounds for an Xcode 26.3 / Expo SDK 57 incompatibility (see below), and I would rather flag that than claim runtime behaviour I did not watch.
- Page-level comments are new to mobile. Web and desktop render them (
toThreadsdrops anchorless rows from the pin layer), but neither has ever created one, so they are an unfamiliar shape there. - Scrolling a focused thread to the top can tuck its first line under the transparent glass header.
contentInsetAdjustmentBehavior="automatic"means the true offset needs the header height, and@react-navigation/elementsis not installed, so there is no honest way to read it. Left rather than hardcoded.
Follow-ups
Xcode 26.3 cannot build apps/mobile. Not addressed here, and it will hit anyone who updates:
expo-modules-jsiannotates a constructorSWIFT_RETURNS_RETAINEDwhile the class is declaredSWIFT_SHARED_REFERENCEafter its closing brace; 26.3 evaluates the former first and rejects it. Present identically in 57.0.5, 57.0.8 and 57.1.0, so no bump fixes it.expo-observefails Swift 6 strict-concurrency checking.- Expo CLI cannot read
app.config.ts— Node 22.17.1 is one minor below 22.18, where TS type-stripping became default.NODE_OPTIONS=--experimental-strip-typesworks around it.
I patched all three locally (node_modules + gitignored ios/Podfile) purely to get a simulator. Worth a committed bun patch plus a build-settings change, which is a decision for the team rather than something to slip into this PR.
Also worth lifting: pinLayout is still duplicated between packages/ui and apps/mobile, same as popoverLayout was.
https://claude.ai/code/session_01HEKrvgfxuBaNLb9Fp9VdZE
Summary by cubic
Fixes mobile page comments so replying stays in one sheet, comments actually post from iOS (the optimistic ID relied on crypto.randomUUID(), which Hermes doesn't provide), and the comment popover no longer covers the block being commented on. Also adds page-level thread support and cuts comment-runtime scroll traffic.
Bug Fixes
- Replies happen inline in the all-comments sheet with a "Replying to X" chip that names the comment; the separate
/threadand/composeroutes are gone. optimisticId()now usesgetRandomValuesand returns a hex string, so it works on all platforms.- The all-comments sheet no longer opens blank, now distinguishes loading, failed, and empty states, and shows its composer only when a reply target is set.
- Agent comments are attributed to the agent (from the MCP session id) instead of the person whose session wrote them.
- The popover places against the space above the keyboard, so it flips above the block instead of drifting onto it while typing.
New Features
- Selecting a block opens a popover anchored to it, using placement math moved from
packages/uitopackages/shared(with newpinSizeandmaxWidthoptions). - Page-level threads now render on web and desktop, draw no pin, and resolved threads sit behind a "View N resolved comments" disclosure.
- The comment runtime skips rect syncs when no pins are tracked and throttles scroll posts to 150ms, cutting bridge traffic from ~120 to 6 messages per 60 frames.
Summary by CodeRabbit
-
New Features
- Added inline mobile commenting with quick replies, reply context, thread focusing, and keyboard-aware composition.
- Added comment resolving/reopening, resolved-comment filtering, expandable replies, and loading-error retry handling.
- Added workspace page browsing with page cards and direct navigation.
- Added a workspace details toolbar shortcut.
- Improved agent-authored comments by displaying their specific agent labels.
-
Bug Fixes
- Page-level comments now display correctly without element anchors.
- Improved comment popover positioning when the keyboard appears.
-
Localization
- Added updated translations for comment, reply, error, resolved-comment, and workspace-detail messages across supported languages.