Skip to content

perf(mobile): skip pending-request scans during unrelated updates - #25473

Open
saphid wants to merge 2 commits into
pingdotgg:mainfrom
saphid:perf/mobile-pending-requests-20261026
Open

saphid wants to merge 2 commits into
pingdotgg:mainfrom
saphid:perf/mobile-pending-requests-20261026

Conversation

@saphid

@saphid saphid commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Problem

A selected mobile thread rescans every turn item and pending request when an unrelated assistant item changes. With a pending approval and question, 100 replacements in a 1,000-row fixture perform 199,600 irrelevant item-type reads and 200 request-status reads, even though the selected requests stay unchanged.

Change

Reuse the selection when the raw request array is unchanged and the turn-item array is identical, or the existing exact-pair replacement hint proves that both replaced rows are unrelated to requests. Relevant request changes, snapshots, skipped updates, history changes and reorders keep the existing full-selection fallback. Null clears both caches.

Scope and approval

This is a focused optimization of redundant selector work, with no change to request behavior or product defaults. The direct consumer is mobile; the web request hook derives separately. Audit tracking: #189.

Separate work in #23855 changes settled-question and queue semantics. This PR preserves current main. If those changes land together, retain that PR's expanded question filter and queue regression tests.

Verification

  • Real AtomRegistry tests drive production projection replacements. The same final tests fail on the original selector: 4 failures, 28 passes; candidate: 32/32 pass across threadDetail.test.ts and threadRequests.test.ts.
  • In the fixture, irrelevant item-type reads fall 199,600 → 400 and request-status reads 200 → 0, preserving selected-result identity. Tests cover request payload/capability changes, resolution/reinsertion, request-type transitions, skipped updates, snapshots, history/reorder, null/reload and registry disposal.
  • Scoped formatting, lint and client-runtime typecheck pass. CI=true vp run check:changed 071239804e375078dd3fae3b14704b4def57e048: exit 0 (format, lint, knip, seven affected package typechecks and 22 adjacent tests pass).
  • Fresh independent GPT-6.1 Sol/high session review found no actionable findings in the complete two-file patch and independently passed all 32 tests. The patch and relevant source dependencies are unchanged after advancing to current main.

These are deterministic selector-operation counts. No device request-card/pre-send smoke, heap profiling, physical energy or battery-life measurement was run. No UI behavior changes are claimed.

Created with GPT-6.1 Sol/high in the Codex harness through T3 Code; reviewed in a separate GPT-6.1 Sol/high session.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Oct 26, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at e7c9ddf

Macroscope's review found this PR approvable — This is a narrowly scoped client-runtime optimization that reuses pending-request selector results only for provably unrelated updates, with fallback behavior preserved for request-relevant changes. The accompanying tests cover the selector’s update, reload, reorder, and lifecycle cases, and no product defaults or user-facing capabilities change.

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

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between e7c9ddf and 3310b65.

Files selected for processing: 2
  • packages/client-runtime/src/state/threadDetail.test.ts
  • packages/client-runtime/src/state/threadDetail.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Walkthrough

The pending-requests atom now tracks raw request and item references. It reuses the selected result when requests are unchanged and item changes meet specific conditions. Tests cover reuse, recomputation, and reset behavior.

Changes: Pending request selection cache

Layer / File(s) Summary
Cache behavior and validation
packages/client-runtime/src/state/threadDetail.ts, packages/client-runtime/src/state/threadDetail.test.ts
The atom reuses its selection when request references are unchanged and items are unchanged or have one replacement between non-request items. Tests cover request and item changes, skipped updates, projection resets, and reloads.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to 3310b

No issue requiring a change before merge is identified; complete normal checks before merging.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title is concise, conventional, and accurately identifies the main performance change: skipping pending-request scans during unrelated mobile updates.
Description check Passed The description follows the required Problem, Change, Scope and approval, and Verification sections. It explains the issue, implementation, scope, related work, test evidence, measured results, and ch…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description follows the required Problem, Change, Scope and approval, and Verification sections. It explains the issue, implementation, scope, related work, test evidence, measured results, and checks not performed.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

GigaZoro pushed a commit to GigaZoro/CodeShip that referenced this pull request Oct 30, 2026
…stream pingdotgg#25473)

Cherry-picked from pingdotgg#25473 (test imports merged by hand)

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

This branch has not been deployed

No deployments
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