* fix: prevent state commands from starting daemon without session_name (#677) State management commands (state_list, state_show, state_clear, state_clean, state_rename) are pure file operations that don't need a running daemon. Previously, these commands would trigger daemon startup via ensure_daemon(), and if AGENT_BROWSER_SESSION_NAME was exported after the first command (e.g. `state clear --all`), the daemon would start without session_name. Subsequent open/close commands would reuse that daemon, causing close to skip state persistence entirely. Fix: execute state management commands locally in the CLI process before ensure_daemon() is called. This is done via a new dispatch_state_command() function in state.rs that centralizes the command routing, used by both the CLI (local path) and the daemon (batch/IPC path). Also: - Add OutputOptions::from_flags() helper to deduplicate construction - Add unit tests for dispatch_state_command routing and error handling * style: fix fmt and clippy warnings - Remove redundant closure in dispatch_state_command (clippy::redundant_closure) - Remove needless borrow in run_batch (clippy::needless_borrow) - Fix trailing blank lines (rustfmt) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: hyunjinee <leehj0110@kakao.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
hyunjinee
parent
d374e413be
commit
9c0955ca99
@@ -23,6 +23,16 @@ pub struct OutputOptions {
|
||||
pub max_output: Option<usize>,
|
||||
}
|
||||
|
||||
impl OutputOptions {
|
||||
pub fn from_flags(flags: &crate::flags::Flags) -> Self {
|
||||
Self {
|
||||
json: flags.json,
|
||||
content_boundaries: flags.content_boundaries,
|
||||
max_output: flags.max_output,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn truncate_if_needed(content: &str, max: Option<usize>) -> String {
|
||||
let Some(limit) = max else {
|
||||
return content.to_string();
|
||||
|
||||
Reference in New Issue
Block a user