Skip to content

mobile: stop typing prune ticks from rebuilding channel pages - #8695

Merged
brow merged 2 commits into
mainfrom
mobile-typing-prune-rebuild
Oct 29, 2026
Merged

brow merged 2 commits into
mainfrom
mobile-typing-prune-rebuild

Conversation

@brow

@brow brow commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Typing in the mobile composer felt slower than a native iOS text field. A device trace on an iPhone 12 mini showed the cause: while anyone in the channel is typing, the whole channel page rebuilds once per second, including the visible message list.

  • ChannelTypingNotifier._prune() runs on a 1 s timer and assigned a new list to state on every tick, even when nothing had changed.
  • _ResolvedChannelDetailPage watched the whole list and only filtered out the current user afterwards, so every tick rebuilt the page and its PositionedList (12 to 35 ms per frame, 8 to 19 ms for the message list alone).
  • Your own typing indicator echoes back from the relay, so the timer kept running the whole time you typed.

In a 30-key trace, 33 of the 35 frames over 12 ms were these rebuilds, 1.00 s apart.

Fix

  • _prune() publishes only when the visible entries change. TypingEntry now compares by value.
  • The channel and thread pages watch visibleTypingProvider, a VisibleTyping value that already excludes the current user and applies the page's scope. Your own echo refreshes its expiry every 3 s, which used to rebuild the page. Now it doesn't.

Other channelTypingProvider consumers are unchanged.

Related issue

None found.

Testing

  • Provider tests: a typing entry held across five prune ticks notifies listeners once, and the pages' shared visibleTypingProvider is not notified by the user's own refreshed echo but is by another user. Breaking either guard fails its test.

  • just mobile-check and just mobile-test pass at 8b8a168.

  • Device trace on an iPhone 12 mini: 30 keys typed into a channel composer, Profile builds with build tracing on both sides. Control is 6661d59, which has the same page code as main.

    control this PR (5ff7541)
    Channel page rebuilds while typing about 1 per second (44 in 40 s) 0
    Largest UI build per key, median / p90 4.9 / 29.3 ms 1.0 / 1.4 ms
    Keys with a build over 16.7 ms 9/30 0/30
    Frames with UI work over 12 ms 35 (33 page rebuilds) 1 (a semantics update from the test driver)
    ComposeBar frame, median 10.2 ms 3.0 ms

    The test driver turns on accessibility, so semantics runs on every frame in both traces. About 1 key in 4 still has a slow frame with about 1 ms of build and 2 ms of raster. A Time Profiler capture put that time in the driver's accessibility queries on the main thread (52% of main-thread samples while typing, none before the first automated tap), so it is a test-harness artifact rather than app work.

  • Dictation on an iPhone SE (2nd gen): a 15 s paragraph dictated into a channel composer, Profile builds with build tracing.

    main this PR (5ff7541)
    UI frame, median / p99 / max 0.9 / 10.4 / 26.1 ms 0.9 / 5.3 / 10.8 ms
    Frames over 16.7 ms 10 0
    Channel page rebuilds 26 (once a second) 6 (composer growth, none over budget)

    Each dictation update costs about 1 ms. The caret stayed at the end and nothing flickered on either build.

buzz-review-completed

🤖 Generated with Claude Code

The typing prune timer published a new list every second while anyone
was typing, and the channel and thread pages watched the whole list, so
each tick rebuilt the page and its message list. Publish only when the
visible entries change, and have pages select a value-equal view that
excludes the current user's own echoed indicator.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Tom Brow <[email protected]>
@brow

brow commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@brow

brow commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator Author

@buzz-security-review 5ff7541

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T17:40:42.025486Z 8b8a168 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

🔐 Codex Security Review

Note: This is an automated, security-focused review generated by Codex.
Use it as a supplement to human review; false positives are possible.

Scope

  • Exact PR diff: 8caf8351c124a2a39f160e342587d427e8c32a51...8b8a16845e5a7e455712623326128a1ba709a3a4
  • Model: gpt-6.1-sol

💡 Click "edited" above to see earlier reviews for this PR.


Review Summary

Overall Risk: NONE

No concrete security, correctness, or reliability findings in the authorized PR range. Typing filters preserve existing scope, and expiry pruning continues when unchanged notifications are suppressed.

Findings

No concrete security, correctness, or reliability findings were identified.

Notes

  • Review used read-only source and history inspection. Builds and tests were not executed, as instructed.

Generated by Codex Security Review |
Requested by: @brow |
Workflow run

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5ff7541314

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@brow
brow marked this pull request as ready for review October 29, 2026 17:35
@brow
brow requested a review from a team as a code owner October 29, 2026 17:35
@brow
brow enabled auto-merge (squash) October 29, 2026 17:36
Channel and thread pages now watch one visibleTypingProvider, and a test
checks that the user's own echoed indicator does not notify it while
another user's typing does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Tom Brow <[email protected]>
@github-actions github-actions Bot removed the codex-security-review-current The posted Codex security review matches its recorded range. label Oct 29, 2026
@brow

brow commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@brow

brow commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator Author

@buzz-security-review 8b8a168

@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Oct 29, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 8b8a16845e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 Carl, an automated reviewer, commenting via Wes's GitHub account.

Verdict: no blockers at 8b8a168. This is a comment, not an approval.

The change is well scoped. _prune() now publishes only when the visible list changes, and the pages select a value-equal VisibleTyping. Self-echo refreshes no longer rebuild the channel or thread page, and expiry and removal still publish from the prune timer.

What we checked:

  • Riverpod lifecycle (3.1.0 as locked). ref.watch gets a fresh .select(...) on every build. flutter_riverpod installs the new subscription before it closes the old one, so rebuilds never hit onCancel/onResume or the 30 s detach. A local widget probe confirmed this: 40 rebuilds over 40 simulated seconds, zero cancel/resume, one relay subscription, real unmount detached at 30 s.
  • Consumers of the old 1 s tick. The reply-handoff hook still checks its deadlines whenever it runs. It gets fresh input when messages change and when entries expire. Inline dots and thread shimmer run their own animations. We found nothing that needs an unchanged list republished every second. Date headings and retention labels read the clock during build, but they already went stale whenever nobody was typing, so that isn't new.

Validation gap, not blocking: the new tests run at the provider/selector level. No page-level test exercises quiet ticks, then natural expiry, then a reply through the real notifier. If you want that, extending an existing channel_detail_page_test.dart typing journey would cover it better than more provider tests.

Remaining gates: Mobile Swift (Native) is still pending. The Codex Security Review run was cancelled and never posted a review. Neither is caused by this diff.

@brow
brow merged commit ff284d0 into main Oct 29, 2026
52 of 53 checks passed
@brow
brow deleted the mobile-typing-prune-rebuild branch October 29, 2026 19:14

This branch was successfully deployed

No deployments
codex-review — 8b8a1684 Deployed Oct 29, 2026 by brow via Run Codex Security Review #10641
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex-security-review-current The posted Codex security review matches its recorded range.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants