Repository navigation
fix(agent): keep a catbus tab's session through restarts, and make claude-only agent-only - #70
Conversation
…aude-only agent-only A catbus tab came back from a restart on the wrong session, or as a bare shell, because other processes in the tab spoke for it: - every catbus-agent run reported its own session id, including a --prompt-file review started by a git hook, a --once run and a spawned sub-agent; only the interactive session reports now - a claude started inside a catbus tab fires the system-wide Claude hooks: its SessionStart replaced the tab's session id (and, on the desktop, its kind) and its SessionEnd wiped the attachment. Both owners now share one rule that refuses a wrapped agent's word on the attachment, and session-end names its kind so the wipe can be refused The claude-only setting becomes agent-only and takes claude or catbus: preference agent_only, flag --agent-only <agent>, verb agent-only claude|catbus|off, POST /agent-only, and one menu entry per agent. The old names are removed; a preferences file with claude_only: true is read as agent_only: claude. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G6dpqPucDGns6rELSQeSdr
| use std::sync::atomic::{AtomicBool, Ordering}; | ||
| use std::time::Duration; | ||
|
|
||
| /// Set once at start-up by a process that is in a tab without being the tab's agent. |
There was a problem hiding this comment.
What if user does mix no tui sessions and normal dessions in the tab lifetime?
Does it stay coherent?
There was a problem hiding this comment.
Not fully, as first pushed — good catch. Three cases:
- One after another (TUI session ends, then a
--no-tuione starts, or the reverse): coherent. The last one started is the tab's session. One caveat that this PR does not change: the app restores withcatbus-agent --resume <id>only, so a--no-tuisession comes back with its conversation but as a TUI. - A
--no-tuisession started behind the tab's agent (from a tool call, say): this was broken. Both reported, and each took the tab's session id back on its next turn. Fixed in 1b992a3: only a session whose stdin is the tab's terminal reports (owns_the_tabnow takeson_terminal). 9f6bbe1 gives the existing abandoned-turn test's agent a terminal, since it models a tab's own process. - Two sessions that both hold the terminal (one backgrounded with
&in the tab's shell): still last-report-wins. I left that alone; telling them apart needs the foreground process group, which meansunsafeor a new dependency in a crate that deniesunsafe.
catbus-agent: clippy clean, 649 tests pass.
Generated by Claude Code
… tab A --no-tui session started behind the tab's own agent, from a tool call, inherits the tab's environment and reported its own session id. The two then traded the tab's session back and forth, each taking it on its next turn. A session whose stdin is not a terminal is not the one a person is at, so it stays silent. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G6dpqPucDGns6rELSQeSdr
The test's agent reports to the app as a tab's own process would, and only a session holding the tab's terminal speaks for the tab now. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G6dpqPucDGns6rELSQeSdr
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #70 +/- ##
========================================
Coverage 80.28% 80.29%
========================================
Files 248 248
Lines 76107 76232 +125
========================================
+ Hits 61103 61207 +104
- Misses 15004 15025 +21
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Generated by Claude Code |
Catbus tabs were not restored
A catbus tab came back from a restart on the wrong session, or as a bare shell, because other processes running in the tab spoke for it.
--prompt-filereview started by a git hook, a--oncerun and a spawned sub-agent each inherit the tab's environment and mint their own session id, so each replaced the id the app resumes with. Only the interactive session reports now (applink::owns_the_tab).--no-tuisessions still report, since a tab can host one.claudestarted inside a catbus tab fires the system-wide Claude hooks. ItsSessionStartreplaced the tab's session id (and, on the desktop, its kind), and itsSessionEndwiped the attachment. The GUI and headless owners now share one rule,report_may_touch_attachment, which refuses a wrapped agent's word on the attachment; the GUI had no guard before.claude-hook session-endnow names its kind so the wipe can be refused, and the status endpoint keeps the reporter's kind on a wipe for that purpose.catbus-agent still does not execute the
/etc/claude-codehooks: they would stamp the tab asclaudeand resume the wrong binary.Claude-only becomes agent-only
The setting now takes
claudeorcatbus.agent_only: "claude" | "catbus"--agent-only <claude|catbus>agent-only claude|catbus|offPOST /agent-onlywith{"agent": "claude"|"catbus"|"off"}The old names (
--claude-only,claude-only on|off,POST /claude-only) are removed, not aliased. A preferences file withclaude_only: trueis read asagent_only: "claude"and the old key is not written back.Verification
cargo test(GUI default): 1572 passed, 0 failedcargo test --no-default-features --features headless,energy,catbus: 1464 passed, 0 failedcargo test -p catbus-agent: all passedcargo clippy --all-targets: clean for the code touched here. With the newer toolchain this was run on, it still fails on four older lints in files this PR does not change (tab-atelier-api/src/respond.rs,catbus-agent/src/cost.rs,src/api.rs:3933,examples/transcript-compact.rs); not checked on the pinned rustc 1.92.The app itself was not launched.
Generated by Claude Code