diff --git a/src/apps/chat/AppChat.tsx b/src/apps/chat/AppChat.tsx index 639577a3c..74324bc27 100644 --- a/src/apps/chat/AppChat.tsx +++ b/src/apps/chat/AppChat.tsx @@ -268,7 +268,7 @@ export function AppChat() { if (!focusedPaneConversationId) return; const cHandler = ConversationsManager.getHandler(focusedPaneConversationId); if (!cHandler.isValid()) return; - const inputHistory = cHandler.historyViewHead('chat-beam-shortcut'); + const inputHistory = cHandler.historyViewHeadOrThrow('chat-beam-shortcut'); if (!inputHistory.length) return; // TODO: replace the Persona and Auto-Cache-hint in the history? diff --git a/src/apps/chat/components/ChatMessageList.tsx b/src/apps/chat/components/ChatMessageList.tsx index 12d8b0b7a..3842fa3d5 100644 --- a/src/apps/chat/components/ChatMessageList.tsx +++ b/src/apps/chat/components/ChatMessageList.tsx @@ -138,7 +138,7 @@ export function ChatMessageList(props: { const handleMessageBeam = React.useCallback(async (messageId: DMessageId) => { // Message option menu Beam if (!conversationId || !props.conversationHandler || !props.conversationHandler.isValid()) return; - const inputHistory = props.conversationHandler.historyViewHead('chat-beam-message'); + const inputHistory = props.conversationHandler.historyViewHeadOrThrow('chat-beam-message'); if (!inputHistory.length) return; // TODO: replace the Persona and Auto-Cache-hint in the history? diff --git a/src/apps/chat/editors/_handleExecute.ts b/src/apps/chat/editors/_handleExecute.ts index c94773fe8..79be46f71 100644 --- a/src/apps/chat/editors/_handleExecute.ts +++ b/src/apps/chat/editors/_handleExecute.ts @@ -24,7 +24,7 @@ export async function _handleExecute(chatExecuteMode: ChatExecuteMode, conversat const chatLLMId = getChatLLMId(); const cHandler = ConversationsManager.getHandler(conversationId); - const initialHistory = cHandler.historyViewHead('chat-execute-' + executeCallerNameDebug) as Readonly; + const initialHistory = cHandler.historyViewHeadOrThrow('handle-execute-' + executeCallerNameDebug) as Readonly; // Update the system message from the active persona to the history // NOTE: this does NOT call setMessages anymore (optimization). make sure to: @@ -72,7 +72,7 @@ export async function _handleExecute(chatExecuteMode: ChatExecuteMode, conversat return await runPersonaOnConversationHead(chatLLMId, conversationId); case 'beam-content': - const updatedInputHistory = cHandler.historyViewHead('chat-beam-execute'); + const updatedInputHistory = cHandler.historyViewHeadOrThrow('chat-beam-execute'); cHandler.beamInvoke(updatedInputHistory, [], null); return true; diff --git a/src/apps/chat/editors/chat-persona.ts b/src/apps/chat/editors/chat-persona.ts index 571035fc1..411b18e64 100644 --- a/src/apps/chat/editors/chat-persona.ts +++ b/src/apps/chat/editors/chat-persona.ts @@ -34,7 +34,7 @@ export async function runPersonaOnConversationHead( const cHandler = ConversationsManager.getHandler(conversationId); - const _history = cHandler.historyViewHead('runPersonaOnConversationHead') as Readonly; + const _history = cHandler.historyViewHeadOrThrow('runPersonaOnConversationHead') as Readonly; if (_history.length === 0) return false; diff --git a/src/common/chat-overlay/ConversationHandler.ts b/src/common/chat-overlay/ConversationHandler.ts index 971b170da..acbbb1a53 100644 --- a/src/common/chat-overlay/ConversationHandler.ts +++ b/src/common/chat-overlay/ConversationHandler.ts @@ -209,7 +209,7 @@ export class ConversationHandler { _chatStoreActions.historyTruncateToIncluded(this.conversationId, messageId, offset); } - historyViewHead(scope: string): Readonly { + historyViewHeadOrThrow(scope: string): Readonly { const messages = _chatStoreActions.historyView(this.conversationId); if (messages === undefined) throw new Error(`allMessages: Conversation not found, ${scope}`); diff --git a/src/modules/aifn/digrams/DiagramsModal.tsx b/src/modules/aifn/digrams/DiagramsModal.tsx index 10ae9b54c..2ad16848c 100644 --- a/src/modules/aifn/digrams/DiagramsModal.tsx +++ b/src/modules/aifn/digrams/DiagramsModal.tsx @@ -95,7 +95,7 @@ export function DiagramsModal(props: { config: DiagramConfig, onClose: () => voi setAbortController(stepAbortController); // cHandler.setAbortController(stepAbortController); - const reChatHistory = cHandler.historyViewHead('diagrams-modal'); + const reChatHistory = cHandler.historyViewHeadOrThrow('diagrams-modal'); const { chatSystemInstruction } = splitSystemMessageFromHistory(reChatHistory); if (!chatSystemInstruction) return setErrorMessage('No System instruction in this conversation');