Skip to content

[CI] Reduce repeated UI imports in draft storage tests - #26145

Merged
nwparker merged 1 commit into
mainfrom
nwparker/draft-attachment-import-leaf
Oct 7, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/draft-attachment-import-leaf

Conversation

@nwparker

@nwparker nwparker commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​13 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​9
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​39 $\color{#cf222e}{\Huge{\mathbf{−}}}$​33 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​6

ELI5

Draft storage tests loaded the attachment UI each time they simulated restarting the app. Reading attachments through the existing draft cache makes the same 40 cases finish in 5.302 instead of 10.567 seconds, a 49.83% reduction in matched whole-command time. Product behavior stays the same.

What Changed

Move the three existing attachment-cache functions into native-chat-draft-cache.ts, preserving their declarations byte-for-byte. The attachment hook imports and reexports those same functions under their original public names. The storage test reloads the existing cache view instead of importing the React hook. A separate hook test now verifies that all three public exports are the exact cache functions.

Why

The cache already reads and writes through the same draft storage owner. Reusing it avoids loading unrelated UI and translation modules in a storage-only test. Every module reset, storage reload, crash recovery, concurrent-window check, assertion and cleanup remains in place. This preserves isolation and persistence coverage without adding another cache or runner.

Linked Issue

Maintainer-requested test performance work; no separate issue. Independent of the cache, automation-fixture and pane-cleanup measurements.

Visual Proof

N/A — function relocation and test imports only; no rendered UI, interaction or React effect changes.

Testing

Frozen source 6d90d51802ddacbbcddaf4af6eeee85972b23789. Both arms ran the same physical file and 40 original named cases, four workers, cache explicitly disabled, existing six setup files, runtime routing and file isolation. Timing covers the whole pnpm test process through output and normal exit.

Pair Before After Time reduction
1 10.925 s 5.210 s 52.31%
2 10.309 s 5.189 s 49.67%
3 10.466 s 5.506 s 47.39%
Mean 10.567 s 5.302 s 49.83%

All six qualified samples passed with exact case/status, configuration and runtime-route parity, unchanged source within each invocation, and no lifecycle or unhandled errors. One candidate invocation failed the preset external-coordinator guard; its raw results remain preserved and only that invalid invocation was repeated. Its original qualified control is retained. A later preflight rejected other coordinators before launching a timed child. The resulting order exceptions are recorded; no passing timing was excluded as an outlier.

The branch was then moved onto main 385fe8ab4eeed0ae819376bac59265f3945004fb. Its three measured files are byte-identical to the measured candidate. The separate public-export test was added after timing and is outside the 40-case cohort. The table remains the frozen-source measurement; final CI qualifies the integrated source separately.

  • Seven existing suites / 124 original cases passed under both Bun's coordinator and stock Node with exact case/status parity before adding the export regression.
  • Those suites plus the one real-export identity case / 125 cases passed under both coordinators on the measured base.
  • Independent source audits preserve all three moved declarations, production literals, call sites, React hooks and original test bodies; the store's 40-case describe block is byte-identical.
  • Local typecheck, changed-code quality and formatting passed on macOS with background launches.
  • All 125 cases also passed under both coordinators on final integrated head 1c9f858cf65341d324af77e1010c484ab0dd48ad.
  • All required PR CI gates pass on head 1c9f858cf65341d324af77e1010c484ab0dd48ad; current-head review has no actionable comments or unresolved threads.
  • Actual CI checkout 088936a1b39ae111b008fc439bf4cc920652b62c retains all 11,412 incoming-main files and reports them exactly once: 11,277 passed, 135 existing skips, zero failed files and zero unhandled errors. Logs report 110,692 passing cases, one expected failure and 1,035 skipped cases; every physical-file runtime route and shard matches the source. All four changed files are byte-identical to the PR head.

The measured speedup is 1.993× for this storage suite. It is not a full-suite or CI-wall-time result, and the requested whole-suite 2× goal remains unmet. Linux qualification depends on PR CI; Windows is not locally measured.

Review

The original hook API and the same draft owner remain in use. Direct hook imports may evaluate that owner earlier relative to React and translation initialization; its module graph depends on neither. Opening storage, hydration, unload listeners and broadcast setup remain lazy inside unchanged lifecycle functions. The existing journal token remains one per module/window, and the cache's existing empty listener map registers no listener at import time. No storage format, execution-host ownership, SSH attachment behavior or remote protocol changes.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer content copied or translated.

Notes

The binding regression uses the real hook exports and existing storage cleanup. It adds no mock or replacement storage owner. Existing rendering, IndexedDB, reload, crash, multi-window and withdrawn-message tests remain covered.

Checklist

  • Focused change; behavior, mechanism, alternatives and measurements explained.
  • N/A visual proof explained above.
  • Independently reviewed for behavior preservation and import-order effects.
  • Cross-platform, folder workspace and SSH behavior considered.
  • Required CI and current-head review pass.

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: c44bf57e-c509-4356-8d1b-ca28d24aad7c
📥 Commits

Reviewing files that changed from the base of the PR and between e6c298e and 1c9f858.

📒 Files selected for processing (4)
  • src/renderer/src/components/native-chat/native-chat-composer-draft-store.test.ts
  • src/renderer/src/components/native-chat/native-chat-draft-cache.ts
  • src/renderer/src/components/native-chat/use-native-chat-composer-attachments.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-composer-attachments.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

The draft-cache module now provides attachment-cache read, append, and test-clear functions. Reads return shallow copies. Appends store image IDs and paths, include present connection IDs, and set fromUser only when requested. The composer attachment hook re-exports these functions. Tests now load the draft-cache module and verify that the hook exports the same function references.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 1c9f8

No actionable merge-blocking issue is identified; the change is mergeable after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 4 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: reducing repeated UI imports in draft storage tests.
Description check ✅ Passed The description covers the required sections with clear scope, rationale, testing results, visual-proof rationale, review notes, and completed checklist items. It explains that no separate issue appli…
  • 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

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.

@nwparker
nwparker merged commit e6bcc5a into main Oct 7, 2026
30 checks passed
@nwparker nwparker changed the title Reduce repeated UI imports in draft storage tests [CI] Reduce repeated UI imports in draft storage tests Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant