Repository navigation
Conversation
…rrupt TUIs Hooks run as children of TUI agents (opencode, claude, gemini) with stdio inherited from the PTY, so the dev-mode stderr echoes in notify-hook (and an ungated failure echo in gemini-hook) printed at the cursor position and corrupted diff-rendered screens with interleaved log fragments. Route all diagnostics to the existing debug_log file channel (/tmp/superset-agent-hooks.log), fold the duplicated debug/non-debug v1 dispatch branches into one, and add a regression test that no hook template writes to stderr.
|
Ready to review this PR? Stage has broken it down into 3 individual chapters for you:
Chapters generated by Stage for commit 819d943 on Jul 12, 2026 5:15pm UTC. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughHook templates now route diagnostics to configurable log files instead of stdout or stderr, while retaining host-service and v1 fallback dispatches. Tests cover detailed debug payloads and prevent stderr redirection. ChangesHook diagnostic logging
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR moves agent hook diagnostics out of the TUI PTY. The main changes are:
Confidence Score: 5/5This looks safe to merge.
|
| Filename | Overview |
|---|---|
| apps/desktop/src/main/lib/agent-setup/templates/notify-hook.template.sh | Moves notify-hook diagnostics to debug_log and keeps v1/v2 dispatch behavior intact. |
| apps/desktop/src/main/lib/agent-setup/templates/gemini-hook.template.sh | Moves Gemini fallback diagnostics from stderr to the debug log while preserving required stdout output. |
| apps/desktop/src/main/lib/agent-setup/notify-hook.test.ts | Updates debug-log expectations and adds coverage for direct stderr redirection in hook templates. |
Reviews (1): Last reviewed commit: "fix(desktop): keep agent hook debug logs..." | Re-trigger Greptile
Summary
[notify-hook]lines and orphaned text fragments overlaying the UI.debug_logfile channel (/tmp/superset-agent-hooks.log, overridable viaSUPERSET_HOOK_DEBUG_LOG). No hook template writes to stdout/stderr anymore (gemini-hook still prints its protocol-required{}JSON to stdout).Why / Context
notify-hook.template.shauto-enables debug output whenSUPERSET_ENV=development, and its stderr echoes were exact duplicates of thedebug_logfile writes next to them. In dev builds, every agent lifecycle event (Start/Stop/PermissionRequest) sprayed log lines into the agent's TUI. Diff-rendering TUIs never recover from foreign writes: they repaint only cells they believe changed, so hook text persists as garbage and bottom-row writes desync their screen model by one line.gemini-hook.template.shadditionally had an ungated stderr echo on its v2→v1 fallback path that fired even in production.How It Works
notify-hook.template.sh: dropped the three stderr echoes; the event-receiveddebug_logline now carries the full field set the echo had (addspaneId,workspaceId). The v1 dispatch was duplicated into debug/non-debug branches solely so debug mode could echo the status code — collapsed to a single branch that always captures the status anddebug_logs it.gemini-hook.template.sh: the fallback echo now appends to the same log file (unconditional, since it's a rare failure-path signal).>&2.Debugging workflow is unchanged in capability:
tail -f /tmp/superset-agent-hooks.loginstead of reading interleaved (and mangled) lines inside the TUI.Manual QA
{{MARKER}}/{{DEFAULT_PORT}}substituted) and executed it with a fake Stop payload:SUPERSET_DEBUG_HOOKS=1: stdout+stderr empty, log file receives the event line (full field set) and dispatch status linebash -non both modified templates.createNotifyScript()rewrites the installednotify.shon next app launch via content comparison (no marker bump needed — hook semantics unchanged, wire payloads identical).Testing
bun test src/main/lib/agent-setup(73 pass, includes new no-stderr regression test)bun run lintbun run typecheck(desktop)Known Limitations
hookSessionId/resourceId) parse as empty in the notify hook — pre-existing and unrelated to the logging channel; the Stop event still dispatches. Worth a separate ticket.Summary by cubic
Keep agent hook debug output off the PTY to stop corrupting diff-rendered TUIs. All diagnostics now go to the hook debug log file instead of stdout/stderr.
notify-hook.template.shandgemini-hook.template.sh; diagnostics append to${SUPERSET_HOOK_DEBUG_LOG:-/tmp/superset-agent-hooks.log}. Gemini still prints only the required JSON to stdout.notify-hookv1 dispatch into a single path and logged status with more context fields (paneId,workspaceId, etc.).>&2) and updated expectations for the notify script content.Written for commit 819d943. Summary will update on new commits.
Summary by CodeRabbit