codex-lens 0.1.23 → 0.1.24

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.
@@ -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-D-AWzk2Q.js"></script>
7
+ <script type="module" crossorigin src="./assets/main-fEtdvo0X.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="./assets/main-CYNmzqDG.css">
9
9
  </head>
10
10
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-lens",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "description": "A visualization tool for Codex that monitors API requests and file system changes",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -46,7 +46,7 @@ export function App() {
46
46
  wsRef.current.close();
47
47
  }
48
48
  };
49
- }, []);
49
+ }, [handleKeyDown]);
50
50
 
51
51
  async function fetchStatus() {
52
52
  try {
@@ -72,30 +72,6 @@ export function App() {
72
72
  setContextMenu(null);
73
73
  }
74
74
 
75
- function handleKeyDown(e) {
76
- if (e.ctrlKey && e.key === 's') {
77
- e.preventDefault();
78
- if (activeTabId) {
79
- saveCurrentFile();
80
- }
81
- return;
82
- }
83
-
84
- if (!activeTabId) return;
85
-
86
- if (e.ctrlKey && e.key === 'w') {
87
- e.preventDefault();
88
- closeTab(activeTabId);
89
- } else if (e.ctrlKey && e.key === 'Tab') {
90
- e.preventDefault();
91
- if (e.shiftKey) {
92
- switchToPrevTab();
93
- } else {
94
- switchToNextTab();
95
- }
96
- }
97
- }
98
-
99
75
  const saveCurrentFile = useCallback(() => {
100
76
  const currentTabId = activeTabIdRef.current;
101
77
  const currentTabs = tabsRef.current;
@@ -133,6 +109,29 @@ export function App() {
133
109
  });
134
110
  }, []);
135
111
 
112
+ const handleKeyDown = useCallback((e) => {
113
+ if (e.ctrlKey && e.key === 's') {
114
+ e.preventDefault();
115
+ console.log('Ctrl+S pressed, activeTabId:', activeTabIdRef.current);
116
+ saveCurrentFile();
117
+ return;
118
+ }
119
+
120
+ if (!activeTabIdRef.current) return;
121
+
122
+ if (e.ctrlKey && e.key === 'w') {
123
+ e.preventDefault();
124
+ closeTab(activeTabIdRef.current);
125
+ } else if (e.ctrlKey && e.key === 'Tab') {
126
+ e.preventDefault();
127
+ if (e.shiftKey) {
128
+ switchToPrevTab();
129
+ } else {
130
+ switchToNextTab();
131
+ }
132
+ }
133
+ }, [saveCurrentFile]);
134
+
136
135
  function handleContentChange(newContent) {
137
136
  setTabs(prevTabs => prevTabs.map(t => {
138
137
  if (t.id === activeTabId) {
@@ -365,7 +364,12 @@ export function App() {
365
364
  <ContextMenu
366
365
  x={contextMenu.x}
367
366
  y={contextMenu.y}
367
+ tabId={contextMenu.tabId}
368
368
  onClose={() => setContextMenu(null)}
369
+ onSave={() => {
370
+ saveCurrentFile();
371
+ setContextMenu(null);
372
+ }}
369
373
  onCloseTab={() => {
370
374
  closeTab(contextMenu.tabId);
371
375
  setContextMenu(null);
@@ -419,9 +423,14 @@ function TabBar({ tabs, activeTabId, onTabClick, onTabClose, onContextMenu }) {
419
423
  );
420
424
  }
421
425
 
422
- function ContextMenu({ x, y, onClose, onCloseTab, onCloseOtherTabs, onCloseAllTabs }) {
426
+ function ContextMenu({ x, y, tabId, onClose, onSave, onCloseTab, onCloseOtherTabs, onCloseAllTabs }) {
427
+ const tabs = tabsRef.current;
428
+ const tab = tabs.find(t => t.id === tabId);
429
+ const canSave = tab && !tab.isDiff;
430
+
423
431
  return (
424
432
  <div className="context-menu" style={{ left: x, top: y }} onClick={(e) => e.stopPropagation()}>
433
+ {canSave && <div className="context-menu-item" onClick={onSave}>保存</div>}
425
434
  <div className="context-menu-item" onClick={onCloseTab}>关闭</div>
426
435
  <div className="context-menu-item" onClick={onCloseOtherTabs}>关闭其他</div>
427
436
  <div className="context-menu-item" onClick={onCloseAllTabs}>关闭所有</div>