andy-stack_vaultkeeper-ai/Stores/ConversationStore.ts
Andrew Beal 8823e3cf23 refactor: convert ChatMode enum to string literals and improve state management
- Change ChatMode enum values from numeric (0,1,2) to string literals ("read_only", "edit", "planning")
- Move chat mode state management from ChatWindow to SettingsService with persistence
- Add chat mode awareness to system prompts and tool validation
- Replace Map with WeakMap for settings subscribers to prevent memory leaks
- Add type-safe event handlers to EventService
- Update esbuild and TypeScript targets from ES2018/ES2020 to ES2022
- Add requiresEditModeEnabled() validation to prevent tool hallucination in read-only mode
- Update all test fixtures to include chatMode in mock settings
2026-05-05 20:54:34 +01:00

25 lines
948 B
TypeScript

import { writable } from 'svelte/store';
import type { Conversation } from 'Conversations/Conversation';
interface IConversationStoreState {
shouldReset: boolean;
conversationToLoad: { conversation: Conversation; filePath: string } | null;
}
function createConversationStore() {
const { subscribe, set, update } = writable<IConversationStoreState>({
shouldReset: false,
conversationToLoad: null,
});
return {
subscribe,
reset: () => set({ shouldReset: true, conversationToLoad: null }),
clearResetFlag: () => update(state => ({ ...state, shouldReset: false })),
loadConversation: (conversation: Conversation, filePath: string) =>
set({ shouldReset: false, conversationToLoad: { conversation, filePath } }),
clearLoadFlag: () => update(state => ({ ...state, conversationToLoad: null })),
};
}
export const conversationStore = createConversationStore();