Skip to content

Classify native chat waiting messages once - #24771

Merged
nwparker merged 1 commit into
mainfrom
nwparker/perf-native-chat-waiting-partition-20261002
Oct 3, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/perf-native-chat-waiting-partition-20261002

Conversation

@nwparker

@nwparker nwparker commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​296 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​296
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​9 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5

ELI5

Check each chat message once to decide whether it belongs in the transcript or behind the running turn.

What Changed

Chat previously checked every message twice while splitting the transcript from messages waiting behind a running turn. Fill a fresh waiting array during the existing transcript filter so each slot is classified once. Message placement, row order, references and both fresh output arrays remain the same. The initial projection and shared waiting-message rules are unchanged.

Why

The actual caller builds a private plain array from ordinary IPC, JSON and literal message records. One traversal removes duplicate work without caching a journal decision or changing how later turns are interpreted. Keeping native filtering preserves sparse-hole handling and avoids a second implementation of the waiting policy.

Linked Issue

Internal performance audit; no pre-existing issue.

Visual Proof

N/A — transcript rows, waiting messages and interactions remain unchanged.

Testing

The original reviewed change is now preserved byte for byte on named main 1fc24d311481a85d5b4ae596898ee072389f040c. Integration checks: 111 tests in seven suites, including the inherited 42 workflow contracts; root separately passes all seven budget cases; full renderer compiler passes. All seven scoped quality scans per PR, format and whitespace pass. Main itself repairs the two earlier workflow-contract CI failures. Existing installed dependencies were used; fresh resolved-dependency CI and a full newer-baseline build remain pending.

Original reviewed-base checks (historical full build/type results below apply to that earlier base):

Actual transcript projection, turn order, subagent sections and slot builders produce all three slot kinds. At 1/12/128/1000 ordinary rows, message classification reads fall from 8/30/262/2006 to 4/15/131/1003. Seven current and legacy journal phases check complete output, original references, fresh arrays and unchanged inputs before operation budgets. Another 896 generated later-journal states cover duplicates, holes, empty and unusual IDs.

Author and independent reviewer each pass 69 tests in six suites. The exact original source fails four count assertions and passes three compatibility controls. Supported web typecheck, scoped lint and format, aggregate Electron build, changed-code quality and max-lines pass on macOS. All invocations use ORCA_BACKGROUND_LAUNCH=1; no app or native device is launched.

  • Actual builder and journal compatibility controls added
  • Physical renderer frames and platform/remote journeys

Review

Root independently approved the exact named-main integration after verifying all original source hashes, every inherited main blob, own budget controls and the author’s full controls and gates. New-head CI must pass before merging.

Independent audit_mobile_cloud approved the exact two frozen hashes, reconstructed the original source, reproduced final and original-source controls and traced the sole production caller and its message ownership. It also reproduced the explicit exotic-input counterexamples and ran two fresh timing processes.

Agent skill upstream boundary

  • Not applicable; no upstream skill material changed.

Notes

Invariant native-chat.waiting-partition: ordinary private builder output and waiting policy remain identical while each message is classified once. Dedicated manifest registration remains an explicit accepted gap; no unrelated terminal lifecycle clearance is claimed.

Changing accessors, proxies, custom Array species and monkeypatched builtins are not equivalent; negative controls demonstrate this. They are absent from the traced private builder and IPC/JSON/literal data path. A new caller admitting them needs a new review.

Local author timing medians improve in all 32 measured shapes. Independent timing improves in 31 of 32, with one tiny shape about 5.24 ns/call higher amid broad outliers; all raw samples are retained. This is a deterministic reduction in classification work, not a guarantee that every timing improves. Physical frames, heap/GC, fleet CPU and native/Windows/Linux/SSH transport performance remain unmeasured. No selection, focus, turn policy, virtual window, host authority, wire or workspace behavior changes. CI must pass before merging.

Checklist

  • Small focused change with ELI5 and measured before/after
  • Visual proof N/A explained
  • Independently reviewed for correctness and performance
  • Platform/remote/workspace and actual ownership boundary considered
  • Full platform CI

Review-bot follow-up

The automatic docstring-coverage suggestion is declined under AGENTS.md: comments explain only non-obvious reasons concisely. This change needs no extra explanatory docstrings or test narration.

Fresh exact-head CI is green. Independent review checked current callers and failure/cleanup paths and found no regression or negative user-facing trade-off. Platform limits remain stated above.

@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d714c847-1c8b-41f2-81b9-8705cab4b6c5
📥 Commits

Reviewing files that changed from the base of the PR and between b5869ee and c460415.

📒 Files selected for processing (2)
  • src/renderer/src/components/native-chat/native-chat-transcript-slots.ts
  • src/renderer/src/components/native-chat/native-chat-waiting-partition-budget.test.ts

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


📝 Walkthrough

Walkthrough

splitNativeChatSlotsWaitingBehindLiveTurn now builds the waiting and transcript arrays in one pass while retaining the existing predicate and slot order. Tests cover partition results, slot references, input immutability, and message-ID lookup counts across transcript sizes and journal states.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to c4604

The waiting-slot partition appears to preserve existing behavior while reducing repeated lookups. No actionable issue remains before normal merge checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly summarizes the main change: classifying native chat waiting messages once.
Description check ✅ Passed The description covers the required sections, explains the change and rationale, describes testing, and clearly identifies remaining validation gaps. It states that no pre-existing issue exists and ex…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

✅ No new issues found.

Reviewed changes — the full single-commit diff of #24771 against main (b6330429f6), with the new budget test re-run against both the PR head and a locally reverted original to confirm it pins the change.

  • Single-pass waiting partition (native-chat-transcript-slots.ts:259) — splitNativeChatSlotsWaitingBehindLiveTurn now fills waitingSlots during its one filter pass instead of running isWaiting across the array twice. Output arrays, draw order, fresh-array identity and slot references are unchanged, and isWaiting is a pure read of a fixed Set plus two message fields, so the single-pass result is provably identical.
  • Classification budget test (native-chat-waiting-partition-budget.test.ts) — 7 tests over real projected slots assert each message id is looked up exactly once per journal phase (1/12/128/1000 rows), plus duplicate references, sparse holes, exotic ids, unchanged inputs and fresh output arrays.

Verification: with the production hunk reverted to the original two-filter form, the test fails 4 count assertions (8 vs 4, 2006 vs 1003, …) while the 3 compatibility controls still pass — the budget assertion is real, not a tautology. Exotic inputs the PR scopes out (getters, custom Array species, monkeypatched builtins) are genuinely absent from the private builder/IPC/JSON path.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Use the existing native filter traversal to populate a fresh waiting array, keeping the original predicate, policy, projection and output ordering while classifying each actual private slot once.
@nwparker
nwparker force-pushed the nwparker/perf-native-chat-waiting-partition-20261002 branch from b633042 to c460415 Compare October 3, 2026 00:54
@nwparker
nwparker merged commit 9142169 into main Oct 3, 2026
32 checks passed
nwparker added a commit that referenced this pull request Oct 3, 2026
…24962)

* fix(opencode): bind legacy attach status to its TUI pane

Adapt the official v1 TUI API to the existing pane reporter and learn structural session identity only after execution-host admission. Preserve known creators, gate new reports to capable hosts, and register the legacy TUI entry without changing user settings or overlay targets.

Credit werlang for the same-directory investigation in #22838 and #22847; no source from that PR is copied.

(cherry picked from commit d9eeb028a23a66b78b08538a5ebf6052499ec24f)

* fix(opencode): fence legacy TUI viewers before creator attribution

Use the execution host's existing admission policy on the physical TUI
pane and launch token before rewriting to a session creator or mutating
the launch-token cache. Preserve live viewers, frozen server stamps and
OpenCode 2 behavior.

Add HTTP regressions for retired panes, closed tabs, replaced tokens and
relay retirement, plus current-launch, alias and compatibility controls.

Follow-up to #22838 and @werlang's original #22847; preserves the original
intentional creator attribution without copying that PR's source.

* fix(opencode): preserve current plugin exports in legacy TUI wrapper

Keep the current server, setup, id and other default export entries when
adding the legacy TUI entry. Cover their preservation and seed the ACL
fixtures with the separate installed TUI/config bytes.

This completes the current-main port of the legacy identity replacement
for issue #22838, carrying @werlang's original PR #22847 contribution.

* fix(opencode): retry timed-out SSH plugin updates (#24666)

Preserve bounded retry behavior and the current-main status-envelope fields.

Original-PR: #24124
Reviewed-source: 103144f9c5029f9217f64970271a5b7f69d3f823

Co-authored-by: Justas Brazauskas <[email protected]>

* fix(opencode): keep Go credentials private and resolve backend keys (#24615)

Preserve the complete credential storage, migration, IPC, Settings and rate-limit refresh change alongside standalone GLM plans, current-main database diagnostics and the reviewed unknown-backend environment correction. Keep native discovery cancellation third and selected environment fourth.

Original-topic-commit: 7903f1cddbc08fe1179f8bd964fff3dcb0e5d020
Original-topic-commit: 588117b5cf1dd57e2310c80068e3ddcc9f9044ec
Original-topic-commit: dedd4f8c862a961393977dc3c2547f049391b509
Original-topic-commit: 6645dae104ee5271139fcc0e9564d9223b74835d
Original-topic-commit: a25b80c02c1af7830b0e6a65e72d965b3ad98276
Restacked-from: a25b80c02c1af7830b0e6a65e72d965b3ad98276
Restacked-onto: b032867021c7ef1436ca606559e9d786580a84dc

Co-authored-by: kespineira <[email protected]>
Co-authored-by: kevimux <[email protected]>
Reported-by: pullfrog
Reviewed-full-source: 849fe093073f4c1606bd65d79a0c725d955d0d1f
Native-helper-source: 80dbe23237db191c1e6280001c7e0563f3ca8846


Reviewed-full-current-source: 36acb57d44adb3d378c0289c8c15f7da0fda214c

* Skip store notifications when refreshed work items are unchanged (#24530)

An identical forced refresh previously returned an empty Zustand patch, creating a new root state and notifying every subscriber. It now returns the current state after renewing the existing freshness timestamp. Real row or metadata changes still publish once.

* Read project activity once while sorting the sidebar (#24549)

Reuse the existing pure recent rank once per actual entry tuple within each synchronous sort; discard the lookup after sorting.

* Skip impossible link and tag matches in docs search results (#24646)

* Skip impossible HTML matches when formatting docs search results

After the existing link-removal phase, skip the unchanged HTML regex only when the current string has no closing delimiter.

* Skip impossible link and tag matches in docs search results

Skip the five unchanged link regexes when their protected-code input lacks ]; skip the unchanged HTML regex when its post-link input lacks >.

* Decode complete transcript lines without copying their bytes (#24546)

Decode each single owned Buffer synchronously; preserve concatenation for multipart records and remove a redundant tail array copy.

* Clear unused speech worker timers after errors and exit (#24924)

Call the existing idle timer cleanup when private current-worker state is cleared; keep current-worker guards, transcript/error order, deliberate warmth and stop deadline unchanged.

* Reuse documentation search excerpts during result navigation (#24574)

Memoize the existing pure excerpt renderer by complete raw text for the current result array, retaining original rendering as a miss fallback.

* Append subagent handoffs without recopying their message list (#24672)

Append each message reference to its private call-local scope list; retain the final merge and existing ordering.

* Cancel plugin retry timers when their fetch is replaced (#24700)

Reuse the existing timer clear block immediately after the fetch generation advances; preserve live retries and all state publications.

* Avoid rebuilding visible file paths for single-row selection (