generated from nhcarrigan/template
bf411adeb7
## Summary This PR resolves several critical bugs that were blocking the permission modal and causing config loss: - **Permission modal not appearing** - Fixed z-index issues and runtime errors - **Config store race condition** - Resolved critical race condition causing settings to be lost - **Excessive logging** - Removed redundant fmt layer that was writing to hidden stdout - **System tool prompts** - Prevented unnecessary permission prompts for built-in tools - **Permission batching** - Added support for parallel permission requests - **ExitPlanMode tool** - Fixed ExitPlanMode tool not functioning correctly ## Changes Made ### Permission Modal Fixes - Updated z-index to proper value (9999) to ensure modal appears above all other UI elements - Fixed runtime errors that were preventing modal from rendering - Resolved issues with permission grants not being properly applied ### Config Store Race Condition - Fixed critical race condition where multiple rapid config updates would result in lost settings - Ensured config writes are properly sequenced to prevent data loss - Added proper synchronisation for config store operations ### Logging Cleanup - Removed redundant fmt formatting layer that was outputting to hidden stdout - Cleaned up excessive debug logging added during troubleshooting - Removed temporary debugging documentation files ### UX Improvements - Added close confirmation modal with minimise to tray option - Implemented batching for parallel permission requests - Added debug console for viewing frontend and backend logs ### ExitPlanMode Fix - Fixed ExitPlanMode tool not functioning correctly, ensuring proper transitions out of plan mode ## Issues Resolved Closes #112 - Permission flow now properly handles multiple tool requests Closes #113 - ExitPlanMode tool now functions correctly Closes #126 - Debug console feature added (partial - basic implementation complete) ## Test Plan - [x] Permission modal appears and functions correctly - [x] Config settings persist across app restarts - [x] No excessive logging in production builds - [x] System tools don't trigger permission prompts - [x] Parallel permission requests are properly batched - [x] Debug console displays frontend and backend logs - [x] ExitPlanMode properly exits plan mode --- ✨ This PR was created with help from Hikari~ 🌸 Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com> Reviewed-on: #127 Co-authored-by: Hikari <hikari@nhcarrigan.com> Co-committed-by: Hikari <hikari@nhcarrigan.com>
126 lines
5.2 KiB
TypeScript
126 lines
5.2 KiB
TypeScript
import { derived } from "svelte/store";
|
|
import { conversationsStore } from "./conversations";
|
|
import type { TerminalLine } from "$lib/types/messages";
|
|
import { characterState } from "$lib/stores/character";
|
|
import {
|
|
setShouldRestoreHistory,
|
|
setSavedHistory,
|
|
getShouldRestoreHistory,
|
|
getSavedHistory,
|
|
clearHistoryRestore,
|
|
} from "./historyRestore";
|
|
|
|
// Re-export TerminalLine type for backwards compatibility
|
|
export type { TerminalLine };
|
|
|
|
// Re-export from conversations store for backwards compatibility
|
|
export const claudeStore = {
|
|
// Existing subscriptions
|
|
connectionStatus: conversationsStore.connectionStatus,
|
|
sessionId: conversationsStore.sessionId,
|
|
currentWorkingDirectory: conversationsStore.currentWorkingDirectory,
|
|
terminalLines: conversationsStore.terminalLines,
|
|
pendingPermission: conversationsStore.pendingPermission,
|
|
pendingQuestion: conversationsStore.pendingQuestion,
|
|
isProcessing: conversationsStore.isProcessing,
|
|
grantedTools: conversationsStore.grantedTools,
|
|
pendingRetryMessage: conversationsStore.pendingRetryMessage,
|
|
attachments: conversationsStore.attachments,
|
|
|
|
// New conversation-aware subscriptions
|
|
conversations: conversationsStore.conversations,
|
|
activeConversationId: conversationsStore.activeConversationId,
|
|
activeConversation: conversationsStore.activeConversation,
|
|
|
|
// Methods
|
|
setConnectionStatus: conversationsStore.setConnectionStatus,
|
|
setConnectionStatusForConversation: conversationsStore.setConnectionStatusForConversation,
|
|
setCharacterStateForConversation: conversationsStore.setCharacterStateForConversation,
|
|
setSessionId: conversationsStore.setSessionId,
|
|
setSessionIdForConversation: conversationsStore.setSessionIdForConversation,
|
|
setWorkingDirectory: conversationsStore.setWorkingDirectory,
|
|
setWorkingDirectoryForConversation: conversationsStore.setWorkingDirectoryForConversation,
|
|
setProcessing: conversationsStore.setProcessing,
|
|
addLine: conversationsStore.addLine,
|
|
addLineToConversation: conversationsStore.addLineToConversation,
|
|
updateLine: conversationsStore.updateLine,
|
|
appendToLine: conversationsStore.appendToLine,
|
|
clearTerminal: conversationsStore.clearTerminal,
|
|
getConversationHistory: conversationsStore.getConversationHistory,
|
|
requestPermission: conversationsStore.requestPermission,
|
|
clearPermission: conversationsStore.clearPermission,
|
|
requestPermissionForConversation: conversationsStore.requestPermissionForConversation,
|
|
clearPermissionForConversation: conversationsStore.clearPermissionForConversation,
|
|
requestQuestion: conversationsStore.requestQuestion,
|
|
clearQuestion: conversationsStore.clearQuestion,
|
|
requestQuestionForConversation: conversationsStore.requestQuestionForConversation,
|
|
clearQuestionForConversation: conversationsStore.clearQuestionForConversation,
|
|
grantTool: conversationsStore.grantTool,
|
|
revokeAllTools: conversationsStore.revokeAllTools,
|
|
isToolGranted: conversationsStore.isToolGranted,
|
|
setPendingRetryMessage: conversationsStore.setPendingRetryMessage,
|
|
|
|
// Conversation management
|
|
createConversation: conversationsStore.createConversation,
|
|
deleteConversation: conversationsStore.deleteConversation,
|
|
switchConversation: conversationsStore.switchConversation,
|
|
renameConversation: conversationsStore.renameConversation,
|
|
saveScrollPosition: conversationsStore.saveScrollPosition,
|
|
getScrollPosition: conversationsStore.getScrollPosition,
|
|
|
|
// Attachment management
|
|
addAttachment: conversationsStore.addAttachment,
|
|
removeAttachment: conversationsStore.removeAttachment,
|
|
clearAttachments: conversationsStore.clearAttachments,
|
|
getAttachments: conversationsStore.getAttachments,
|
|
|
|
getGrantedTools: (): string[] => {
|
|
let tools: string[] = [];
|
|
conversationsStore.grantedTools.subscribe((t) => (tools = Array.from(t)))();
|
|
return tools;
|
|
},
|
|
|
|
// History restoration methods from main branch
|
|
setShouldRestoreHistory: setShouldRestoreHistory,
|
|
setSavedConversationHistory: setSavedHistory,
|
|
getShouldRestoreHistory: getShouldRestoreHistory,
|
|
getSavedConversationHistory: getSavedHistory,
|
|
|
|
reset: () => {
|
|
// Reset only the active conversation
|
|
conversationsStore.clearTerminal();
|
|
conversationsStore.setSessionId(null);
|
|
conversationsStore.setWorkingDirectory("");
|
|
conversationsStore.setProcessing(false);
|
|
conversationsStore.revokeAllTools();
|
|
conversationsStore.clearAttachments();
|
|
// Also clear history restoration
|
|
clearHistoryRestore();
|
|
},
|
|
};
|
|
|
|
export const hasPermissionPending = derived(
|
|
claudeStore.activeConversation,
|
|
($conversation) =>
|
|
$conversation?.pendingPermissions !== null &&
|
|
$conversation?.pendingPermissions !== undefined &&
|
|
$conversation.pendingPermissions.length > 0
|
|
);
|
|
|
|
export const hasQuestionPending = derived(
|
|
claudeStore.activeConversation,
|
|
($conversation) => $conversation?.pendingQuestion !== null
|
|
);
|
|
|
|
// Derived store to check if Claude is currently processing (can be interrupted)
|
|
export const isClaudeProcessing = derived(
|
|
[claudeStore.connectionStatus, characterState],
|
|
([$connectionStatus, $characterState]) => {
|
|
// Must be connected and in one of the processing states
|
|
return (
|
|
$connectionStatus === "connected" &&
|
|
["thinking", "typing", "searching", "coding", "mcp"].includes($characterState)
|
|
);
|
|
}
|
|
);
|