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
7 changes: 5 additions & 2 deletions CLI/cmux.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28512,8 +28512,11 @@ struct CMUXCLI {
// the ~60s-later idle_prompt Notification can consult it, and forwarded
// to the app so it can suppress the done-ping until work truly drains.
let hasPendingBackgroundWork = hasActiveClaudeBackgroundWork(parsedInput)
let hasUnsettledWork = stopFailure == nil && (hasPendingBackgroundWork
|| parsedInput.rawObject?["stop_hook_active"] as? Bool == true)
// Claude sets stop_hook_active on a re-entry after a Stop hook
// blocked once. That flag describes hook recursion, not work
// still running; only authoritative background-work signals
// should keep the sidebar in Running.
let hasUnsettledWork = stopFailure == nil && hasPendingBackgroundWork

// Update session with transcript summary and send completion notification.
let completion = stopFailure.map(claudeStopFailureSummary) ?? summarizeClaudeHookStop(
Expand Down
11 changes: 10 additions & 1 deletion tests/test_claude_hook_stop_last_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,13 @@ def main() -> int:
payload = {
"session_id": f"sess-{uuid.uuid4().hex}",
"hook_event_name": "Stop",
"stop_hook_active": True,
"cwd": "/Users/lawrence/fun",
"last_assistant_message": "2",
}

with CapturingSocketServer(workspace_id=workspace_id, surface_id=surface_id) as server:
env = os.environ.copy()
env = {key: value for key, value in os.environ.items() if not key.startswith("CMUX_")}
env["CMUX_SOCKET_PATH"] = server.socket_path
env["CMUX_WORKSPACE_ID"] = workspace_id
env["CMUX_SURFACE_ID"] = surface_id
Expand Down Expand Up @@ -262,6 +263,14 @@ def main() -> int:
if notifications[0] != expected:
print(f"FAIL: incorrect semantic completion: {notifications[0]!r}")
return 1
if not any(
command.startswith("set_status claude_code Idle ")
and f"--tab={workspace_id}" in command
and f"--panel={surface_id}" in command
for command in server.commands
):
print(f"FAIL: final Stop with stop_hook_active=true did not settle Idle: {server.commands!r}")
return 1

print("PASS: Claude cron guard denies durable jobs and Stop notification uses final assistant text")
return 0
Expand Down
Loading