Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
cf0e226
test: cover non-blocking Codex feed permissions
lawrencecchen Jun 6, 2026
970950f
fix: keep Codex permission hooks non-blocking
lawrencecchen Jun 6, 2026
dc3f0c9
feat: bridge Codex app-server approvals to Feed
lawrencecchen Jun 6, 2026
d57d329
Validate Codex Teams launch cwd
lawrencecchen Jun 6, 2026
7ed2a21
Address Codex Teams approval review findings
lawrencecchen Jun 6, 2026
851b337
Align Feed TUI Codex permission modes
lawrencecchen Jun 6, 2026
da2eb3a
Handle unsupported Codex app-server requests
lawrencecchen Jun 6, 2026
f310df0
Close Codex watcher on unsupported requests
lawrencecchen Jun 6, 2026
b2ff9f4
Preserve persistent Codex file approvals
lawrencecchen Jun 6, 2026
f5f8d0e
Close Codex watcher on unresolved approvals
lawrencecchen Jun 6, 2026
01629cb
Honor Codex advertised approval decisions
lawrencecchen Jun 6, 2026
1bf0e8e
Bound Codex approval item cache
lawrencecchen Jun 6, 2026
79313b8
Convert Feed coordinator tests to Swift Testing
lawrencecchen Jun 6, 2026
6e7dcda
Ignore unsupported Codex watcher requests
lawrencecchen Jun 6, 2026
89b82c2
Share Codex approval bridge with tests
lawrencecchen Jun 8, 2026
7e75cfe
Merge remote-tracking branch 'origin/main' into feat-codex-permission…
lawrencecchen Jun 8, 2026
9c53e39
Serialize Feed coordinator tests
lawrencecchen Jun 8, 2026
bda5691
Gate Codex persistent approval modes per request
lawrencecchen Jun 8, 2026
3dedb11
Merge remote-tracking branch 'origin/main' into feat-codex-permission…
lawrencecchen Jun 8, 2026
4e1898a
Keep Codex approval scopes explicit
lawrencecchen Jun 8, 2026
97888a4
Avoid denial for unsupported Codex persistent replies
lawrencecchen Jun 8, 2026
f88ad19
Merge remote-tracking branch 'origin/main' into feat-codex-permission…
lawrencecchen Jun 8, 2026
bc0fcbb
Isolate Codex watcher approval waits
lawrencecchen Jun 8, 2026
cd49928
Gate Codex approval actions by capability
lawrencecchen Jun 8, 2026
1a6aa40
Treat file-change approvals as one-shot by default
lawrencecchen Jun 8, 2026
cf30c9e
Validate Codex notification approval actions
lawrencecchen Jun 8, 2026
73aa15c
Close Codex approval feed sockets
lawrencecchen Jun 8, 2026
7aab7f5
Harden Codex approval feed bridge
lawrencecchen Jun 8, 2026
8d2f296
Merge remote-tracking branch 'origin/main' into feat-codex-permission…
lawrencecchen Jun 8, 2026
5f63044
Merge remote-tracking branch 'origin/main' into feat-codex-permission…
lawrencecchen Jun 8, 2026
8863a42
Fix feed capability test encoder call
lawrencecchen Jun 8, 2026
524cbea
Keep Codex watcher approvals soft fallback
lawrencecchen Jun 8, 2026
c36c8bb
Answer Codex watcher approval fallbacks
lawrencecchen Jun 8, 2026
bb19d16
Keep Codex approval fallback native
lawrencecchen Jun 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLI/CMUXCLI+AgentHookDefinitions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extension CMUXCLI {

enum HookFormat {
case flat // Cursor: {"hooks": {"event": [{"command": "..."}]}, "version": 1}
case nested(timeoutMs: Int) // Codex/Gemini: nested with type/command/timeout
case nested(timeoutMs: Int) // Nested type/command/timeout hooks; timeout unit is agent-specific.
case kiroAgentJSON(timeoutMs: Int) // ~/.kiro/agents/*.json flat command entries with timeout_ms
case antigravityJSON(timeoutSeconds: Int) // ~/.gemini/config/hooks.json named hook groups
case rovoDevYAML
Expand Down
5 changes: 4 additions & 1 deletion CLI/FeedEventClassifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ struct FeedEventClassifier {
"Notification": .statusNotification,
],
"codex": [
"PermissionRequest": .approvalRequest,
// Codex runs PermissionRequest hooks before its own approval
// reviewer. Treat this as telemetry so "Approve for me" can still
// use Codex's auto-review path instead of blocking on cmux Feed.
"PermissionRequest": .toolStart,
"PreToolUse": .toolStart,
"beforeShellExecution": .toolStart,
"PostToolUse": .toolEnd,
Expand Down
506 changes: 478 additions & 28 deletions CLI/cmux.swift

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Sources/Feed/FeedPermissionActionPolicy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import CMUXWorkstream

enum FeedPermissionActionPolicy {
static func supportsPersistentPermissionModes(source: WorkstreamSource) -> Bool {
source != .codex && source != .hermesAgent
source != .hermesAgent

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Gate Codex Always Allow on advertised decisions

With this source-only policy, FeedPanelView shows “Always Allow” for every Codex approval, but Codex app-server requests can advertise the exact choices in availableDecisions (the app-server README says clients can use it to render the choices) and the new response helpers still fall back from Feed mode always to plain accept when no persistent Codex decision is available. In those command/file-change prompts, clicking “Always Allow” silently grants only a one-off approval; gate the persistent button on the specific request's available_decisions/grant data instead of enabling it for all Codex items.

Useful? React with 👍 / 👎.

}

static func supportsBypassPermissions(source: WorkstreamSource) -> Bool {
Expand Down
17 changes: 16 additions & 1 deletion cmuxTests/CLIGenericHookPersistenceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2915,11 +2915,12 @@ extension CLINotifyProcessIntegrationRegressionTests {
.appendingPathComponent("cmux-session.json", isDirectory: false)
let json = try XCTUnwrap(JSONSerialization.jsonObject(with: Data(contentsOf: hookURL)) as? [String: Any])
let hooks = try XCTUnwrap(json["hooks"] as? [String: Any])
let allCommands = hooks.values
let codexHookEntries = hooks.values
.compactMap { $0 as? [[String: Any]] }
.flatMap { $0 }
.compactMap { $0["hooks"] as? [[String: Any]] }
.flatMap { $0 }
let allCommands = codexHookEntries

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Misleading variable name in a Grok test

The variable is named codexHookEntries but this function (testGrokHookInstallPinsInstallingCLIAndSocketWithoutCMUXInterpolation) reads from .grok/hooks/cmux-session.json. The rename was clearly intended for the Codex test function, and this Grok function only needs it as a stepping stone to allCommands — a neutral name like hookEntries would be more accurate here.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

.compactMap { $0["command"] as? String }

XCTAssertFalse(allCommands.isEmpty)
Expand Down Expand Up @@ -3139,6 +3140,20 @@ extension CLINotifyProcessIntegrationRegressionTests {
1,
"Codex setup should collapse duplicate cmux-owned prompt hooks to one entry, saw \(allCommands)"
)
XCTAssertTrue(
codexHookEntries.contains {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Declare codexHookEntries before asserting timeouts

When cmuxTests is built, this new assertion references codexHookEntries, but this test only defines allCommands above and never binds the flattened hook dictionaries. The symbol exists in a different test method, so the suite will fail to compile before any Codex hook regression tests can run.

Useful? React with 👍 / 👎.

($0["command"] as? String)?.contains("hooks codex prompt-submit") == true
&& ($0["timeout"] as? Int) == 5
},
"Codex lifecycle hooks must use Codex's second-based timeout field, saw \(codexHookEntries)"
)
XCTAssertTrue(
codexHookEntries.contains {
($0["command"] as? String)?.contains("hooks feed --source codex --event PermissionRequest") == true
&& ($0["timeout"] as? Int) == 5
},
"Codex Feed hooks are telemetry and must use a short second-based timeout, saw \(codexHookEntries)"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 codexHookEntries is out of scope — compile error

codexHookEntries is only defined inside testGrokHookInstallPinsInstallingCLIAndSocketWithoutCMUXInterpolation (line 2918), a completely different function that reads from .grok/hooks/cmux-session.json. The two new assertions here are inside testCodexHookInstallPrefersLaunchingAppBundledCLI, which still derives only allCommands at line 3116-3121 without ever binding codexHookEntries. The fix is to split the allCommands derivation in testCodexHookInstallPrefersLaunchingAppBundledCLI the same way the Grok function was split — introduce a codexHookEntries binding there and derive allCommands from it.

)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

func testGrokHookInstallRejectsFileAtHooksDirectory() throws {
Expand Down
219 changes: 218 additions & 1 deletion cmuxTests/FeedCoordinatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,235 @@ import CMUXWorkstream
#endif

final class FeedCoordinatorTests: XCTestCase {
func testCodexTeamsResolvesExplicitWorkingDirectoryFlags() throws {
let base = "/tmp/cmux-base"

XCTAssertEqual(
CMUXCLI.codexTeamsResolvedWorkingDirectory(
commandArgs: ["-C", "child", "prompt"],
baseDirectory: base
),
"/tmp/cmux-base/child"
)
XCTAssertEqual(
CMUXCLI.codexTeamsResolvedWorkingDirectory(
commandArgs: ["--cwd=/tmp/cmux-review", "--cd", "/tmp/cmux-final"],
baseDirectory: base
),
"/tmp/cmux-final"
)
XCTAssertNil(
CMUXCLI.codexTeamsResolvedWorkingDirectory(
commandArgs: ["--", "-C", "/tmp/inside-prompt"],
baseDirectory: base
)
)
}

func testCodexTeamsValidatesExplicitWorkingDirectoryExists() throws {
let existing = FileManager.default.temporaryDirectory
.appendingPathComponent("cmux-codex-teams-cwd-\(UUID().uuidString)", isDirectory: true)
try FileManager.default.createDirectory(at: existing, withIntermediateDirectories: true)
defer { try? FileManager.default.removeItem(at: existing) }

XCTAssertNoThrow(
try CMUXCLI.validateCodexTeamsWorkingDirectory(
commandArgs: ["-C", existing.path],
baseDirectory: "/tmp"
)
)

XCTAssertThrowsError(
try CMUXCLI.validateCodexTeamsWorkingDirectory(
commandArgs: ["-C", existing.appendingPathComponent("missing").path],
baseDirectory: "/tmp"
)
)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify working directory resolution and validation handle absolute vs relative paths consistently

# Search for the implementation of both functions
ast-grep --pattern $'func codexTeamsResolvedWorkingDirectory(commandArgs: $_, baseDirectory: $_) -> $_ {
  $$$
}'

ast-grep --pattern $'func validateCodexTeamsWorkingDirectory(commandArgs: $_, baseDirectory: $_) throws {
  $$$
}'

Repository: manaflow-ai/cmux

Length of output: 42


Clarify -C/--cd/--cwd working-directory semantics

  • codexTeamsResolvedWorkingDirectory treats absolute -C values as standardized absolute paths and intentionally ignores baseDirectory; validateCodexTeamsWorkingDirectory validates that resolved path exists and is a directory.
  • testCodexTeamsValidatesExplicitWorkingDirectoryExists covers the absolute branch; for parity with testCodexTeamsResolvesExplicitWorkingDirectoryFlags, add relative -C <child> validation cases against baseDirectory.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmuxTests/FeedCoordinatorTests.swift` around lines 36 - 55, The test only
exercises absolute -C paths; add cases to
testCodexTeamsValidatesExplicitWorkingDirectoryExists that pass a relative -C
(e.g. a child folder name) and assert validateCodexTeamsWorkingDirectory uses
baseDirectory to resolve and validate the resulting path (mirroring
testCodexTeamsResolvesExplicitWorkingDirectoryFlags and the behavior in
codexTeamsResolvedWorkingDirectory); create the child directory under the
temporary baseDirectory, call CMUXCLI.validateCodexTeamsWorkingDirectory with
commandArgs ["-C", "<child>"] and baseDirectory set to the temp base, assert no
throw for existing child and XCTAssertThrowsError for a missing child path.


func testClaudePermissionActionPolicyKeepsBypassUserOwned() {
XCTAssertTrue(FeedPermissionActionPolicy.supportsPersistentPermissionModes(source: .claude))
XCTAssertFalse(FeedPermissionActionPolicy.supportsBypassPermissions(source: .claude))
XCTAssertTrue(CMUXCLI.feedSourceSupportsPersistentPermissionModes("claude"))
XCTAssertFalse(CMUXCLI.feedSourceSupportsBypassPermissions("claude"))

XCTAssertFalse(FeedPermissionActionPolicy.supportsPersistentPermissionModes(source: .codex))
XCTAssertTrue(FeedPermissionActionPolicy.supportsPersistentPermissionModes(source: .codex))
XCTAssertFalse(FeedPermissionActionPolicy.supportsBypassPermissions(source: .codex))
XCTAssertTrue(CMUXCLI.feedSourceSupportsPersistentPermissionModes("codex"))
XCTAssertFalse(CMUXCLI.feedSourceSupportsBypassPermissions("codex"))

XCTAssertTrue(FeedPermissionActionPolicy.supportsPersistentPermissionModes(source: .opencode))
XCTAssertTrue(FeedPermissionActionPolicy.supportsBypassPermissions(source: .opencode))
XCTAssertTrue(CMUXCLI.feedSourceSupportsPersistentPermissionModes("opencode"))
XCTAssertTrue(CMUXCLI.feedSourceSupportsBypassPermissions("opencode"))

XCTAssertFalse(FeedPermissionActionPolicy.supportsPersistentPermissionModes(source: .hermesAgent))
XCTAssertFalse(FeedPermissionActionPolicy.supportsBypassPermissions(source: .hermesAgent))
XCTAssertFalse(CMUXCLI.feedSourceSupportsPersistentPermissionModes("hermes-agent"))
XCTAssertFalse(CMUXCLI.feedSourceSupportsBypassPermissions("hermes-agent"))
}

func testCodexAppServerApprovalBuildsActionableFeedEvent() throws {
let event = CMUXCLI.codexTeamsFeedEvent(
method: "item/commandExecution/requestApproval",
requestId: 41,
params: [
"threadId": "thread-1",
"turnId": "turn-1",
"itemId": "call-1",
"approvalId": "approval-1",
"command": "touch /tmp/cmux-security-review",
"cwd": "/tmp/project",
"reason": "requires approval",
"additionalPermissions": [
"fileSystem": ["write": ["/tmp/project"]]
],
"networkApprovalContext": ["host": "example.com"],
"commandActions": [["type": "write", "path": "/tmp/cmux-security-review"]],
"proposedExecpolicyAmendment": [["kind": "prefix", "value": "touch"]],
"availableDecisions": ["accept", "acceptForSession", "decline"]
],
workspaceId: "workspace-1",
relatedItem: [
"type": "commandExecution",
"id": "call-1",
"command": "touch /tmp/cmux-security-review",
"cwd": "/tmp/project"
]
)

XCTAssertEqual(event["session_id"] as? String, "codex-thread-1")
XCTAssertEqual(event["hook_event_name"] as? String, "PermissionRequest")
XCTAssertEqual(event["_source"] as? String, "codex")
XCTAssertEqual(event["workspace_id"] as? String, "workspace-1")
XCTAssertEqual(event["_opencode_request_id"] as? String, "codex-app-server-approval-1")
XCTAssertEqual(event["tool_name"] as? String, "Bash")
XCTAssertEqual(event["cwd"] as? String, "/tmp/project")

let toolInput = try XCTUnwrap(event["tool_input"] as? [String: Any])
XCTAssertEqual(toolInput["app_server_method"] as? String, "item/commandExecution/requestApproval")
XCTAssertEqual(toolInput["request_id"] as? String, "41")
XCTAssertEqual(toolInput["item_id"] as? String, "approval-1")
XCTAssertEqual(toolInput["turn_id"] as? String, "turn-1")
XCTAssertEqual(toolInput["command"] as? String, "touch /tmp/cmux-security-review")
XCTAssertNotNil(toolInput["approval_params"])
XCTAssertNotNil(toolInput["additional_permissions"])
XCTAssertNotNil(toolInput["network_approval_context"])
XCTAssertNotNil(toolInput["command_actions"])
XCTAssertNotNil(toolInput["proposed_execpolicy_amendment"])
XCTAssertEqual((toolInput["related_item"] as? [String: Any])?["type"] as? String, "commandExecution")

let context = try XCTUnwrap(event["context"] as? [String: Any])
XCTAssertEqual(context["permissionMode"] as? String, "codex app-server")
XCTAssertEqual(context["assistantPreamble"] as? String, "requires approval")
}

func testCodexAppServerPermissionsApprovalBuildsFeedEventAndResponse() throws {
let permissions: [String: Any] = [
"network": ["enabled": true],
"fileSystem": [
"read": ["/tmp/read"],
"write": ["/tmp/write"]
]
]
let event = CMUXCLI.codexTeamsFeedEvent(
method: "item/permissions/requestApproval",
requestId: "permissions-request",
params: [
"threadId": "thread-1",
"turnId": "turn-1",
"itemId": "permissions-call",
"environmentId": "local",
"cwd": "/tmp/project",
"reason": "Need broader access",
"permissions": permissions
],
workspaceId: "workspace-1"
)

XCTAssertEqual(event["tool_name"] as? String, "request_permissions")
XCTAssertEqual(event["_opencode_request_id"] as? String, "codex-app-server-permissions-call")
let toolInput = try XCTUnwrap(event["tool_input"] as? [String: Any])
XCTAssertEqual(toolInput["app_server_method"] as? String, "item/permissions/requestApproval")
XCTAssertNotNil(toolInput["approval_params"])
XCTAssertNotNil(toolInput["permissions"])

let once = try XCTUnwrap(
CMUXCLI.codexTeamsAppServerApprovalResponse(
method: "item/permissions/requestApproval",
params: ["permissions": permissions],
mode: "once"
)
)
XCTAssertEqual(once["scope"] as? String, "turn")
XCTAssertNotNil(once["permissions"])

let always = try XCTUnwrap(
CMUXCLI.codexTeamsAppServerApprovalResponse(
method: "item/permissions/requestApproval",
params: ["permissions": permissions],
mode: "always"
)
)
XCTAssertEqual(always["scope"] as? String, "session")

let deny = try XCTUnwrap(
CMUXCLI.codexTeamsAppServerApprovalResponse(
method: "item/permissions/requestApproval",
params: ["permissions": permissions],
mode: "deny"
)
)
XCTAssertEqual(deny["scope"] as? String, "turn")
XCTAssertEqual((deny["permissions"] as? [String: Any])?.isEmpty, true)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Validate permissions payload structure in event and response.

This test builds a nested permissions structure (lines 127-133) but only checks its presence in the event via XCTAssertNotNil (line 154). Similarly, the response validation for once mode (line 164) checks that permissions is not nil but doesn't verify the actual content matches the input structure. Only the deny case (line 183) validates the payload (asserting it's empty).

Validate that the permissions structure flows correctly from params → event tool_input → response payload for at least one allow case.

🔍 Suggested validation
 let toolInput = try XCTUnwrap(event["tool_input"] as? [String: Any])
 XCTAssertEqual(toolInput["app_server_method"] as? String, "item/permissions/requestApproval")
 XCTAssertNotNil(toolInput["approval_params"])
-XCTAssertNotNil(toolInput["permissions"])
+let eventPermissions = try XCTUnwrap(toolInput["permissions"] as? [String: Any])
+let eventFileSystem = try XCTUnwrap(eventPermissions["fileSystem"] as? [String: Any])
+XCTAssertEqual(eventFileSystem["write"] as? [String], ["/tmp/write"])
+XCTAssertEqual(eventFileSystem["read"] as? [String], ["/tmp/read"])

 let once = try XCTUnwrap(
     CMUXCLI.codexTeamsAppServerApprovalResponse(
         method: "item/permissions/requestApproval",
         params: ["permissions": permissions],
         mode: "once"
     )
 )
 XCTAssertEqual(once["scope"] as? String, "turn")
-XCTAssertNotNil(once["permissions"])
+let oncePermissions = try XCTUnwrap(once["permissions"] as? [String: Any])
+let onceFileSystem = try XCTUnwrap(oncePermissions["fileSystem"] as? [String: Any])
+XCTAssertEqual(onceFileSystem["write"] as? [String], ["/tmp/write"])
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func testCodexAppServerPermissionsApprovalBuildsFeedEventAndResponse() throws {
let permissions: [String: Any] = [
"network": ["enabled": true],
"fileSystem": [
"read": ["/tmp/read"],
"write": ["/tmp/write"]
]
]
let event = CMUXCLI.codexTeamsFeedEvent(
method: "item/permissions/requestApproval",
requestId: "permissions-request",
params: [
"threadId": "thread-1",
"turnId": "turn-1",
"itemId": "permissions-call",
"environmentId": "local",
"cwd": "/tmp/project",
"reason": "Need broader access",
"permissions": permissions
],
workspaceId: "workspace-1"
)
XCTAssertEqual(event["tool_name"] as? String, "request_permissions")
XCTAssertEqual(event["_opencode_request_id"] as? String, "codex-app-server-permissions-call")
let toolInput = try XCTUnwrap(event["tool_input"] as? [String: Any])
XCTAssertEqual(toolInput["app_server_method"] as? String, "item/permissions/requestApproval")
XCTAssertNotNil(toolInput["approval_params"])
XCTAssertNotNil(toolInput["permissions"])
let once = try XCTUnwrap(
CMUXCLI.codexTeamsAppServerApprovalResponse(
method: "item/permissions/requestApproval",
params: ["permissions": permissions],
mode: "once"
)
)
XCTAssertEqual(once["scope"] as? String, "turn")
XCTAssertNotNil(once["permissions"])
let always = try XCTUnwrap(
CMUXCLI.codexTeamsAppServerApprovalResponse(
method: "item/permissions/requestApproval",
params: ["permissions": permissions],
mode: "always"
)
)
XCTAssertEqual(always["scope"] as? String, "session")
let deny = try XCTUnwrap(
CMUXCLI.codexTeamsAppServerApprovalResponse(
method: "item/permissions/requestApproval",
params: ["permissions": permissions],
mode: "deny"
)
)
XCTAssertEqual(deny["scope"] as? String, "turn")
XCTAssertEqual((deny["permissions"] as? [String: Any])?.isEmpty, true)
}
func testCodexAppServerPermissionsApprovalBuildsFeedEventAndResponse() throws {
let permissions: [String: Any] = [
"network": ["enabled": true],
"fileSystem": [
"read": ["/tmp/read"],
"write": ["/tmp/write"]
]
]
let event = CMUXCLI.codexTeamsFeedEvent(
method: "item/permissions/requestApproval",
requestId: "permissions-request",
params: [
"threadId": "thread-1",
"turnId": "turn-1",
"itemId": "permissions-call",
"environmentId": "local",
"cwd": "/tmp/project",
"reason": "Need broader access",
"permissions": permissions
],
workspaceId: "workspace-1"
)
XCTAssertEqual(event["tool_name"] as? String, "request_permissions")
XCTAssertEqual(event["_opencode_request_id"] as? String, "codex-app-server-permissions-call")
let toolInput = try XCTUnwrap(event["tool_input"] as? [String: Any])
XCTAssertEqual(toolInput["app_server_method"] as? String, "item/permissions/requestApproval")
XCTAssertNotNil(toolInput["approval_params"])
let eventPermissions = try XCTUnwrap(toolInput["permissions"] as? [String: Any])
let eventFileSystem = try XCTUnwrap(eventPermissions["fileSystem"] as? [String: Any])
XCTAssertEqual(eventFileSystem["write"] as? [String], ["/tmp/write"])
XCTAssertEqual(eventFileSystem["read"] as? [String], ["/tmp/read"])
let once = try XCTUnwrap(
CMUXCLI.codexTeamsAppServerApprovalResponse(
method: "item/permissions/requestApproval",
params: ["permissions": permissions],
mode: "once"
)
)
XCTAssertEqual(once["scope"] as? String, "turn")
let oncePermissions = try XCTUnwrap(once["permissions"] as? [String: Any])
let onceFileSystem = try XCTUnwrap(oncePermissions["fileSystem"] as? [String: Any])
XCTAssertEqual(onceFileSystem["write"] as? [String], ["/tmp/write"])
let always = try XCTUnwrap(
CMUXCLI.codexTeamsAppServerApprovalResponse(
method: "item/permissions/requestApproval",
params: ["permissions": permissions],
mode: "always"
)
)
XCTAssertEqual(always["scope"] as? String, "session")
let deny = try XCTUnwrap(
CMUXCLI.codexTeamsAppServerApprovalResponse(
method: "item/permissions/requestApproval",
params: ["permissions": permissions],
mode: "deny"
)
)
XCTAssertEqual(deny["scope"] as? String, "turn")
XCTAssertEqual((deny["permissions"] as? [String: Any])?.isEmpty, true)
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmuxTests/FeedCoordinatorTests.swift` around lines 126 - 184, The test
currently only checks presence of the nested permissions payload; update
testCodexAppServerPermissionsApprovalBuildsFeedEventAndResponse to assert the
permissions content is preserved end-to-end: after creating permissions and
calling CMUXCLI.codexTeamsFeedEvent, unwrap event["tool_input"] and assert its
"permissions" (or nested "approval_params"->"permissions" if applicable) equals
the original permissions structure; then for the "once" (allow) response from
CMUXCLI.codexTeamsAppServerApprovalResponse, unwrap once["permissions"] and
assert it matches the original permissions dictionary (deep-equality), leaving
the existing "deny" empty assertion intact.


func testCodexAppServerApprovalResponseFollowsFeedDecision() {
let params: [String: Any] = [
"availableDecisions": ["accept", "acceptForSession", "decline"]
]

XCTAssertEqual(
CMUXCLI.codexTeamsPermissionMode(fromFeedPushResponse: [
"status": "resolved",
"decision": ["kind": "permission", "mode": "always"]
]),
"always"
)
XCTAssertEqual(
CMUXCLI.codexTeamsAppServerApprovalResponse(
method: "item/commandExecution/requestApproval",
params: params,
mode: "always"
)?["decision"] as? String,
"acceptForSession"
)
let amendmentDecision = CMUXCLI.codexTeamsAppServerApprovalResponse(
method: "item/commandExecution/requestApproval",
params: [
"availableDecisions": [["acceptWithExecpolicyAmendment": [:]]],
"proposedExecpolicyAmendment": [["kind": "prefix", "value": "npm test"]]
],
mode: "always"
)?["decision"] as? [String: Any]
XCTAssertNotNil(amendmentDecision?["acceptWithExecpolicyAmendment"])
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
XCTAssertEqual(
CMUXCLI.codexTeamsAppServerApprovalResponse(
method: "item/fileChange/requestApproval",
params: [:],
mode: "once"
)?["decision"] as? String,
"accept"
)
XCTAssertEqual(
CMUXCLI.codexTeamsAppServerApprovalResponse(
method: "item/commandExecution/requestApproval",
params: params,
mode: "deny"
)?["decision"] as? String,
"decline"
)
XCTAssertNil(CMUXCLI.codexTeamsPermissionMode(fromFeedPushResponse: ["status": "timed_out"]))
}

func testBlockingIngestExpiresItemWhenHookTimesOut() async {
Expand Down
9 changes: 5 additions & 4 deletions cmuxTests/FeedEventClassificationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,15 @@ struct FeedEventClassificationTests {
#expect(classify("gemini", "PreToolUse", tool: "AskUserQuestion").actionable == true)
}

/// Codex has a dedicated `PermissionRequest` feed event, so its
/// pre-tool events (`PreToolUse` and the Codex-specific
/// `beforeShellExecution`) are telemetry only.
/// Codex runs `PermissionRequest` hooks before its own approval reviewer,
/// so Feed must keep both pre-tool events and permission requests as
/// telemetry. Otherwise "Approve for me" gets bypassed by cmux's Feed UI.
@Test func codexPreToolUseIsTelemetry() {
#expect(classify("codex", "PreToolUse", tool: "shell").actionable == false)
#expect(classify("codex", "beforeShellExecution", tool: "shell").actionable == false)
#expect(classify("codex", "beforeShellExecution", tool: "shell").name == "PreToolUse")
#expect(classify("codex", "PermissionRequest", tool: "shell").actionable == true)
#expect(classify("codex", "PermissionRequest", tool: "shell").name == "PreToolUse")
#expect(classify("codex", "PermissionRequest", tool: "shell").actionable == false)
}

/// Unknown source + unknown event is safe by default.
Expand Down
2 changes: 1 addition & 1 deletion docs/agent-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Supported agent names are `codex`, `grok`, `opencode`, `pi`, `omp`, `amp`, `curs
| Agent | Binary checked | Installed file | Session restore | Feed bridge |
| --- | --- | --- | --- | --- |
| Claude Code | `claude` through wrapper | wrapper-injected settings | `claude --resume <id>` | PermissionRequest |
| Codex | `codex` | `~/.codex/hooks.json`, `~/.codex/config.toml` | `codex resume <id>` | PreToolUse, PermissionRequest |
| Codex | `codex` | `~/.codex/hooks.json`, `~/.codex/config.toml` | `codex resume <id>` | PreToolUse, PermissionRequest telemetry |
| Grok | `grok` | `~/.grok/hooks/cmux-session.json` | `grok -r <id>` | PreToolUse |
| OpenCode | `opencode` | `~/.config/opencode/plugins/cmux-session.js`, `~/.config/opencode/plugins/cmux-feed.js` | `opencode --session <id>` | plugin event bus |
| Pi | `pi` | `~/.pi/agent/extensions/cmux-session.ts` | `pi --session <id>` | none |
Expand Down
8 changes: 5 additions & 3 deletions docs/feed.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Installs supported agent hooks whose binaries are on `PATH`. See [Agent hook int
| Agent | Config | Feed trigger |
|--------------|-------------------------------------------|--------------------------|
| Claude Code | wrapper-injected | PermissionRequest |
| Codex | `~/.codex/hooks.json` | PermissionRequest |
| Codex | `~/.codex/hooks.json` | PreToolUse / PermissionRequest telemetry |
| Grok | `~/.grok/hooks/cmux-session.json` | PreToolUse |
| OpenCode | `~/.config/opencode/plugins/cmux-feed.js` | plugin event bus |
| Cursor CLI | `~/.cursor/hooks.json` | beforeShellExecution |
Expand Down Expand Up @@ -128,13 +128,15 @@ For Claude Code, the cmux wrapper launches Claude with `--allow-dangerously-skip

For Claude Code, AskUserQuestion is answered by allowing the PermissionRequest with an updated tool input containing the selected answers. Other agents use their native question reply shape where available.

Codex's `request_user_input` and `update_plan` currently surface through its app-server request/notification path, not through command hooks. A stock `codex` TUI running in a cmux terminal keeps those frames inside Codex's in-process app-server client, so its plan-mode questions still fall back to Codex's own TUI. cmux can route Codex permission approvals through `PermissionRequest`; showing Codex plan questions in Feed would require launching Codex against a shared standalone app server and adding a Codex app-server Feed adapter, or upstream Codex hook coverage for those frames.
Codex's hook-level `request_user_input`, `update_plan`, and approval prompts stay in Codex's own TUI/app-server path. cmux records Codex `PreToolUse` and `PermissionRequest` hooks as non-blocking telemetry only, because Codex runs `PermissionRequest` hooks before its `Approve for me` auto-review path. Blocking in hook mode would make Codex ask for Feed approval before its own reviewer can decide.

When Codex is launched through `cmux codex-teams`, cmux owns the private Codex app-server connection. The Codex Teams watcher listens for app-server command and file-change approval requests, which happen after Codex has decided that user approval is needed, and bridges those requests to Feed as actionable permission cards. A Feed click responds to the app-server request. If Feed times out or no decision is returned, cmux does not send a denial so Codex's native TUI approval can still answer the request.

## Timeout behavior

Feed is advisory, not blocking. The hook waits at most 120 seconds for a user decision. On timeout the bridge emits `{}` (no decision) and the agent falls through to its own in-TUI prompt. This matches Vibe Island's "soft wait" model, it never freezes a workflow forever.

Per-event timeout inside agent hook configs is raised to roughly 120 to 125 seconds for Feed bridge entries (Claude uses 125 seconds for PermissionRequest), so a user taking 30 seconds to approve something does not trip default 5 000 ms hook timeouts.
Per-event timeout inside agent hook configs is raised to roughly 120 to 125 seconds for blocking Feed bridge entries (Claude uses 125 seconds for PermissionRequest), so a user taking 30 seconds to approve something does not trip default 5 000 ms hook timeouts. Codex Feed hooks stay non-blocking and use a short timeout because Codex owns its own approval UI.

## Storage

Expand Down
Loading
Loading