@myrialabs/clopen 0.1.4 → 0.1.6
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.
- package/backend/lib/chat/stream-manager.ts +8 -0
- package/backend/lib/database/migrations/022_add_snapshot_changes_column.ts +35 -0
- package/backend/lib/database/migrations/index.ts +7 -0
- package/backend/lib/database/queries/snapshot-queries.ts +7 -4
- package/backend/lib/files/file-watcher.ts +34 -0
- package/backend/lib/project/status-manager.ts +6 -4
- package/backend/lib/snapshot/snapshot-service.ts +471 -316
- package/backend/lib/terminal/pty-session-manager.ts +1 -32
- package/backend/ws/chat/stream.ts +45 -2
- package/backend/ws/snapshot/restore.ts +77 -67
- package/backend/ws/system/operations.ts +95 -0
- package/frontend/App.svelte +24 -7
- package/frontend/lib/components/chat/ChatInterface.svelte +14 -14
- package/frontend/lib/components/chat/input/ChatInput.svelte +2 -2
- package/frontend/lib/components/chat/input/components/ChatInputActions.svelte +1 -1
- package/frontend/lib/components/chat/input/components/EngineModelPicker.svelte +8 -3
- package/frontend/lib/components/chat/input/composables/use-textarea-resize.svelte.ts +12 -2
- package/frontend/lib/components/chat/tools/AskUserQuestionTool.svelte +3 -8
- package/frontend/lib/components/checkpoint/TimelineModal.svelte +222 -30
- package/frontend/lib/components/common/ConnectionBanner.svelte +55 -0
- package/frontend/lib/components/common/MonacoEditor.svelte +14 -0
- package/frontend/lib/components/common/UpdateBanner.svelte +88 -0
- package/frontend/lib/components/common/xterm/XTerm.svelte +9 -0
- package/frontend/lib/components/common/xterm/xterm-service.ts +9 -0
- package/frontend/lib/components/git/DiffViewer.svelte +16 -2
- package/frontend/lib/components/history/HistoryModal.svelte +8 -4
- package/frontend/lib/components/settings/SettingsModal.svelte +2 -2
- package/frontend/lib/components/settings/appearance/AppearanceSettings.svelte +59 -0
- package/frontend/lib/components/settings/general/GeneralSettings.svelte +6 -1
- package/frontend/lib/components/settings/general/UpdateSettings.svelte +123 -0
- package/frontend/lib/components/terminal/Terminal.svelte +1 -7
- package/frontend/lib/components/workspace/DesktopNavigator.svelte +11 -19
- package/frontend/lib/components/workspace/MobileNavigator.svelte +4 -15
- package/frontend/lib/components/workspace/WorkspaceLayout.svelte +1 -1
- package/frontend/lib/components/workspace/panels/FilesPanel.svelte +3 -2
- package/frontend/lib/components/workspace/panels/GitPanel.svelte +3 -2
- package/frontend/lib/services/notification/global-stream-monitor.ts +56 -16
- package/frontend/lib/services/snapshot/snapshot.service.ts +71 -32
- package/frontend/lib/stores/core/app.svelte.ts +47 -0
- package/frontend/lib/stores/core/presence.svelte.ts +80 -1
- package/frontend/lib/stores/core/projects.svelte.ts +10 -2
- package/frontend/lib/stores/core/sessions.svelte.ts +15 -2
- package/frontend/lib/stores/features/settings.svelte.ts +10 -1
- package/frontend/lib/stores/features/terminal.svelte.ts +6 -0
- package/frontend/lib/stores/ui/connection.svelte.ts +40 -0
- package/frontend/lib/stores/ui/update.svelte.ts +124 -0
- package/frontend/lib/stores/ui/workspace.svelte.ts +4 -3
- package/frontend/lib/utils/ws.ts +5 -1
- package/index.html +1 -1
- package/package.json +1 -1
- package/shared/types/database/schema.ts +18 -0
- package/shared/types/stores/settings.ts +4 -0
- package/shared/utils/ws-client.ts +16 -2
- package/vite.config.ts +1 -0
|
@@ -37,6 +37,11 @@ const BINARY_ACTIONS = new Set<string>([
|
|
|
37
37
|
// Client Options
|
|
38
38
|
// ============================================================================
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Connection status for external consumers
|
|
42
|
+
*/
|
|
43
|
+
export type WSConnectionStatus = 'connected' | 'disconnected' | 'reconnecting';
|
|
44
|
+
|
|
40
45
|
/**
|
|
41
46
|
* WebSocket client options
|
|
42
47
|
*/
|
|
@@ -49,6 +54,8 @@ export interface WSClientOptions {
|
|
|
49
54
|
reconnectDelay?: number;
|
|
50
55
|
/** Maximum reconnect delay in ms */
|
|
51
56
|
maxReconnectDelay?: number;
|
|
57
|
+
/** Callback when connection status changes */
|
|
58
|
+
onStatusChange?: (status: WSConnectionStatus, reconnectAttempts: number) => void;
|
|
52
59
|
}
|
|
53
60
|
|
|
54
61
|
// ============================================================================
|
|
@@ -197,7 +204,7 @@ function decodeBinaryMessage(buffer: ArrayBuffer): { action: string; payload: an
|
|
|
197
204
|
export class WSClient<TAPI extends { client: any; server: any }> {
|
|
198
205
|
private ws: WebSocket | null = null;
|
|
199
206
|
private url: string;
|
|
200
|
-
private options: Required<WSClientOptions>;
|
|
207
|
+
private options: Required<Omit<WSClientOptions, 'onStatusChange'>> & Pick<WSClientOptions, 'onStatusChange'>;
|
|
201
208
|
private reconnectAttempts = 0;
|
|
202
209
|
private reconnectTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
203
210
|
private listeners = new Map<string, Set<(payload: any) => void>>();
|
|
@@ -226,7 +233,8 @@ export class WSClient<TAPI extends { client: any; server: any }> {
|
|
|
226
233
|
autoReconnect: options.autoReconnect ?? true,
|
|
227
234
|
maxReconnectAttempts: options.maxReconnectAttempts ?? 5,
|
|
228
235
|
reconnectDelay: options.reconnectDelay ?? 1000,
|
|
229
|
-
maxReconnectDelay: options.maxReconnectDelay ?? 30000
|
|
236
|
+
maxReconnectDelay: options.maxReconnectDelay ?? 30000,
|
|
237
|
+
onStatusChange: options.onStatusChange ?? undefined
|
|
230
238
|
};
|
|
231
239
|
|
|
232
240
|
this.connect();
|
|
@@ -262,6 +270,7 @@ export class WSClient<TAPI extends { client: any; server: any }> {
|
|
|
262
270
|
debug.log('websocket', 'Connected');
|
|
263
271
|
this.isConnected = true;
|
|
264
272
|
this.reconnectAttempts = 0;
|
|
273
|
+
this.options.onStatusChange?.('connected', 0);
|
|
265
274
|
|
|
266
275
|
// Sync context on reconnection - MUST await before flushing queue
|
|
267
276
|
if (this.context.userId || this.context.projectId) {
|
|
@@ -320,7 +329,10 @@ export class WSClient<TAPI extends { client: any; server: any }> {
|
|
|
320
329
|
|
|
321
330
|
// Auto-reconnect
|
|
322
331
|
if (this.shouldReconnect && this.options.autoReconnect) {
|
|
332
|
+
this.options.onStatusChange?.('reconnecting', this.reconnectAttempts);
|
|
323
333
|
this.scheduleReconnect();
|
|
334
|
+
} else {
|
|
335
|
+
this.options.onStatusChange?.('disconnected', this.reconnectAttempts);
|
|
324
336
|
}
|
|
325
337
|
};
|
|
326
338
|
} catch (err) {
|
|
@@ -389,6 +401,7 @@ export class WSClient<TAPI extends { client: any; server: any }> {
|
|
|
389
401
|
private scheduleReconnect(): void {
|
|
390
402
|
if (this.options.maxReconnectAttempts > 0 && this.reconnectAttempts >= this.options.maxReconnectAttempts) {
|
|
391
403
|
debug.error('websocket', 'Max reconnect attempts reached');
|
|
404
|
+
this.options.onStatusChange?.('disconnected', this.reconnectAttempts);
|
|
392
405
|
return;
|
|
393
406
|
}
|
|
394
407
|
|
|
@@ -399,6 +412,7 @@ export class WSClient<TAPI extends { client: any; server: any }> {
|
|
|
399
412
|
);
|
|
400
413
|
|
|
401
414
|
debug.log('websocket', `Reconnecting in ${delay}ms (attempt ${this.reconnectAttempts})`);
|
|
415
|
+
this.options.onStatusChange?.('reconnecting', this.reconnectAttempts);
|
|
402
416
|
|
|
403
417
|
this.reconnectTimeout = setTimeout(() => {
|
|
404
418
|
this.connect();
|