1- import { trace } from '@opentelemetry/api'
2- import {
3- BasicTracerProvider ,
4- InMemorySpanExporter ,
5- SimpleSpanProcessor ,
6- } from '@opentelemetry/sdk-trace-base'
71import { copilotHttpMock , copilotHttpMockFns } from '@sim/testing'
82import { encryptionMock , encryptionMockFns } from '@sim/testing/mocks/encryption.mock'
93import {
@@ -12,7 +6,7 @@ import {
126} from '@sim/testing/mocks/mothership-async-runs.mock'
137import { createMockRequest } from '@sim/testing/mocks/request.mock'
148import type { NextRequest } from 'next/server'
15- import { afterEach , beforeEach , describe , expect , it , vi } from 'vitest'
9+ import { beforeEach , describe , expect , it , vi } from 'vitest'
1610
1711const { publishToolConfirmation, getTrustedWorkflowToolExecution } = vi . hoisted ( ( ) => ( {
1812 publishToolConfirmation : vi . fn ( ) ,
@@ -33,9 +27,6 @@ vi.mock('@/lib/workflows/executor/execution-state', () => ({
3327 getTrustedWorkflowToolExecution,
3428} ) )
3529
36- import { CopilotConfirmOutcome } from '@/lib/mothership/generated/trace-attribute-values-v1'
37- import { TraceAttr } from '@/lib/mothership/generated/trace-attributes-v1'
38- import { TraceSpan } from '@/lib/mothership/generated/trace-spans-v1'
3930import { POST } from './route'
4031
4132const {
@@ -49,17 +40,6 @@ const {
4940
5041const encryptSecret = encryptionMockFns . mockEncryptSecret
5142
52- /** Records the confirm spans and returns a reader for the outcome the route recorded. */
53- function recordConfirmOutcome ( ) : ( ) => unknown {
54- const exporter = new InMemorySpanExporter ( )
55- trace . setGlobalTracerProvider (
56- new BasicTracerProvider ( { spanProcessors : [ new SimpleSpanProcessor ( exporter ) ] } )
57- )
58- return ( ) =>
59- exporter . getFinishedSpans ( ) . find ( ( span ) => span . name === TraceSpan . CopilotConfirmToolResult )
60- ?. attributes [ TraceAttr . CopilotConfirmOutcome ]
61- }
62-
6343describe ( 'Copilot Confirm API Route' , ( ) => {
6444 const existingRow = {
6545 toolCallId : 'tool-call-123' ,
@@ -71,10 +51,6 @@ describe('Copilot Confirm API Route', () => {
7151 claimedBy : 'workflow:execution-1' ,
7252 }
7353
74- afterEach ( ( ) => {
75- trace . disable ( )
76- } )
77-
7854 beforeEach ( ( ) => {
7955 copilotHttpMockFns . mockAuthenticateCopilotRequestSessionOnly . mockResolvedValue ( {
8056 userId : 'user-1' ,
@@ -175,7 +151,6 @@ describe('Copilot Confirm API Route', () => {
175151 } )
176152
177153 it ( 'rejects a native success before the desktop authorization claim' , async ( ) => {
178- const recordedOutcome = recordConfirmOutcome ( )
179154 getAsyncToolCall . mockResolvedValue ( {
180155 ...existingRow ,
181156 toolName : 'browser_snapshot' ,
@@ -191,7 +166,6 @@ describe('Copilot Confirm API Route', () => {
191166 )
192167
193168 expect ( response . status ) . toBe ( 409 )
194- expect ( recordedOutcome ( ) ) . toBe ( CopilotConfirmOutcome . HeldByDesktop )
195169 expect ( completeAsyncToolCall ) . not . toHaveBeenCalled ( )
196170 expect ( detachAsyncToolCall ) . not . toHaveBeenCalled ( )
197171 expect ( encryptSecret ) . not . toHaveBeenCalled ( )
@@ -244,7 +218,6 @@ describe('Copilot Confirm API Route', () => {
244218 ] as const ) (
245219 'rejects a pending %s %s when the native authorization claim wins the race' ,
246220 async ( toolName , status ) => {
247- const recordedOutcome = recordConfirmOutcome ( )
248221 getAsyncToolCall . mockResolvedValue ( {
249222 ...existingRow ,
250223 toolName,
@@ -264,7 +237,6 @@ describe('Copilot Confirm API Route', () => {
264237 expect ( await response . json ( ) ) . toEqual ( {
265238 error : 'The desktop app holds this tool call; only its own result settles it' ,
266239 } )
267- expect ( recordedOutcome ( ) ) . toBe ( CopilotConfirmOutcome . HeldByDesktop )
268240 expect ( completePendingAsyncToolCall ) . toHaveBeenCalledOnce ( )
269241 expect ( completeClaimedAsyncToolCall ) . not . toHaveBeenCalled ( )
270242 expect ( completeAsyncToolCall ) . not . toHaveBeenCalled ( )
@@ -314,7 +286,6 @@ describe('Copilot Confirm API Route', () => {
314286 )
315287
316288 it ( 'refuses a not-started report for a call the desktop already claimed' , async ( ) => {
317- const recordedOutcome = recordConfirmOutcome ( )
318289 getAsyncToolCall . mockResolvedValue ( {
319290 ...existingRow ,
320291 toolName : 'browser_snapshot' ,
@@ -335,7 +306,6 @@ describe('Copilot Confirm API Route', () => {
335306 expect ( await response . json ( ) ) . toEqual ( {
336307 error : 'The desktop app holds this tool call; only its own result settles it' ,
337308 } )
338- expect ( recordedOutcome ( ) ) . toBe ( CopilotConfirmOutcome . HeldByDesktop )
339309 } )
340310
341311 it ( 'does not publish when another terminal transition wins indeterminate claim reconciliation' , async ( ) => {
0 commit comments