Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
address comments
  • Loading branch information
icecrasher321 committed Apr 15, 2026
commit 7d4f7a097419d0b9340d3238d25003f203c1a346
2 changes: 1 addition & 1 deletion apps/sim/app/api/copilot/chat/stop/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ vi.mock('@/lib/copilot/tasks', () => ({
},
}))

import { POST } from './route'
import { POST } from '@/app/api/copilot/chat/stop/route'

function createRequest(body: Record<string, unknown>) {
return new NextRequest('http://localhost:3000/api/copilot/chat/stop', {
Expand Down
7 changes: 3 additions & 4 deletions apps/sim/app/api/copilot/chat/stop/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { z } from 'zod'
import { getSession } from '@/lib/auth'
import { normalizeMessage, type PersistedMessage } from '@/lib/copilot/chat/persisted-message'
import { taskPubSub } from '@/lib/copilot/tasks'
import { generateId } from '@/lib/core/utils/uuid'

const logger = createLogger('CopilotChatStopAPI')

Expand Down Expand Up @@ -110,11 +111,9 @@ export async function POST(req: NextRequest) {
: hasContent
? [{ type: 'text', channel: 'assistant', content }, { type: 'stopped' }]
: [{ type: 'stopped' }]
const shouldAppendAssistant = canAppendAssistant

if (shouldAppendAssistant) {
if (canAppendAssistant) {
const normalized = normalizeMessage({
id: crypto.randomUUID(),
id: generateId(),
role: 'assistant',
content,
timestamp: new Date().toISOString(),
Expand Down
7 changes: 5 additions & 2 deletions apps/sim/lib/copilot/chat/effective-transcript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
*/

import { describe, expect, it } from 'vitest'
import {
buildEffectiveChatTranscript,
getLiveAssistantMessageId,
} from '@/lib/copilot/chat/effective-transcript'
import { normalizeMessage } from '@/lib/copilot/chat/persisted-message'
import {
MothershipStreamV1CompletionStatus,
MothershipStreamV1EventType,
MothershipStreamV1SessionKind,
MothershipStreamV1TextChannel,
} from '@/lib/copilot/generated/mothership-stream-v1'
import type { StreamBatchEvent } from '@/lib/copilot/request/session/types'
import { buildEffectiveChatTranscript, getLiveAssistantMessageId } from './effective-transcript'
import { normalizeMessage } from './persisted-message'

function toBatchEvent(eventId: number, event: StreamBatchEvent['event']): StreamBatchEvent {
return {
Expand Down
4 changes: 2 additions & 2 deletions apps/sim/lib/copilot/chat/effective-transcript.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { normalizeMessage, type PersistedMessage } from '@/lib/copilot/chat/persisted-message'
import { resolveStreamToolOutcome } from '@/lib/copilot/chat/stream-tool-outcome'
import {
MothershipStreamV1CompletionStatus,
type MothershipStreamV1ErrorPayload,
Expand All @@ -11,8 +13,6 @@ import {
} from '@/lib/copilot/generated/mothership-stream-v1'
import type { FilePreviewSession } from '@/lib/copilot/request/session/file-preview-session-contract'
import type { StreamBatchEvent } from '@/lib/copilot/request/session/types'
import { normalizeMessage, type PersistedMessage } from './persisted-message'
import { resolveStreamToolOutcome } from './stream-tool-outcome'

interface StreamSnapshotLike {
events: StreamBatchEvent[]
Expand Down