• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stacklok / toolhive-studio / 29571051485

17 Jul 2026 09:44AM UTC coverage: 71.713% (+0.5%) from 71.204%
29571051485

Pull #2475

github

samuv
fix(chat): harden Effect runtime adapters after external review

Make readiness and runtime retrieval atomic, type adapter programs against
ChatServices, and tighten domain-error narrowing plus agent/settings edge cases.

Co-authored-by: Cursor <cursoragent@cursor.com>
Pull Request #2475: refactor(chat): migrate main-process chat to Effect domain services

5476 of 8187 branches covered (66.89%)

871 of 1363 new or added lines in 42 files covered. (63.9%)

1 existing line in 1 file now uncovered.

8153 of 11369 relevant lines covered (71.71%)

137.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

31.58
/main/src/chat/runtime/lifecycle.ts
1
import log from '../../logger'
2
import {
3
  disposeChatRuntime,
4
  getManagedRuntimeOrThrow,
5
  initializeChatRuntime,
6
} from './managed-runtime'
7
import {
8
  getChatRuntimeHealth,
9
  getChatUnavailableReason,
10
  markChatRuntimeInitializing,
11
  markChatRuntimeReady,
12
  markChatRuntimeUnavailable,
13
} from './health'
14
import { AgentsService } from '../agents/agents-service'
15
import { SettingsService } from '../settings/settings-service'
16
import { shutdownAllActiveStreams } from '../streaming/stream-registry-service'
17

18
export async function bootstrapChatRuntime(): Promise<void> {
NEW
19
  markChatRuntimeInitializing()
×
NEW
20
  try {
×
NEW
21
    await initializeChatRuntime()
×
NEW
22
    const runtime = getManagedRuntimeOrThrow()
×
NEW
23
    await runtime.runPromise(AgentsService.seedBuiltinAgents())
×
NEW
24
    await runtime.runPromise(SettingsService.reconcileEnabledMcpTools())
×
NEW
25
    markChatRuntimeReady()
×
NEW
26
    log.info('[CHAT] Effect runtime initialized')
×
27
  } catch (error) {
NEW
28
    markChatRuntimeUnavailable(
×
29
      error instanceof Error ? error.message : 'unknown initialization error'
×
30
    )
NEW
31
    log.error('[CHAT] Effect runtime initialization failed:', error)
×
32
  }
33
}
34

35
export async function shutdownChatRuntime(): Promise<void> {
36
  // Mark unavailable before dispose so IPC adapters never observe ready=true
37
  // with a null ManagedRuntime mid-teardown.
38
  markChatRuntimeUnavailable('runtime_disposing')
1✔
39
  try {
1✔
40
    shutdownAllActiveStreams()
1✔
41
    await disposeChatRuntime()
1✔
42
    markChatRuntimeUnavailable('runtime_disposed')
1✔
43
    log.info('[CHAT] Effect runtime disposed')
1✔
44
  } catch (error) {
NEW
45
    markChatRuntimeUnavailable('runtime_dispose_failed')
×
NEW
46
    log.error('[CHAT] Effect runtime disposal failed:', error)
×
47
  }
48
}
49

50
export function getChatRuntimeStatus() {
NEW
51
  return {
×
52
    health: getChatRuntimeHealth(),
53
    reason: getChatUnavailableReason(),
54
  }
55
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc