Skip to content

Commit 593d7d9

Browse files
committed
app-server: Replay pending item requests on thread/resume
Replay pending client requests after `thread/resume` and emit resolved notifications when those requests clear so approval/input UI state stays in sync after reconnects and across subscribed clients. Affected RPCs: - `item/commandExecution/requestApproval` - `item/fileChange/requestApproval` - `item/tool/requestUserInput` - `skill/requestApproval` Motivation: - Resumed clients need to see pending approval/input requests that were already outstanding before the reconnect. - Clients also need an explicit signal when a pending request resolves or is cleared so stale UI can be removed on turn start, completion, or interruption. Implementation notes: - Track pending client requests in `ThreadState` and replay them after `thread/resume` attaches the connection. - Reuse the original JSON-RPC request id for replays and resend prerequisite notifications like `item/started` for pending file change approvals. - Emit `item/commandExecution/approvalResolved`, `item/fileChange/approvalResolved`, `item/tool/requestUserInputResolved`, and `skill/approvalResolved` when pending requests are answered or cleared by lifecycle cleanup. - Update the app-server protocol schema, generated TypeScript bindings, and README docs for the replay/resolution flow. High-level test plan: - Added automated coverage for replaying pending command execution, file change, and skill approval requests on `thread/resume`. - Added automated coverage for resolved notifications in command approval, file change approval, request_user_input, skill approval, turn start, and turn interrupt flows. - Verified schema/docs updates in the relevant protocol and app-server tests. Manual testing: - Not run.
1 parent f86087e commit 593d7d9

24 files changed

+2095
-206
lines changed

codex-rs/app-server-protocol/schema/json/ServerNotification.json

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,21 @@
653653
}
654654
]
655655
},
656+
"CommandExecutionApprovalResolvedNotification": {
657+
"properties": {
658+
"requestId": {
659+
"$ref": "#/definitions/RequestId"
660+
},
661+
"threadId": {
662+
"type": "string"
663+
}
664+
},
665+
"required": [
666+
"requestId",
667+
"threadId"
668+
],
669+
"type": "object"
670+
},
656671
"CommandExecutionOutputDeltaNotification": {
657672
"properties": {
658673
"delta": {
@@ -853,6 +868,21 @@
853868
],
854869
"type": "object"
855870
},
871+
"FileChangeApprovalResolvedNotification": {
872+
"properties": {
873+
"requestId": {
874+
"$ref": "#/definitions/RequestId"
875+
},
876+
"threadId": {
877+
"type": "string"
878+
}
879+
},
880+
"required": [
881+
"requestId",
882+
"threadId"
883+
],
884+
"type": "object"
885+
},
856886
"FileChangeOutputDeltaNotification": {
857887
"properties": {
858888
"delta": {
@@ -1422,6 +1452,17 @@
14221452
],
14231453
"type": "object"
14241454
},
1455+
"RequestId": {
1456+
"anyOf": [
1457+
{
1458+
"type": "string"
1459+
},
1460+
{
1461+
"format": "int64",
1462+
"type": "integer"
1463+
}
1464+
]
1465+
},
14251466
"SessionSource": {
14261467
"oneOf": [
14271468
{
@@ -1449,6 +1490,21 @@
14491490
}
14501491
]
14511492
},
1493+
"SkillRequestApprovalResolvedNotification": {
1494+
"properties": {
1495+
"requestId": {
1496+
"$ref": "#/definitions/RequestId"
1497+
},
1498+
"threadId": {
1499+
"type": "string"
1500+
}
1501+
},
1502+
"required": [
1503+
"requestId",
1504+
"threadId"
1505+
],
1506+
"type": "object"
1507+
},
14521508
"SubAgentSource": {
14531509
"oneOf": [
14541510
{
@@ -2592,6 +2648,21 @@
25922648
],
25932649
"type": "object"
25942650
},
2651+
"ToolRequestUserInputResolvedNotification": {
2652+
"properties": {
2653+
"requestId": {
2654+
"$ref": "#/definitions/RequestId"
2655+
},
2656+
"threadId": {
2657+
"type": "string"
2658+
}
2659+
},
2660+
"required": [
2661+
"requestId",
2662+
"threadId"
2663+
],
2664+
"type": "object"
2665+
},
25952666
"Turn": {
25962667
"properties": {
25972668
"error": {
@@ -3402,6 +3473,26 @@
34023473
"title": "Item/commandExecution/terminalInteractionNotification",
34033474
"type": "object"
34043475
},
3476+
{
3477+
"properties": {
3478+
"method": {
3479+
"enum": [
3480+
"item/commandExecution/approvalResolved"
3481+
],
3482+
"title": "Item/commandExecution/approvalResolvedNotificationMethod",
3483+
"type": "string"
3484+
},
3485+
"params": {
3486+
"$ref": "#/definitions/CommandExecutionApprovalResolvedNotification"
3487+
}
3488+
},
3489+
"required": [
3490+
"method",
3491+
"params"
3492+
],
3493+
"title": "Item/commandExecution/approvalResolvedNotification",
3494+
"type": "object"
3495+
},
34053496
{
34063497
"properties": {
34073498
"method": {
@@ -3422,6 +3513,66 @@
34223513
"title": "Item/fileChange/outputDeltaNotification",
34233514
"type": "object"
34243515
},
3516+
{
3517+
"properties": {
3518+
"method": {
3519+
"enum": [
3520+
"item/fileChange/approvalResolved"
3521+
],
3522+
"title": "Item/fileChange/approvalResolvedNotificationMethod",
3523+
"type": "string"
3524+
},
3525+
"params": {
3526+
"$ref": "#/definitions/FileChangeApprovalResolvedNotification"
3527+
}
3528+
},
3529+
"required": [
3530+
"method",
3531+
"params"
3532+
],
3533+
"title": "Item/fileChange/approvalResolvedNotification",
3534+
"type": "object"
3535+
},
3536+
{
3537+
"properties": {
3538+
"method": {
3539+
"enum": [
3540+
"item/tool/requestUserInputResolved"
3541+
],
3542+
"title": "Item/tool/requestUserInputResolvedNotificationMethod",
3543+
"type": "string"
3544+
},
3545+
"params": {
3546+
"$ref": "#/definitions/ToolRequestUserInputResolvedNotification"
3547+
}
3548+
},
3549+
"required": [
3550+
"method",
3551+
"params"
3552+
],
3553+
"title": "Item/tool/requestUserInputResolvedNotification",
3554+
"type": "object"
3555+
},
3556+
{
3557+
"properties": {
3558+
"method": {
3559+
"enum": [
3560+
"skill/approvalResolved"
3561+
],
3562+
"title": "Skill/approvalResolvedNotificationMethod",
3563+
"type": "string"
3564+
},
3565+
"params": {
3566+
"$ref": "#/definitions/SkillRequestApprovalResolvedNotification"
3567+
}
3568+
},
3569+
"required": [
3570+
"method",
3571+
"params"
3572+
],
3573+
"title": "Skill/approvalResolvedNotification",
3574+
"type": "object"
3575+
},
34253576
{
34263577
"properties": {
34273578
"method": {

0 commit comments

Comments
 (0)