@@ -693,6 +693,7 @@ export class AgentServer {
693693 // After waiting, just attach the SSE controller if needed
694694 if ( this . session && sseController ) {
695695 this . session . sseController = sseController ;
696+ this . session . hasDesktopConnected = true ;
696697 this . replayPendingEvents ( ) ;
697698 }
698699 return ;
@@ -1592,22 +1593,27 @@ ${attributionInstructions}
15921593 }
15931594
15941595 // Relay permission requests to the desktop app when:
1595- // - Questions: always relay (need human answers regardless of mode)
1596- // - Plan approvals: always relay
1596+ // - Plan approvals: always relay because they gate autonomy changes
1597+ // that require human confirmation (buffered until desktop connects)
1598+ // - Questions: relay when desktop is connected
15971599 // - Edit/bash in "default" mode: relay for manual approval
1598- // Other modes auto-approve. No client connected → auto-approve.
1600+ // Other modes auto-approve. No client connected → auto-approve
1601+ // (except plan approvals, which wait for a desktop).
15991602 {
16001603 const isQuestion = codeToolKind === "question" ;
16011604 const sessionPermissionMode = this . getSessionPermissionMode ( ) ;
1602- const needsRelay =
1605+ const needsDesktopApproval =
16031606 isQuestion ||
1604- isPlanApproval ||
16051607 this . shouldRelayPermissionToClient ( sessionPermissionMode ) ;
16061608
1607- if ( needsRelay && this . session ?. hasDesktopConnected ) {
1608- this . logger . info ( "Relaying permission to connected client" , {
1609+ if (
1610+ isPlanApproval ||
1611+ ( needsDesktopApproval && this . session ?. hasDesktopConnected )
1612+ ) {
1613+ this . logger . info ( "Relaying permission request" , {
16091614 kind : params . toolCall ?. kind ,
16101615 isQuestion,
1616+ hasDesktopConnected : this . session ?. hasDesktopConnected ?? false ,
16111617 sessionPermissionMode,
16121618 } ) ;
16131619 return this . relayPermissionToClient ( params ) ;
0 commit comments