generated from nhcarrigan/template
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9e2f2912bc | |||
| ca08b990d8 | |||
| 1fe39bbbc1 |
@@ -28,6 +28,9 @@ pub struct ClaudeStartOptions {
|
|||||||
|
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub use_worktree: bool,
|
pub use_worktree: bool,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
|
pub disable_1m_context: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
@@ -119,6 +122,9 @@ pub struct HikariConfig {
|
|||||||
|
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub use_worktree: bool,
|
pub use_worktree: bool,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
|
pub disable_1m_context: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for HikariConfig {
|
impl Default for HikariConfig {
|
||||||
@@ -152,6 +158,7 @@ impl Default for HikariConfig {
|
|||||||
budget_warning_threshold: 0.8,
|
budget_warning_threshold: 0.8,
|
||||||
discord_rpc_enabled: true,
|
discord_rpc_enabled: true,
|
||||||
use_worktree: false,
|
use_worktree: false,
|
||||||
|
disable_1m_context: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,6 +266,8 @@ mod tests {
|
|||||||
assert_eq!(config.budget_action, BudgetAction::Warn);
|
assert_eq!(config.budget_action, BudgetAction::Warn);
|
||||||
assert!((config.budget_warning_threshold - 0.8).abs() < f32::EPSILON);
|
assert!((config.budget_warning_threshold - 0.8).abs() < f32::EPSILON);
|
||||||
assert!(config.discord_rpc_enabled);
|
assert!(config.discord_rpc_enabled);
|
||||||
|
assert!(!config.use_worktree);
|
||||||
|
assert!(!config.disable_1m_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -292,6 +301,7 @@ mod tests {
|
|||||||
budget_warning_threshold: 0.75,
|
budget_warning_threshold: 0.75,
|
||||||
discord_rpc_enabled: true,
|
discord_rpc_enabled: true,
|
||||||
use_worktree: true,
|
use_worktree: true,
|
||||||
|
disable_1m_context: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let json = serde_json::to_string(&config).unwrap();
|
let json = serde_json::to_string(&config).unwrap();
|
||||||
|
|||||||
@@ -305,6 +305,8 @@ pub struct AgentEndEvent {
|
|||||||
pub duration_ms: Option<u64>,
|
pub duration_ms: Option<u64>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub num_turns: Option<u32>,
|
pub num_turns: Option<u32>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub last_assistant_message: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
|||||||
+212
-13
@@ -279,6 +279,11 @@ impl WslBridge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disable 1M context window if requested
|
||||||
|
if options.disable_1m_context {
|
||||||
|
cmd.env("CLAUDE_CODE_DISABLE_1M_CONTEXT", "1");
|
||||||
|
}
|
||||||
|
|
||||||
cmd
|
cmd
|
||||||
} else {
|
} else {
|
||||||
// Running on Windows - use wsl with bash login shell to ensure PATH is loaded
|
// Running on Windows - use wsl with bash login shell to ensure PATH is loaded
|
||||||
@@ -319,6 +324,11 @@ impl WslBridge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disable 1M context window if requested
|
||||||
|
if options.disable_1m_context {
|
||||||
|
claude_cmd.push_str("CLAUDE_CODE_DISABLE_1M_CONTEXT=1 ");
|
||||||
|
}
|
||||||
|
|
||||||
claude_cmd.push_str(
|
claude_cmd.push_str(
|
||||||
"claude --output-format stream-json --input-format stream-json --verbose",
|
"claude --output-format stream-json --input-format stream-json --verbose",
|
||||||
);
|
);
|
||||||
@@ -755,6 +765,7 @@ fn handle_stderr(
|
|||||||
conversation_id: conversation_id.clone(),
|
conversation_id: conversation_id.clone(),
|
||||||
duration_ms: None,
|
duration_ms: None,
|
||||||
num_turns: None,
|
num_turns: None,
|
||||||
|
last_assistant_message: stop_data.last_assistant_message,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -828,27 +839,78 @@ fn parse_subagent_start_hook(line: &str) -> Option<SubagentStartData> {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct SubagentStopData {
|
struct SubagentStopData {
|
||||||
parent_tool_use_id: Option<String>,
|
parent_tool_use_id: Option<String>,
|
||||||
|
last_assistant_message: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Extracts the content of a Rust Debug-formatted `Some("...")` field from a hook line.
|
||||||
|
/// Handles escaped characters (e.g. `\"` → `"`, `\\` → `\`, `\n` → newline).
|
||||||
|
/// Returns `None` if the field is absent or formatted as `None`.
|
||||||
|
fn extract_debug_string_value(line: &str, key: &str) -> Option<String> {
|
||||||
|
let prefix = format!("{}=Some(\"", key);
|
||||||
|
let start_idx = line.find(&prefix)? + prefix.len();
|
||||||
|
let rest = &line[start_idx..];
|
||||||
|
|
||||||
|
let mut result = String::new();
|
||||||
|
let mut chars = rest.chars();
|
||||||
|
loop {
|
||||||
|
match chars.next() {
|
||||||
|
Some('"') => return Some(result),
|
||||||
|
Some('\\') => match chars.next() {
|
||||||
|
Some('n') => result.push('\n'),
|
||||||
|
Some('t') => result.push('\t'),
|
||||||
|
Some('"') => result.push('"'),
|
||||||
|
Some('\\') => result.push('\\'),
|
||||||
|
Some(c) => {
|
||||||
|
result.push('\\');
|
||||||
|
result.push(c);
|
||||||
|
}
|
||||||
|
None => break,
|
||||||
|
},
|
||||||
|
Some(c) => result.push(c),
|
||||||
|
None => break,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_subagent_stop_hook(line: &str) -> Option<SubagentStopData> {
|
fn parse_subagent_stop_hook(line: &str) -> Option<SubagentStopData> {
|
||||||
// Parse: [SubagentStop Hook] ... parent_tool_use_id=Some("toolu_xxx"), ...
|
// Parse: [SubagentStop Hook] ... parent_tool_use_id=Some("toolu_xxx"), last_assistant_message=Some("..."), ...
|
||||||
|
|
||||||
// Extract parent_tool_use_id if present
|
let parent_tool_use_id = extract_debug_string_value(line, "parent_tool_use_id");
|
||||||
let parent_tool_use_id = if line.contains("parent_tool_use_id=Some") {
|
let last_assistant_message = extract_debug_string_value(line, "last_assistant_message");
|
||||||
line.split("parent_tool_use_id=Some(\"")
|
|
||||||
.nth(1)?
|
|
||||||
.split('"')
|
|
||||||
.next()
|
|
||||||
.map(|s| s.to_string())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
Some(SubagentStopData {
|
Some(SubagentStopData {
|
||||||
parent_tool_use_id,
|
parent_tool_use_id,
|
||||||
|
last_assistant_message,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Extract text content from a ToolResult's `content` field.
|
||||||
|
/// The content may be a JSON string or an array of typed content blocks.
|
||||||
|
fn extract_tool_result_text(content: &serde_json::Value) -> Option<String> {
|
||||||
|
match content {
|
||||||
|
serde_json::Value::String(s) if !s.is_empty() => Some(s.clone()),
|
||||||
|
serde_json::Value::Array(blocks) => {
|
||||||
|
let texts: Vec<String> = blocks
|
||||||
|
.iter()
|
||||||
|
.filter_map(|block| {
|
||||||
|
if block.get("type")?.as_str()? == "text" {
|
||||||
|
block.get("text")?.as_str().map(String::from)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
if texts.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(texts.join("\n"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn process_json_line(
|
fn process_json_line(
|
||||||
line: &str,
|
line: &str,
|
||||||
app: &AppHandle,
|
app: &AppHandle,
|
||||||
@@ -1150,8 +1212,8 @@ fn process_json_line(
|
|||||||
}
|
}
|
||||||
ContentBlock::ToolResult {
|
ContentBlock::ToolResult {
|
||||||
tool_use_id,
|
tool_use_id,
|
||||||
|
content,
|
||||||
is_error,
|
is_error,
|
||||||
..
|
|
||||||
} => {
|
} => {
|
||||||
// Emit agent-end for all tool results
|
// Emit agent-end for all tool results
|
||||||
// The frontend will ignore IDs that don't match known agents
|
// The frontend will ignore IDs that don't match known agents
|
||||||
@@ -1169,6 +1231,7 @@ fn process_json_line(
|
|||||||
conversation_id: conversation_id.clone(),
|
conversation_id: conversation_id.clone(),
|
||||||
duration_ms: None,
|
duration_ms: None,
|
||||||
num_turns: None,
|
num_turns: None,
|
||||||
|
last_assistant_message: extract_tool_result_text(content),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1586,8 +1649,8 @@ fn process_json_line(
|
|||||||
for block in &message.content {
|
for block in &message.content {
|
||||||
if let ContentBlock::ToolResult {
|
if let ContentBlock::ToolResult {
|
||||||
tool_use_id,
|
tool_use_id,
|
||||||
|
content,
|
||||||
is_error,
|
is_error,
|
||||||
..
|
|
||||||
} = block
|
} = block
|
||||||
{
|
{
|
||||||
let now = SystemTime::now()
|
let now = SystemTime::now()
|
||||||
@@ -1604,6 +1667,7 @@ fn process_json_line(
|
|||||||
conversation_id: conversation_id.clone(),
|
conversation_id: conversation_id.clone(),
|
||||||
duration_ms: None,
|
duration_ms: None,
|
||||||
num_turns: None,
|
num_turns: None,
|
||||||
|
last_assistant_message: extract_tool_result_text(content),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -2155,5 +2219,140 @@ mod tests {
|
|||||||
assert!(result.is_some());
|
assert!(result.is_some());
|
||||||
let data = result.unwrap();
|
let data = result.unwrap();
|
||||||
assert_eq!(data.parent_tool_use_id, None);
|
assert_eq!(data.parent_tool_use_id, None);
|
||||||
|
assert_eq!(data.last_assistant_message, None);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse_subagent_stop_hook_with_last_message() {
|
||||||
|
let line = r#"[SubagentStop Hook] stop_hook_active=true, parent_tool_use_id=Some("toolu_01ABC123"), last_assistant_message=Some("Task completed successfully."), session_id=123"#;
|
||||||
|
let result = parse_subagent_stop_hook(line);
|
||||||
|
|
||||||
|
assert!(result.is_some());
|
||||||
|
let data = result.unwrap();
|
||||||
|
assert_eq!(data.parent_tool_use_id, Some("toolu_01ABC123".to_string()));
|
||||||
|
assert_eq!(
|
||||||
|
data.last_assistant_message,
|
||||||
|
Some("Task completed successfully.".to_string())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse_subagent_stop_hook_with_last_message_none() {
|
||||||
|
let line = r#"[SubagentStop Hook] stop_hook_active=true, parent_tool_use_id=Some("toolu_01ABC123"), last_assistant_message=None, session_id=123"#;
|
||||||
|
let result = parse_subagent_stop_hook(line);
|
||||||
|
|
||||||
|
assert!(result.is_some());
|
||||||
|
let data = result.unwrap();
|
||||||
|
assert_eq!(data.last_assistant_message, None);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_extract_debug_string_value_simple() {
|
||||||
|
let line = r#"key=Some("hello world")"#;
|
||||||
|
assert_eq!(
|
||||||
|
extract_debug_string_value(line, "key"),
|
||||||
|
Some("hello world".to_string())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_extract_debug_string_value_with_escaped_quotes() {
|
||||||
|
let line = r#"key=Some("say \"hi\" there")"#;
|
||||||
|
assert_eq!(
|
||||||
|
extract_debug_string_value(line, "key"),
|
||||||
|
Some(r#"say "hi" there"#.to_string())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_extract_debug_string_value_none_variant() {
|
||||||
|
let line = "key=None";
|
||||||
|
assert_eq!(extract_debug_string_value(line, "key"), None);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_extract_debug_string_value_missing_key() {
|
||||||
|
let line = "other=Some(\"value\")";
|
||||||
|
assert_eq!(extract_debug_string_value(line, "key"), None);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse_subagent_stop_hook_with_commas_in_message() {
|
||||||
|
let line = r#"[SubagentStop Hook] parent_tool_use_id=Some("toolu_01"), last_assistant_message=Some("Found 3 files, all passing.")"#;
|
||||||
|
let result = parse_subagent_stop_hook(line);
|
||||||
|
|
||||||
|
assert!(result.is_some());
|
||||||
|
let data = result.unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
data.last_assistant_message,
|
||||||
|
Some("Found 3 files, all passing.".to_string())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// extract_tool_result_text tests
|
||||||
|
#[test]
|
||||||
|
fn test_extract_tool_result_text_plain_string() {
|
||||||
|
let content = serde_json::json!("Hello from agent");
|
||||||
|
assert_eq!(
|
||||||
|
extract_tool_result_text(&content),
|
||||||
|
Some("Hello from agent".to_string())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_extract_tool_result_text_empty_string() {
|
||||||
|
let content = serde_json::json!("");
|
||||||
|
assert_eq!(extract_tool_result_text(&content), None);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_extract_tool_result_text_array_single_text_block() {
|
||||||
|
let content = serde_json::json!([{"type": "text", "text": "Agent completed the task."}]);
|
||||||
|
assert_eq!(
|
||||||
|
extract_tool_result_text(&content),
|
||||||
|
Some("Agent completed the task.".to_string())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_extract_tool_result_text_array_multiple_text_blocks() {
|
||||||
|
let content = serde_json::json!([
|
||||||
|
{"type": "text", "text": "First part."},
|
||||||
|
{"type": "text", "text": "Second part."}
|
||||||
|
]);
|
||||||
|
assert_eq!(
|
||||||
|
extract_tool_result_text(&content),
|
||||||
|
Some("First part.\nSecond part.".to_string())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_extract_tool_result_text_array_non_text_block() {
|
||||||
|
let content = serde_json::json!([{"type": "image", "source": {"type": "base64"}}]);
|
||||||
|
assert_eq!(extract_tool_result_text(&content), None);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_extract_tool_result_text_array_mixed_blocks() {
|
||||||
|
let content = serde_json::json!([
|
||||||
|
{"type": "image", "source": {}},
|
||||||
|
{"type": "text", "text": "Found results."}
|
||||||
|
]);
|
||||||
|
assert_eq!(
|
||||||
|
extract_tool_result_text(&content),
|
||||||
|
Some("Found results.".to_string())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_extract_tool_result_text_null() {
|
||||||
|
let content = serde_json::Value::Null;
|
||||||
|
assert_eq!(extract_tool_result_text(&content), None);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_extract_tool_result_text_empty_array() {
|
||||||
|
let content = serde_json::json!([]);
|
||||||
|
assert_eq!(extract_tool_result_text(&content), None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ async function changeDirectory(path: string): Promise<void> {
|
|||||||
mcp_servers_json: config.mcp_servers_json || null,
|
mcp_servers_json: config.mcp_servers_json || null,
|
||||||
allowed_tools: allAllowedTools,
|
allowed_tools: allAllowedTools,
|
||||||
use_worktree: config.use_worktree ?? false,
|
use_worktree: config.use_worktree ?? false,
|
||||||
|
disable_1m_context: config.disable_1m_context ?? false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -137,6 +138,7 @@ async function startNewConversation(): Promise<void> {
|
|||||||
mcp_servers_json: config.mcp_servers_json || null,
|
mcp_servers_json: config.mcp_servers_json || null,
|
||||||
allowed_tools: allAllowedTools,
|
allowed_tools: allAllowedTools,
|
||||||
use_worktree: config.use_worktree ?? false,
|
use_worktree: config.use_worktree ?? false,
|
||||||
|
disable_1m_context: config.disable_1m_context ?? false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -318,6 +318,16 @@
|
|||||||
<span class="text-[10px] text-red-400">Errored / Killed</span>
|
<span class="text-[10px] text-red-400">Errored / Killed</span>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Last assistant message snippet -->
|
||||||
|
{#if agent.lastAssistantMessage}
|
||||||
|
<p
|
||||||
|
class="mt-1 text-[10px] text-[var(--text-secondary)] italic truncate"
|
||||||
|
title={agent.lastAssistantMessage}
|
||||||
|
>
|
||||||
|
{agent.lastAssistantMessage}
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
discord_rpc_enabled: true,
|
discord_rpc_enabled: true,
|
||||||
show_thinking_blocks: true,
|
show_thinking_blocks: true,
|
||||||
use_worktree: false,
|
use_worktree: false,
|
||||||
|
disable_1m_context: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
let showCustomThemeEditor = $state(false);
|
let showCustomThemeEditor = $state(false);
|
||||||
@@ -489,6 +490,22 @@
|
|||||||
Launch sessions with <code class="font-mono">--worktree</code> for isolated git worktree environments
|
Launch sessions with <code class="font-mono">--worktree</code> for isolated git worktree environments
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Disable 1M Context Window -->
|
||||||
|
<div class="mb-4">
|
||||||
|
<label class="flex items-center gap-3 cursor-pointer">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
bind:checked={config.disable_1m_context}
|
||||||
|
class="w-4 h-4 rounded border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--accent-primary)] focus:ring-[var(--accent-primary)]"
|
||||||
|
/>
|
||||||
|
<span class="text-sm text-[var(--text-primary)]">Disable 1M context window</span>
|
||||||
|
</label>
|
||||||
|
<p class="text-xs text-[var(--text-tertiary)] mt-1 ml-7">
|
||||||
|
Sets <code class="font-mono">CLAUDE_CODE_DISABLE_1M_CONTEXT=1</code> to opt out of the extended
|
||||||
|
context window
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- Greeting Section -->
|
<!-- Greeting Section -->
|
||||||
|
|||||||
@@ -363,6 +363,7 @@ User: ${formattedMessage}`;
|
|||||||
mcp_servers_json: config.mcp_servers_json || null,
|
mcp_servers_json: config.mcp_servers_json || null,
|
||||||
allowed_tools: allAllowedTools,
|
allowed_tools: allAllowedTools,
|
||||||
use_worktree: config.use_worktree ?? false,
|
use_worktree: config.use_worktree ?? false,
|
||||||
|
disable_1m_context: config.disable_1m_context ?? false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,7 @@
|
|||||||
mcp_servers_json: config.mcp_servers_json || null,
|
mcp_servers_json: config.mcp_servers_json || null,
|
||||||
allowed_tools: newGrantedTools,
|
allowed_tools: newGrantedTools,
|
||||||
use_worktree: config.use_worktree ?? false,
|
use_worktree: config.use_worktree ?? false,
|
||||||
|
disable_1m_context: config.disable_1m_context ?? false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -102,6 +102,7 @@
|
|||||||
discord_rpc_enabled: true,
|
discord_rpc_enabled: true,
|
||||||
show_thinking_blocks: true,
|
show_thinking_blocks: true,
|
||||||
use_worktree: false,
|
use_worktree: false,
|
||||||
|
disable_1m_context: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
let streamerModeActive = $state(false);
|
let streamerModeActive = $state(false);
|
||||||
@@ -180,6 +181,7 @@
|
|||||||
mcp_servers_json: currentConfig.mcp_servers_json || null,
|
mcp_servers_json: currentConfig.mcp_servers_json || null,
|
||||||
allowed_tools: allAllowedTools,
|
allowed_tools: allAllowedTools,
|
||||||
use_worktree: currentConfig.use_worktree ?? false,
|
use_worktree: currentConfig.use_worktree ?? false,
|
||||||
|
disable_1m_context: currentConfig.disable_1m_context ?? false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -292,6 +294,7 @@
|
|||||||
mcp_servers_json: currentConfig.mcp_servers_json || null,
|
mcp_servers_json: currentConfig.mcp_servers_json || null,
|
||||||
allowed_tools: allAllowedTools,
|
allowed_tools: allAllowedTools,
|
||||||
use_worktree: currentConfig.use_worktree ?? false,
|
use_worktree: currentConfig.use_worktree ?? false,
|
||||||
|
disable_1m_context: currentConfig.disable_1m_context ?? false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -107,6 +107,7 @@
|
|||||||
mcp_servers_json: config.mcp_servers_json || null,
|
mcp_servers_json: config.mcp_servers_json || null,
|
||||||
allowed_tools: grantedToolsList,
|
allowed_tools: grantedToolsList,
|
||||||
use_worktree: config.use_worktree ?? false,
|
use_worktree: config.use_worktree ?? false,
|
||||||
|
disable_1m_context: config.disable_1m_context ?? false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -177,6 +177,32 @@ describe("agents store", () => {
|
|||||||
const agents = get(getAgentsForConversation(conversationId));
|
const agents = get(getAgentsForConversation(conversationId));
|
||||||
expect(agents[0].status).toBe("running"); // Status unchanged
|
expect(agents[0].status).toBe("running"); // Status unchanged
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("stores lastAssistantMessage when provided", () => {
|
||||||
|
const agent = createMockAgent({ status: "running" });
|
||||||
|
agentStore.addAgent(conversationId, agent);
|
||||||
|
|
||||||
|
agentStore.endAgent(
|
||||||
|
conversationId,
|
||||||
|
agent.toolUseId,
|
||||||
|
Date.now(),
|
||||||
|
false,
|
||||||
|
"Task completed successfully."
|
||||||
|
);
|
||||||
|
|
||||||
|
const agents = get(getAgentsForConversation(conversationId));
|
||||||
|
expect(agents[0].lastAssistantMessage).toBe("Task completed successfully.");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("leaves lastAssistantMessage undefined when not provided", () => {
|
||||||
|
const agent = createMockAgent({ status: "running" });
|
||||||
|
agentStore.addAgent(conversationId, agent);
|
||||||
|
|
||||||
|
agentStore.endAgent(conversationId, agent.toolUseId, Date.now(), false);
|
||||||
|
|
||||||
|
const agents = get(getAgentsForConversation(conversationId));
|
||||||
|
expect(agents[0].lastAssistantMessage).toBeUndefined();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("markAllErrored", () => {
|
describe("markAllErrored", () => {
|
||||||
|
|||||||
@@ -45,7 +45,13 @@ function createAgentStore() {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
endAgent(conversationId: string, toolUseId: string, endedAt: number, isError: boolean) {
|
endAgent(
|
||||||
|
conversationId: string,
|
||||||
|
toolUseId: string,
|
||||||
|
endedAt: number,
|
||||||
|
isError: boolean,
|
||||||
|
lastAssistantMessage?: string
|
||||||
|
) {
|
||||||
agentsByConversation.update((state) => {
|
agentsByConversation.update((state) => {
|
||||||
const agents = state[conversationId];
|
const agents = state[conversationId];
|
||||||
if (!agents) return state;
|
if (!agents) return state;
|
||||||
@@ -62,6 +68,7 @@ function createAgentStore() {
|
|||||||
endedAt,
|
endedAt,
|
||||||
status: isError ? "errored" : "completed",
|
status: isError ? "errored" : "completed",
|
||||||
durationMs,
|
durationMs,
|
||||||
|
lastAssistantMessage,
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -195,6 +195,7 @@ describe("config store", () => {
|
|||||||
discord_rpc_enabled: true,
|
discord_rpc_enabled: true,
|
||||||
show_thinking_blocks: true,
|
show_thinking_blocks: true,
|
||||||
use_worktree: false,
|
use_worktree: false,
|
||||||
|
disable_1m_context: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(config.model).toBe("claude-sonnet-4");
|
expect(config.model).toBe("claude-sonnet-4");
|
||||||
@@ -242,6 +243,7 @@ describe("config store", () => {
|
|||||||
discord_rpc_enabled: true,
|
discord_rpc_enabled: true,
|
||||||
show_thinking_blocks: true,
|
show_thinking_blocks: true,
|
||||||
use_worktree: false,
|
use_worktree: false,
|
||||||
|
disable_1m_context: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(config.model).toBeNull();
|
expect(config.model).toBeNull();
|
||||||
@@ -788,6 +790,7 @@ describe("config store", () => {
|
|||||||
discord_rpc_enabled: false,
|
discord_rpc_enabled: false,
|
||||||
show_thinking_blocks: true,
|
show_thinking_blocks: true,
|
||||||
use_worktree: false,
|
use_worktree: false,
|
||||||
|
disable_1m_context: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockInvokeImpl = vi.mocked(invoke);
|
const mockInvokeImpl = vi.mocked(invoke);
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ export interface HikariConfig {
|
|||||||
show_thinking_blocks: boolean;
|
show_thinking_blocks: boolean;
|
||||||
// Worktree isolation
|
// Worktree isolation
|
||||||
use_worktree: boolean;
|
use_worktree: boolean;
|
||||||
|
// Disable 1M context window
|
||||||
|
disable_1m_context: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultConfig: HikariConfig = {
|
const defaultConfig: HikariConfig = {
|
||||||
@@ -90,6 +92,7 @@ const defaultConfig: HikariConfig = {
|
|||||||
discord_rpc_enabled: true,
|
discord_rpc_enabled: true,
|
||||||
show_thinking_blocks: true,
|
show_thinking_blocks: true,
|
||||||
use_worktree: false,
|
use_worktree: false,
|
||||||
|
disable_1m_context: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
function createConfigStore() {
|
function createConfigStore() {
|
||||||
|
|||||||
+9
-2
@@ -474,10 +474,17 @@ export async function initializeTauriListeners() {
|
|||||||
unlisteners.push(agentUpdateUnlisten);
|
unlisteners.push(agentUpdateUnlisten);
|
||||||
|
|
||||||
const agentEndUnlisten = await listen<AgentEndPayload>("claude:agent-end", (event) => {
|
const agentEndUnlisten = await listen<AgentEndPayload>("claude:agent-end", (event) => {
|
||||||
const { tool_use_id, ended_at, is_error, conversation_id } = event.payload;
|
const { tool_use_id, ended_at, is_error, conversation_id, last_assistant_message } =
|
||||||
|
event.payload;
|
||||||
const targetConversationId = conversation_id || get(claudeStore.activeConversationId);
|
const targetConversationId = conversation_id || get(claudeStore.activeConversationId);
|
||||||
if (targetConversationId) {
|
if (targetConversationId) {
|
||||||
agentStore.endAgent(targetConversationId, tool_use_id, ended_at, is_error);
|
agentStore.endAgent(
|
||||||
|
targetConversationId,
|
||||||
|
tool_use_id,
|
||||||
|
ended_at,
|
||||||
|
is_error,
|
||||||
|
last_assistant_message
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
unlisteners.push(agentEndUnlisten);
|
unlisteners.push(agentEndUnlisten);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export interface AgentInfo {
|
|||||||
durationMs?: number;
|
durationMs?: number;
|
||||||
characterName: string;
|
characterName: string;
|
||||||
characterAvatar: string;
|
characterAvatar: string;
|
||||||
|
lastAssistantMessage?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AgentStartPayload {
|
export interface AgentStartPayload {
|
||||||
@@ -31,4 +32,5 @@ export interface AgentEndPayload {
|
|||||||
conversation_id?: string;
|
conversation_id?: string;
|
||||||
duration_ms?: number;
|
duration_ms?: number;
|
||||||
num_turns?: number;
|
num_turns?: number;
|
||||||
|
last_assistant_message?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user