From 1492983ba9f5b0054f931d6f2403a5b2ff468052 Mon Sep 17 00:00:00 2001 From: Naomi Carrigan Date: Fri, 6 Feb 2026 09:27:37 -0800 Subject: [PATCH] fix: stats persistence --- src/lib/commands/slashCommands.ts | 7 +++++++ src/lib/components/CompactMode.svelte | 4 ++++ src/lib/components/InputBar.svelte | 9 +++++++-- src/routes/+page.svelte | 4 ++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/lib/commands/slashCommands.ts b/src/lib/commands/slashCommands.ts index 86b31f8..4df82a3 100644 --- a/src/lib/commands/slashCommands.ts +++ b/src/lib/commands/slashCommands.ts @@ -107,6 +107,12 @@ async function startNewConversation(): Promise { conversationId, }); + // Get granted tools before interrupting + const activeConversation = get(conversationsStore.activeConversation); + const grantedTools = activeConversation ? Array.from(activeConversation.grantedTools) : []; + const config = configStore.getConfig(); + const allAllowedTools = [...new Set([...grantedTools, ...config.auto_granted_tools])]; + claudeStore.addLine("system", "Starting new conversation..."); characterState.setState("thinking"); @@ -120,6 +126,7 @@ async function startNewConversation(): Promise { conversationId, options: { working_dir: workingDir, + allowed_tools: allAllowedTools, }, }); diff --git a/src/lib/components/CompactMode.svelte b/src/lib/components/CompactMode.svelte index 5dbbbd1..ca172e8 100644 --- a/src/lib/components/CompactMode.svelte +++ b/src/lib/components/CompactMode.svelte @@ -5,6 +5,7 @@ import { characterState, characterInfo } from "$lib/stores/character"; import { isStreamerMode } from "$lib/stores/config"; import { handleNewUserMessage } from "$lib/notifications/rules"; + import { setSkipNextGreeting } from "$lib/tauri"; import type { CharacterState, CharacterStateInfo } from "$lib/types/states"; interface Props { @@ -127,6 +128,9 @@ const conversationId = get(claudeStore.activeConversationId); if (!conversationId) return; + // Set flag to preserve stats/permissions (don't treat next connect as new session) + setSkipNextGreeting(true); + await invoke("interrupt_claude", { conversationId }); claudeStore.addLine("system", "Interrupted"); characterState.setState("idle"); diff --git a/src/lib/components/InputBar.svelte b/src/lib/components/InputBar.svelte index bbb09ac..2d55fd6 100644 --- a/src/lib/components/InputBar.svelte +++ b/src/lib/components/InputBar.svelte @@ -338,17 +338,22 @@ User: ${formattedMessage}`; throw new Error("No active conversation"); } - // Get current working directory before reconnecting + // Get current working directory and granted tools before reconnecting const workingDir = await invoke("get_working_directory", { conversationId }); + const activeConversation = get(conversationsStore.activeConversation); + const grantedTools = activeConversation ? Array.from(activeConversation.grantedTools) : []; + const config = configStore.getConfig(); + const allAllowedTools = [...new Set([...grantedTools, ...config.auto_granted_tools])]; // Set the flag to skip greeting on next connection setSkipNextGreeting(true); - // Reconnect to Claude + // Reconnect to Claude with preserved permissions await invoke("start_claude", { conversationId, options: { working_dir: workingDir, + allowed_tools: allAllowedTools, }, }); diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index ef85d70..31ea0f0 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -8,6 +8,7 @@ initializeDiscordRpc, stopDiscordRpc, updateDiscordRpc, + setSkipNextGreeting, } from "$lib/tauri"; import { configStore, applyTheme, applyFontSize, isCompactMode } from "$lib/stores/config"; import { initNotificationSync, cleanupNotificationSync } from "$lib/stores/notifications"; @@ -278,6 +279,9 @@ const conversationId = get(claudeStore.activeConversationId); if (!conversationId) return; + // Set flag to preserve stats/permissions (don't treat next connect as new session) + setSkipNextGreeting(true); + await invoke("interrupt_claude", { conversationId }); claudeStore.addLine("system", "Process interrupted"); } catch (error) {