• 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

16.67
/main/src/chat/threads-storage.ts
1
import { Effect } from 'effect'
2
import type { LanguageModelUsage } from 'ai'
3
import type { UIMessage } from 'ai'
4
import { runChatSyncOr, runChatToResultSync } from './runtime'
5
import { ThreadsService } from './threads/threads-service'
6
import type { ChatSettingsThread, ThreadMessage } from './threads/types'
7

8
export type { ChatSettingsThread } from './threads/types'
9

10
export function createThread(
11
  title?: string,
12
  initialMessages: ThreadMessage[] = [],
3✔
13
  explicitId?: string
14
): { success: boolean; threadId?: string; error?: string } {
15
  return runChatToResultSync(
3✔
16
    ThreadsService.createThread(title, initialMessages, explicitId).pipe(
17
      Effect.map(({ threadId }) => ({ threadId }))
2✔
18
    )
19
  )
20
}
21

22
export function getThread(threadId: string): ChatSettingsThread | null {
NEW
23
  return runChatSyncOr(ThreadsService.getThread(threadId), null)
×
24
}
25

26
export function getAllThreads(): ChatSettingsThread[] {
NEW
27
  return runChatSyncOr(ThreadsService.getAllThreads(), [])
×
28
}
29

30
export function updateThread(
31
  threadId: string,
32
  updates: Partial<Omit<ChatSettingsThread, 'id' | 'createdAt'>>
33
): { success: boolean; error?: string } {
NEW
34
  return runChatToResultSync(
×
35
    ThreadsService.updateThread(threadId, updates).pipe(Effect.as({}))
36
  )
37
}
38

39
export function addMessageToThread(
40
  threadId: string,
41
  message: UIMessage<{
42
    createdAt?: number
43
    model?: string
44
    providerId?: string
45
    totalUsage?: LanguageModelUsage
46
    responseTime?: number
47
    finishReason?: string
48
  }>
49
): { success: boolean; error?: string } {
NEW
50
  return runChatToResultSync(
×
51
    ThreadsService.addMessageToThread(threadId, message).pipe(Effect.as({}))
52
  )
53
}
54

55
export function updateThreadMessages(
56
  threadId: string,
57
  messages: ChatSettingsThread['messages']
58
): { success: boolean; error?: string } {
NEW
59
  return runChatToResultSync(
×
60
    ThreadsService.updateThreadMessages(threadId, messages).pipe(Effect.as({}))
61
  )
62
}
63

64
export function deleteThread(threadId: string): {
65
  success: boolean
66
  error?: string
67
} {
NEW
68
  return runChatToResultSync(
×
69
    ThreadsService.deleteThread(threadId).pipe(Effect.as({}))
70
  )
71
}
72

73
export function getActiveThreadId(): string | undefined {
NEW
74
  return runChatSyncOr(ThreadsService.getActiveThreadId(), undefined)
×
75
}
76

77
export function setActiveThreadId(threadId: string | undefined): {
78
  success: boolean
79
  error?: string
80
} {
NEW
81
  return runChatToResultSync(
×
82
    ThreadsService.setActiveThreadId(threadId).pipe(Effect.as({}))
83
  )
84
}
85

86
export function clearAllThreads(): { success: boolean; error?: string } {
NEW
87
  return runChatToResultSync(
×
88
    ThreadsService.clearAllThreads().pipe(Effect.as({}))
89
  )
90
}
91

92
export function getThreadCount(): number {
NEW
93
  return runChatSyncOr(ThreadsService.getThreadCount(), 0)
×
94
}
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