Disable shell execution hooks to fix broken notifications
beforeShellExecution in hooks.json required a JSON response we never provided, likely causing Cursor to silently break the entire hook pipeline. Commenting out those entries (and afterShellExecution) from HOOKS_CONFIG restores reliable preToolUse/postToolUse delivery. All Python handler code is retained as dead code for reference. Also reverts the is_cursor_frontmost() gate in _check_pending — pulses should fire unconditionally when the approval delay expires. Made-with: Cursor
This commit is contained in:
@@ -607,3 +607,45 @@ class TestFlasherDaemon:
|
||||
)
|
||||
assert "/a" not in daemon._pending_approvals
|
||||
assert "/b" in daemon._pending_approvals
|
||||
|
||||
# --- shellApproved / shellCompleted (disabled, debug-logged only) ---
|
||||
|
||||
def test_shellApproved_does_not_cancel_pending(self):
|
||||
"""shellApproved is a no-op — pending approval must survive."""
|
||||
daemon = self._make_daemon(approval_delay=10.0)
|
||||
|
||||
daemon._handle_message(
|
||||
json.dumps({"workspace": "/path", "event": "preToolUse", "tool": "Shell"}).encode()
|
||||
)
|
||||
assert "/path" in daemon._pending_approvals
|
||||
|
||||
daemon._handle_message(
|
||||
json.dumps({"workspace": "/path", "event": "shellApproved", "tool": "Shell"}).encode()
|
||||
)
|
||||
assert "/path" in daemon._pending_approvals
|
||||
|
||||
def test_shellCompleted_does_not_dismiss(self):
|
||||
"""shellCompleted is a no-op — active pulse must survive."""
|
||||
daemon = self._make_daemon()
|
||||
daemon._active_pulses["/path"] = MagicMock()
|
||||
|
||||
daemon._handle_message(
|
||||
json.dumps({"workspace": "/path", "event": "shellCompleted", "tool": "Shell"}).encode()
|
||||
)
|
||||
|
||||
daemon.overlay.dismiss_tag.assert_not_called()
|
||||
assert "/path" in daemon._active_pulses
|
||||
|
||||
def test_shellCompleted_does_not_cancel_pending(self):
|
||||
"""shellCompleted is a no-op — pending approval must survive."""
|
||||
daemon = self._make_daemon(approval_delay=10.0)
|
||||
|
||||
daemon._handle_message(
|
||||
json.dumps({"workspace": "/path", "event": "preToolUse", "tool": "Shell"}).encode()
|
||||
)
|
||||
assert "/path" in daemon._pending_approvals
|
||||
|
||||
daemon._handle_message(
|
||||
json.dumps({"workspace": "/path", "event": "shellCompleted", "tool": "Shell"}).encode()
|
||||
)
|
||||
assert "/path" in daemon._pending_approvals
|
||||
|
||||
@@ -103,3 +103,74 @@ class TestHookNotify:
|
||||
os.unlink(sock_path)
|
||||
|
||||
assert received[0]["workspace"] == ""
|
||||
|
||||
def test_beforeShellExecution_mapped_to_shellApproved(self):
|
||||
sock_path = _short_sock_path()
|
||||
received = []
|
||||
|
||||
server = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
server.bind(sock_path)
|
||||
server.listen(1)
|
||||
|
||||
def accept():
|
||||
conn, _ = server.accept()
|
||||
data = conn.recv(4096)
|
||||
received.append(json.loads(data))
|
||||
conn.close()
|
||||
|
||||
t = threading.Thread(target=accept)
|
||||
t.start()
|
||||
|
||||
try:
|
||||
hook_input = json.dumps({
|
||||
"workspace_roots": ["/Users/me/project"],
|
||||
"hook_event_name": "beforeShellExecution",
|
||||
"command": "npm install",
|
||||
})
|
||||
_run_hook_main(hook_input, sock_path)
|
||||
t.join(timeout=2)
|
||||
finally:
|
||||
server.close()
|
||||
if os.path.exists(sock_path):
|
||||
os.unlink(sock_path)
|
||||
|
||||
assert len(received) == 1
|
||||
assert received[0]["event"] == "shellApproved"
|
||||
assert received[0]["tool"] == "Shell"
|
||||
assert received[0]["workspace"] == "/Users/me/project"
|
||||
|
||||
def test_afterShellExecution_mapped_to_shellCompleted(self):
|
||||
sock_path = _short_sock_path()
|
||||
received = []
|
||||
|
||||
server = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
server.bind(sock_path)
|
||||
server.listen(1)
|
||||
|
||||
def accept():
|
||||
conn, _ = server.accept()
|
||||
data = conn.recv(4096)
|
||||
received.append(json.loads(data))
|
||||
conn.close()
|
||||
|
||||
t = threading.Thread(target=accept)
|
||||
t.start()
|
||||
|
||||
try:
|
||||
hook_input = json.dumps({
|
||||
"workspace_roots": ["/Users/me/project"],
|
||||
"hook_event_name": "afterShellExecution",
|
||||
"command": "npm install",
|
||||
"output": "added 100 packages",
|
||||
"duration": 5432,
|
||||
})
|
||||
_run_hook_main(hook_input, sock_path)
|
||||
t.join(timeout=2)
|
||||
finally:
|
||||
server.close()
|
||||
if os.path.exists(sock_path):
|
||||
os.unlink(sock_path)
|
||||
|
||||
assert len(received) == 1
|
||||
assert received[0]["event"] == "shellCompleted"
|
||||
assert received[0]["tool"] == "Shell"
|
||||
|
||||
Reference in New Issue
Block a user