@@ -15,6 +15,7 @@ import {
1515import {
1616 buildPendingUserInputAnswers ,
1717 buildThreadFeed ,
18+ derivePendingApprovals ,
1819 deriveThreadFeedPresentation ,
1920 isPendingUserInputOptionSelected ,
2021 setPendingUserInputCustomAnswer ,
@@ -142,6 +143,59 @@ describe("pending user input answers", () => {
142143 } ) ;
143144} ) ;
144145
146+ describe ( "pending approvals" , ( ) => {
147+ it ( "keeps app access approvals and persistence choices from remote environments" , ( ) => {
148+ const options = [
149+ { decision : "decline" , label : "Decline" } ,
150+ { decision : "acceptAlways" , label : "Always allow Safari" } ,
151+ { decision : "accept" , label : "Approve" } ,
152+ ] ;
153+ const activity = makeActivity ( {
154+ id : EventId . make ( "approval-safari" ) ,
155+ kind : "approval.requested" ,
156+ summary : "App access approval requested" ,
157+ createdAt : "2026-08-24T00:00:00.000Z" ,
158+ payload : {
159+ requestId : "req-safari" ,
160+ requestType : "mcp_elicitation_approval" ,
161+ detail : "Allow ChatGPT to use Safari?" ,
162+ appName : "Safari" ,
163+ options,
164+ } ,
165+ } ) ;
166+
167+ expect ( derivePendingApprovals ( [ activity ] ) ) . toEqual ( [
168+ {
169+ requestId : "req-safari" ,
170+ requestKind : "mcp-elicitation" ,
171+ createdAt : "2026-08-24T00:00:00.000Z" ,
172+ detail : "Allow ChatGPT to use Safari?" ,
173+ appName : "Safari" ,
174+ options,
175+ } ,
176+ ] ) ;
177+ } ) ;
178+
179+ it ( "removes an app access approval after a remote client rejects it" , ( ) => {
180+ const requested = makeActivity ( {
181+ id : EventId . make ( "approval-safari-open" ) ,
182+ kind : "approval.requested" ,
183+ summary : "App access approval requested" ,
184+ createdAt : "2026-08-24T00:00:00.000Z" ,
185+ payload : { requestId : "req-safari" , requestKind : "mcp-elicitation" } ,
186+ } ) ;
187+ const resolved = makeActivity ( {
188+ id : EventId . make ( "approval-safari-resolved" ) ,
189+ kind : "approval.resolved" ,
190+ summary : "Approval resolved" ,
191+ createdAt : "2026-08-24T00:00:01.000Z" ,
192+ payload : { requestId : "req-safari" , decision : "decline" } ,
193+ } ) ;
194+
195+ expect ( derivePendingApprovals ( [ requested , resolved ] ) ) . toEqual ( [ ] ) ;
196+ } ) ;
197+ } ) ;
198+
145199function makeActivity (
146200 input : Partial < OrchestrationThreadActivity > &
147201 Pick < OrchestrationThreadActivity , "id" | "kind" | "summary" | "createdAt" > ,
0 commit comments