codex-lens 0.1.13 → 0.1.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.
- package/build.js +6 -2
- package/dist/aggregator.js +0 -100
- package/dist/pty-manager.js +22 -3
- package/dist/public/assets/main-DHXlOYFo.js +88 -0
- package/dist/public/assets/main-OkH3Xq_f.css +32 -0
- package/dist/public/index.html +2 -2
- package/package.json +19 -1
- package/src/aggregator.js +0 -116
- package/src/components/App.jsx +111 -248
- package/src/components/CodeViewer.jsx +158 -0
- package/src/global.css +351 -403
- package/src/pty-manager.js +28 -3
- package/dist/public/assets/main-CIs8emEJ.js +0 -50
- package/dist/public/assets/main-DA0U-HuE.css +0 -32
- package/dist/snapshot-manager.js +0 -208
- package/src/snapshot-manager.js +0 -230
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
@import"https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=DM+Sans:wght@400;500;600;700&display=swap";/**
|
|
2
|
+
* Copyright (c) 2014 The xterm.js authors. All rights reserved.
|
|
3
|
+
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
4
|
+
* https://github.com/chjj/term.js
|
|
5
|
+
* @license MIT
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in
|
|
15
|
+
* all copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
* THE SOFTWARE.
|
|
24
|
+
*
|
|
25
|
+
* Originally forked from (with the author's permission):
|
|
26
|
+
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
27
|
+
* http://bellard.org/jslinux/
|
|
28
|
+
* Copyright (c) 2011 Fabrice Bellard
|
|
29
|
+
* The original design remains. The terminal itself
|
|
30
|
+
* has been extended to include xterm CSI codes, among
|
|
31
|
+
* other features.
|
|
32
|
+
*/.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm .xterm-scroll-area{visibility:hidden}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{-webkit-user-select:text;user-select:text;white-space:pre}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}:root{--bg-primary: #000000;--bg-secondary: #0A0A0A;--bg-tertiary: #141414;--bg-elevated: #1A1A1A;--bg-surface: #0F0F0F;--text-primary: #F8FAFC;--text-secondary: #94A3B8;--text-muted: #64748B;--border-color: rgba(148, 163, 184, .15);--border-glow: rgba(34, 197, 94, .3);--accent-color: #22C55E;--accent-hover: #16A34A;--accent-glow: rgba(34, 197, 94, .4);--accent-soft: rgba(34, 197, 94, .1);--diff-add-bg: rgba(34, 197, 94, .12);--diff-add-text: #4ADE80;--diff-add-border: #22C55E;--diff-remove-bg: rgba(239, 68, 68, .12);--diff-remove-text: #F87171;--diff-remove-border: #EF4444;--danger-color: #EF4444;--danger-hover: #DC2626;--success-color: #22C55E;--success-hover: #16A34A;--warning-color: #F59E0B;--info-color: #3B82F6;--font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;--font-display: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;--font-mono: "JetBrains Mono", "Fira Code", "SF Mono", "Consolas", monospace;--shadow-xs: 0 1px 2px rgba(0, 0, 0, .2);--shadow-sm: 0 2px 4px rgba(0, 0, 0, .2);--shadow-md: 0 4px 12px rgba(0, 0, 0, .3);--shadow-lg: 0 8px 24px rgba(0, 0, 0, .4);--shadow-xl: 0 16px 48px rgba(0, 0, 0, .5);--shadow-glow: 0 0 24px var(--accent-glow);--shadow-glow-sm: 0 0 12px var(--accent-glow);--radius-xs: 4px;--radius-sm: 6px;--radius-md: 10px;--radius-lg: 14px;--radius-xl: 20px;--transition-fast: .12s ease;--transition-normal: .2s ease;--transition-slow: .3s ease;--blur-sm: 8px;--blur-md: 16px;--blur-lg: 24px}@media (prefers-reduced-motion: reduce){*,*:before,*:after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}}*{margin:0;padding:0;box-sizing:border-box}html,body,#root{height:100%;width:100%;overflow:hidden}body{font-family:var(--font-family);background:var(--bg-primary);color:var(--text-primary);font-size:14px;line-height:1.6;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.app-container{display:flex;flex-direction:column;height:100vh;width:100vw;background:var(--bg-primary)}.top-bar{display:flex;align-items:center;justify-content:space-between;padding:12px 20px;background:linear-gradient(180deg,#1e293bf2,#1e293bd9);-webkit-backdrop-filter:blur(var(--blur-md));backdrop-filter:blur(var(--blur-md));border-bottom:1px solid var(--border-color);min-height:52px;position:relative;z-index:100}.top-bar:after{content:"";position:absolute;bottom:0;left:0;right:0;height:1px;background:linear-gradient(90deg,transparent,var(--accent-color),transparent);opacity:.3}.top-bar-left,.top-bar-center,.top-bar-right{display:flex;align-items:center;gap:16px}.top-bar-left{width:260px}.top-bar-center{flex:1;justify-content:center}.top-bar-right{width:40%;justify-content:flex-end}.top-bar-title{font-family:var(--font-display);font-weight:600;font-size:13px;text-transform:uppercase;letter-spacing:1px;color:var(--text-secondary);display:flex;align-items:center;gap:8px}.top-bar-title:before{content:"";display:inline-block;width:3px;height:14px;background:var(--accent-color);border-radius:2px}.main-content{display:flex;flex:1;overflow:hidden;gap:1px;background:var(--border-color)}.panel{display:flex;flex-direction:column;overflow:hidden;background:linear-gradient(180deg,var(--bg-secondary) 0%,rgba(30,41,59,.95) 100%)}.left-panel{width:260px;flex-shrink:0}.middle-panel{flex:1;min-width:300px}.right-panel{width:40%;min-width:300px;max-width:60%}.panel-content{flex:1;overflow:auto;padding:8px}.file-tree{padding:4px}.file-item{padding:8px 12px;cursor:pointer;border-radius:var(--radius-sm);display:flex;align-items:center;gap:10px;transition:all var(--transition-fast);position:relative;margin:2px 0}.file-item:before{content:"";position:absolute;left:0;top:50%;transform:translateY(-50%);width:3px;height:0;background:var(--accent-color);border-radius:0 2px 2px 0;transition:height var(--transition-fast)}.file-item:hover{background:#94a3b814}.file-item:hover:before{height:60%}.file-item:active{transform:scale(.98)}.file-item.active{background:var(--accent-soft);color:var(--text-primary)}.file-item.active:before{height:70%}.file-icon{width:18px;height:18px;display:flex;align-items:center;justify-content:center;font-size:14px;opacity:.9}.file-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px}.diff-line{font-family:var(--font-mono);font-size:13px;padding:3px 16px 3px 20px;white-space:pre;border-left:3px solid transparent;transition:background var(--transition-fast);position:relative}.diff-line.added{background:var(--diff-add-bg);color:var(--diff-add-text);border-left-color:var(--diff-add-border)}.diff-line.removed{background:var(--diff-remove-bg);color:var(--diff-remove-text);border-left-color:var(--diff-remove-border)}.diff-line:before{display:inline-block;width:16px;margin-left:-16px;text-align:center;font-weight:600;font-size:12px}.diff-line.added:before{content:"+";color:var(--diff-add-text)}.diff-line.removed:before{content:"-";color:var(--diff-remove-text)}.tab-bar{display:flex;background:#0f172a99;border-bottom:1px solid var(--border-color);overflow-x:auto;min-height:40px;scrollbar-width:none}.tab-bar::-webkit-scrollbar{display:none}.tab{display:flex;align-items:center;gap:8px;padding:10px 16px;background:transparent;border-right:1px solid var(--border-color);cursor:pointer;min-width:100px;max-width:180px;font-size:13px;color:var(--text-muted);transition:all var(--transition-fast);position:relative}.tab:hover{background:#94a3b80d;color:var(--text-secondary)}.tab.active{background:var(--bg-secondary);color:var(--text-primary)}.tab.active:after{content:"";position:absolute;bottom:0;left:0;right:0;height:2px;background:var(--accent-color)}.tab-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tab-close{background:none;border:none;color:var(--text-muted);font-size:16px;cursor:pointer;padding:2px 6px;border-radius:var(--radius-xs);line-height:1;transition:all var(--transition-fast);opacity:.6}.tab-close:hover{background:#ef444433;color:var(--danger-color);opacity:1}.context-menu{position:fixed;background:linear-gradient(180deg,var(--bg-tertiary) 0%,var(--bg-secondary) 100%);border:1px solid var(--border-color);border-radius:var(--radius-md);padding:6px;min-width:160px;box-shadow:var(--shadow-lg);z-index:1000;animation:contextMenuIn .15s ease;-webkit-backdrop-filter:blur(var(--blur-sm));backdrop-filter:blur(var(--blur-sm))}@keyframes contextMenuIn{0%{opacity:0;transform:scale(.95) translateY(-4px)}to{opacity:1;transform:scale(1) translateY(0)}}.context-menu-item{padding:10px 14px;cursor:pointer;font-size:13px;color:var(--text-primary);border-radius:var(--radius-sm);transition:all var(--transition-fast)}.context-menu-item:hover{background:var(--accent-soft);color:var(--accent-color)}.file-context-menu{position:fixed;background:linear-gradient(180deg,var(--bg-tertiary) 0%,var(--bg-secondary) 100%);border:1px solid var(--border-color);border-radius:var(--radius-md);padding:6px;min-width:200px;box-shadow:var(--shadow-lg);z-index:1000;animation:contextMenuIn .15s ease;-webkit-backdrop-filter:blur(var(--blur-sm));backdrop-filter:blur(var(--blur-sm))}.ws-status{display:inline-block;width:8px;height:8px;border-radius:50%;margin-left:8px;transition:all var(--transition-normal)}.ws-status.connected{background:var(--success-color);box-shadow:0 0 8px var(--success-color);animation:pulse 2s infinite}.ws-status.disconnected{background:var(--danger-color);box-shadow:0 0 8px var(--danger-color)}@keyframes pulse{0%,to{opacity:1;box-shadow:0 0 8px var(--success-color)}50%{opacity:.7;box-shadow:0 0 4px var(--success-color)}}.version-info{display:flex;align-items:center;gap:10px}.version-number{font-size:11px;color:var(--text-muted);font-weight:500;font-family:var(--font-mono);padding:3px 8px;background:#94a3b81a;border-radius:var(--radius-xs)}.update-badge{font-size:10px;padding:4px 10px;background:linear-gradient(135deg,var(--warning-color) 0%,#FBBF24 100%);color:var(--bg-primary);border-radius:var(--radius-sm);cursor:pointer;font-weight:600;transition:all var(--transition-fast)}.update-badge:hover{transform:translateY(-1px);box-shadow:0 4px 12px #f59e0b4d}.terminal-wrapper{flex:1;overflow:hidden;min-height:0}.section{margin-bottom:8px}.section-title{padding:10px 12px 6px;font-size:10px;font-weight:600;color:var(--text-muted);text-transform:uppercase;letter-spacing:.8px}.empty-state{padding:40px 24px;text-align:center;color:var(--text-muted);font-size:13px;display:flex;flex-direction:column;align-items:center;gap:12px}.empty-state:before{content:"";width:48px;height:48px;background:linear-gradient(135deg,var(--bg-tertiary) 0%,var(--bg-elevated) 100%);border-radius:var(--radius-lg);display:flex;align-items:center;justify-content:center}.code-panel{font-family:var(--font-mono)}.code-viewer-codemirror{height:100%;width:100%;overflow:hidden}.code-viewer-codemirror .cm-editor{height:100%}.code-viewer-codemirror .cm-scroller{overflow:auto}.code-content{padding:16px;white-space:pre-wrap;word-break:break-all;line-height:1.7;font-size:13px}.diff-container{font-family:var(--font-mono);font-size:13px;padding:8px 0}.task-btn{padding:8px 18px;border:none;border-radius:var(--radius-sm);font-size:12px;font-weight:600;cursor:pointer;transition:all var(--transition-fast);font-family:var(--font-family);display:inline-flex;align-items:center;gap:6px}.task-btn:hover{transform:translateY(-1px)}.task-btn:active{transform:translateY(0)}.task-btn-clear{background:transparent;color:var(--text-secondary);border:1px solid var(--border-color)}.task-btn-clear:hover{background:var(--accent-soft);border-color:var(--accent-color);color:var(--accent-color);box-shadow:var(--shadow-glow-sm)}::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:var(--bg-elevated);border-radius:3px}::-webkit-scrollbar-thumb:hover{background:var(--text-muted)}::-webkit-scrollbar-corner{background:transparent}@media (max-width: 1024px){.left-panel{width:220px}.right-panel{width:45%;min-width:250px}.top-bar-left{width:220px}}@media (max-width: 768px){.main-content{flex-direction:column}.left-panel,.right-panel{width:100%;max-width:none;min-width:auto}.middle-panel{min-height:300px}.top-bar{flex-wrap:wrap;padding:10px 16px}.top-bar-left,.top-bar-center,.top-bar-right{width:auto}.top-bar-center{order:3;width:100%;justify-content:flex-start;margin-top:8px;padding-top:8px;border-top:1px solid var(--border-color)}}
|
package/dist/public/index.html
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Codex Viewer</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/main-
|
|
8
|
-
<link rel="stylesheet" crossorigin href="./assets/main-
|
|
7
|
+
<script type="module" crossorigin src="./assets/main-DHXlOYFo.js"></script>
|
|
8
|
+
<link rel="stylesheet" crossorigin href="./assets/main-OkH3Xq_f.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
11
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codex-lens",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"description": "A visualization tool for Codex that monitors API requests and file system changes with task snapshot rollback",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,6 +24,24 @@
|
|
|
24
24
|
"rollback"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
+
"@codemirror/lang-cpp": "^6.0.3",
|
|
28
|
+
"@codemirror/lang-css": "^6.3.1",
|
|
29
|
+
"@codemirror/lang-go": "^6.0.1",
|
|
30
|
+
"@codemirror/lang-html": "^6.4.11",
|
|
31
|
+
"@codemirror/lang-java": "^6.0.2",
|
|
32
|
+
"@codemirror/lang-javascript": "^6.2.5",
|
|
33
|
+
"@codemirror/lang-json": "^6.0.2",
|
|
34
|
+
"@codemirror/lang-markdown": "^6.5.0",
|
|
35
|
+
"@codemirror/lang-python": "^6.2.1",
|
|
36
|
+
"@codemirror/lang-rust": "^6.0.2",
|
|
37
|
+
"@codemirror/lang-sql": "^6.10.0",
|
|
38
|
+
"@codemirror/lang-yaml": "^6.1.2",
|
|
39
|
+
"@codemirror/language": "^6.12.2",
|
|
40
|
+
"@codemirror/state": "^6.6.0",
|
|
41
|
+
"@codemirror/view": "^6.40.0",
|
|
42
|
+
"@lezer/highlight": "^1.2.3",
|
|
43
|
+
"@replit/codemirror-minimap": "^0.5.2",
|
|
44
|
+
"@uiw/react-codemirror": "^4.25.8",
|
|
27
45
|
"@xterm/addon-fit": "^0.10.0",
|
|
28
46
|
"@xterm/addon-web-links": "^0.11.0",
|
|
29
47
|
"@xterm/xterm": "^5.5.0",
|
package/src/aggregator.js
CHANGED
|
@@ -7,7 +7,6 @@ import { createProxyServer } from './proxy.js';
|
|
|
7
7
|
import { FileWatcher, scanDirectory } from './watcher.js';
|
|
8
8
|
import { createLogger } from './lib/logger.js';
|
|
9
9
|
import { spawnCodex, writeToPty, resizePty, killPty, onPtyData, onPtyExit, getPtyState, getOutputBuffer } from './pty-manager.js';
|
|
10
|
-
import { SnapshotManager } from './snapshot-manager.js';
|
|
11
10
|
import path from 'path';
|
|
12
11
|
import { fileURLToPath } from 'url';
|
|
13
12
|
import { readFileSync, existsSync } from 'fs';
|
|
@@ -57,9 +56,6 @@ class Aggregator {
|
|
|
57
56
|
this.proxyServer = null;
|
|
58
57
|
this.fileWatcher = null;
|
|
59
58
|
this.ptyProcess = null;
|
|
60
|
-
this.snapshotManager = new SnapshotManager();
|
|
61
|
-
this.currentTaskId = null;
|
|
62
|
-
this.taskStatus = 'idle';
|
|
63
59
|
}
|
|
64
60
|
|
|
65
61
|
async start(proxyPort) {
|
|
@@ -251,121 +247,9 @@ class Aggregator {
|
|
|
251
247
|
}
|
|
252
248
|
}));
|
|
253
249
|
}
|
|
254
|
-
} else if (data.type === 'start_task') {
|
|
255
|
-
this.handleStartTask(ws);
|
|
256
|
-
} else if (data.type === 'rollback_task') {
|
|
257
|
-
this.handleRollbackTask(ws);
|
|
258
|
-
} else if (data.type === 'complete_task') {
|
|
259
|
-
this.handleCompleteTask(ws);
|
|
260
|
-
} else if (data.type === 'get_task_status') {
|
|
261
|
-
ws.send(JSON.stringify({
|
|
262
|
-
type: 'task_status',
|
|
263
|
-
data: {
|
|
264
|
-
status: this.taskStatus,
|
|
265
|
-
taskId: this.currentTaskId
|
|
266
|
-
}
|
|
267
|
-
}));
|
|
268
250
|
}
|
|
269
251
|
}
|
|
270
252
|
|
|
271
|
-
async handleStartTask(ws) {
|
|
272
|
-
if (this.taskStatus === 'running') {
|
|
273
|
-
ws.send(JSON.stringify({ type: 'error', message: 'Task already running' }));
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
this.currentTaskId = Date.now().toString();
|
|
278
|
-
this.taskStatus = 'running';
|
|
279
|
-
|
|
280
|
-
const result = await this.snapshotManager.createSnapshot(this.projectRoot, this.currentTaskId);
|
|
281
|
-
|
|
282
|
-
if (result.success) {
|
|
283
|
-
logger.info(`Task started: ${this.currentTaskId}, ${result.filesCount} files snapshotted`);
|
|
284
|
-
this.broadcast({
|
|
285
|
-
type: 'task_status',
|
|
286
|
-
data: {
|
|
287
|
-
status: this.taskStatus,
|
|
288
|
-
taskId: this.currentTaskId,
|
|
289
|
-
filesCount: result.filesCount
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
ws.send(JSON.stringify({
|
|
293
|
-
type: 'task_started',
|
|
294
|
-
data: {
|
|
295
|
-
taskId: this.currentTaskId,
|
|
296
|
-
filesCount: result.filesCount
|
|
297
|
-
}
|
|
298
|
-
}));
|
|
299
|
-
} else {
|
|
300
|
-
this.taskStatus = 'idle';
|
|
301
|
-
this.currentTaskId = null;
|
|
302
|
-
ws.send(JSON.stringify({ type: 'error', message: 'Failed to create snapshot: ' + result.error }));
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
async handleRollbackTask(ws) {
|
|
307
|
-
if (!this.currentTaskId || this.taskStatus !== 'running') {
|
|
308
|
-
ws.send(JSON.stringify({ type: 'error', message: 'No active task to rollback' }));
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
const taskId = this.currentTaskId;
|
|
313
|
-
const result = await this.snapshotManager.restoreSnapshot(taskId);
|
|
314
|
-
|
|
315
|
-
if (result.success) {
|
|
316
|
-
await this.snapshotManager.deleteSnapshot(taskId);
|
|
317
|
-
logger.info(`Task rolled back: ${taskId}, ${result.restoredCount} files restored`);
|
|
318
|
-
|
|
319
|
-
this.taskStatus = 'idle';
|
|
320
|
-
this.currentTaskId = null;
|
|
321
|
-
|
|
322
|
-
this.broadcast({
|
|
323
|
-
type: 'task_status',
|
|
324
|
-
data: {
|
|
325
|
-
status: this.taskStatus,
|
|
326
|
-
taskId: null
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
ws.send(JSON.stringify({
|
|
331
|
-
type: 'task_rolled_back',
|
|
332
|
-
data: {
|
|
333
|
-
restoredCount: result.restoredCount
|
|
334
|
-
}
|
|
335
|
-
}));
|
|
336
|
-
} else {
|
|
337
|
-
ws.send(JSON.stringify({ type: 'error', message: 'Failed to rollback: ' + result.error }));
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
async handleCompleteTask(ws) {
|
|
342
|
-
if (!this.currentTaskId || this.taskStatus !== 'running') {
|
|
343
|
-
ws.send(JSON.stringify({ type: 'error', message: 'No active task to complete' }));
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
const taskId = this.currentTaskId;
|
|
348
|
-
await this.snapshotManager.deleteSnapshot(taskId);
|
|
349
|
-
|
|
350
|
-
logger.info(`Task completed: ${taskId}`);
|
|
351
|
-
|
|
352
|
-
this.taskStatus = 'idle';
|
|
353
|
-
this.currentTaskId = null;
|
|
354
|
-
|
|
355
|
-
this.broadcast({
|
|
356
|
-
type: 'task_status',
|
|
357
|
-
data: {
|
|
358
|
-
status: this.taskStatus,
|
|
359
|
-
taskId: null
|
|
360
|
-
}
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
ws.send(JSON.stringify({
|
|
364
|
-
type: 'task_completed',
|
|
365
|
-
data: {}
|
|
366
|
-
}));
|
|
367
|
-
}
|
|
368
|
-
|
|
369
253
|
broadcast(event) {
|
|
370
254
|
const message = JSON.stringify(event);
|
|
371
255
|
for (const client of this.clients) {
|