The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
perf(desktop): Bot Mode wakes paint-first — transcript paint completes the wake instead of the full runtime boot (#89206 class)
Teknium5ce09b3c1e59
diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.tsindex 12d4ee5dd3a..7243a2973d2 100644--- a/apps/desktop/src/sdk/index.ts+++ b/apps/desktop/src/sdk/index.ts@@ -260,9 +260,23 @@ function waitForFocusedSessionHydration({const profileMatches = normalizeProfileKey($activeGatewayProfile.get()) === profileconst sessionMatches = $selectedStoredSessionId.get() === storedSessionIdconst runtimeReady = Boolean($activeSessionId.get())- const historyReady = !expectHistory || Boolean($messages.get().length)-- if (profileMatches && sessionMatches && runtimeReady && historyReady) {+ const historyPainted = Boolean($messages.get().length)++ // Paint-first hydration: for a history-bearing chat, the wake is DONE+ // the moment the persisted transcript is painted on the right session —+ // the REST prefetch delivers it seconds after the profile backend's+ // HTTP comes up, while the full runtime resume (agent build, MCP+ // discovery, skill load) keeps warming in the background and binds the+ // composer when it lands. Gating on runtimeReady serialized the wake+ // behind that whole boot: on a cold multi-profile start the 20s budget+ // regularly lost the race on slower machines and surfaced as "errors+ // waking up bots" even though the transcript had been available almost+ // immediately. Only an expected-EMPTY chat still waits for the runtime+ // — with no transcript to paint, a bound runtime is the only proof the+ // surface is real rather than a stuck loader.+ const hydrated = expectHistory ? historyPainted : runtimeReady++ if (profileMatches && sessionMatches && hydrated) {finish()}}@@ -464,9 +478,16 @@ export const host = {const profile = (options.profile ?? '').trim()const targetProfile = normalizeProfileKey(profile || $activeGatewayProfile.get())const expectHistory = options.expectHistory ?? false+ // Wake-path phase timings. Logged ONLY on a hydration timeout (bridged+ // into desktop.log via the renderer-console tap), so a support bundle+ // pinpoints WHERE the budget went — profile activation vs hydration —+ // instead of leaving us to infer it from process spawn timestamps.+ const wakeStartedAt = Date.now()+ let profileActiveAt = wakeStartedAtif (profile && profile !== $activeGatewayProfile.get()) {await ensureGatewayProfile(profile)+ profileActiveAt = Date.now()if (options.keepAllProfilesScope !== false) {setShowAllProfiles(true)@@ -533,6 +554,15 @@ export const host = {error instanceof Error &&error.message.startsWith('Timed out loading ')) {+ console.warn('[bot-wake] hydration timed out', {+ hydrationWaitMs: Date.now() - profileActiveAt,+ profile: targetProfile,+ profileActivationMs: profileActiveAt - wakeStartedAt,+ runtimeBound: Boolean($activeSessionId.get()),+ selectionSettled: $selectedStoredSessionId.get() === storedSessionId,+ storedSessionId,+ transcriptPainted: $messages.get().length > 0+ })// Reuse the core stranded-session surface: it renders the explicit// error and Retry button, and the normal resume path clears the latch.setResumeExhaustedSessionId(storedSessionId)diff --git a/apps/desktop/src/sdk/profile-routing.test.ts b/apps/desktop/src/sdk/profile-routing.test.tsindex 2b44afbd8fd..26ca655169b 100644--- a/apps/desktop/src/sdk/profile-routing.test.ts+++ b/apps/desktop/src/sdk/profile-routing.test.ts@@ -391,6 +391,45 @@ describe('profile-aware plugin session opens', () => {expect($gatewaySwapTarget.get()).toBeNull()})+ it('resolves a history-bearing wake on transcript paint without waiting for the runtime (paint-first)', async () => {+ vi.mocked(ensureGatewayProfile).mockImplementationOnce(async (target: null | string | undefined) => {+ $activeGatewayProfile.set(target || 'default')+ })++ setMockAtom($selectedStoredSessionId, null)+ setMockAtom($activeSessionId, null)+ setMockAtom($messages, [])++ let resolved = false++ const opening = host+ .openSession('slow-runtime-chat', {+ profile: 'hyoseob',+ awaitHydration: true,+ expectHistory: true,+ hydrationTimeoutMs: 1_000+ })+ .then(() => {+ resolved = true+ })++ await Promise.resolve()+ await Promise.resolve()+ expect(resolved).toBe(false)++ // The REST prefetch paints the persisted transcript while the runtime+ // resume (agent build, MCP discovery, skill load) is still warming — the+ // exact cold-boot shape where the runtime takes 30s+ on slow machines.+ // The wake must complete on the paint; the runtime binds in background.+ setMockAtom($selectedStoredSessionId, 'slow-runtime-chat')+ setMockAtom($messages, [{ id: 'painted-history', parts: [], role: 'assistant' }] as never)++ await opening+ expect(resolved).toBe(true)+ expect($activeSessionId.get()).toBeNull()+ expect($gatewaySwapTarget.get()).toBeNull()+ })+it('accepts an explicitly empty Bot Chat once its main runtime is bound', async () => {$activeGatewayProfile.set('hyoseob')diff --git a/hermes_cli/web_server.py b/hermes_cli/web_server.pyindex 1b72435eda3..85f6d61ee54 100644--- a/hermes_cli/web_server.py+++ b/hermes_cli/web_server.py@@ -18975,7 +18975,11 @@ def start_server(if headless:# No SPA, and the JSON-RPC/WS endpoints are auth-gated — don't# advertise a paste-and-connect URL, just announce the bind.- print(f" Hermes backend listening on {host}:{actual_port}")+ # flush: on a piped stdout (Desktop spawn) this line is+ # block-buffered and can surface MINUTES after the flushed+ # READY sentinel above, which reads as a slow boot in+ # support bundles when the backend was actually up.+ print(f" Hermes backend listening on {host}:{actual_port}", flush=True)else:print(f" Hermes Web UI → http://{host}:{actual_port}")_maybe_open_browser(host, actual_port, open_browser, initial_profile)