Skip to content

Commit 7d4f7a0

Browse files
committed
address comments
1 parent 3417332 commit 7d4f7a0

4 files changed

Lines changed: 11 additions & 9 deletions

File tree

apps/sim/app/api/copilot/chat/stop/route.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ vi.mock('@/lib/copilot/tasks', () => ({
6363
},
6464
}))
6565

66-
import { POST } from './route'
66+
import { POST } from '@/app/api/copilot/chat/stop/route'
6767

6868
function createRequest(body: Record<string, unknown>) {
6969
return new NextRequest('http://localhost:3000/api/copilot/chat/stop', {

apps/sim/app/api/copilot/chat/stop/route.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { z } from 'zod'
77
import { getSession } from '@/lib/auth'
88
import { normalizeMessage, type PersistedMessage } from '@/lib/copilot/chat/persisted-message'
99
import { taskPubSub } from '@/lib/copilot/tasks'
10+
import { generateId } from '@/lib/core/utils/uuid'
1011

1112
const logger = createLogger('CopilotChatStopAPI')
1213

@@ -110,11 +111,9 @@ export async function POST(req: NextRequest) {
110111
: hasContent
111112
? [{ type: 'text', channel: 'assistant', content }, { type: 'stopped' }]
112113
: [{ type: 'stopped' }]
113-
const shouldAppendAssistant = canAppendAssistant
114-
115-
if (shouldAppendAssistant) {
114+
if (canAppendAssistant) {
116115
const normalized = normalizeMessage({
117-
id: crypto.randomUUID(),
116+
id: generateId(),
118117
role: 'assistant',
119118
content,
120119
timestamp: new Date().toISOString(),

apps/sim/lib/copilot/chat/effective-transcript.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
*/
44

55
import { describe, expect, it } from 'vitest'
6+
import {
7+
buildEffectiveChatTranscript,
8+
getLiveAssistantMessageId,
9+
} from '@/lib/copilot/chat/effective-transcript'
10+
import { normalizeMessage } from '@/lib/copilot/chat/persisted-message'
611
import {
712
MothershipStreamV1CompletionStatus,
813
MothershipStreamV1EventType,
914
MothershipStreamV1SessionKind,
1015
MothershipStreamV1TextChannel,
1116
} from '@/lib/copilot/generated/mothership-stream-v1'
1217
import type { StreamBatchEvent } from '@/lib/copilot/request/session/types'
13-
import { buildEffectiveChatTranscript, getLiveAssistantMessageId } from './effective-transcript'
14-
import { normalizeMessage } from './persisted-message'
1518

1619
function toBatchEvent(eventId: number, event: StreamBatchEvent['event']): StreamBatchEvent {
1720
return {

apps/sim/lib/copilot/chat/effective-transcript.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { normalizeMessage, type PersistedMessage } from '@/lib/copilot/chat/persisted-message'
2+
import { resolveStreamToolOutcome } from '@/lib/copilot/chat/stream-tool-outcome'
13
import {
24
MothershipStreamV1CompletionStatus,
35
type MothershipStreamV1ErrorPayload,
@@ -11,8 +13,6 @@ import {
1113
} from '@/lib/copilot/generated/mothership-stream-v1'
1214
import type { FilePreviewSession } from '@/lib/copilot/request/session/file-preview-session-contract'
1315
import type { StreamBatchEvent } from '@/lib/copilot/request/session/types'
14-
import { normalizeMessage, type PersistedMessage } from './persisted-message'
15-
import { resolveStreamToolOutcome } from './stream-tool-outcome'
1616

1717
interface StreamSnapshotLike {
1818
events: StreamBatchEvent[]

0 commit comments

Comments
 (0)