@myrialabs/clopen 0.2.13 → 0.2.15

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.
Files changed (43) hide show
  1. package/backend/snapshot/helpers.ts +8 -0
  2. package/backend/snapshot/snapshot-service.ts +9 -7
  3. package/backend/ws/snapshot/timeline.ts +6 -2
  4. package/bin/clopen.ts +377 -100
  5. package/frontend/components/chat/ChatInterface.svelte +6 -1
  6. package/frontend/components/chat/formatters/Tools.svelte +3 -1
  7. package/frontend/components/chat/input/components/EngineModelPicker.svelte +12 -1
  8. package/frontend/components/chat/input/components/LoadingIndicator.svelte +2 -2
  9. package/frontend/components/chat/message/ChatMessage.svelte +0 -29
  10. package/frontend/components/chat/message/ChatMessages.svelte +2 -2
  11. package/frontend/components/chat/message/MessageBubble.svelte +0 -6
  12. package/frontend/components/chat/message/MessageHeader.svelte +0 -16
  13. package/frontend/components/chat/tools/SkillTool.svelte +21 -0
  14. package/frontend/components/chat/tools/index.ts +1 -0
  15. package/frontend/components/chat/widgets/ContextIndicator.svelte +186 -0
  16. package/frontend/components/checkpoint/TimelineModal.svelte +3 -1
  17. package/frontend/components/common/overlay/Dialog.svelte +2 -2
  18. package/frontend/components/history/HistoryModal.svelte +3 -3
  19. package/frontend/components/preview/browser/BrowserPreview.svelte +7 -0
  20. package/frontend/components/preview/browser/components/Canvas.svelte +8 -0
  21. package/frontend/components/settings/engines/AIEnginesSettings.svelte +1 -1
  22. package/frontend/components/settings/general/AuthModeSettings.svelte +2 -2
  23. package/frontend/components/settings/model/EngineModelPicker.svelte +9 -0
  24. package/frontend/components/tunnel/TunnelInactive.svelte +4 -4
  25. package/frontend/components/workspace/PanelHeader.svelte +4 -0
  26. package/frontend/components/workspace/panels/ChatPanel.svelte +6 -0
  27. package/frontend/services/chat/chat.service.ts +44 -1
  28. package/frontend/services/terminal/project.service.ts +52 -0
  29. package/frontend/stores/ui/settings-modal.svelte.ts +1 -1
  30. package/frontend/stores/ui/theme.svelte.ts +11 -11
  31. package/frontend/stores/ui/workspace.svelte.ts +1 -1
  32. package/frontend/utils/chat/message-grouper.ts +33 -5
  33. package/frontend/utils/chat/message-processor.ts +2 -1
  34. package/frontend/utils/chat/tool-handler.ts +38 -3
  35. package/frontend/utils/context-manager.ts +35 -237
  36. package/index.html +2 -2
  37. package/package.json +1 -1
  38. package/shared/types/messaging/index.ts +1 -0
  39. package/shared/types/messaging/tool.ts +24 -1
  40. package/shared/utils/anonymous-user.ts +4 -4
  41. package/shared/utils/ws-client.ts +23 -1
  42. package/frontend/components/chat/modal/TokenUsageModal.svelte +0 -124
  43. package/frontend/components/chat/widgets/TokenUsage.svelte +0 -78
@@ -275,6 +275,11 @@ function findSessionEndByParent(
275
275
  sessionContinuation = child;
276
276
  break;
277
277
  }
278
+ // System messages (e.g. compact_boundary) are part of session continuation
279
+ if (sdk.type === 'system') {
280
+ sessionContinuation = child;
281
+ break;
282
+ }
278
283
  } catch {
279
284
  continue;
280
285
  }
@@ -314,6 +319,9 @@ function findSessionEndByTimestamp(
314
319
  lastValidEnd = msg;
315
320
  } else if (sdk.type === 'user' && isInternalToolMessage(sdk)) {
316
321
  lastValidEnd = msg;
322
+ } else if (sdk.type === 'system') {
323
+ // System messages (e.g. compact_boundary) are part of session continuation
324
+ lastValidEnd = msg;
317
325
  } else if (sdk.type === 'user' && !isInternalToolMessage(sdk)) {
318
326
  // Hit the next real user message (checkpoint) - stop
319
327
  break;
@@ -479,9 +479,6 @@ export class SnapshotService {
479
479
  let restoredFiles = 0;
480
480
  let skippedFiles = 0;
481
481
 
482
- // Update in-memory baseline as we restore
483
- const baseline = this.sessionBaselines.get(sessionId) || {};
484
-
485
482
  for (const [filepath, expectedHash] of expectedState) {
486
483
  // Check conflict resolution
487
484
  if (conflictResolutions && conflictResolutions[filepath] === 'keep') {
@@ -509,7 +506,6 @@ export class SnapshotService {
509
506
  // File should not exist at the target → delete it
510
507
  try {
511
508
  await fs.unlink(fullPath);
512
- delete baseline[filepath];
513
509
  debug.log('snapshot', `Deleted: ${filepath}`);
514
510
  restoredFiles++;
515
511
  } catch {
@@ -522,7 +518,6 @@ export class SnapshotService {
522
518
  const dir = path.dirname(fullPath);
523
519
  await fs.mkdir(dir, { recursive: true });
524
520
  await fs.writeFile(fullPath, content);
525
- baseline[filepath] = expectedHash;
526
521
  debug.log('snapshot', `Restored: ${filepath}`);
527
522
  restoredFiles++;
528
523
  } catch (err) {
@@ -532,8 +527,15 @@ export class SnapshotService {
532
527
  }
533
528
  }
534
529
 
535
- // Update in-memory baseline to reflect restored state
536
- this.sessionBaselines.set(sessionId, baseline);
530
+ // Force re-initialize baseline from actual disk state.
531
+ // This is critical because:
532
+ // 1. Files already at expected state were skipped (baseline not updated for them)
533
+ // 2. After server restart, baseline starts empty — only restored files get entries
534
+ // 3. Files not mentioned in any snapshot are missing from the partial baseline
535
+ // Without this, subsequent captures would compute oldHash='' for files missing
536
+ // from the baseline, causing future restores to incorrectly delete those files.
537
+ this.sessionBaselines.delete(sessionId);
538
+ await this.initializeSessionBaseline(projectPath, sessionId);
537
539
 
538
540
  debug.log('snapshot', `Restore complete: ${restoredFiles} restored, ${skippedFiles} skipped`);
539
541
  return { restoredFiles, skippedFiles };
@@ -126,9 +126,13 @@ export const timelineHandler = createRouter()
126
126
  const isOnActivePath = activePathIds.has(cp.id);
127
127
  const isCurrent = cp.id === activeCheckpointId;
128
128
 
129
- // Orphaned = descendant of active checkpoint in the checkpoint tree
129
+ // Orphaned = in the "future" relative to the current checkpoint.
130
+ // At initial state: ALL checkpoints are orphaned (we've gone back before any messages).
131
+ // Otherwise: only descendants of the active checkpoint that are not on the active path.
130
132
  let isOrphaned = false;
131
- if (activeCheckpointId && !isOnActivePath) {
133
+ if (isAtInitialState) {
134
+ isOrphaned = true;
135
+ } else if (activeCheckpointId && !isOnActivePath) {
132
136
  isOrphaned = isDescendant(cp.id, activeCheckpointId, childrenMap);
133
137
  }
134
138