• 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

78.57
/main/src/chat/active-streams.ts
1
import type { WebContents } from 'electron'
2
import { isChatRuntimeReady, runChatPromise, runChatSync } from './runtime'
3
import {
4
  StreamRegistryService,
5
  purgeSender as purgeSenderImpl,
6
  _resetActiveStreamsForTests as resetActiveStreamsImpl,
7
} from './streaming/stream-registry-service'
8
import type { RunStreamOptions } from './streaming/stream-registry-service'
9

10
export type { RunStreamOptions }
11

12
export async function runManagedStream(
13
  options: RunStreamOptions
14
): Promise<void> {
15
  return runChatPromise(StreamRegistryService.runManagedStream(options))
16✔
16
}
17

18
export function subscribeToStream(chatId: string, sender: WebContents) {
19
  return runChatSync(StreamRegistryService.subscribeToStream(chatId, sender))
7✔
20
}
21

22
export function unsubscribeFromStream(
23
  chatId: string,
24
  sender: WebContents
25
): void {
26
  if (!isChatRuntimeReady()) return
1!
27
  runChatSync(StreamRegistryService.unsubscribeFromStream(chatId, sender))
1✔
28
}
29

30
export function cancelStream(chatId: string): boolean {
31
  if (!isChatRuntimeReady()) return false
2!
32
  return runChatSync(StreamRegistryService.cancelStream(chatId))
2✔
33
}
34

35
export function getActiveStreamId(chatId: string): string | null {
36
  if (!isChatRuntimeReady()) return null
4!
37
  return runChatSync(StreamRegistryService.getActiveStreamId(chatId))
4✔
38
}
39

40
export function getStreamingChatIds(): string[] {
NEW
41
  if (!isChatRuntimeReady()) return []
×
NEW
42
  return runChatSync(StreamRegistryService.getStreamingChatIds())
×
43
}
44

45
export function setToolUiMetadata(
46
  chatId: string,
47
  metadata: Record<string, unknown>
48
): void {
49
  if (!isChatRuntimeReady()) return
1!
50
  runChatSync(StreamRegistryService.setToolUiMetadata(chatId, metadata))
1✔
51
}
52

53
/**
54
 * Best-effort subscriber cleanup on WebContents destroy.
55
 * Must not go through the managed runtime — quit disposes the runtime
56
 * before windows are destroyed, and this listener still fires.
57
 */
58
export function purgeSender(sender: WebContents): void {
NEW
59
  purgeSenderImpl(sender)
×
60
}
61

62
/** Test-only helper. */
63
export function _resetActiveStreamsForTests(): void {
64
  resetActiveStreamsImpl()
15✔
65
}
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