dsh-gufa-code 1.3.58 → 1.3.60

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/client.js CHANGED
@@ -16,7 +16,7 @@ const GUFA_NS = 'gufa-code'
16
16
  const G = {}
17
17
  G.NS = GUFA_NS
18
18
  /** 客户端构建标记(排查页面是否加载了新代码时看标题栏) */
19
- G.BUILD = '1.3.58'
19
+ G.BUILD = '1.3.60'
20
20
  G.PANEL_ID = 'gufa-code'
21
21
  /** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
22
22
  G.pendingEntryWorkspace = null
@@ -6753,6 +6753,37 @@ G.Explorer = function Explorer(props) {
6753
6753
  void loadDir('')
6754
6754
  }, [root, loadDir])
6755
6755
 
6756
+ /* 刷新已加载过的所有目录(根 + 展开过的子目录),而不是只刷根目录:
6757
+ 用户在系统 Finder 里新建/改名/删除文件后,点刷新也能看到子目录里的变化。 */
6758
+ const refreshAll = useCallback(() => {
6759
+ const paths = Object.keys(dirsRef.current)
6760
+ if (paths.length === 0) return
6761
+ for (const path of paths) void loadDir(path)
6762
+ }, [loadDir])
6763
+
6764
+ /* 从别的 App(Finder/终端)切回古法编程时,自动刷新已加载目录,不需要手动点刷新。 */
6765
+ useEffect(() => {
6766
+ if (!root) return undefined
6767
+ let timer = null
6768
+ const scheduleRefresh = () => {
6769
+ if (timer !== null) window.clearTimeout(timer)
6770
+ timer = window.setTimeout(() => {
6771
+ timer = null
6772
+ refreshAll()
6773
+ }, 180)
6774
+ }
6775
+ const onVisibilityChange = () => {
6776
+ if (document.visibilityState === 'visible') scheduleRefresh()
6777
+ }
6778
+ window.addEventListener('focus', scheduleRefresh)
6779
+ document.addEventListener('visibilitychange', onVisibilityChange)
6780
+ return () => {
6781
+ if (timer !== null) window.clearTimeout(timer)
6782
+ window.removeEventListener('focus', scheduleRefresh)
6783
+ document.removeEventListener('visibilitychange', onVisibilityChange)
6784
+ }
6785
+ }, [root, refreshAll])
6786
+
6756
6787
  // 刷新令牌:重新读取已展开过的目录,保留展开状态
6757
6788
  const dirsRef = useRef(dirs)
6758
6789
  dirsRef.current = dirs
@@ -7076,7 +7107,7 @@ G.Explorer = function Explorer(props) {
7076
7107
  multi.length > 1 ? h('span', { className: 'gufa-badge' }, String(multi.length)) : null,
7077
7108
  h(G.IconButton, { title: t('explorer.newFile'), onClick: () => props.onNewFile?.(selectedDir()) }, h(G.Icon, { name: 'plus', size: 14 })),
7078
7109
  h(G.IconButton, { title: t('explorer.newFolder'), onClick: () => props.onNewFolder?.(selectedDir()) }, h(G.Icon, { name: 'folder', size: 14 })),
7079
- h(G.IconButton, { title: t('explorer.refresh'), onClick: () => void loadDir('') }, h(G.Icon, { name: 'refresh', size: 13 })),
7110
+ h(G.IconButton, { title: t('explorer.refresh'), onClick: () => refreshAll() }, h(G.Icon, { name: 'refresh', size: 13 })),
7080
7111
  ),
7081
7112
  notice !== ''
7082
7113
  ? h('div', { className: 'gufa-explorer-notice', title: notice }, notice)
@@ -13319,7 +13350,19 @@ const GUFA_PLUGIN = {
13319
13350
  /* ignore */
13320
13351
  }
13321
13352
  }
13322
- void G.api('dev.log', { message: `float-hittest ${probeAt(135, 713)} | ${probeAt(300, 713)} | ${probeAt(900, 500)} | ${probeAt(1500, 60)} | modal[${modalInfo}] | rows[${rows.slice(0, 12).join(' ; ')}]` }).catch(() => {})
13353
+ // 可输入控件位置(用于自动化验证复制/粘贴)
13354
+ let inputs = []
13355
+ try {
13356
+ for (const node of document.querySelectorAll('textarea, input, [contenteditable="true"]')) {
13357
+ const rect = node.getBoundingClientRect()
13358
+ if (rect.width < 30 || rect.height < 12) continue
13359
+ inputs.push(`${node.tagName}@${Math.round(rect.left)},${Math.round(rect.top)},${Math.round(rect.width)}x${Math.round(rect.height)}`)
13360
+ if (inputs.length >= 8) break
13361
+ }
13362
+ } catch {
13363
+ inputs = ['err']
13364
+ }
13365
+ void G.api('dev.log', { message: `float-hittest ${probeAt(135, 713)} | ${probeAt(300, 713)} | ${probeAt(900, 500)} | ${probeAt(1500, 60)} | modal[${modalInfo}] | rows[${rows.slice(0, 12).join(' ; ')}] | inputs[${inputs.join(' ; ')}]` }).catch(() => {})
13323
13366
  }, 5000)
13324
13367
  }
13325
13368
  } catch {
@@ -1088,6 +1088,29 @@ static AXUIElementRef GufaCopyAXWindow(pid_t pid, NSString *title) {
1088
1088
  return found;
1089
1089
  }
1090
1090
 
1091
+ /* WKWebView 的「复制/粘贴/剪切」在 macOS 上依赖 App 菜单的 key equivalent
1092
+ (Cmd+C/V/X 由主菜单转发成 copy:/paste:/cut: action)。
1093
+ 悬浮层是独立进程且没有主菜单,不加这个的话编辑器/输入框里复制粘贴全部失效。
1094
+ 注意只加剪切/复制/粘贴:Cmd+Z / Cmd+A / Cmd+F 等交给网页自己处理(Monaco 有自己的实现),
1095
+ 加进菜单反而会拦截网页快捷键。 */
1096
+ static void GufaInstallEditMenu(void) {
1097
+ NSMenu *mainMenu = [[NSMenu alloc] init];
1098
+ NSMenuItem *appMenuItem = [[NSMenuItem alloc] init];
1099
+ [mainMenu addItem:appMenuItem];
1100
+ NSMenu *appMenu = [[NSMenu alloc] initWithTitle:@"古法编程悬浮层"];
1101
+ appMenuItem.submenu = appMenu;
1102
+ [appMenu addItemWithTitle:@"关于古法编程悬浮层" action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
1103
+
1104
+ NSMenuItem *editMenuItem = [[NSMenuItem alloc] init];
1105
+ [mainMenu addItem:editMenuItem];
1106
+ NSMenu *editMenu = [[NSMenu alloc] initWithTitle:@"编辑"];
1107
+ editMenuItem.submenu = editMenu;
1108
+ [editMenu addItemWithTitle:@"剪切" action:@selector(cut:) keyEquivalent:@"x"];
1109
+ [editMenu addItemWithTitle:@"复制" action:@selector(copy:) keyEquivalent:@"c"];
1110
+ [editMenu addItemWithTitle:@"粘贴" action:@selector(paste:) keyEquivalent:@"v"];
1111
+ NSApp.mainMenu = mainMenu;
1112
+ }
1113
+
1091
1114
  int main(int argc, const char *argv[]) {
1092
1115
  if (argc > 1 && (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-v") == 0)) {
1093
1116
  printf("gufa-float-macos %s\n", GUFA_FLOAT_VERSION);
@@ -1108,6 +1131,7 @@ int main(int argc, const char *argv[]) {
1108
1131
  @autoreleasepool {
1109
1132
  [NSApplication sharedApplication];
1110
1133
  [NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory];
1134
+ GufaInstallEditMenu();
1111
1135
  GufaInstallTermHandler();
1112
1136
  GufaAppDelegate *delegate = [[GufaAppDelegate alloc] init];
1113
1137
  NSApp.delegate = delegate;
@@ -7,8 +7,8 @@
7
7
  <key>CFBundleDisplayName</key><string>古法编程悬浮层</string>
8
8
  <key>CFBundleExecutable</key><string>gufa-float</string>
9
9
  <key>CFBundlePackageType</key><string>APPL</string>
10
- <key>CFBundleShortVersionString</key><string>1.3.58</string>
11
- <key>CFBundleVersion</key><string>1.3.58</string>
10
+ <key>CFBundleShortVersionString</key><string>1.3.60</string>
11
+ <key>CFBundleVersion</key><string>1.3.60</string>
12
12
  <key>LSUIElement</key><true/>
13
13
  <key>NSHighResolutionCapable</key><true/>
14
14
  <key>NSPrincipalClass</key><string>NSApplication</string>
@@ -117,6 +117,29 @@
117
117
  - 排查要点:`float-hittest` 日志会打印 elementFromPoint 与临时 `.gufa-modal` 的计算样式(bg/color),
118
118
  `float-styles` 打印覆盖层透明度;终端输入问题优先看窗口是否 key,而不是 transport。
119
119
 
120
+ ## 资源管理器外部文件变化(1.3.59 修复)
121
+
122
+ 问题:在 Finder/终端里新建/删除文件后切回古法编程,资源管理器不显示;点右上角刷新也只刷新根目录,
123
+ 展开的子目录里新建的文件仍然看不到。
124
+
125
+ 原因:刷新按钮只调用 `loadDir('')`(根目录),没有刷新已经展开/加载过的子目录;
126
+ 切换回窗口时也不会自动刷新。
127
+
128
+ 修复:
129
+ - 刷新按钮改为 `refreshAll()`:重读「根目录 + 所有已加载目录」;
130
+ - 窗口 `focus` / `visibilitychange`(可见)时防抖 180ms 自动 `refreshAll()`,从 Finder 切回来无需手动刷新。
131
+
132
+ ## 摸鱼窗口里复制/粘贴失效(1.3.60 修复)
133
+
134
+ macOS 上 WKWebView 的「复制/粘贴/剪切」是**通过 App 主菜单的 key equivalent** 转成 `copy:/paste:/cut:` 再走 responder chain 的。
135
+ 悬浮层是独立进程、没有主菜单,所以 Cmd+C/V 在编辑器、输入框里全部失效。
136
+
137
+ 修复:helper 安装 `NSApp.mainMenu`,只添加「编辑 → 剪切/复制/粘贴」三项(Cmd+X/C/V)。
138
+ **不要**把 Cmd+Z / Cmd+A / Cmd+F 加进菜单:Monaco 自己处理这些快捷键,菜单会拦截并走 WebView 原生选择/撤销,行为反而错乱。
139
+
140
+ 验证:悬浮层聊天输入框 Cmd+V → 粘贴成功,Cmd+A+C 后 `pbpaste` 内容正确;
141
+ 编辑器(.gitignore)里 Cmd+V 插入成功并自动保存,Cmd+A+C 后 `pbpaste` 为整个文件文本。
142
+
120
143
  ## 5.1 摸鱼会话框比编辑器黑:官方会话根节点自己又画了一层底
121
144
 
122
145
  - 现象:摸鱼里编辑器/终端都统一了,右侧会话框看起来明显更黑更实。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-gufa-code",
3
- "version": "1.3.58",
3
+ "version": "1.3.60",
4
4
  "description": "古法编程 · AI 辅助:一键把 DSH 主面板变成 VS Code 风格 IDE(Monaco 编辑器、文件树、Git、SSH、真实终端 + 右侧官方会话);主张亲手写、每个改动心中有数,AI 是助理、你是第一责任人",
5
5
  "icon": "icon.svg",
6
6
  "keywords": [
@@ -62,6 +62,37 @@ G.Explorer = function Explorer(props) {
62
62
  void loadDir('')
63
63
  }, [root, loadDir])
64
64
 
65
+ /* 刷新已加载过的所有目录(根 + 展开过的子目录),而不是只刷根目录:
66
+ 用户在系统 Finder 里新建/改名/删除文件后,点刷新也能看到子目录里的变化。 */
67
+ const refreshAll = useCallback(() => {
68
+ const paths = Object.keys(dirsRef.current)
69
+ if (paths.length === 0) return
70
+ for (const path of paths) void loadDir(path)
71
+ }, [loadDir])
72
+
73
+ /* 从别的 App(Finder/终端)切回古法编程时,自动刷新已加载目录,不需要手动点刷新。 */
74
+ useEffect(() => {
75
+ if (!root) return undefined
76
+ let timer = null
77
+ const scheduleRefresh = () => {
78
+ if (timer !== null) window.clearTimeout(timer)
79
+ timer = window.setTimeout(() => {
80
+ timer = null
81
+ refreshAll()
82
+ }, 180)
83
+ }
84
+ const onVisibilityChange = () => {
85
+ if (document.visibilityState === 'visible') scheduleRefresh()
86
+ }
87
+ window.addEventListener('focus', scheduleRefresh)
88
+ document.addEventListener('visibilitychange', onVisibilityChange)
89
+ return () => {
90
+ if (timer !== null) window.clearTimeout(timer)
91
+ window.removeEventListener('focus', scheduleRefresh)
92
+ document.removeEventListener('visibilitychange', onVisibilityChange)
93
+ }
94
+ }, [root, refreshAll])
95
+
65
96
  // 刷新令牌:重新读取已展开过的目录,保留展开状态
66
97
  const dirsRef = useRef(dirs)
67
98
  dirsRef.current = dirs
@@ -385,7 +416,7 @@ G.Explorer = function Explorer(props) {
385
416
  multi.length > 1 ? h('span', { className: 'gufa-badge' }, String(multi.length)) : null,
386
417
  h(G.IconButton, { title: t('explorer.newFile'), onClick: () => props.onNewFile?.(selectedDir()) }, h(G.Icon, { name: 'plus', size: 14 })),
387
418
  h(G.IconButton, { title: t('explorer.newFolder'), onClick: () => props.onNewFolder?.(selectedDir()) }, h(G.Icon, { name: 'folder', size: 14 })),
388
- h(G.IconButton, { title: t('explorer.refresh'), onClick: () => void loadDir('') }, h(G.Icon, { name: 'refresh', size: 13 })),
419
+ h(G.IconButton, { title: t('explorer.refresh'), onClick: () => refreshAll() }, h(G.Icon, { name: 'refresh', size: 13 })),
389
420
  ),
390
421
  notice !== ''
391
422
  ? h('div', { className: 'gufa-explorer-notice', title: notice }, notice)
@@ -546,7 +546,19 @@ const GUFA_PLUGIN = {
546
546
  /* ignore */
547
547
  }
548
548
  }
549
- void G.api('dev.log', { message: `float-hittest ${probeAt(135, 713)} | ${probeAt(300, 713)} | ${probeAt(900, 500)} | ${probeAt(1500, 60)} | modal[${modalInfo}] | rows[${rows.slice(0, 12).join(' ; ')}]` }).catch(() => {})
549
+ // 可输入控件位置(用于自动化验证复制/粘贴)
550
+ let inputs = []
551
+ try {
552
+ for (const node of document.querySelectorAll('textarea, input, [contenteditable="true"]')) {
553
+ const rect = node.getBoundingClientRect()
554
+ if (rect.width < 30 || rect.height < 12) continue
555
+ inputs.push(`${node.tagName}@${Math.round(rect.left)},${Math.round(rect.top)},${Math.round(rect.width)}x${Math.round(rect.height)}`)
556
+ if (inputs.length >= 8) break
557
+ }
558
+ } catch {
559
+ inputs = ['err']
560
+ }
561
+ void G.api('dev.log', { message: `float-hittest ${probeAt(135, 713)} | ${probeAt(300, 713)} | ${probeAt(900, 500)} | ${probeAt(1500, 60)} | modal[${modalInfo}] | rows[${rows.slice(0, 12).join(' ; ')}] | inputs[${inputs.join(' ; ')}]` }).catch(() => {})
550
562
  }, 5000)
551
563
  }
552
564
  } catch {