Skip to content

perf(warmup): add conversation bootstrap preheating on input focus#1703

Merged
piorpua merged 5 commits intomainfrom
perf/warmup-preheating
Mar 25, 2026
Merged

perf(warmup): add conversation bootstrap preheating on input focus#1703
piorpua merged 5 commits intomainfrom
perf/warmup-preheating

Conversation

@kaizhou-lab
Copy link
Copy Markdown
Collaborator

Summary

  • Pre-warm conversation workers on SendBox input focus with 1s debounce, reducing ACP first-token latency by ~7s for existing conversations
  • Suppress ACP stream events during warmup to prevent sidebar loading spinner
  • Add warmup trigger after new conversation creation in GuidPage

Changes

IPC Layer

  • Add conversation.warmup IPC channel (ipcBridge.ts)
  • Add warmup provider: calls getOrBuildTask for all agents, plus initAgent() for ACP (conversationBridge.ts)

ACP Agent

  • Add bootstrapping flag to suppress onStreamEvent during warmup, preventing sidebar loading spinner
  • Clear bootstrapping on sendMessage() so progress events show during actual user waits
  • Remove temporary [Send-PERF] logging (AcpAgentManager.ts)

Renderer

  • Trigger warmup on SendBox focus with 1s debounce; cancel on blur to avoid rapid switching spawning multiple CLI processes (sendbox.tsx)
  • Trigger warmup after new conversation creation in all 4 agent paths: gemini, openclaw, nanobot, acp (useGuidSend.ts)

Tests

  • Add 4 warmup provider tests: getOrBuildTask call, ACP initAgent dispatch, non-ACP skip, error suppression (conversationBridge.test.ts)
  • Add 4 SendBox warmup debounce tests: 1s trigger, blur cancel, same-conversation dedup, different-conversation re-trigger (sendboxWarmup.dom.test.ts)

Related Issue

Closes #1701

Test Plan

  • Open an existing ACP conversation → verify no sidebar loading spinner on entry
  • Focus input, wait 1s, then send message → verify faster first response (~4s API only vs ~11s without warmup)
  • Rapidly switch between conversations → verify only the final conversation triggers warmup
  • Create a new conversation from GuidPage → verify warmup triggers before navigation
  • bun run test passes (13 tests in warmup-related files)

- Add warmup IPC channel to trigger getOrBuildTask + initAgent early
- For ACP agents, initAgent spawns CLI subprocess (~7s) during warmup
- Add bootstrapping flag to suppress stream events during warmup,
  preventing sidebar loading spinner; cleared on sendMessage
- Trigger warmup on SendBox focus with 1s debounce to avoid rapid
  conversation switching from spawning multiple processes
- Trigger warmup after new conversation creation in GuidPage
- Clean up temporary [Send-PERF] logging from conversationBridge
  and AcpAgentManager
- Add unit tests for warmup provider and SendBox debounce logic
* main:
  fix: ensure SQLite WAL is checkpointed on graceful shutdown
  test: mock UserRepository in webuiQR unit test
  chore: revert oss-pr command to simpler version and remove commit skill
  test: fix local env isolation and remove invalid BetterSqlite3Driver unit test
Add missing warmup channel to ipcBridge mock in
conversationBridge.tray.test.ts to fix test failure after
warmup provider was added.
- Use globalThis.localStorage?.clear?.() instead of localStorage.clear()
  in useConversationShortcuts and conversationHistoryContext dom tests
  to handle environments where localStorage.clear is not a function
- Skip i18n-packaged test when out/renderer directory does not exist,
  preventing false failure when build artifacts are partially cleaned
Add initStorage mock to tray.test.ts to break the import chain
tray → workerTaskManagerSingleton → GeminiAgentManager → initStorage
→ getPlatformServices() which throws in CI when modules are reset
between tests and re-resolved without platform registration.
@piorpua piorpua merged commit 35c5a5a into main Mar 25, 2026
17 checks passed
@piorpua piorpua deleted the perf/warmup-preheating branch March 25, 2026 08:29
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.

perf(warmup): add conversation bootstrap preheating on input focus

2 participants