feat: add worktree isolation support and hook event display

Closes #152, closes #150

- Add use_worktree bool to ClaudeStartOptions and HikariConfig (Rust + TS)
- Pass --worktree flag to claude in both WSL and non-WSL command paths
- Detect WorktreeCreate/WorktreeRemove hook events in stderr handler
- Emit worktree events with distinct line_type instead of error
- Add worktree line type to TerminalLine union, Terminal rendering, and tests
- Display worktree events in green with [worktree] prefix
- Add worktree isolation toggle to Agent Settings section of ConfigSidebar
- Thread use_worktree through all seven start_claude call sites
This commit is contained in:
2026-02-24 17:39:09 -08:00
committed by Naomi Carrigan
parent 108a1b16b2
commit 54280b3920
14 changed files with 83 additions and 5 deletions
+8
View File
@@ -25,6 +25,9 @@ pub struct ClaudeStartOptions {
#[serde(default)]
pub resume_session_id: Option<String>,
#[serde(default)]
pub use_worktree: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -113,6 +116,9 @@ pub struct HikariConfig {
#[serde(default = "default_discord_rpc_enabled")]
pub discord_rpc_enabled: bool,
#[serde(default)]
pub use_worktree: bool,
}
impl Default for HikariConfig {
@@ -145,6 +151,7 @@ impl Default for HikariConfig {
budget_action: BudgetAction::Warn,
budget_warning_threshold: 0.8,
discord_rpc_enabled: true,
use_worktree: false,
}
}
}
@@ -284,6 +291,7 @@ mod tests {
budget_action: BudgetAction::Block,
budget_warning_threshold: 0.75,
discord_rpc_enabled: true,
use_worktree: true,
};
let json = serde_json::to_string(&config).unwrap();
+19 -2
View File
@@ -265,6 +265,11 @@ impl WslBridge {
}
}
// Add worktree flag if requested
if options.use_worktree {
cmd.arg("--worktree");
}
cmd.current_dir(working_dir);
// Set API key as environment variable if specified
@@ -351,6 +356,11 @@ impl WslBridge {
}
}
// Add worktree flag if requested
if options.use_worktree {
claude_cmd.push_str(" --worktree");
}
// Use bash -lc to load login profile (ensures PATH includes claude)
cmd.args(["-e", "bash", "-lc", &claude_cmd]);
@@ -751,11 +761,18 @@ fn handle_stderr(
}
}
// Still emit the stderr line as output
// Worktree hook events are informational — emit with a distinct type
let is_worktree_event = line.contains("[WorktreeCreate Hook]")
|| line.contains("[WorktreeRemove Hook]");
let _ = app.emit(
"claude:output",
OutputEvent {
line_type: "error".to_string(),
line_type: if is_worktree_event {
"worktree".to_string()
} else {
"error".to_string()
},
content: line,
tool_name: None,
conversation_id: conversation_id.clone(),