Skip to content

fix(mobile): open search results at the exact message - #9899

Open
wesbillman wants to merge 20 commits into
mainfrom
mobile-search-exact-message
Open

wesbillman wants to merge 20 commits into
mainfrom
mobile-search-exact-message

Conversation

@wesbillman

@wesbillman wesbillman commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

What changes

Tapping a mobile message search result opens its exact message. A thread reply opens in its thread. A reply also sent to the channel opens in the channel. Forum results and channels that require joining keep their existing routes.

Older results use the existing message history path. The list keeps the target in view as older pages load or live messages change its position. In a wide search pane, the detail keeps its thread navigation when the original result disappears. Scrolling, navigating, or sending a new message takes control of the list.

Each open still reads its target by ID, as Activity and message links do on main. Each page holds its targets until it closes, so a wide-pane re-tap cannot unpin the new pane's target. An older target above unloaded history does not trigger automatic paging below it.

Out of scope, for a follow-up: skipping the ID read when the newest window already has the hit, and keeping the target in view when a page lands after the user drags. Today the landing page can push it out of view, as it does for Activity on main.

Verification

  • At 758679cf2 (cut to the placement core after the 03:20Z re-review: the search-hit hint, the window-refresh wait, the shared ID read and held-target paging are removed, so each open sends its own ID read with its own deadline. The hold count, the detached-target fill check, the reconnect catch-up check and the Retry guard are kept): pre-push passed on this HEAD, including the full mobile suite. Analysis and formatting were clean. Each kept guard was broken in turn and its test failed. Not exercised on a device. Earlier entries describe code that has since been removed.
  • At 9532c6020 (brow's 05:06Z blocker 1): restores the check when a drag starts, so a drag at a clamped top edge above an older deep-linked message still pages through hidden-only history and retries after a failed fetch (this also affects Activity and link opens). A two-row test fails without the fix. Pre-push passed on this HEAD, including the full mobile suite. Not exercised on a device. Blocker 2, the extra ID read per Search tap, waits on Wes's decision.
  • At 5dfba27b6 (fix for the 00:24Z re-review: each page now holds its own count on a deep-link target, so a wide-pane re-tap's stale release or a denied open's release no longer unpins another page's target, and opens of one ID share a single read that pins and publishes once; main merged in, with comment-only trims to stay under the file-size limit): pre-push passed, the full mobile suite passed (6,610 tests, 83 skipped), and analysis, formatting and the file-size check were clean. Each part of the fix (count before the denial return, count rather than set, holds kept through denial, per-ID shared read, cleanup on failure, still-held fence) was broken in turn and its test failed. Not exercised on a device.
  • At ac26a8750 (fix for the 23:32Z re-review: a released search-hit lookup retires instead of parking, so repeated offline opens of one hit send one ID read and publish once; main merged in): pre-push passed, the full mobile suite passed (6,601 tests, 83 skipped), and analysis, formatting and the file-size check were clean. The regression test fails with each part of the fix broken. Not exercised on a device.
  • At 59dbbfea3 (fixes for the 21:23Z re-review: a failed first load keeps Retry when a search hit's lookup lands, and a hinted lookup waits for a due window refresh instead of sending an ID read): pre-push passed, the full mobile suite passed (6,570 tests, 83 skipped), and analysis, formatting and the file-size check were clean. Each fix has a regression test confirmed to fail with its fix broken. Not exercised on a device.
  • At 2bef9eefe (fixes for the 18:58Z re-review: a search hit is only a hint, so a deleted hit is never shown, and Android drags at a clamped edge keep paging older; main merged in, including the relay_session_test fix from test(mobile): keep the publish timeout test off the unbuilt session's state #10162): pre-push passed, the full mobile suite passed (6,567 tests, 83 skipped), and analysis, formatting and the file-size check were clean. Each fix has a regression test confirmed to fail with its fix broken. Not exercised on a device.
  • At f16dde519 (fixes for the pre-review, with main merged in): pre-push passed, the full mobile suite passed (6,528 tests, 83 skipped), and analysis, formatting and the file-size check were clean. Each fix has a regression test, and each test was confirmed to fail with its fix broken. These fixes have not been exercised on a device.
  • At 6b10970da, pre-push passed with 6,166 mobile tests, 72 skips, and 27 crypto tests. Analysis, formatting, and the repository file-size check passed. The widget regressions reproduce target drift with 20 live arrivals and the pane rebuild error after the tapped search tile is removed.
  • Isolated iPhone 17e simulator on iOS 27.0, with a synthetic 120-message channel. Compared baseline c5d480427 with the ea39b596e app sources plus local measurement instrumentation. The older match stayed visible once paging settled, a drag moved it without snapping back, and recent and thread matches opened at the selected message.
  • The final change gives a newly sent message priority over the history anchor. Both widget cases failed on ea39b596e and passed on e4a3faad6, including when history and the send arrived in the same frame. The simulator captures are from ea39b596e. Widget tests cover the later changes for live arrivals and pane rebuilds.

Try it

  1. Search for a distinctive phrase in an older channel message. Tap it and let history settle. Send a few messages from another device. The result should stay visible, and automatic paging should not pull in history below it. Drag the list and confirm that it follows the drag.
  2. Search for a non-broadcast thread reply. Tap it and confirm that the enclosing thread opens with the selected reply in view.
  3. Search for a recent channel message and confirm it appears in view when tapped. In a channel where you can send, send a message without scrolling first. The list should follow your send.
  4. In a wide window, open a thread reply from search. Change the query so the tapped result disappears, then resize. The open pane should retain the thread and selected reply.
  5. In a wide window, tap an older search result, then tap the same result again. The pane should reopen at that message and stay there.

wesbillman and others added 2 commits November 23, 2026 11:25
Tapping a message result opened its channel at the newest page, so an older
hit or a thread reply was not shown. Pass the hit to the channel page's
existing message focus, and open a thread reply in its thread, as Activity
does. A reply also sent to the channel opens in the channel. Forum results
are unchanged.

Co-authored-by: Wes <wesb@block.xyz>
Co-authored-by: Groot <f4c08302591916fb4b80926bf7e18d22eef8aa0c877e4e841acc46405a45700b@buzz.block.builderlab.xyz>
Signed-off-by: Wes <wesb@block.xyz>
A link to a message older than the newest page jumped to it, then the
automatic older-page fetch filled the gap below it and pushed it out of
view. Follow the target while that fill moves it, and stop once the user
scrolls or navigates. Entries newer than the latest one it was placed with
are live updates and do not move it.

Co-authored-by: Wes <wesb@block.xyz>
Co-authored-by: Groot <f4c08302591916fb4b80926bf7e18d22eef8aa0c877e4e841acc46405a45700b@buzz.block.builderlab.xyz>
Signed-off-by: Wes <wesb@block.xyz>
wesbillman added a commit that referenced this pull request Nov 23, 2026
@wesbillman

Copy link
Copy Markdown
Collaborator Author

🤖 Simulator comparison on an iPhone 17e with synthetic messages. Before is c5d480427. After is ea39b596e plus local measurement instrumentation.

Older channel result

Before, selecting message 10 opened the newest page. After, the result stays visible after automatic paging settles.

before-c5d480427-older-zanzibar

after-ea39b596e-older-zanzibar-settled

A subsequent drag moves the result without snapping back.

after-ea39b596e-older-zanzibar-user-scroll

Thread reply

Before, tapping reply 4 opened the channel at the newest messages. After, its thread opens with the reply in view.

before-c5d480427-thread-kumquat

after-ea39b596e-thread-kumquat

@wesbillman
wesbillman marked this pull request as ready for review November 23, 2026 23:43
@wesbillman
wesbillman requested a review from a team as a code owner November 23, 2026 23:43
@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 23, 2026
@github-actions

github-actions Bot commented Nov 23, 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: 5825a7a81fc28c27b409e4f70f68b883a0bb9769...6b10970da9275775d3620104926448e924b80f63
  • 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 identified in the authorized PR range.

Findings

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

Notes

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

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

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator Author

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.

Blocking. (Posted as a comment because GitHub won't let the author request changes on their own PR.) The routing matches how Activity opens messages (broadcast handling, thread root, pane key and reopen, back navigation), and non-forum kinds and the non-member path behave correctly. There are two blockers, explained inline:

  1. The target can drift out of view as live messages arrive, and re-anchoring stops after the latest-at-placement row is deleted (message_list.dart).
  2. The pane detail builder looks up ConversationPaneScope through the search tile's context after that tile may have unmounted (search_page.dart).

Validation gaps: the history test mixes a live append into the backfill, which hides the live-only case. The new search tests run without a pane scope, so they only cover replaceCurrentRoute, not the push path the app uses.

To merge: fix both, add a live-only update to the existing history journey and assert that the target stays in view, and keep CI green.

Reviewed by the Royal Court (Mongo, Princess Donut, Mordecai). Both blockers were reproduced in scratch widget tests at this head.

// Older pages filling the gap below the target move its index, so keep
// it in place until a scroll or a navigation. Entries after the latest
// one it was placed with are live updates, which leave it where it is.
final liveCount = anchor?.$2 == null ? 0 : reversedIndexOf(anchor!.$2);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Blocker: the linked message drifts out of view as live messages arrive.

scrollable_positioned_list keeps its numeric index when items change. Each live append raises the target's reversed index, while targetIndex - liveCount stays equal to anchor.$1, so the effect skips the correction and the list shows a different row at the anchor. A widget probe at this head showed 20 incoming rows pushing the target off screen without any scrolling. To reproduce, open an older hit in a busy channel, leave it alone, and let other clients post while paging is pending.

There is a second path to the same failure. If the latest-at-placement row (anchor.$2) is deleted, liveCount becomes null and re-anchoring stops, so a later history page can push the target out of view.

The existing test (channel_detail_page_test.dart:9115) doesn't catch this. It mixes a live append into the backfill, and the backfill alone forces a correction.

Suggested fix, validated against the probes and the existing deep-link cases: drop the latest-entry sentinel. Track the last placed index, key the effect on the target's actual reversedIndexOf(initialMessageId), and re-place whenever that index changes, until a drag, navigation or local send clears the anchor. Also cancel stale post-frame callbacks. Keying on the target index also covers a related bug that already exists on main: the effect depends on entries.length, so a same-length replacement page that newly contains the target never places it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤖 Fixed in aff9b0d and published at 6b10970. The list now re-places the linked message when its reversed index changes, including on live arrivals, until the user scrolls, navigates or sends. The live-only regression failed on the prior implementation and passed with the fix. Full mobile pre-push passed at the published head.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤖 Fixed in aff9b0d. Verified at 6b10970.

initialMessageId: messageId,
initialThreadRootId: threadRootId,
initialThreadRouteBehavior:
ConversationPaneScope.maybeOf(context) == null

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Blocker: a deactivated context is read on a pane rebuild.

ConversationPaneController.open stores this builder, and _CoveringDetail calls it again on every rebuild. context here is the tapped _MessageTile's. After a new query or a scroll unmounts that tile, the next rebuild (a resize or rotation, or popping the thread over the detail) calls ConversationPaneScope.maybeOf on a deactivated element. In debug, this repro hits Looking up a deactivated widget's ancestor is unsafe in a scratch test: wide pane, tap a hit, run a new query, then resize. In release we expect the lookup to return null (inferred, not run). The page would then switch to replaceCurrentRoute inside the pane and run pushReplacement over the pane route.

The base builder never read context. Activity's equivalent reads a long-lived page context. Fix: compute the behavior once, before openConversationPane, and capture the value in the builder. A scratch test confirmed that this change fixes the crash.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤖 Fixed in aff9b0d and published at 6b10970. The pane captures the thread route behavior before opening. The wide-pane regression opens the thread with push, removes the tapped tile by changing the query, and resizes. It reproduces the deactivated-context exception on the prior implementation and passes with the fix.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤖 Fixed in aff9b0d. Verified at 6b10970.

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤖 Star Lord recommends changes at e4a3faa. The delayed first jump can override a scroll or send. The target-index fix in Carl’s review also needs to cover the cached-to-relay handoff when the row count stays the same. Source-only review.

}
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!context.mounted || !itemScrollController.isAttached) return;
if (didJumpToInitialMessage.value &&

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤖 [P2] Cancel the pending initial jump when the user takes control. Open a result outside an already-loaded history window and scroll or send while the event-by-ID fetch is pending. Both actions clear the anchor, but didJumpToInitialMessage is still false, so the delayed target bypasses this guard and jumps away from what the user was reading or the message they just sent. Record cancellation independently of whether the initial placement has run, and check it before scheduling and applying the jump.

wesbillman and others added 2 commits November 23, 2026 17:00
The list keeps its numeric position when items change, so a live post
raised the target's index and pushed it out of view, and deleting the
latest row placed with it stopped re-anchoring. Re-place the target
whenever its own index changes until a scroll, navigation or local send
releases it, and drop stale placement callbacks. This also places a
target that first appears in a same-length replacement page.

Search's pane keeps the detail builder after the tapped tile unmounts,
so resolve the thread route behavior before opening the pane instead of
reading the tile's context on a later rebuild.

Co-authored-by: Groot <f4c08302591916fb4b80926bf7e18d22eef8aa0c877e4e841acc46405a45700b@buzz.block.builderlab.xyz>
Signed-off-by: Wes <wesb@block.xyz>
Signed-off-by: Wes <wesb@block.xyz>
@github-actions github-actions Bot removed the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 24, 2026
@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 24, 2026

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator Author

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.

No blockers remain. aff9b0d resolves both findings from the previous review:

  • The deep-link effect now keys on the target's own index and re-places the target whenever that index changes, until a scroll, navigation or local send releases it. Stale placement callbacks are dropped. This also covers the same-length replacement page case.
  • Search resolves the thread route behavior before it opens the pane, so the stored builder no longer reads the tile's context.

Validation: the history journey now includes a live-only burst of 20 posts. I ran it locally against the e4a3faa message_list.dart and it fails there; at this head it passes, as do the local-send cases and the full search_page_test.dart. The search tests now also run inside a wide AdaptiveConversationDestination, which covers the push path the app uses. Mobile CI was still running when I posted this.

Not approving: approval needs Wes's explicit sign-off.

@brow brow 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.

🤖 Pre-review recommends rework; four problems block landing at 6b10970.

  1. Re-placing an older target keeps it as the oldest row on screen, so the viewport auto-fill runs to its 5-page cap (one page on main) and then shows "Load earlier messages" above the target while every page lands below it. This also hits Activity, reminder, push and link opens.
  2. On a narrow layout, a non-broadcast reply in an unjoined open channel replaces the channel page with a read-only thread, so the reader loses the Join button that the same tap reached before.
  3. A Search tap into a cold channel now sends an exact-ID read for an event Search already holds, even when the newest window returns it.
  4. A drag or send before the first placement doesn't cancel the pending jump (both guards key on didJumpToInitialMessage), so a late target pulls the reader away.

To resolve:

  1. Stop the auto-fill and the button from treating a target above an unloaded gap as short history, or page around the target instead.
  2. Push the thread instead of replacing the channel for non-members.
  3. Seed the channel with the search hit's event, or skip the read when the window supplies it.
  4. Mark the first jump as done wherever the anchor is released.

Details in Buzz: buzz://message?channel=e71f9a2a-ac46-473d-a24e-5e16fd8cb7b1&id=7b044424237e19a0fbb4d15b3b06deb1698deab8a7c0e55ae7333fb3a3b5c197

wesbillman and others added 4 commits December 3, 2026 09:41
…ch-review

Signed-off-by: Wes <wesb@block.xyz>
- A deep-link target above unloaded history no longer counts as short
  history, so it doesn't drive viewport auto-fill or offer Load earlier
  above it. Scrolling still pages normally.
- On a phone, a non-member's thread opens over the channel instead of
  replacing it, keeping Join.
- Search passes the hit's event to the channel, which skips the exact-ID
  read for an event it already holds.
- Releasing the anchor (drag, send, jump) also ends a pending first jump.

Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>
Signed-off-by: Wes <wesb@block.xyz>
A page that lands between a detached deep-link target and the newest
window no longer pushes the target off screen; it is re-placed at its
last position. Older pages also wait for a reconnect re-read, and the
Solo flat timeline's detached-target check is covered.

Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>
Signed-off-by: Wes <wesb@block.xyz>
Jump to latest, oldest unread and scroll to oldest drop the hold, so a
page landing mid-navigation can't pull the reader back. A live post
during the fetch keeps the hold for the page, and an empty list holds
nothing.

Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>
Signed-off-by: Wes <wesb@block.xyz>
@wesbillman

Copy link
Copy Markdown
Collaborator Author

🤖 All four findings from the pre-review at 6b10970 are fixed as of f16dde519. The branch also has current main merged in. Each fix has a test, and I broke each fix once to confirm its test fails without it.

  1. Paging around an older target. When a deep-link target sits above history that hasn't loaded (isDetachedTarget), the viewport no longer counts as short history until the newest row is also on screen, and it holds off while a reconnect re-read is in flight. Scrolling still pages in the history below the target. A visible target is put back where the reader had it when a page lands below it, and jump to latest, oldest unread and scroll to oldest drop that hold. This covers both the channel window and the legacy/Solo history paths.
  2. Narrow layout, unjoined channel. On a phone, opening the thread replaces the channel route only for members. A non-member gets the thread pushed on top, so Join stays one step back.
  3. Cold Search open. Search passes the event it already holds through to the channel, and loadEventsById reads only the IDs it wasn't given.
  4. Drag or send before the first placement. Each release point also ends the pending first jump: drag, send, jump to latest, oldest unread and scroll to oldest.

Gates: format, analyze and the file-size check are clean, the full mobile flutter test passes (6528), and the pre-push hooks passed. I haven't exercised it on a device yet.

@brow brow 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.

🤖 Pre-review at f16dde5: the four earlier problems are fixed. Two new ones from the repair still block landing.

  1. A deleted search hit comes back. If a message is deleted after Search returns it and before the tap, a cold channel open skips the exact-ID read and merges Search's copy into the timeline. The newest window omits deleted rows and sends deletions only for rows it returns, so nothing removes it, and it stays after closing Search and reopening the channel. The ID-only handoff kept it out, because the relay's ID read excludes deleted events. Fix shape: treat the held event as a hint only. Wait for the newest window; if it returns the hit, no read is needed. Otherwise read by ID as Activity does, and add only what the relay returns.

  2. Android: dead edge above a held old target. With the target more than 5 pages behind the newest window, the first drag toward older loads 5 pages. After that the list sits at the clamped edge, where a drag moves no positions, so the paging check never runs again. The detached rule in _historyFits also hides "Load earlier messages". It reads as the start of the channel, and only a reverse drag restarts paging. This reaches Activity and message-link opens too, which keep paging on main. Fix shape: re-run the older-page check from the scroll gesture that resets the page cap (or on overscroll), or offer the button at the cap while a detached target is held.

Follow-ups, not blocking:

  • Each loading drag near a held target fetches 5 pages back to back, with the target off screen for a frame per page.
  • A send in the same frame as a landing page still gets one stale jump to the target before going to latest.
  • A large live burst followed by a page one frame later can skip the re-placement.

Details in Buzz: buzz://message?channel=e71f9a2a-ac46-473d-a24e-5e16fd8cb7b1&id=7b044424237e19a0fbb4d15b3b06deb1698deab8a7c0e55ae7333fb3a3b5c197

wesbillman and others added 3 commits December 3, 2026 13:51
A search hit's copy no longer goes into the timeline: the channel waits
for its newest window, and reads the target by ID only when the window
lacks it, so a message deleted since the search stays out. A drag at
the clamped top edge above a held old target re-runs the older-page
check, which a drag that moves no positions never triggered.

Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>
Signed-off-by: Wes <wesb@block.xyz>
…ch-review

Signed-off-by: Wes <wesb@block.xyz>
Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>
Signed-off-by: Wes <wesb@block.xyz>
@wesbillman

Copy link
Copy Markdown
Collaborator Author

🤖 Both blockers from the 18:58Z re-review are fixed at 2bef9eefe.

  • Deleted search hit put back in the timeline. Search's copy of the hit is now only a hint. If the hint matches, the channel waits for its newest window and uses the hit only when the window already holds it. Otherwise it reads the message by ID, and the relay's ID read leaves out deleted messages. The hint itself is never added to the timeline. Test: a caller's copy of a deep-link target is only a hint (in and out of window).
  • Android dead edge above an old target. A drag at a clamped edge moves no positions, so the older-page check never ran after the auto-fill cap reset. The scroll handler now runs the same check after the reset. Test: the old-hit paging test drags six times and reaches the oldest message. Without the fix, paging stopped after the first cap.

main is merged in, including #10162, which fixes the relay_session_test failure that made Tests 2/3 red. The full mobile suite passes (6,567 tests, 83 skipped). This is not yet exercised on a device.

Not changed, open for a product call: one drag near a held target can still load up to five pages (the existing auto-fill cap) instead of one.

@brow brow 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.

🤖 Pre-review at 2bef9ee: both earlier problems are fixed (the deleted hit stays out, and Android pages past the clamped edge). Two new ones from the repair still block landing.

  1. A failed channel load loses Retry on a Search open. On a cold channel with no saved rows, when the newest window fails, the hinted lookup waits for that failure and then reads the target by ID. loadEventsById publishes the result as AsyncData over the AsyncError, so "Failed to load messages" and Retry disappear. The page shows only the hit (or nothing if it was deleted), history never counts as loaded, and paging stays off. On main, Search kept Retry here. Fix shape: don't publish a target-only list over an error while history has not loaded. Pin the target and keep the error, which also closes the same race for Activity and message links.

  2. Redundant ID read when no init is in flight. Reopening a channel after more than 30 s detached for a hit newer than its cached rows, or tapping a hit while the session is not connected, finds no init to wait for. It sends the ID read, and the window refresh that follows returns the same hit. That is one extra relay request per such tap, and main's Search tap sends none. Fix shape: with a hint present and a window refresh due (resume pending or session not connected), wait for that init to settle before deciding on the read.

Follow-ups, not blocking: recheck that the target is still retained and access not denied after the wait, before sending the ID read; limit the new gesture-start paging check to older-directed drags; a superseded init can delay the lookup up to 8 s; null checkOlderPages on cleanup; a loading drag near a held target still shows 5 off-target frames.

Details in Buzz: buzz://message?channel=e71f9a2a-ac46-473d-a24e-5e16fd8cb7b1&id=7b044424237e19a0fbb4d15b3b06deb1698deab8a7c0e55ae7333fb3a3b5c197

wesbillman and others added 2 commits December 3, 2026 16:08
… hit

A hinted target lookup no longer publishes a target-only list over a
failed first load's error, so Failed to load messages and Retry stay.

It also waits for a window refresh that is due but not yet running
(session disconnected, or a chat detached past its 30 s grace and about
to rebuild) before reading the target by ID, so the refresh can supply
the hit. The settle signal is now one completer per load end, also
settled on dispose and denial, and the lookup rechecks mount, access and
retention after the wait.

Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>
Signed-off-by: Wes <wesb@block.xyz>
Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>
Signed-off-by: Wes <wesb@block.xyz>
@wesbillman

Copy link
Copy Markdown
Collaborator Author

🤖 Both blockers from the 21:23Z re-review are fixed at 59dbbfea3.

  • A failed channel load lost Retry on a Search open. loadEventsById no longer publishes a target-only list over an error. The targets stay pinned, and the next successful load merges them in. Activity and link opens use the same path. Test: a failed first load keeps its error past a hinted lookup.
  • Redundant ID read when no init is in flight. A hinted lookup now waits while a window refresh is due: an init is running, the session is not connected, or the chat is detached and about to rebuild. It then checks whether the window has the hit. The settle signal now fires on every load end, on dispose and on denial, so the wait can't hang. Test: a hinted lookup waits for a due window refresh (disconnected and detached cases).

Also done from the follow-ups: after the wait, the lookup re-checks mount, access and retention before it sends the ID read.

Still not done: limiting the gesture-start check to older-directed drags, the 8 s superseded-init delay, clearing checkOlderPages on cleanup, and the five off-target frames.

The full mobile suite passes (6,570 tests, 83 skipped). This has not been exercised on a device.

@brow brow 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.

🤖 Pre-review at 59dbbfea: both round-3 problems are fixed (a failed load keeps Retry, and an in-window Search hit sends no ID read). One new problem from the repair still blocks landing.

Abandoned hinted lookups park with no bound, then all fire. A hinted lookup started while the session is not connected or the chat is detached awaits _initSettled with no timeout (mobile/lib/features/channels/channel_messages_provider/pagination.dart:40-42). Leaving the page calls releaseDeepLinkEvents (mobile/lib/features/channels/channel_messages_provider.dart:1168-1173), which does not wake or retire the waiter, and the provider is kept alive. Reopening the same out-of-window hit re-adds its ID to _retainedDeepLinkEventIds (:1135), so after the next successful init every parked waiter passes retainAll (pagination.dart:44) and sends its own fetchHistory (:52).

Cost: N identical ID reads in a burst on the connection that just recovered (five offline opens of one hit gave five reads), where the open route needs one and main's Search sends none. At 2bef9ee those held reads expired unsent after 8 s. Each parked waiter also copies, sorts and republishes the timeline (channel_messages_provider.dart:1159-1164), including with an empty result on a later ordinary open of that channel (four publishes instead of one after three abandoned opens).

Fix shape: retire the wait when its route releases it (call _settleInit() from releaseDeepLinkEvents and stop waiting once none of the call's IDs are still retained, or use a per-lookup generation), share one in-flight read per ID, and return early in loadEventsById when the lookup produced no events. A test that opens and releases one out-of-window hit N times offline and then reconnects should see one ID read and one publish.

Follow-ups, not blocking: Retry does not re-read a target whose ID read also failed; limit the gesture-start paging check to older-directed drags; null checkOlderPages on cleanup; a loading drag near a held target still shows 5 off-target frames.

Details in Buzz: buzz://message?channel=e71f9a2a-ac46-473d-a24e-5e16fd8cb7b1&id=7b044424237e19a0fbb4d15b3b06deb1698deab8a7c0e55ae7333fb3a3b5c197

wesbillman and others added 2 commits December 3, 2026 16:58
A hinted lookup parked on a due window refresh now belongs to the newest
open of each of its IDs. Releasing the IDs wakes it, and an ID released
or taken by a newer open is left to that open, so N abandoned offline
opens of one hit send one ID read on reconnect instead of N. A lookup
that finds nothing returns without republishing the timeline.

Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>
Signed-off-by: Wes <wesb@block.xyz>
…ch-review

Signed-off-by: Wes <wesb@block.xyz>
@wesbillman

Copy link
Copy Markdown
Collaborator Author

🤖 The 23:32Z blocker is fixed at ac26a8750 (fix commit 4794bce41, then a merge of main).

  • Abandoned hinted lookups no longer park and then all fire. Each deep-link ID now belongs to its newest lookup. releaseDeepLinkEvents drops that ownership and wakes the waiters. A waiting lookup stops once it owns none of its IDs, and after the wait it keeps only the IDs it still owns. A released open therefore returns at once without a read, and only the newest open of an ID can send one.
  • No more empty publishes. loadEventsById returns early when the lookup found nothing.
  • I didn't add a shared in-flight read per ID. Once abandoned lookups retire, a parked lookup never has a duplicate to share with. Reads already in flight behave as on main.

Test: abandoned offline opens of a hit leave one read for the last opens and releases one out-of-window hit five times offline, then reconnects. It expects four lookups settled with no publish before the reconnect, then one ID read and two publishes (the reconnect's window, then the hit). Breaking any of the three parts fails it.

The full mobile suite passes (6,601 tests, 83 skipped). This has not been exercised on a device. Follow-ups still open: Retry doesn't re-read a target whose ID read also failed, the gesture-start check isn't limited to older-directed drags, checkOlderPages isn't cleared on cleanup, and there are still five off-target frames.

@brow brow 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.

🤖 Pre-review at ac26a875: the round-4 blocker is fixed (abandoned offline opens retire with no read, empty lookups no longer publish) and the merge of main is clean. Two related problems still block landing. Both are in the lookup ownership, and one small change covers them.

1. A stale release strips the new pane's target, and then every re-tap sends a read that places nothing. In the wide layout, re-tapping the open Search result now remounts the detail pane (reopen: messageId != null, mobile/lib/features/search/search_page.dart:819). The new page's effect runs loadEventsById before the old page's cleanup runs releaseDeepLinkEvents (mobile/lib/features/channels/channel_detail_page.dart:598-621). The release is not scoped to its caller (mobile/lib/features/channels/channel_messages_provider.dart:1163-1170), so it removes the new page's ID from the retained set and the lookup map. If the first read is still in flight (or the app is offline), the answer fails the retained check (:1145-1149), nothing is pinned, and :1153-1158 publishes an unchanged timeline. The hit never enters state, so each later re-tap sends another read (:1139-1142) and the previous pane's release strips it again, at any link speed.

Cost: one exact-ID read and one timeline publish per tap, with no jump, until another result is chosen. On main the same tap is a no-op (no reopen, and ConversationPaneController.open returns early), so it sends nothing.

Fix shape: return a lookup token from loadEventsById and have releaseDeepLinkEvents remove only IDs that _deepLinkLookups still maps to that token.

2. A second open duplicates a read that is already in flight. Online, Back and re-tap of the same hit within one round trip passes the ownership check and sends a second identical ID read (mobile/lib/features/channels/channel_messages_provider/pagination.dart:49-64). The first answer already places the target, so the second read and its publish are wasted on a slow link, where main's Search sends none.

Fix shape: share one in-flight read per ID (an ID to Future map, dropped when it settles), pinning for whichever lookup still owns the ID.

A test that taps one out-of-window hit four times in a wide pane with the first answer held should see one ID read and the target placed.

Follow-ups, not blocking: skip the publish when a read pinned nothing; Retry does not re-read a target whose ID read also failed; limit the gesture-start paging check to older-directed drags; null checkOlderPages on cleanup; a loading drag near a held target still shows 5 off-target frames.

Details in Buzz: buzz://message?channel=e71f9a2a-ac46-473d-a24e-5e16fd8cb7b1&id=7b044424237e19a0fbb4d15b3b06deb1698deab8a7c0e55ae7333fb3a3b5c197

@brow

brow commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

🤖 Bot review: reviewed, findings not addressed yet

Mobile review team: blocking findings not yet addressed. Details in Buzz: buzz://message?channel=e71f9a2a-ac46-473d-a24e-5e16fd8cb7b1&id=7b044424237e19a0fbb4d15b3b06deb1698deab8a7c0e55ae7333fb3a3b5c197

Kept by Team Queue. Change it from the sheet or with the review_queue tool.

wesbillman and others added 3 commits December 3, 2026 19:42
Each loadEventsById call now adds a hold for its targets before any
return, and each releaseDeepLinkEvents call removes one. A target unpins
only after its last hold is released, so a wide-pane remount's stale
release no longer strips the new pane's target, and a denied open's
release no longer takes another page's hold. An ID being read has one
shared read that pins still-held targets and publishes once. Its entry
is removed on failure too.

Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>
Signed-off-by: Wes <wesb@block.xyz>
…ch-review

Signed-off-by: Wes <wesb@block.xyz>
…fter merging main

Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>
Signed-off-by: Wes <wesb@block.xyz>
@wesbillman

Copy link
Copy Markdown
Collaborator Author

🤖 Addressed both blockers from this review in c542eeae2 (pushed with a main merge as 5dfba27b6).

1. A stale release stripped the new pane's target. Deep-link state was per ID, but its lifetime is per page, so either holder's release dropped the ID for both. Each loadEventsById call now adds a hold for its targets before it can return, including on the access-denied and already-in-state paths. Each releaseDeepLinkEvents call takes away one hold, and a target unpins only when its last hold is released. _denyAccess clears the pinned events but leaves the holds, because pages still release later. In the remount order (new load, then old release) the count goes 1 → 2 → 1 and the target stays pinned. reopen is kept, so a re-tap still jumps.

2. A second open duplicated an in-flight ID read. Reads are now keyed per ID. A call reads only IDs with no read in flight and awaits the rest. The shared read itself checks mounted / not denied / still held, writes the pinned events and publishes once, so joiners only await. Its entries are removed by identity in finally, so a failed read doesn't block Retry or a later open. An ID that loses its last hold while a hinted read is parked leaves that read, so a later open reads it afresh.

Tests, each confirmed to fail with its part of the fix broken:

  • a release ends only its own open's hold on a target: count vs. set, and the still-held fence.
  • a page opened while access was denied releases only its hold: count before the denial return, and holds kept through denial.
  • repeated opens of a hit share one read (remount: true/false): one ID read and one publish.
  • target reads are per ID and cleared on failure: per-ID join and cleanup on failure.
  • a target dropped from a running read is read afresh

Full mobile suite: 6,610 passed. Not yet exercised on a device. The non-blocking follow-ups are still open; skipping the publish when nothing was pinned is now done.

@brow brow 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.

🤖 Pre-review at 5dfba27b: both round-5 blockers are repaired (holds balance, repeated opens share one read, an empty read no longer publishes) and the merge and trim are clean. One new problem blocks landing. It comes from the shared read and reaches flows that work on main.

A reopen that joins a shared read loses the target when that read expires. fetchHistory starts its 8 s timer when it is called, even while the REQ is held unsent for a disconnected socket (mobile/lib/shared/relay/relay_session.dart:341-369). A second loadEventsById for the same ID now only awaits the first read (mobile/lib/features/channels/channel_messages_provider.dart:1142-1143, :1156). So during a reconnect backoff: open an ID-only target, close it, reopen it 7 s later, reconnect 2 s after that. Both calls fail on the first deadline, the route swallows the error (mobile/lib/features/channels/channel_detail_page.dart:170-179), and no ID read reaches the relay.

Cost: the open page shows the newest window with no jump or unread anchor until the user leaves and opens it a third time. On main each call issues its own read with its own deadline, so the second open sends one read on reconnect and places the target. No Search is involved: message links, Activity and the unread-anchor IDs all pass ID-only targets through this effect on main. From source, a reopen 7 s into a read on a stalled but connected socket also inherits the 1 s that is left. We did not probe that case.

Fix shape: when a read that a caller only joined fails, that caller re-enters the read-or-join step once, with its own hints, for IDs that are still held and not pinned. It takes no new hold, and it goes through _deepLinkReads so surviving joiners share one retry. The call that started the failed read does not retry, so exact reads never exceed main's one per open. Parking ID-only lookups started offline on the existing hold-aware wait (mobile/lib/features/channels/channel_messages_provider/pagination.dart:66-73) is a fine addition, but alone it leaves the connected case. The provider is at 1,196 of 1,200 lines, so this probably belongs in pagination.dart.

A test with the real session and a fake transport should cover it: disconnected, open an ID-only out-of-window target, close it, reopen at +7 s, reconnect at +9 s. Expect exactly one exact-ID read on the wire and the target placed, with the four-tap test still at one read.

Follow-ups, not blocking: _denyAccess clears pinned events but keeps holds, so a page open through denial and recovery loses its target; guard pagination.dart:77 by identity; Retry does not re-read a failed target; limit the gesture-start paging check to older-directed drags; null checkOlderPages on cleanup; a loading drag near a held target still shows 5 off-target frames.

Details in Buzz: buzz://message?channel=e71f9a2a-ac46-473d-a24e-5e16fd8cb7b1&id=7b044424237e19a0fbb4d15b3b06deb1698deab8a7c0e55ae7333fb3a3b5c197

Drop the search-hit hint, the window-refresh wait and the shared
per-ID read: each deep-link open sends its own ID read, as on main, so
no open can inherit another open's deadline. Drop held-target paging
(the Android dead edge only arises with it). Keep the exact-message
routing, target re-placement, the per-page hold count, the detached
target fill check, the reconnect catch-up check and the Retry guard.

Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>
Signed-off-by: Wes <wesb@block.xyz>
@wesbillman

Copy link
Copy Markdown
Collaborator Author

🤖 Rather than patch the shared read again, I cut the PR down in 758679cf2 (pushed).

Blocker (a reopen inherited the shared read's deadline): fixed at the root. The shared per-ID read is gone, so each loadEventsById sends its own ID read with its own deadline, as on main. No open can join or inherit another open's read.

Also removed: the search-hit hint (SearchHit.event, initialMessage, hints), the window-refresh wait (_initSettled, _windowRefreshDue, and the _liveDetached/onResume changes) and held-target paging (_heldTarget, _useHeldTarget, checkOlderPages). These existed to save one ID read per search tap, or to keep a held target in view while a page loads after a drag. Both are now a follow-up.

Kept:

  • Exact-message and thread routing, with reopen.
  • Target re-placement until a scroll, jump or send.
  • The per-page hold count, incremented before the denial return. _denyAccess leaves the holds alone.
  • The landed-read fence: mounted, not denied, still held.
  • The hasError Retry guard.
  • _historyFits with the detached-target clause and the isCatchingUp line.

Each kept guard has a test that fails with the guard broken.

The production diff against main is now 6 files, about +120/−30. Your other follow-ups (Retry not re-reading a failed target, the _denyAccess recovery gap) and the drag push-out limit will go in a follow-up issue. Not exercised on a device.

@brow brow 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.

🤖 Pre-review at 758679cf: the round-6 blocker is repaired (each open has its own read and deadline), holds balance, and the cut left nothing behind. Two problems block landing. The first is an earlier repair that the cut removed, and the second is the read that this cut moves to a follow-up.

1. Android: the top edge above an old target stalls again. Above a detached target _historyFits is false (mobile/lib/features/channels/channel_detail_page/hidden_history_paging.dart:92-104), so _viewportFill never offers "Load earlier messages" at the 5-page cap or after a failed fetch (:111-128). A drag at the clamped edge resets the cap and the pause (mobile/lib/features/channels/channel_detail_page/message_list.dart:935-942) but moves no item, so onPositionsChanged (:544) never runs again. This happens when the older pages hold only hidden rows (five pages of membership notices) or after one failed older fetch.

Cost: the list reads as the start of the channel, and only scrolling newer first recovers. On main the button appears, successive drags advance 5, 10, 15, 18 pages, and a failed fetch retries on the next drag. This reaches existing Activity and message-link opens.

Fix shape: restore the gesture-start check that this cut removed with held-target paging (checkOlderPages, called where the scroll gesture resets the cap), and restore the clamped-edge test with a hidden-only case and a failed-fetch case. message_list.dart is at 1198 of 1200 lines, so something has to move out.

2. Search still sends ID reads that main does not. With no hint and no wait, loadEventsById reads every target missing from state (mobile/lib/features/channels/channel_messages_provider.dart:1125-1147). Main's Search sends none in these cases:

  • A cold recent hit sends 1 read for an event the window then returns.
  • A hit newer than the cached rows after a detach sends 1.
  • An open abandoned while offline sends 1 on a reconnect inside 8 s and places nothing.
  • Four wide-pane re-taps while the first read is unanswered send 4 reads and 4 publishes.
  • Back plus re-tap while the read is in flight sends 2.

The single read for an out-of-window hit is the feature's own cost and is fine.

Fix shape, in two small parts:

  • For a Search open only, have the mounted page wait for a current window, including across an offline gap, then read only IDs that are still held and missing. Activity and link opens stay eager. Because the wait belongs to the page, a closed page sends nothing, and nothing is parked in the provider.
  • Keep one in-flight read per ID in pagination.dart. A second caller awaits it, then reads only IDs still held and missing, on its own deadline, so it cannot inherit the first read's timer.

A test with the real session and a fake transport should see 0 reads for a cold recent hit, 0 for an abandoned offline open, and 1 for four re-taps, with the target placed.

Follow-ups, not blocking:

  • After the first drag, the landed page pushes the target off screen.
  • With short history and hidden-only pages, the button shows above the target.
  • A read that pins nothing republishes an unchanged list.
  • _denyAccess clears pinned targets but keeps holds.
  • Retry does not re-read a failed target.

Details in Buzz: buzz://message?channel=e71f9a2a-ac46-473d-a24e-5e16fd8cb7b1&id=7b044424237e19a0fbb4d15b3b06deb1698deab8a7c0e55ae7333fb3a3b5c197

Above a detached deep-link target the rows never fit, so a drag at the
clamped top edge moved no positions and nothing re-ran the paging check:
hidden-only pages or a failed fetch stalled the list. Activity and link
opens reach this too. Restore the gesture-start check.

Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>
Signed-off-by: Wes <wesb@block.xyz>
@wesbillman

Copy link
Copy Markdown
Collaborator Author

🤖 Blocker 1 is fixed in 9532c6020. Dragging at the clamped top edge starts the older-page check again, so above an older deep-linked message the drag still pages through hidden-only history and retries after a failed fetch. This affects Activity and link opens too. The new test has a hidden-only row and a failed-fetch row, and both fail without the fix. Pre-push passed on this HEAD, including the full mobile suite.

Blocker 2 (the extra ID reads from Search) is on hold while Wes decides between accepting one read per Search tap, tracked in #10177, and adding the wait in this PR.

This branch was previously deployed

1 inactive (outdated) deployment
codex-review — 6b10970d Deployed Nov 24, 2026 by wesbillman via Run Codex Security Review #17796
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