Skip to content

fix(mobile): a thread shared while open holds a new writer's message for its author - #875

Merged
Jacksondr5 merged 3 commits into
j5/mainfrom
j5code/mobile-people-read
Nov 1, 2026
Merged

Jacksondr5 merged 3 commits into
j5/mainfrom
j5code/mobile-people-read

Conversation

@Jacksondr5

@Jacksondr5 Jacksondr5 commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Problem

Mobile knew a thread was shared only from its cached author record, which counts a thread as shared once an author is recorded. So a thread that was shared while open on the phone could show the first collaborator's message raw: the platform's note and [Message from …] line, drawn as the reader's own words. It stayed that way until the record refreshed (#859's documented gap). Closes #871.

What changed

Mobile now reads who reaches the thread, and subscribes to changes to it, as web does. Sharing a thread moves that read's change counter, so the phone knows the thread is shared before anyone else writes. A message nobody is recorded for is then held until its author's record answers, the same "pending" path a message already takes before the first read. A thread only one person writes to is unaffected, so nothing is held back for a round trip there (Jackson's Checkpoint 1 decision).

Shared code, so web and mobile follow one rule:

  • scopePeople and scopePeopleChanges move from web's sharingManage into client-runtime's createSharingEnvironmentAtoms.
  • The "may be shared" rule moves from web's useSharedConversationEntries into mayBeSharedConversation in client-runtime j5/sharedConversation.ts. A thread may be shared when:
    • its record says so;
    • more than one person can write to it;
    • to a reader who isn't the first owner, anyone else reaches it at all;
    • or no read has answered yet.

Web's behaviour is unchanged, and its sharing tests pass.

UI changes

Android 16 emulator, 1080×2400 in the light theme: the same person (Taylor Base), first message, thread title and viewport on both sides. Each side needs its own thread that starts private, so the history above the shared message differs. Before is base c2b7939de8, after is 25e43af51a.

The first message from a newly added collaborator, with the thread open on the phone.

  • Before: it lands on the right as the reader's own, showing the platform's raw <j5_shared_conversation> note.
  • After: it appears once, on the left under Taylor's name, below the muted note line.
Before After
First message from a newly added collaborator, before First message from a newly added collaborator, after

Before, the raw message showing until it corrects itself (about 16 seconds in):

android-first-share-before.mp4

After, the message arrives clean (reviewed frame by frame at 0.5s):

android-first-share-after.mp4

Web, the same shared thread: it renders on base, and on the fixed head.

Base After the fix
The shared thread on web, before The shared thread on web, after

A follow-up message in the already-shared thread, after: still drawn as in #859.

A follow-up message in an already-shared thread, after

Live testing

The crew's tester ran Android 16 and web on an isolated test server, with real Claude Haiku turns, the Test owner and a collaborator, Taylor Base: pass at 25e43af51a.

  • Base reproduced the bug first try: a raw note, drawn as the reader's own, until it corrected itself.
  • On head, the first message after sharing showed clean and on the left. A follow-up in the already-shared thread was also clean, and a private thread still sends at once.

Regression found and fixed during testing. At 0f54cdd941 every web thread hit "Too many re-renders"; base didn't. The new shared call ran before the timeline hook's state, and that stopped the React Compiler memoizing the entries the hook returns. ConversationTimeline derives state from those entries during render, so it looped. 25e43af51a moves the call after the hook. A browser test (sharedTimeline.browser.test.tsx), which fails on 0f54cdd941, holds the entries stable. The tester confirmed the web tabs that had looped now render, for the owner and for the collaborator.

Not exercised: iOS (deferred to the checkpoint), and slow links beyond the emulator's.

Upstream impact

None new. The upstream files involved are unchanged; FORK.md case 99's text now names the people read.

Checklist

  • One concern: the description has no "also"
  • Tests cover the changed behavior: sharedConversationFeed.test.ts (a thread shared after its record was read), client-runtime sharedConversation.test.ts (mayBeSharedConversation), and web sharedTimeline.browser.test.tsx (stable entries)
  • UI changes: before/after above, with before and after videos (Android; iOS at the checkpoint)
  • Live testing: the section above says what ran live and what did not
  • Upstream-owned files: no new edits; case 99's text updated
  • Upstream product: unchanged
  • Surfaces: mobile is the client, and web shares the rule. No contract changes; the people read is per environment, like the author record. An older server without the read fails it, and mobile falls back to the record alone.
  • Docs: nothing to rewrite here; any user-doc change goes in the wave-2 docs PR

Claude Opus 5.5 in J5 Code (Claude Code harness).

🤖 Generated with Claude Code

…for its author

Mobile knew a thread was shared only from its cached author record,
which says shared once an author is recorded. A thread shared while
open could show the first collaborator's message raw, drawn as the
reader's, until the record refreshed. Mobile now reads and subscribes to
who reaches the thread, as web does, and holds a message nobody is
recorded for while more than one person writes. The scope-people atoms
and the rule (mayBeSharedConversation) move into client-runtime, shared
with web.

Closes #871

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
j5-code Ready Ready Preview Nov 1, 2026 8:15pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 10 billable files and costs up to $2.50.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 10 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 3 included reviews currently available. Your 43 included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between edc4350 and 09a25c3.

Files selected for processing: 10
  • FORK.md
  • apps/mobile/src/j5/sharing/sharedConversation.tsx
  • apps/mobile/src/j5/sharing/sharedConversationFeed.test.ts
  • apps/mobile/src/j5/sharing/sharedConversationFeed.ts
  • apps/web/src/j5/sharing/sharedTimeline.browser.test.tsx
  • apps/web/src/j5/sharing/sharedTimeline.ts
  • apps/web/src/j5/sharing/sharingManage.ts
  • packages/client-runtime/src/j5/sharedConversation.test.ts
  • packages/client-runtime/src/j5/sharedConversation.ts
  • packages/client-runtime/src/j5/sharing.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@github-actions github-actions Bot added the size:L 100-499 effective changed lines (test files excluded in mixed PRs). label Nov 1, 2026

@Jacksondr5 Jacksondr5 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Combined review: reviewer-opus and reviewer-sol (Claude Opus 5.5 and GPT Sol 6.1), head 0f54cdd

Both of us reviewed the PR independently. Neither found anything that blocks merge.

  • The rule. mayBeSharedConversation is web's expression line for line: record.shared, writers > 1, readsOthers, and the read that hasn't answered yet. A people of null becomes [] inside, as web's ?? [] did. Its tests cover each case: initial, failed, unshared, first owner, Viewer and several writers.
  • The atoms. scopePeople and scopePeopleChanges move into createSharingEnvironmentAtoms with the same labels, tags and staleTimeMs. Web's sharingManage now points at the same family.
  • Mobile. useThreadPeople reads the people and refreshes when the revision moves, as web's useScopePeople does. Sharing a thread moves that revision, so a thread shared while open reads as shared before the new writer's first message arrives. That closes the limitation #859 documented, and the new feed test reproduces exactly that case.
  • Parity note. When two Owners hold server scope, writers > 1 holds in every thread, so mobile now holds new messages until their author is read, as web already does.

53 shared and 51 mobile focused tests pass.

The panel has no open code findings. Before merge it still needs the tester's run and green J5 CI.

@github-actions github-actions Bot added the vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. label Nov 1, 2026
Computing who may be shared through the shared mayBeSharedConversation
before the timeline's state hook stopped the React Compiler memoizing
the entries it returns; ConversationTimeline derives state from them in
render and hit React's re-render limit on every thread. The call now
runs after the hook, so the entries keep their identity while nothing
they read changes, and a browser test holds that.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@Jacksondr5 Jacksondr5 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Combined review: reviewer-opus and reviewer-sol, head 25e43af

Fixed: the web regression the tester found. In useSharedConversationEntries, the pure mayBeSharedConversation(...) call moves after the useState and setStored block, with the same inputs and the same result. The React Compiler memoizes the entries again, so ConversationTimeline no longer re-renders forever.

  • Test. sharedTimeline.browser.test.tsx checks that the entries keep their identity across a rerender. reviewer-sol ran it against 0f54cdd's sharedTimeline.ts, and it fails there on exactly that identity assertion. It passes on this head. It follows the repository's browser-test rules: a disposable render, a fresh element on each rerender, router: false with a reason, and fixtures that are never changed. Its module mocks pull in no Shiki or diff workers.
  • Mobile. useSharedConversationFeed already runs in the order this fix restores, with its people hook before the state hook and the presentation after it. Native's ThreadFeed also doesn't derive state from the feed during render.

The panel has no open code findings. Before merge it still needs the tester's re-run and green J5 CI.

Jacksondr5 added a commit that referenced this pull request Nov 1, 2026

This branch was successfully deployed

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

Labels

size:L 100-499 effective changed lines (test files excluded in mixed PRs). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mobile: read who can reach a thread (the people read), so shared authors never flash raw

1 participant