codex-lens 0.1.24 → 0.1.25
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/dist/public/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Codex Lens</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/main-
|
|
7
|
+
<script type="module" crossorigin src="./assets/main-DJ9sK-1n.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="./assets/main-CYNmzqDG.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/package.json
CHANGED
package/src/components/App.jsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
2
|
import { TerminalPanel } from './TerminalPanel';
|
|
3
3
|
import { CodeViewer } from './CodeViewer';
|
|
4
4
|
|
|
@@ -15,6 +15,7 @@ export function App() {
|
|
|
15
15
|
const wsRef = useRef(null);
|
|
16
16
|
const activeTabIdRef = useRef(null);
|
|
17
17
|
const tabsRef = useRef([]);
|
|
18
|
+
const saveCurrentFileRef = useRef(null);
|
|
18
19
|
|
|
19
20
|
useEffect(() => {
|
|
20
21
|
activeTabIdRef.current = activeTabId;
|
|
@@ -24,55 +25,7 @@ export function App() {
|
|
|
24
25
|
tabsRef.current = tabs;
|
|
25
26
|
}, [tabs]);
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
fetchStatus();
|
|
29
|
-
connectWebSocket();
|
|
30
|
-
document.addEventListener('click', handleDocumentClick);
|
|
31
|
-
document.addEventListener('keydown', handleKeyDown);
|
|
32
|
-
|
|
33
|
-
const preventBrowserSave = (e) => {
|
|
34
|
-
if (e.ctrlKey && e.key === 's') {
|
|
35
|
-
e.preventDefault();
|
|
36
|
-
e.stopPropagation();
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
window.addEventListener('keydown', preventBrowserSave, true);
|
|
40
|
-
|
|
41
|
-
return () => {
|
|
42
|
-
document.removeEventListener('click', handleDocumentClick);
|
|
43
|
-
document.removeEventListener('keydown', handleKeyDown);
|
|
44
|
-
window.removeEventListener('keydown', preventBrowserSave, true);
|
|
45
|
-
if (wsRef.current) {
|
|
46
|
-
wsRef.current.close();
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}, [handleKeyDown]);
|
|
50
|
-
|
|
51
|
-
async function fetchStatus() {
|
|
52
|
-
try {
|
|
53
|
-
const port = window.location.port === '5173' ? '5174' : window.location.port;
|
|
54
|
-
const protocol = window.location.protocol === 'https:' ? 'https:' : 'http:';
|
|
55
|
-
const response = await fetch(`${protocol}//${window.location.hostname}:${port}/api/status`);
|
|
56
|
-
if (response.ok) {
|
|
57
|
-
const data = await response.json();
|
|
58
|
-
setVersion(data.version);
|
|
59
|
-
setLatestVersion(data.latestVersion);
|
|
60
|
-
setHasUpdate(data.hasUpdate);
|
|
61
|
-
if (data.projectRoot) {
|
|
62
|
-
const parts = data.projectRoot.split(/[/\\]/);
|
|
63
|
-
setProjectName(parts[parts.length - 1] || data.projectRoot);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
} catch (error) {
|
|
67
|
-
console.error('Failed to fetch status:', error);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function handleDocumentClick() {
|
|
72
|
-
setContextMenu(null);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const saveCurrentFile = useCallback(() => {
|
|
28
|
+
function saveCurrentFile() {
|
|
76
29
|
const currentTabId = activeTabIdRef.current;
|
|
77
30
|
const currentTabs = tabsRef.current;
|
|
78
31
|
const activeTab = currentTabs.find(t => t.id === currentTabId);
|
|
@@ -107,30 +60,85 @@ export function App() {
|
|
|
107
60
|
.catch(error => {
|
|
108
61
|
console.error('Failed to save file:', error);
|
|
109
62
|
});
|
|
110
|
-
}
|
|
63
|
+
}
|
|
111
64
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
saveCurrentFileRef.current = saveCurrentFile;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
async function fetchStatus() {
|
|
70
|
+
try {
|
|
71
|
+
const port = window.location.port === '5173' ? '5174' : window.location.port;
|
|
72
|
+
const protocol = window.location.protocol === 'https:' ? 'https:' : 'http:';
|
|
73
|
+
const response = await fetch(`${protocol}//${window.location.hostname}:${port}/api/status`);
|
|
74
|
+
if (response.ok) {
|
|
75
|
+
const data = await response.json();
|
|
76
|
+
setVersion(data.version);
|
|
77
|
+
setLatestVersion(data.latestVersion);
|
|
78
|
+
setHasUpdate(data.hasUpdate);
|
|
79
|
+
if (data.projectRoot) {
|
|
80
|
+
const parts = data.projectRoot.split(/[/\\]/);
|
|
81
|
+
setProjectName(parts[parts.length - 1] || data.projectRoot);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error('Failed to fetch status:', error);
|
|
118
86
|
}
|
|
87
|
+
}
|
|
119
88
|
|
|
120
|
-
|
|
89
|
+
function handleDocumentClick() {
|
|
90
|
+
setContextMenu(null);
|
|
91
|
+
}
|
|
121
92
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (e.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
fetchStatus();
|
|
95
|
+
connectWebSocket();
|
|
96
|
+
|
|
97
|
+
function handleKeyDown(e) {
|
|
98
|
+
if (e.ctrlKey && e.key === 's') {
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
console.log('Ctrl+S pressed, activeTabId:', activeTabIdRef.current);
|
|
101
|
+
if (saveCurrentFileRef.current) {
|
|
102
|
+
saveCurrentFileRef.current();
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!activeTabIdRef.current) return;
|
|
108
|
+
|
|
109
|
+
if (e.ctrlKey && e.key === 'w') {
|
|
110
|
+
e.preventDefault();
|
|
111
|
+
closeTab(activeTabIdRef.current);
|
|
112
|
+
} else if (e.ctrlKey && e.key === 'Tab') {
|
|
113
|
+
e.preventDefault();
|
|
114
|
+
if (e.shiftKey) {
|
|
115
|
+
switchToPrevTab();
|
|
116
|
+
} else {
|
|
117
|
+
switchToNextTab();
|
|
118
|
+
}
|
|
131
119
|
}
|
|
132
120
|
}
|
|
133
|
-
|
|
121
|
+
|
|
122
|
+
document.addEventListener('click', handleDocumentClick);
|
|
123
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
124
|
+
|
|
125
|
+
const preventBrowserSave = (e) => {
|
|
126
|
+
if (e.ctrlKey && e.key === 's') {
|
|
127
|
+
e.preventDefault();
|
|
128
|
+
e.stopPropagation();
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
window.addEventListener('keydown', preventBrowserSave, true);
|
|
132
|
+
|
|
133
|
+
return () => {
|
|
134
|
+
document.removeEventListener('click', handleDocumentClick);
|
|
135
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
136
|
+
window.removeEventListener('keydown', preventBrowserSave, true);
|
|
137
|
+
if (wsRef.current) {
|
|
138
|
+
wsRef.current.close();
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}, []);
|
|
134
142
|
|
|
135
143
|
function handleContentChange(newContent) {
|
|
136
144
|
setTabs(prevTabs => prevTabs.map(t => {
|
|
@@ -260,7 +268,8 @@ export function App() {
|
|
|
260
268
|
function closeTab(tabId) {
|
|
261
269
|
setTabs(prev => {
|
|
262
270
|
const newTabs = prev.filter(t => t.id !== tabId);
|
|
263
|
-
|
|
271
|
+
const currentActiveId = activeTabIdRef.current;
|
|
272
|
+
if (currentActiveId === tabId) {
|
|
264
273
|
const newActiveId = newTabs.length > 0 ? newTabs[newTabs.length - 1].id : null;
|
|
265
274
|
setActiveTabId(newActiveId);
|
|
266
275
|
}
|
|
@@ -283,20 +292,24 @@ export function App() {
|
|
|
283
292
|
}
|
|
284
293
|
|
|
285
294
|
function switchToNextTab() {
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
setActiveTabId(
|
|
295
|
+
const currentTabs = tabsRef.current;
|
|
296
|
+
const currentActiveId = activeTabIdRef.current;
|
|
297
|
+
const currentIndex = currentTabs.findIndex(t => t.id === currentActiveId);
|
|
298
|
+
if (currentIndex < currentTabs.length - 1) {
|
|
299
|
+
setActiveTabId(currentTabs[currentIndex + 1].id);
|
|
300
|
+
} else if (currentTabs.length > 0) {
|
|
301
|
+
setActiveTabId(currentTabs[0].id);
|
|
291
302
|
}
|
|
292
303
|
}
|
|
293
304
|
|
|
294
305
|
function switchToPrevTab() {
|
|
295
|
-
const
|
|
306
|
+
const currentTabs = tabsRef.current;
|
|
307
|
+
const currentActiveId = activeTabIdRef.current;
|
|
308
|
+
const currentIndex = currentTabs.findIndex(t => t.id === currentActiveId);
|
|
296
309
|
if (currentIndex > 0) {
|
|
297
|
-
setActiveTabId(
|
|
298
|
-
} else if (
|
|
299
|
-
setActiveTabId(
|
|
310
|
+
setActiveTabId(currentTabs[currentIndex - 1].id);
|
|
311
|
+
} else if (currentTabs.length > 0) {
|
|
312
|
+
setActiveTabId(currentTabs[currentTabs.length - 1].id);
|
|
300
313
|
}
|
|
301
314
|
}
|
|
302
315
|
|