1+ import { derivePendingRequests } from "@t3tools/client-runtime/pending-requests" ;
12import { describe , expect , it } from "vite-plus/test" ;
23import { codexFeedbackMessage } from "@t3tools/client-runtime/state/threads" ;
34
@@ -16,8 +17,6 @@ import {
1617 agentSpawnSummary ,
1718 buildPendingUserInputAnswers ,
1819 buildThreadFeed ,
19- derivePendingApprovals ,
20- derivePendingUserInputs ,
2120 deriveThreadFeedPresentation ,
2221 isPendingUserInputOptionSelected ,
2322 setPendingUserInputCustomAnswer ,
@@ -107,7 +106,7 @@ describe("pending user input answers", () => {
107106 createdAt : "2026-09-03T00:00:00.000Z" ,
108107 payload : { requestId : "async-1" , responseMode : "message" , questions : [ question ] } ,
109108 } ) ;
110- const questions = derivePendingUserInputs ( [ requested ] ) [ 0 ] ?. questions ;
109+ const questions = derivePendingRequests ( [ requested ] ) . userInputs [ 0 ] ?. questions ;
111110 expect ( questions ) . toEqual ( [ question ] ) ;
112111 expect ( buildPendingUserInputAnswers ( questions ! , { "0" : { customAnswer : "Example" } } ) ) . toEqual ( {
113112 "0" : "Example" ,
@@ -126,7 +125,7 @@ describe("pending user input answers", () => {
126125 } ,
127126 } ) ;
128127
129- expect ( derivePendingUserInputs ( [ requested ] ) ) . toEqual ( [
128+ expect ( derivePendingRequests ( [ requested ] ) . userInputs ) . toEqual ( [
130129 {
131130 requestId : "interaction_1" ,
132131 createdAt : requested . createdAt ,
@@ -265,121 +264,6 @@ describe("pending user input answers", () => {
265264 } ) ;
266265} ) ;
267266
268- describe ( "pending approvals" , ( ) => {
269- it . each ( [ { } , { requestType : "unknown" } ] ) (
270- "exposes legacy OpenCode approvals without a known request kind: %j" ,
271- ( legacyPayload ) => {
272- const requested = makeActivity ( {
273- id : EventId . make ( "approval-legacy" ) ,
274- kind : "approval.requested" ,
275- summary : "Approval requested" ,
276- createdAt : "2026-08-24T00:00:00.000Z" ,
277- payload : { requestId : "per-legacy" , detail : "*" , ...legacyPayload } ,
278- } ) ;
279-
280- expect ( derivePendingApprovals ( [ requested ] ) ) . toEqual ( [
281- {
282- requestId : "per-legacy" ,
283- requestKind : "command" ,
284- createdAt : requested . createdAt ,
285- detail : "*" ,
286- } ,
287- ] ) ;
288- } ,
289- ) ;
290-
291- it . each ( [ "tool_user_input" , "auth_tokens_refresh" ] ) (
292- "does not turn %s into an approval" ,
293- ( requestType ) => {
294- const activity = makeActivity ( {
295- id : EventId . make ( "approval-non-approval" ) ,
296- kind : "approval.requested" ,
297- summary : "Approval requested" ,
298- createdAt : "2026-08-24T00:00:00.000Z" ,
299- payload : { requestId : "not-an-approval" , requestType } ,
300- } ) ;
301-
302- expect ( derivePendingApprovals ( [ activity ] ) ) . toEqual ( [ ] ) ;
303- } ,
304- ) ;
305-
306- it . each ( [ "approval.resolved" , "provider.approval.respond.failed" ] ) (
307- "removes legacy approvals after %s" ,
308- ( kind ) => {
309- const requested = makeActivity ( {
310- id : EventId . make ( "approval-legacy-open" ) ,
311- kind : "approval.requested" ,
312- summary : "Approval requested" ,
313- createdAt : "2026-08-24T00:00:00.000Z" ,
314- payload : { requestId : "per-legacy" , requestType : "unknown" } ,
315- } ) ;
316- const resolved = makeActivity ( {
317- id : EventId . make ( "approval-legacy-resolved" ) ,
318- kind,
319- summary : "Approval resolved" ,
320- createdAt : "2026-08-24T00:00:01.000Z" ,
321- payload : {
322- requestId : "per-legacy" ,
323- detail : "Unknown pending permission request: per-legacy" ,
324- } ,
325- } ) ;
326-
327- expect ( derivePendingApprovals ( [ requested , resolved ] ) ) . toEqual ( [ ] ) ;
328- } ,
329- ) ;
330-
331- it ( "keeps app access approvals and persistence choices from remote environments" , ( ) => {
332- const options = [
333- { decision : "decline" , label : "Decline" } ,
334- { decision : "acceptAlways" , label : "Always allow Safari" } ,
335- { decision : "accept" , label : "Approve" } ,
336- ] ;
337- const activity = makeActivity ( {
338- id : EventId . make ( "approval-safari" ) ,
339- kind : "approval.requested" ,
340- summary : "App access approval requested" ,
341- createdAt : "2026-08-24T00:00:00.000Z" ,
342- payload : {
343- requestId : "req-safari" ,
344- requestType : "mcp_elicitation_approval" ,
345- detail : "Allow ChatGPT to use Safari?" ,
346- appName : "Safari" ,
347- options,
348- } ,
349- } ) ;
350-
351- expect ( derivePendingApprovals ( [ activity ] ) ) . toEqual ( [
352- {
353- requestId : "req-safari" ,
354- requestKind : "mcp-elicitation" ,
355- createdAt : "2026-08-24T00:00:00.000Z" ,
356- detail : "Allow ChatGPT to use Safari?" ,
357- appName : "Safari" ,
358- options,
359- } ,
360- ] ) ;
361- } ) ;
362-
363- it ( "removes an app access approval after a remote client rejects it" , ( ) => {
364- const requested = makeActivity ( {
365- id : EventId . make ( "approval-safari-open" ) ,
366- kind : "approval.requested" ,
367- summary : "App access approval requested" ,
368- createdAt : "2026-08-24T00:00:00.000Z" ,
369- payload : { requestId : "req-safari" , requestKind : "mcp-elicitation" } ,
370- } ) ;
371- const resolved = makeActivity ( {
372- id : EventId . make ( "approval-safari-resolved" ) ,
373- kind : "approval.resolved" ,
374- summary : "Approval resolved" ,
375- createdAt : "2026-08-24T00:00:01.000Z" ,
376- payload : { requestId : "req-safari" , decision : "decline" } ,
377- } ) ;
378-
379- expect ( derivePendingApprovals ( [ requested , resolved ] ) ) . toEqual ( [ ] ) ;
380- } ) ;
381- } ) ;
382-
383267function makeActivity (
384268 input : Partial < OrchestrationThreadActivity > &
385269 Pick < OrchestrationThreadActivity , "id" | "kind" | "summary" | "createdAt" > ,
0 commit comments