snow-ai 0.3.8 → 0.3.9

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.
@@ -265,6 +265,63 @@ export default function ChatScreen({ skipWelcome }) {
265
265
  streamingState.setRetryStatus(null);
266
266
  // Remove all pending tool call messages (those with toolPending: true)
267
267
  setMessages(prev => prev.filter(msg => !msg.toolPending));
268
+ // Clean up incomplete conversation in session (handled in useConversation abort cleanup)
269
+ // This will remove:
270
+ // 1. User message without AI response (scenario 1)
271
+ // 2. Assistant message with tool_calls but no tool results (scenario 2)
272
+ const session = sessionManager.getCurrentSession();
273
+ if (session && session.messages.length > 0) {
274
+ // Use async cleanup to avoid blocking UI
275
+ (async () => {
276
+ try {
277
+ // Find the last complete conversation round
278
+ const messages = session.messages;
279
+ let truncateIndex = messages.length;
280
+ // Scan from the end to find incomplete round
281
+ for (let i = messages.length - 1; i >= 0; i--) {
282
+ const msg = messages[i];
283
+ if (!msg)
284
+ continue;
285
+ // If last message is user message without assistant response, remove it
286
+ if (msg.role === 'user' && i === messages.length - 1) {
287
+ truncateIndex = i;
288
+ break;
289
+ }
290
+ // If assistant message has tool_calls, verify all tool results exist
291
+ if (msg.role === 'assistant' &&
292
+ msg.tool_calls &&
293
+ msg.tool_calls.length > 0) {
294
+ const toolCallIds = new Set(msg.tool_calls.map(tc => tc.id));
295
+ // Check if all tool results exist after this assistant message
296
+ for (let j = i + 1; j < messages.length; j++) {
297
+ const followMsg = messages[j];
298
+ if (followMsg && followMsg.role === 'tool' && followMsg.tool_call_id) {
299
+ toolCallIds.delete(followMsg.tool_call_id);
300
+ }
301
+ }
302
+ // If some tool results are missing, remove from this assistant message onwards
303
+ if (toolCallIds.size > 0) {
304
+ truncateIndex = i;
305
+ break;
306
+ }
307
+ }
308
+ // If we found a complete assistant response without tool calls, we're done
309
+ if (msg.role === 'assistant' && !msg.tool_calls) {
310
+ break;
311
+ }
312
+ }
313
+ // Truncate session if needed
314
+ if (truncateIndex < messages.length) {
315
+ await sessionManager.truncateMessages(truncateIndex);
316
+ // Also clear from saved messages tracking
317
+ clearSavedMessages();
318
+ }
319
+ }
320
+ catch (error) {
321
+ console.error('Failed to clean up incomplete conversation:', error);
322
+ }
323
+ })();
324
+ }
268
325
  // Add discontinued message
269
326
  setMessages(prev => [
270
327
  ...prev,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-ai",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "description": "Intelligent Command Line Assistant powered by AI",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -1,18 +0,0 @@
1
- export declare const APP_NAME = "AI Bot CLI";
2
- export declare const APP_VERSION = "1.0.0";
3
- export declare const APP_DESCRIPTION = "Intelligent Command Line Assistant";
4
- export declare const COLORS: {
5
- readonly primary: "cyan";
6
- readonly secondary: "magenta";
7
- readonly success: "green";
8
- readonly warning: "yellow";
9
- readonly error: "red";
10
- readonly info: "blue";
11
- readonly muted: "gray";
12
- };
13
- export declare const COMMANDS: {
14
- readonly HELP: "help";
15
- readonly VERSION: "version";
16
- readonly EXIT: "exit";
17
- readonly CLEAR: "clear";
18
- };
@@ -1,18 +0,0 @@
1
- export const APP_NAME = 'AI Bot CLI';
2
- export const APP_VERSION = '1.0.0';
3
- export const APP_DESCRIPTION = 'Intelligent Command Line Assistant';
4
- export const COLORS = {
5
- primary: 'cyan',
6
- secondary: 'magenta',
7
- success: 'green',
8
- warning: 'yellow',
9
- error: 'red',
10
- info: 'blue',
11
- muted: 'gray',
12
- };
13
- export const COMMANDS = {
14
- HELP: 'help',
15
- VERSION: 'version',
16
- EXIT: 'exit',
17
- CLEAR: 'clear',
18
- };