generated from nhcarrigan/template
feat: add ability to run multiple agents via tabbed views (#47)
### Explanation _No response_ ### Issue Closes #30 Closes #41 ### Attestations - [ ] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/) - [ ] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/). - [ ] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/). ### Dependencies - [ ] I have pinned the dependencies to a specific patch version. ### Style - [ ] I have run the linter and resolved any errors. - [ ] My pull request uses an appropriate title, matching the conventional commit standards. - [ ] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request. ### Tests - [ ] My contribution adds new code, and I have added tests to cover it. - [ ] My contribution modifies existing code, and I have updated the tests to reflect these changes. - [ ] All new and existing tests pass locally with my changes. - [ ] Code coverage remains at or above the configured threshold. ### Documentation _No response_ ### Versioning _No response_ Reviewed-on: #47 Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com> Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
This commit was merged in pull request #47.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { get } from "svelte/store";
|
||||
import { claudeStore, isClaudeProcessing } from "$lib/stores/claude";
|
||||
import { characterState } from "$lib/stores/character";
|
||||
import { handleNewUserMessage } from "$lib/notifications/rules";
|
||||
@@ -45,8 +46,6 @@
|
||||
let messageToSend = formattedMessage;
|
||||
if (getShouldRestoreHistory()) {
|
||||
const savedHistory = getSavedHistory();
|
||||
console.log("Should restore history:", true);
|
||||
console.log("Saved history:", savedHistory);
|
||||
|
||||
if (savedHistory) {
|
||||
// Prepend the conversation history with a context message
|
||||
@@ -56,13 +55,9 @@ ${savedHistory}
|
||||
[Continuing conversation after reconnection:]
|
||||
User: ${formattedMessage}`;
|
||||
|
||||
console.log("Message with history:", messageToSend);
|
||||
|
||||
// Clear the restoration flags
|
||||
clearHistoryRestore();
|
||||
}
|
||||
} else {
|
||||
console.log("Should restore history:", false);
|
||||
}
|
||||
|
||||
// Reset notification state for new user message
|
||||
@@ -72,7 +67,14 @@ User: ${formattedMessage}`;
|
||||
characterState.setState("thinking");
|
||||
|
||||
try {
|
||||
await invoke("send_prompt", { message: messageToSend });
|
||||
const conversationId = get(claudeStore.activeConversationId);
|
||||
if (!conversationId) {
|
||||
throw new Error("No active conversation");
|
||||
}
|
||||
await invoke("send_prompt", {
|
||||
conversationId,
|
||||
message: messageToSend,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Failed to send prompt:", error);
|
||||
claudeStore.addLine("error", `Failed to send: ${error}`);
|
||||
@@ -85,18 +87,18 @@ User: ${formattedMessage}`;
|
||||
async function handleInterrupt() {
|
||||
// Save the conversation history FIRST before anything else
|
||||
const history = claudeStore.getConversationHistory();
|
||||
console.log("Saving conversation history:", history);
|
||||
|
||||
if (history) {
|
||||
setSavedHistory(history);
|
||||
setShouldRestoreHistory(true);
|
||||
console.log("History saved and restoration flag set");
|
||||
} else {
|
||||
console.log("No history to save");
|
||||
}
|
||||
|
||||
try {
|
||||
await invoke("interrupt_claude");
|
||||
const conversationId = get(claudeStore.activeConversationId);
|
||||
if (!conversationId) {
|
||||
throw new Error("No active conversation");
|
||||
}
|
||||
await invoke("interrupt_claude", { conversationId });
|
||||
claudeStore.addLine("system", "Process interrupted - reconnecting...");
|
||||
characterState.setState("idle");
|
||||
|
||||
@@ -106,14 +108,20 @@ User: ${formattedMessage}`;
|
||||
// Auto-reconnect after a brief delay
|
||||
setTimeout(async () => {
|
||||
try {
|
||||
const conversationId = get(claudeStore.activeConversationId);
|
||||
if (!conversationId) {
|
||||
throw new Error("No active conversation");
|
||||
}
|
||||
|
||||
// Get current working directory before reconnecting
|
||||
const workingDir = await invoke<string>("get_working_directory");
|
||||
const workingDir = await invoke<string>("get_working_directory", { conversationId });
|
||||
|
||||
// Set the flag to skip greeting on next connection
|
||||
setSkipNextGreeting(true);
|
||||
|
||||
// Reconnect to Claude
|
||||
await invoke("start_claude", {
|
||||
conversationId,
|
||||
options: {
|
||||
working_dir: workingDir,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user