Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ const CODEX_MANAGED_EVENTS: Record<string, { matcher?: string }> = {
// A planning question blocks on user input; resume working after its answer.
// Match only this tool so ordinary tool calls never signal a waiting state.
PreToolUse: { matcher: "^request_user_input$" },
PostToolUse: { matcher: "^request_user_input$" },
// Reassert working state after any tool call so a cleared or missed Start
// self-heals during a turn, matching Claude's lifecycle behavior.
PostToolUse: { matcher: "*" },
Stop: {},
Interrupt: {},
SubagentStart: {},
Expand Down
27 changes: 17 additions & 10 deletions packages/agent-setup/src/agent-wrappers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1908,14 +1908,18 @@ describe("agent-wrappers codex hooks.json", () => {
).toBe(true);
}

for (const eventName of ["PreToolUse", "PostToolUse"]) {
expect(parsed.hooks[eventName]).toEqual([
{
matcher: "^request_user_input$",
hooks: [{ type: "command", command: expectedCommand }],
},
]);
}
expect(parsed.hooks.PreToolUse).toEqual([
{
matcher: "^request_user_input$",
hooks: [{ type: "command", command: expectedCommand }],
},
]);
expect(parsed.hooks.PostToolUse).toEqual([
{
matcher: "*",
hooks: [{ type: "command", command: expectedCommand }],
},
]);
});

it("preserves user hooks when merging", () => {
Expand Down Expand Up @@ -2034,10 +2038,13 @@ describe("agent-wrappers codex hooks.json", () => {
).toBe(true);
}

for (const eventName of ["PreToolUse", "PostToolUse"]) {
for (const [eventName, matcher] of [
["PreToolUse", "^request_user_input$"],
["PostToolUse", "*"],
] as const) {
expect(parsed.hooks[eventName]).toHaveLength(2);
expect(parsed.hooks[eventName]).toContainEqual({
matcher: "^request_user_input$",
matcher,
hooks: [{ type: "command", command: expectedManagedCommand }],
});
}
Expand Down
22 changes: 22 additions & 0 deletions packages/agent-setup/src/codex-working-status.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { describe, expect, it } from "bun:test";
import { getCodexGlobalHooksJsonContent } from "./agent-wrappers-claude-codex-opencode";

const command =
'[ -n "$SUPERSET_HOME_DIR" ] && [ -x "$SUPERSET_HOME_DIR/hooks/notify.sh" ] && SUPERSET_HOOK_HARNESS=codex "$SUPERSET_HOME_DIR/hooks/notify.sh" || true';

describe("Codex working status hooks", () => {
it("reasserts working after every tool while keeping pre-tool waiting scoped", () => {
const content = getCodexGlobalHooksJsonContent("/tmp/notify.sh");
if (!content) throw new Error("expected hooks content");
const hooks = JSON.parse(content).hooks;

expect(hooks.PreToolUse).toContainEqual({
matcher: "^request_user_input$",
hooks: [{ type: "command", command }],
});
expect(hooks.PostToolUse).toContainEqual({
matcher: "*",
hooks: [{ type: "command", command }],
});
});
});
Loading