Commit edb86b6
perf(llm): load the two stream-guard modules in parallel
Both output-cap sites awaited liveDeadlines and streamFaultInjection in
sequence. The two imports are independent, so that costs an extra microtask
hop on every streamed turn for nothing (react-doctor
server-sequential-independent-await). This is the hot path: every answer
passes through it.
Both pairs are now a single Promise.all. The lone streamFaultInjection import
in trackCommit has no partner and is left alone.
Ported from the unmerged fix/stream-fault-injection (PR #464, closed). Its
sibling commit — the fault-injection switches themselves — is already on main
by another route; only this follow-up was left behind. A straight cherry-pick
would have conflicted: the streamChat site now also destructures
MAX_SUMMARY_OUTPUT_CHARS, which was added after that branch was cut, so the
first hunk had to be re-derived rather than replayed.
Behaviour is unchanged — same modules, same bindings, same order of use.
Validation:
- Build validated on macOS: tsc -p electron/tsconfig.json --noEmit, 0 errors
- Covered by automated tests: StreamFaultInjection 8/8 (including "both
output-cap sites honour the test ceiling", which pins exactly these two
sites), RunawayStreamOutputCap 20/20, CodingRegenCeiling 3/3,
PostCommitNoProviderSwitch 10/10
- Caveat: RunawayStreamOutputCap imports the built bundle from
dist-electron, which predates this edit, so its runtime assertions
exercised the pre-change build. Its source-assertion half did read the
patched .ts. A rebuild would close that gap; the change is a semantically
identical refactor, so the residual risk is low.
- Platform-neutral: no platform-specific code path is touched.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JJS2xjF8uDPMa4EpXey5FL1 parent aa9748a commit edb86b6
1 file changed
Lines changed: 17 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5529 | 5529 | | |
5530 | 5530 | | |
5531 | 5531 | | |
5532 | | - | |
5533 | | - | |
| 5532 | + | |
| 5533 | + | |
| 5534 | + | |
| 5535 | + | |
| 5536 | + | |
| 5537 | + | |
| 5538 | + | |
| 5539 | + | |
| 5540 | + | |
| 5541 | + | |
| 5542 | + | |
5534 | 5543 | | |
5535 | 5544 | | |
5536 | 5545 | | |
| |||
5629 | 5638 | | |
5630 | 5639 | | |
5631 | 5640 | | |
5632 | | - | |
5633 | | - | |
| 5641 | + | |
| 5642 | + | |
| 5643 | + | |
| 5644 | + | |
| 5645 | + | |
| 5646 | + | |
5634 | 5647 | | |
5635 | 5648 | | |
5636 | 5649 | | |
| |||
0 commit comments