Skip to content

Commit 291638a

Browse files
committed
fix: executePermissionRequestHook内のマージロジックに UpdatedPermissions を追加
複数アクションを持つフックで後のアクションの UpdatedPermissions が破棄される バグを修正。updatedInput と同様に last non-null wins のロジックを追加。 合わせて deny/ask への切り替わり時に UpdatedPermissions もクリアする。 Codexレビュー(3回目)で指摘。
1 parent 6151b3d commit 291638a

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

hooks_tool_permission.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,13 +787,19 @@ func executePermissionRequestHook(executor *ActionExecutor, hook PermissionReque
787787
mergedOutput.UpdatedInput = actionOutput.UpdatedInput
788788
}
789789

790+
// UpdatedPermissions: last non-null value wins
791+
if actionOutput.UpdatedPermissions != nil {
792+
mergedOutput.UpdatedPermissions = actionOutput.UpdatedPermissions
793+
}
794+
790795
// Clear fields incompatible with behavior change (公式仕様準拠)
791796
// This must happen AFTER setting all fields from actionOutput
792797
if previousBehavior != mergedOutput.Behavior {
793798
switch mergedOutput.Behavior {
794-
case "deny":
795-
// deny時: updatedInputをクリア (公式仕様: deny時はupdatedInput不可)
799+
case "deny", "ask":
800+
// deny/ask時: updatedInput/updatedPermissionsをクリア (公式仕様: allow時のみ有効)
796801
mergedOutput.UpdatedInput = nil
802+
mergedOutput.UpdatedPermissions = nil
797803
case "allow":
798804
// allow時: decision内のmessage/interruptをクリア(公式仕様: allow時はdecision.message/interrupt不可)
799805
// Note: systemMessageはトップレベルのフィールドでdecisionとは独立なので残す

0 commit comments

Comments
 (0)