Skip to content

fix(mobile): throttle streaming thread visit updates - #9931

Open
saphid wants to merge 3 commits into
pingdotgg:t3code/codex-turn-mappingfrom
saphid:fix/v2-mobile-visit-throttle-20260905
Open

fix(mobile): throttle streaming thread visit updates#9931
saphid wants to merge 3 commits into
pingdotgg:t3code/codex-turn-mappingfrom
saphid:fix/v2-mobile-visit-throttle-20260905

Conversation

@saphid

@saphid saphid commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Every thread updatedAt change previously sent a visit command from React Native. Apply the web client’s ten-second trailing throttle, retaining the latest watermark. Navigation to another thread and an unseen completion still dispatch immediately; cleanup cancels a pending timer when selection changes or content hides.

Measured at persisted thread.visited events on one isolated iPhone 16 Pro simulator (iOS 26.5), with one burst per revision: 20 real thread.metadata.update commands at approximately 250 ms intervals over five seconds. Both runs used the same visible thread and disposable V2 server.

Revision Updates Persisted visit writes Result
Before (ThreadDetailScreen.tsx from b9fa1399c) 20 20 One visit for each update
After (#9931 9d459a6bb, integrated at fa6a1ab04) 20 2 Visits 10.010 seconds apart; final watermark equals the newest update

This measures write volume and dispatch spacing, not rendering speed. Title updates provide a controlled source of updatedAt changes; this was not a timed provider-token stream. The shared native Debug build exited 0; only the JavaScript bundle changed. The integrated candidate also includes #9929, explaining the visible file chip in the after recording.

Before: clean recording · Before: annotated recording

After: clean recording · After: annotated recording

Recordings preserve original timing (before 29.53 s; after 53.63 s), with no idle trimming or speed changes. Captions report the stored-event measurements; the videos do not display a request counter. These caption-only recordings were visually inspected; the interaction-packet validator requires tap/swipe events and was not applicable.

Before/after stills

Before: 20 visit writes

After: two visits and newest watermark retained

React Native typecheck and targeted lint passed in frozen integration verification. Android was not separately exercised. Targets Julius’s Orchestrator V2 branch in #2829; this changes only React Native.

A direct Claude Opus 5 high review attempt exited 1 because OAuth expired before model execution; no Claude review occurred. Implemented and verified with GPT-6 in Codex/T3.


Note

Low Risk
Scoped to mobile visit-dispatch timing and unread-marker behavior; reduces server write volume without changing auth or data models.

Overview
Mobile thread “visited” writes no longer fire on every updatedAt tick during streaming. ThreadDetailScreen now matches the web client’s 10-second trailing throttle, so rapid metadata updates coalesce into spaced visit commands while still persisting the latest watermark.

Visit recording is skipped when thread content is hidden (showContent). Immediate dispatch still happens when switching threads, when there is an unseen run completion (latestRun.completedAt after lastVisitedAt), or when the throttle window has elapsed; otherwise a timer defers the write and clears on unmount or dependency changes (e.g. thread switch).

Reviewed by Cursor Bugbot for commit 9d459a6. Bugbot is set up for automated code reviews on this repo. Configure here.

Current-base verification

Updated to exact V2 base 415ed0f73b97f1655b6282492f81d0b2bba3a9cc at head fd24ed3442c2d65721d08725b4da16201c31f58c. The original leaf plus this base synthesizes cleanly as tree 707816c8e075d4d622f78e2163eba31ce2ef45f8; current V2 base still dispatches a visit for every eligible updatedAt change, so the throttle is not superseded.

  • React Native typecheck passes.
  • Targeted lint and diff checks pass. Reported warnings in ThreadDetailScreen.tsx predate the visit-throttle hunk.
  • The one-file contribution is patch-identical to the prior reviewed head. There is no focused unit test for this component effect on the branch.

The existing iPhone simulator write-volume evidence remains bound to the stated patch-identical revision. No fresh native run or Android measurement was performed; parent integration owns current-client proof. Fresh independent Claude review remains unavailable because OAuth is signed out; no Claude review is claimed. Refreshed by GPT-6 in the Codex harness.

Note

Throttle streaming thread visit updates in ThreadDetailScreen

  • ThreadDetailScreen now only sends visit-watermark updates while screen content is shown.
  • Dispatches immediately on thread switch or an unseen latest-run completion; other updates use a trailing ten-second delay.
  • Records the last dispatch thread key and timestamp in a ref, and clears pending timers on effect cleanup.
  • Risk: the ten-second throttle in the visited-watermark effect may delay watermark updates for in-progress threads; check the effect deps on latestRunCompletionTimestamp in ThreadDetailScreen.tsx.

Macroscope summarized fd24ed3.

@github-actions github-actions Bot added the vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. label Sep 5, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Macroscope has since reviewed this pull request. An earlier review was skipped by a cost limit; a review has now completed, so that notice no longer applies.

@github-actions github-actions Bot added the size:XXL 1,000+ changed lines (additions + deletions). label Sep 5, 2026
@saphid
saphid force-pushed the fix/v2-mobile-visit-throttle-20260905 branch from 3ffe845 to 9d459a6 Compare September 5, 2026 05:07
@github-actions github-actions Bot added size:S 10-29 changed lines (additions + deletions). and removed size:XXL 1,000+ changed lines (additions + deletions). labels Sep 5, 2026
@saphid
saphid marked this pull request as ready for review September 5, 2026 07:15
@macroscopeapp

macroscopeapp Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 9d459a6

Macroscope's review found this PR approvable — This is a small, isolated mobile fix that throttles redundant thread-visit writes while preserving immediate updates for navigation and completed runs. Its behavior matches the established web implementation and has no schema, infrastructure, security, billing, or default-setting impact.

You can add or adjust custom eligibility rules. Learn more.

@t3-code t3-code 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.

reviewed diff and relevant surrounding code at 5c4609f5eb0948f5c5e6c1d61834e240b958eee3. no blocking findings.

the effect keeps a trailing newest watermark, bypasses the throttle for unseen completion/thread changes, and cancels pending work when content hides. isolated execution of the actual effect callback passed initial dispatch, trailing update, completion, thread switch, hidden cleanup and dedupe checks with mocked clock/command. no code changes needed. this was not a mounted react or native-device test.

ci snapshot: no failing or pending checks; some checks are skipped. this is a comment review, not an approval or merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). 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.

1 participant