snow-ai 0.3.21 → 0.3.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -323,9 +323,20 @@ export default function ChatScreen({ skipWelcome }) {
323
323
  // We need to truncate to the same user message in the session file
324
324
  if (currentSession) {
325
325
  // Count how many user messages we're deleting (from selectedIndex onwards in UI)
326
- const uiUserMessagesToDelete = messages
327
- .slice(selectedIndex)
328
- .filter(msg => msg.role === 'user').length;
326
+ // But exclude any uncommitted user messages that weren't saved to session
327
+ const messagesAfterSelected = messages.slice(selectedIndex);
328
+ const hasDiscontinuedMessage = messagesAfterSelected.some(msg => msg.discontinued);
329
+ let uiUserMessagesToDelete = 0;
330
+ if (hasDiscontinuedMessage) {
331
+ // If there's a discontinued message, it means all messages from selectedIndex onwards
332
+ // (including user messages) were not saved to session
333
+ // So we don't need to delete any user messages from session
334
+ uiUserMessagesToDelete = 0;
335
+ }
336
+ else {
337
+ // Normal case: count all user messages from selectedIndex onwards
338
+ uiUserMessagesToDelete = messagesAfterSelected.filter(msg => msg.role === 'user').length;
339
+ }
329
340
  // Check if the selected message is a user message that might not be in session
330
341
  // (e.g., interrupted before AI response)
331
342
  const selectedMessage = messages[selectedIndex];
@@ -621,9 +632,25 @@ export default function ChatScreen({ skipWelcome }) {
621
632
  }
622
633
  }
623
634
  // If some tool results are missing, remove from this assistant message onwards
635
+ // But only if this is the last assistant message with tool_calls in the entire conversation
624
636
  if (toolCallIds.size > 0) {
625
- truncateIndex = i;
626
- break;
637
+ // Additional check: ensure this is the last assistant message with tool_calls
638
+ let hasLaterAssistantWithTools = false;
639
+ for (let k = i + 1; k < messages.length; k++) {
640
+ const laterMsg = messages[k];
641
+ if (laterMsg?.role === 'assistant' &&
642
+ laterMsg?.tool_calls &&
643
+ laterMsg.tool_calls.length > 0) {
644
+ hasLaterAssistantWithTools = true;
645
+ break;
646
+ }
647
+ }
648
+ // Only truncate if no later assistant messages have tool_calls
649
+ // This preserves complete historical conversations
650
+ if (!hasLaterAssistantWithTools) {
651
+ truncateIndex = i;
652
+ break;
653
+ }
627
654
  }
628
655
  }
629
656
  // If we found a complete assistant response without tool calls, we're done
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-ai",
3
- "version": "0.3.21",
3
+ "version": "0.3.22",
4
4
  "description": "Intelligent Command Line Assistant powered by AI",
5
5
  "license": "MIT",
6
6
  "bin": {