dsh-gufa-code 1.3.60 → 1.3.62

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/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
  一个 DSH 插件。点工作区行「…」菜单里的 **古法编程** 后,主面板切换成一个三栏 IDE:
13
13
 
14
- - **左**:活动栏 + 资源管理器 / 源代码管理 / SSH / 终端;
14
+ - **左**:活动栏 + 资源管理器 / 全局搜索 / 源代码管理 / SSH / 终端;
15
15
  - **中**:Monaco 编辑器(标签页、面包屑、状态栏、两文件对比、Git diff);
16
16
  - **右**:**官方 DSH 会话面板原样停靠** —— 工具调用、自动读写文件、审批弹窗、斜杠命令、上下文引用、会话历史都还在。
17
17
 
@@ -41,6 +41,7 @@ dsh plugin add dsh-gufa-code
41
41
  - Monaco 编辑器(离线随包分发,无需联网下载);
42
42
  - 多标签、按扩展名语法高亮、面包屑、状态栏(分支 / 行列 / 保存状态);
43
43
  - 保存走磁盘版本冲突检测 + 原子写;未保存标记;
44
+ - **全局搜索**(左栏放大镜 / `⌘⇧F`):整个项目的文本搜索,支持区分大小写、正则;结果按文件分组、高亮匹配,点击直接跳到文件对应行列;Git 项目用 `git ls-files` 枚举文件(尊重 `.gitignore`、含未跟踪文件),非 Git 项目遍历目录并自动跳过 `node_modules` 等依赖/缓存目录;
44
45
  - 资源管理器右键:新建 / 重命名 / 删除 / 复制 / 粘贴 / 打开所在文件夹 / 两文件对比;
45
46
  - **从 Finder 粘贴/拖入文件**:系统剪贴板里复制的文件可直接 ⌘V 粘进资源管理器(写入选中的目录,重名自动加「副本」),也可从 Finder 直接拖进文件树;
46
47
  - **粘贴文件到聊天框 = @引用**:在 Finder 复制文件后在右侧对话输入框 ⌘V,会自动匹配项目内同名同内容文件并插入 `@相对路径` 引用(图片仍按 DSH 默认附件处理);
@@ -50,7 +51,7 @@ dsh plugin add dsh-gufa-code
50
51
 
51
52
  ### 快捷键(仅 IDE 模式生效,参考 VS Code)
52
53
 
53
- `⌘S` 保存、`⌘K` 清空终端、`⌘J` / `` ⌃` `` 终端、`⌘B` 左栏、`⌘W` 关标签、`⌘⇧E` / `⌘⇧G` 资源管理器 / 源代码管理、`⌘⇧U` SSH、`⌃⇧\`` 新建终端、`⌘/` 行注释(非编辑器区为快捷键列表)。
54
+ `⌘S` 保存、`⌘K` 清空终端、`⌘J` / `` ⌃` `` 终端、`⌘B` 左栏、`⌘W` 关标签、`⌘⇧E` / `⌘⇧F` / `⌘⇧G` 资源管理器 / 全局搜索 / 源代码管理、`⌘⇧U` SSH、`⌃⇧\`` 新建终端、`⌘/` 行注释(非编辑器区为快捷键列表)。
54
55
  经典模式的快捷键完全不受影响。
55
56
 
56
57
  ### 左侧面板
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.60'
19
+ G.BUILD = '1.3.62'
20
20
  G.PANEL_ID = 'gufa-code'
21
21
  /** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
22
22
  G.pendingEntryWorkspace = null
@@ -120,6 +120,7 @@ const DICT_ZH = {
120
120
  'shortcuts.toggleSidebar': '显示 / 隐藏左侧栏',
121
121
  'shortcuts.closeTab': '关闭当前标签页',
122
122
  'shortcuts.explorer': '聚焦资源管理器',
123
+ 'shortcuts.search': '聚焦全局搜索',
123
124
  'shortcuts.git': '聚焦源代码管理',
124
125
  'shortcuts.ssh': '聚焦 SSH 主机',
125
126
  'shortcuts.newTerminal': '新建终端',
@@ -184,12 +185,23 @@ const DICT_ZH = {
184
185
  'app.manualPath': '或直接输入路径',
185
186
  'app.pathPlaceholder': '例如 /Users/me/project',
186
187
  'activity.explorer': '资源管理器',
188
+ 'activity.search': '搜索',
187
189
  'activity.git': '源代码管理',
188
190
  'activity.ssh': 'SSH 远程',
189
191
  'activity.terminal': '终端',
190
192
  'activity.chat': '古法 AI 助手',
191
193
  'activity.collapseChat': '收起 AI 面板',
192
194
  'activity.expandChat': '展开 AI 面板',
195
+ 'search.placeholder': '搜索项目中的文本,回车立即搜索',
196
+ 'search.caseSensitive': '区分大小写',
197
+ 'search.regex': '使用正则表达式',
198
+ 'search.clear': '清空搜索',
199
+ 'search.searching': '搜索中…',
200
+ 'search.idle': '输入关键字搜索整个项目',
201
+ 'search.noResult': '没有找到匹配结果',
202
+ 'search.summary': '{count} 个结果 · {files} 个文件',
203
+ 'search.truncated': '结果过多已截断,请缩小范围',
204
+ 'search.error': '搜索失败',
193
205
  'explorer.empty': '目录为空',
194
206
  'explorer.newFile': '新建文件',
195
207
  'explorer.newFolder': '新建文件夹',
@@ -349,6 +361,7 @@ const DICT_EN = {
349
361
  'shortcuts.toggleSidebar': 'Toggle sidebar',
350
362
  'shortcuts.closeTab': 'Close current tab',
351
363
  'shortcuts.explorer': 'Focus explorer',
364
+ 'shortcuts.search': 'Focus search',
352
365
  'shortcuts.git': 'Focus source control',
353
366
  'shortcuts.ssh': 'Focus SSH hosts',
354
367
  'shortcuts.newTerminal': 'New terminal',
@@ -404,12 +417,23 @@ const DICT_EN = {
404
417
  'app.manualPath': 'Or type a path',
405
418
  'app.pathPlaceholder': 'e.g. /Users/me/project',
406
419
  'activity.explorer': 'Explorer',
420
+ 'activity.search': 'Search',
407
421
  'activity.git': 'Source control',
408
422
  'activity.ssh': 'SSH',
409
423
  'activity.terminal': 'Terminal',
410
424
  'activity.chat': 'Gufa AI',
411
425
  'activity.collapseChat': 'Collapse AI panel',
412
426
  'activity.expandChat': 'Expand AI panel',
427
+ 'search.placeholder': 'Search text across the project (Enter to run)',
428
+ 'search.caseSensitive': 'Match case',
429
+ 'search.regex': 'Use regular expression',
430
+ 'search.clear': 'Clear search',
431
+ 'search.searching': 'Searching…',
432
+ 'search.idle': 'Type a keyword to search the whole project',
433
+ 'search.noResult': 'No matches found',
434
+ 'search.summary': '{count} results · {files} files',
435
+ 'search.truncated': 'Too many results, truncated — narrow the query',
436
+ 'search.error': 'Search failed',
413
437
  'explorer.empty': 'Folder is empty',
414
438
  'explorer.newFile': 'New file',
415
439
  'explorer.newFolder': 'New folder',
@@ -1659,6 +1683,29 @@ html[data-platform=darwin][data-fullscreen] .gufa-titlebar{height:44px;padding-l
1659
1683
  .gufa-explorer-notice{margin:4px 10px 0;padding:3px 8px;border-radius:6px;font-size:11px;line-height:1.5;color:var(--gufa-text);
1660
1684
  background:color-mix(in srgb, var(--gufa-accent) 14%, transparent);border:0.5px solid color-mix(in srgb, var(--gufa-accent) 40%, transparent);
1661
1685
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
1686
+ /* ── 搜索面板(全局文本搜索) ───────────────────────────────────────── */
1687
+ .gufa-search-bar{display:flex;flex-direction:column;gap:6px;padding:6px 8px;border-bottom:1px solid var(--gufa-border);flex:0 0 auto}
1688
+ .gufa-search-input-wrap{display:flex;align-items:center;gap:6px;height:28px;padding:0 8px;border-radius:7px;border:1px solid var(--gufa-border);background:var(--gufa-layer2);color:var(--gufa-text-dim)}
1689
+ .gufa-search-input-wrap:focus-within{border-color:var(--gufa-accent)}
1690
+ .gufa-search-input{flex:1 1 auto;min-width:0;height:100%;border:0;background:transparent;color:var(--gufa-text);font-size:12px;outline:none}
1691
+ .gufa-search-input::placeholder{color:var(--gufa-text-dim)}
1692
+ .gufa-search-toggles{display:flex;align-items:center;gap:5px;min-height:22px}
1693
+ .gufa-search-toggle{height:22px;min-width:25px;padding:0 5px;border-radius:5px;border:1px solid var(--gufa-border);background:transparent;color:var(--gufa-text-dim);font:600 11px ui-monospace,Menlo,Consolas,monospace;cursor:pointer}
1694
+ .gufa-search-toggle:hover{color:var(--gufa-text);background:var(--gufa-hover)}
1695
+ .gufa-search-toggle[data-active]{background:var(--gufa-accent);border-color:var(--gufa-accent);color:#fff}
1696
+ .gufa-search-summary{margin-left:auto;font-size:11px;color:var(--gufa-text-dim);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
1697
+ .gufa-search-file{margin:0 6px}
1698
+ .gufa-search-file-head{display:flex;align-items:center;gap:5px;width:100%;height:24px;padding:0 6px;border:0;background:transparent;color:var(--gufa-text);border-radius:5px;cursor:pointer;text-align:left}
1699
+ .gufa-search-file-head:hover{background:var(--gufa-hover)}
1700
+ .gufa-search-file-name{flex:0 0 auto;max-width:55%;font-size:12px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
1701
+ .gufa-search-file-dir{flex:1 1 auto;min-width:0;font-size:10.5px;color:var(--gufa-text-dim);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
1702
+ .gufa-search-file-count{flex:0 0 auto;font-size:10.5px;color:var(--gufa-text-dim);border:1px solid var(--gufa-border);border-radius:999px;padding:0 6px;line-height:15px}
1703
+ .gufa-search-match{display:flex;align-items:baseline;gap:8px;width:100%;padding:2px 6px 2px 24px;border:0;background:transparent;color:var(--gufa-text-dim);cursor:pointer;border-radius:5px;text-align:left}
1704
+ .gufa-search-match:hover{background:var(--gufa-hover);color:var(--gufa-text)}
1705
+ .gufa-search-line{flex:0 0 auto;min-width:24px;text-align:right;font:11px ui-monospace,Menlo,Consolas,monospace;opacity:.65}
1706
+ .gufa-search-text{flex:1 1 auto;min-width:0;font:11.5px ui-monospace,Menlo,Consolas,monospace;white-space:pre;overflow:hidden;text-overflow:ellipsis}
1707
+ .gufa-search-hit{background:rgba(192,57,43,.38);color:var(--gufa-text);border-radius:2px;padding:0 1px}
1708
+
1662
1709
  .gufa-tree-chevron{width:14px;flex:0 0 auto;opacity:.7;display:flex;align-items:center;justify-content:center}
1663
1710
  .gufa-tree-icon{width:15px;flex:0 0 auto;opacity:.85;display:flex;align-items:center;justify-content:center}
1664
1711
  .gufa-tree-badge{font-size:10px;color:var(--gufa-accent);flex:0 0 auto;font-weight:600}
@@ -2774,6 +2821,7 @@ G.FooterAction = function FooterAction(props) {
2774
2821
  const propsRef = useRef(props)
2775
2822
  const activePathRef = useRef(activePath)
2776
2823
  const statusRef = useRef('loading')
2824
+ const pendingRevealRef = useRef(null)
2777
2825
 
2778
2826
  /** idle → loading → ready / error */
2779
2827
  const [status, setStatus] = useState('loading')
@@ -3211,6 +3259,17 @@ G.FooterAction = function FooterAction(props) {
3211
3259
  }
3212
3260
  }
3213
3261
  reportCursor()
3262
+ const pending = pendingRevealRef.current
3263
+ if (pending !== null && pending !== undefined && pending.path === targetTab.path) {
3264
+ pendingRevealRef.current = null
3265
+ try {
3266
+ editor.setPosition({ lineNumber: pending.line, column: pending.column })
3267
+ editor.revealLineInCenter(pending.line)
3268
+ editor.focus()
3269
+ } catch {
3270
+ /* ignore */
3271
+ }
3272
+ }
3214
3273
  /* 打开/切换文件不抢焦点:只有用户点击编辑区时才进入键盘编辑 */
3215
3274
  }
3216
3275
  } else if (targetTab !== null) {
@@ -3218,6 +3277,31 @@ G.FooterAction = function FooterAction(props) {
3218
3277
  }
3219
3278
  }, [status, tabs, activePath, root, reportCursor, disposeAllModels, disposeModelAt])
3220
3279
 
3280
+ /* 搜索面板点击结果 → 打开文件并跳到对应行列(由 App 通过 bus 发来) */
3281
+ useEffect(() => {
3282
+ if (G.bus === null || G.bus === undefined || typeof G.bus.on !== 'function') return undefined
3283
+ return G.bus.on('editor:reveal', (detail) => {
3284
+ const editor = editorRef.current
3285
+ if (editor === null || editor === undefined) return
3286
+ const rawLine = Number(detail?.line)
3287
+ const rawColumn = Number(detail?.column)
3288
+ const line = Number.isFinite(rawLine) ? Math.max(1, Math.trunc(rawLine)) : 1
3289
+ const column = Number.isFinite(rawColumn) ? Math.max(1, Math.trunc(rawColumn)) : 1
3290
+ const path = typeof detail?.path === 'string' && detail.path !== '' ? detail.path : null
3291
+ if (path !== null && modelPathRef.current !== path) {
3292
+ pendingRevealRef.current = { path, line, column }
3293
+ return
3294
+ }
3295
+ try {
3296
+ editor.setPosition({ lineNumber: line, column })
3297
+ editor.revealLineInCenter(line)
3298
+ editor.focus()
3299
+ } catch (error) {
3300
+ /* ignore */
3301
+ }
3302
+ })
3303
+ }, [])
3304
+
3221
3305
  /* ── Git diff 视图:Monaco DiffEditor(未暂存的一侧可编辑并保存) ── */
3222
3306
  useEffect(() => {
3223
3307
  const disposeDiff = () => {
@@ -7201,6 +7285,219 @@ G.MenuItem = function MenuItem(props) {
7201
7285
  )
7202
7286
  }
7203
7287
 
7288
+ /* ── 全局搜索(左侧「搜索」面板) ──────────────────────────────────────── */
7289
+ G.SearchPanel = function SearchPanel(props) {
7290
+ const t = G.useT()
7291
+ const root = props.root
7292
+ const [query, setQuery] = useState('')
7293
+ const [caseSensitive, setCaseSensitive] = useState(false)
7294
+ const [regex, setRegex] = useState(false)
7295
+ const [status, setStatus] = useState('idle')
7296
+ const [result, setResult] = useState(null)
7297
+ const [error, setError] = useState('')
7298
+ const [collapsed, setCollapsed] = useState({})
7299
+ const inputRef = useRef(null)
7300
+ const requestRef = useRef(0)
7301
+
7302
+ const focusInput = useCallback(() => {
7303
+ const node = inputRef.current
7304
+ if (node === null || node === undefined) return
7305
+ try {
7306
+ node.focus()
7307
+ if (typeof node.select === 'function') node.select()
7308
+ } catch {
7309
+ /* ignore */
7310
+ }
7311
+ }, [])
7312
+
7313
+ const runSearch = useCallback(async (value) => {
7314
+ const text = String(value ?? '').trim()
7315
+ if (text === '' || typeof root !== 'string' || root === '') {
7316
+ requestRef.current += 1
7317
+ setResult(null)
7318
+ setStatus('idle')
7319
+ setError('')
7320
+ return
7321
+ }
7322
+ const seq = requestRef.current + 1
7323
+ requestRef.current = seq
7324
+ setStatus('loading')
7325
+ setError('')
7326
+ try {
7327
+ const value = await G.api('fs.search', {
7328
+ root,
7329
+ query: text,
7330
+ options: { caseSensitive, regex, maxFiles: 200, maxMatches: 500 },
7331
+ })
7332
+ if (seq !== requestRef.current) return
7333
+ setResult(value)
7334
+ setStatus('ready')
7335
+ } catch (err) {
7336
+ if (seq !== requestRef.current) return
7337
+ setResult(null)
7338
+ setError(G.errorText(err))
7339
+ setStatus('error')
7340
+ }
7341
+ }, [root, caseSensitive, regex])
7342
+
7343
+ /* 输入防抖搜索(回车立即搜索) */
7344
+ useEffect(() => {
7345
+ if (typeof root !== 'string' || root === '') return undefined
7346
+ const text = query.trim()
7347
+ if (text === '') {
7348
+ setResult(null)
7349
+ setStatus('idle')
7350
+ setError('')
7351
+ return undefined
7352
+ }
7353
+ const timer = window.setTimeout(() => { void runSearch(text) }, 320)
7354
+ return () => window.clearTimeout(timer)
7355
+ }, [query, runSearch, root])
7356
+
7357
+ /* 快捷键/按钮打开搜索面板时聚焦输入框 */
7358
+ useEffect(() => {
7359
+ if (G.bus === null || G.bus === undefined || typeof G.bus.on !== 'function') return undefined
7360
+ return G.bus.on('search:focus', focusInput)
7361
+ }, [focusInput])
7362
+
7363
+ useEffect(() => {
7364
+ if (props.active === true) focusInput()
7365
+ }, [props.active, focusInput])
7366
+
7367
+ const summary = (() => {
7368
+ if (status === 'loading') return t('search.searching')
7369
+ if (status === 'error' || result === null) return ''
7370
+ if (result.total === 0) return result.truncated === true ? t('search.truncated') : t('search.noResult')
7371
+ const base = t('search.summary', { count: result.total, files: result.files.length })
7372
+ return result.truncated === true ? `${base} · ${t('search.truncated')}` : base
7373
+ })()
7374
+
7375
+ const highlight = (match) => {
7376
+ const text = typeof match.text === 'string' ? match.text : ''
7377
+ const start = Number.isFinite(match.start) ? match.start : -1
7378
+ const end = Number.isFinite(match.end) ? match.end : -1
7379
+ if (start < 0 || end <= start || start >= text.length) return [text]
7380
+ const safeEnd = Math.min(end, text.length)
7381
+ return [
7382
+ text.slice(0, start),
7383
+ h('mark', { key: 'hit', className: 'gufa-search-hit' }, text.slice(start, safeEnd)),
7384
+ text.slice(safeEnd),
7385
+ ]
7386
+ }
7387
+
7388
+ const body = (() => {
7389
+ if (typeof root !== 'string' || root === '') {
7390
+ return h('div', { className: 'gufa-hint', style: { padding: '10px 12px' } }, t('explorer.openProjectFirst'))
7391
+ }
7392
+ if (error !== '') {
7393
+ return h('div', { className: 'gufa-error-banner', style: { margin: '8px' } }, h(G.Icon, { name: 'warn', size: 12 }), h('span', null, `${t('search.error')}:${error}`))
7394
+ }
7395
+ if (status === 'idle') return h('div', { className: 'gufa-hint', style: { padding: '10px 12px' } }, t('search.idle'))
7396
+ if (status === 'loading') return h('div', { className: 'gufa-hint', style: { padding: '10px 12px', display: 'flex', gap: 8, alignItems: 'center' } }, h(G.Spinner), t('search.searching'))
7397
+ if (result === null || result.total === 0) {
7398
+ const emptyText = result !== null && result.truncated === true ? t('search.truncated') : t('search.noResult')
7399
+ return h('div', { className: 'gufa-hint', style: { padding: '10px 12px' } }, emptyText)
7400
+ }
7401
+ return h(
7402
+ 'div',
7403
+ { className: 'gufa-search-results' },
7404
+ ...result.files.map((file) => {
7405
+ const isCollapsed = collapsed[file.path] === true
7406
+ return h(
7407
+ 'div',
7408
+ { key: file.path, className: 'gufa-search-file' },
7409
+ h(
7410
+ 'button',
7411
+ {
7412
+ type: 'button',
7413
+ className: 'gufa-search-file-head',
7414
+ title: file.path,
7415
+ onClick: () => setCollapsed((current) => ({ ...current, [file.path]: !isCollapsed })),
7416
+ },
7417
+ h(G.Icon, { name: isCollapsed ? 'chevron-right' : 'chevron-down', size: 11 }),
7418
+ h('span', { className: 'gufa-search-file-name' }, G.basename(file.path)),
7419
+ h('span', { className: 'gufa-search-file-dir' }, G.dirname(file.path)),
7420
+ h('span', { className: 'gufa-search-file-count' }, String(file.matches.length)),
7421
+ ),
7422
+ isCollapsed
7423
+ ? null
7424
+ : file.matches.map((match, index) =>
7425
+ h(
7426
+ 'button',
7427
+ {
7428
+ key: `${file.path}:${match.line}:${match.column}:${index}`,
7429
+ type: 'button',
7430
+ className: 'gufa-search-match',
7431
+ title: `${file.path}:${match.line}:${match.column}`,
7432
+ onClick: () => props.onOpenFile?.(file.path, match.line, match.column),
7433
+ },
7434
+ h('span', { className: 'gufa-search-line' }, String(match.line)),
7435
+ h('span', { className: 'gufa-search-text' }, ...highlight(match)),
7436
+ ),
7437
+ ),
7438
+ )
7439
+ }),
7440
+ )
7441
+ })()
7442
+
7443
+ return h(
7444
+ 'div',
7445
+ { className: 'gufa-search-panel', style: { display: 'flex', flexDirection: 'column', flex: '1 1 auto', minHeight: 0 } },
7446
+ h('div', { className: 'gufa-panel-head' }, h('span', { className: 'gufa-panel-head-title' }, t('activity.search'))),
7447
+ h(
7448
+ 'div',
7449
+ { className: 'gufa-search-bar' },
7450
+ h(
7451
+ 'div',
7452
+ { className: 'gufa-search-input-wrap' },
7453
+ h(G.Icon, { name: 'search', size: 13 }),
7454
+ h('input', {
7455
+ ref: inputRef,
7456
+ className: 'gufa-search-input',
7457
+ type: 'text',
7458
+ value: query,
7459
+ placeholder: t('search.placeholder'),
7460
+ spellCheck: false,
7461
+ onChange: (event) => setQuery(event.target.value),
7462
+ onKeyDown: (event) => {
7463
+ if (event.key === 'Enter') {
7464
+ event.preventDefault()
7465
+ void runSearch(query)
7466
+ } else if (event.key === 'Escape') {
7467
+ event.preventDefault()
7468
+ setQuery('')
7469
+ inputRef.current?.blur?.()
7470
+ }
7471
+ },
7472
+ }),
7473
+ query === ''
7474
+ ? null
7475
+ : h(G.IconButton, { title: t('search.clear'), onClick: () => { setQuery(''); focusInput() } }, h(G.Icon, { name: 'close', size: 11 })),
7476
+ ),
7477
+ h(
7478
+ 'div',
7479
+ { className: 'gufa-search-toggles' },
7480
+ h('button', {
7481
+ type: 'button',
7482
+ className: 'gufa-search-toggle',
7483
+ 'data-active': caseSensitive ? '' : undefined,
7484
+ title: t('search.caseSensitive'),
7485
+ onClick: () => setCaseSensitive((value) => !value),
7486
+ }, 'Aa'),
7487
+ h('button', {
7488
+ type: 'button',
7489
+ className: 'gufa-search-toggle',
7490
+ 'data-active': regex ? '' : undefined,
7491
+ title: t('search.regex'),
7492
+ onClick: () => setRegex((value) => !value),
7493
+ }, '.*'),
7494
+ h('span', { className: 'gufa-search-summary', title: summary }, summary),
7495
+ ),
7496
+ ),
7497
+ h('div', { className: 'gufa-panel-body gufa-scroll' }, body),
7498
+ )
7499
+ }
7500
+
7204
7501
  /* ── 源代码管理(Git) ─────────────────────────────────────────────────── */
7205
7502
  G.GitPanel = function GitPanel(props) {
7206
7503
  const t = G.useT()
@@ -9222,6 +9519,7 @@ G.shortcutAction = function shortcutAction(event) {
9222
9519
  }
9223
9520
  if (event.shiftKey === true) {
9224
9521
  if (key === 'e') return 'panelExplorer'
9522
+ if (key === 'f') return 'panelSearch'
9225
9523
  if (key === 'g') return 'panelGit'
9226
9524
  if (key === 'h' || key === 'u') return 'panelSsh'
9227
9525
  if (key === 'b') return 'toggleSidebar'
@@ -9336,6 +9634,7 @@ const GUFA_SHORTCUT_COMMANDS = [
9336
9634
  { action: 'toggleSidebar', id: 'gufa.ide.toggleSidebar', labelKey: 'shortcuts.toggleSidebar', code: 'KeyB', modifiers: ['primary', 'shift'], regions: ['page', 'editable'] },
9337
9635
  { action: 'closeTab', id: 'gufa.ide.closeTab', labelKey: 'shortcuts.closeTab', code: 'KeyW', modifiers: ['primary', 'shift'], regions: ['page', 'editable'] },
9338
9636
  { action: 'panelExplorer', id: 'gufa.ide.panelExplorer', labelKey: 'shortcuts.explorer', code: 'KeyE', modifiers: ['primary', 'shift'], regions: ['page', 'editable'] },
9637
+ { action: 'panelSearch', id: 'gufa.ide.panelSearch', labelKey: 'shortcuts.search', code: 'KeyF', modifiers: ['primary', 'shift'], regions: ['page', 'editable'] },
9339
9638
  { action: 'panelGit', id: 'gufa.ide.panelGit', labelKey: 'shortcuts.git', code: 'KeyG', modifiers: ['primary', 'shift'], regions: ['page', 'editable'] },
9340
9639
  { action: 'panelSsh', id: 'gufa.ide.panelSsh', labelKey: 'shortcuts.ssh', code: 'KeyU', modifiers: ['primary', 'shift'], regions: ['page', 'editable'] },
9341
9640
  { action: 'newTerminal', id: 'gufa.ide.newTerminal', labelKey: 'shortcuts.newTerminal', code: 'Backquote', modifiers: ['control', 'shift'], regions: ['page', 'editable', 'terminal'] },
@@ -9656,6 +9955,7 @@ G.SHORTCUTS = [
9656
9955
  { action: 'toggleSidebar', labelKey: 'shortcuts.toggleSidebar', keys: ['B'], shift: false },
9657
9956
  { action: 'closeTab', labelKey: 'shortcuts.closeTab', keys: ['W'], shift: false },
9658
9957
  { action: 'panelExplorer', labelKey: 'shortcuts.explorer', keys: ['E'], shift: true },
9958
+ { action: 'panelSearch', labelKey: 'shortcuts.search', keys: ['F'], shift: true },
9659
9959
  { action: 'panelGit', labelKey: 'shortcuts.git', keys: ['G'], shift: true },
9660
9960
  { action: 'panelSsh', labelKey: 'shortcuts.ssh', keys: ['U'], shift: true },
9661
9961
  { action: 'newTerminal', labelKey: 'shortcuts.newTerminal', keys: ['`'], shift: true, macText: '⌃⇧`', otherText: 'Ctrl+Shift+`' },
@@ -9964,6 +10264,8 @@ G.GufaApp = function GufaApp(props) {
9964
10264
  const [gitRefreshToken, setGitRefreshToken] = useState(0)
9965
10265
  const [sshRefreshToken, setSshRefreshToken] = useState(0)
9966
10266
  const [gitStatus, setGitStatus] = useState(null)
10267
+ const gitSignatureRef = useRef('')
10268
+ const gitInFlightRef = useRef(false)
9967
10269
  const [modal, setModal] = useState(null)
9968
10270
  const [shortcutsOpen, setShortcutsOpen] = useState(false)
9969
10271
  const [trashUndo, setTrashUndo] = useState([])
@@ -10087,13 +10389,31 @@ G.GufaApp = function GufaApp(props) {
10087
10389
  const refreshGit = useCallback(async () => {
10088
10390
  if (project === null || project.isGit !== true) {
10089
10391
  setGitStatus(null)
10392
+ gitSignatureRef.current = ''
10090
10393
  return
10091
10394
  }
10395
+ if (gitInFlightRef.current) return
10396
+ gitInFlightRef.current = true
10092
10397
  try {
10093
10398
  const value = await G.api('git.status', { root: project.root })
10094
10399
  setGitStatus(value)
10400
+ /* 轮询时如果发现工作区状态变化(AI/外部修改了文件),顺带刷新资源管理器与 Git 面板 */
10401
+ const signature = JSON.stringify({
10402
+ branch: value?.branch ?? '',
10403
+ changes: (Array.isArray(value?.changes) ? value.changes : [])
10404
+ .map((change) => `${String(change?.path ?? '')}:${String(change?.status ?? '')}`)
10405
+ .sort(),
10406
+ })
10407
+ const previous = gitSignatureRef.current
10408
+ gitSignatureRef.current = signature
10409
+ if (previous !== '' && previous !== signature) {
10410
+ setRefreshToken((token) => token + 1)
10411
+ setGitRefreshToken((token) => token + 1)
10412
+ }
10095
10413
  } catch {
10096
10414
  setGitStatus(null)
10415
+ } finally {
10416
+ gitInFlightRef.current = false
10097
10417
  }
10098
10418
  }, [project])
10099
10419
 
@@ -10101,6 +10421,34 @@ G.GufaApp = function GufaApp(props) {
10101
10421
  void refreshGit()
10102
10422
  }, [refreshGit, gitRefreshToken])
10103
10423
 
10424
+ /* AI/外部进程改了文件时,Git 面板与资源管理器要能自动出现标识,不需要手动点 Git 按钮。
10425
+ - 3.5s 轮询 git.status(窗口可见时);状态签名变化 → 刷新 Git 面板 + 资源管理器
10426
+ - 非 Git 项目:6s 静默重读已加载目录,至少能看到外部新建/删除的文件 */
10427
+ useEffect(() => {
10428
+ if (project === null) return undefined
10429
+ const tickGit = () => {
10430
+ if (document.visibilityState !== 'visible') return
10431
+ void refreshGit()
10432
+ }
10433
+ const tickTree = () => {
10434
+ if (document.visibilityState !== 'visible') return
10435
+ if (project.isGit !== true) setRefreshToken((token) => token + 1)
10436
+ }
10437
+ const onVisible = () => {
10438
+ if (document.visibilityState === 'visible') void refreshGit()
10439
+ }
10440
+ const gitTimer = window.setInterval(tickGit, 3500)
10441
+ const treeTimer = window.setInterval(tickTree, 6000)
10442
+ window.addEventListener('focus', onVisible)
10443
+ document.addEventListener('visibilitychange', onVisible)
10444
+ return () => {
10445
+ window.clearInterval(gitTimer)
10446
+ window.clearInterval(treeTimer)
10447
+ window.removeEventListener('focus', onVisible)
10448
+ document.removeEventListener('visibilitychange', onVisible)
10449
+ }
10450
+ }, [project, refreshGit])
10451
+
10104
10452
  const gitStatuses = useMemo(() => {
10105
10453
  const map = {}
10106
10454
  for (const change of gitStatus?.changes ?? []) map[change.path] = change.status
@@ -10130,6 +10478,21 @@ G.GufaApp = function GufaApp(props) {
10130
10478
  }
10131
10479
  }, [project, tabs])
10132
10480
 
10481
+ /* 从搜索/定位结果打开文件并跳到指定行列(等 tab 切换完成后再触发编辑器 reveal) */
10482
+ const openFileAt = useCallback(async (path, line, column) => {
10483
+ if (typeof path !== 'string' || path === '') return
10484
+ await openFile(path)
10485
+ const targetLine = Number.isFinite(Number(line)) ? Math.max(1, Math.trunc(Number(line))) : 1
10486
+ const targetColumn = Number.isFinite(Number(column)) ? Math.max(1, Math.trunc(Number(column))) : 1
10487
+ window.setTimeout(() => {
10488
+ try {
10489
+ G.bus.emit('editor:reveal', { path, line: targetLine, column: targetColumn })
10490
+ } catch {
10491
+ /* ignore */
10492
+ }
10493
+ }, 120)
10494
+ }, [openFile])
10495
+
10133
10496
  /* 原子恢复标签集合:按快照顺序、去重、最后激活指定文件(避免 openFile 并发产生重复标签) */
10134
10497
  const applyTabs = useCallback(async (paths, active) => {
10135
10498
  if (project === null || !Array.isArray(paths)) return
@@ -11630,6 +11993,10 @@ G.GufaApp = function GufaApp(props) {
11630
11993
  if (activePath !== null) closeTabWithConfirm(activePath)
11631
11994
  },
11632
11995
  panelExplorer: () => patchUi({ view: 'explorer', sidebarOpen: true }),
11996
+ panelSearch: () => {
11997
+ patchUi({ view: 'search', sidebarOpen: true })
11998
+ window.setTimeout(() => { G.bus.emit('search:focus') }, 0)
11999
+ },
11633
12000
  panelGit: () => {
11634
12001
  patchUi({ view: 'git', sidebarOpen: true })
11635
12002
  setGitRefreshToken((token) => token + 1)
@@ -11737,6 +12104,7 @@ G.GufaApp = function GufaApp(props) {
11737
12104
  /* ── 渲染 ─────────────────────────────────────────────────────────── */
11738
12105
  const activityItems = [
11739
12106
  { id: 'explorer', icon: 'files', label: t('activity.explorer'), onClick: () => patchUi({ view: 'explorer', sidebarOpen: true }) },
12107
+ { id: 'search', icon: 'search', label: t('activity.search'), onClick: () => { patchUi({ view: 'search', sidebarOpen: true }); G.bus.emit('search:focus') } },
11740
12108
  { id: 'git', icon: 'git', label: t('activity.git'), badge: gitStatus?.changes?.length ?? 0, onClick: () => { patchUi({ view: 'git', sidebarOpen: true }); setGitRefreshToken((token) => token + 1) } },
11741
12109
  { id: 'ssh', icon: 'server', label: t('activity.ssh'), onClick: () => { patchUi({ view: 'ssh', sidebarOpen: true }); setSshRefreshToken((token) => token + 1) } },
11742
12110
  { id: 'terminal', icon: 'terminal', label: t('activity.terminal'), active: ui.terminalOpen, onClick: () => patchUi({ terminalOpen: !ui.terminalOpen }) },
@@ -11763,6 +12131,12 @@ G.GufaApp = function GufaApp(props) {
11763
12131
  onRename: (path) => setModal({ type: 'rename', path }),
11764
12132
  onDelete: (path) => void deleteEntry(path),
11765
12133
  })),
12134
+ h('div', { key: 'search', style: { display: ui.view === 'search' ? 'flex' : 'none', flex: '1 1 auto', minHeight: 0, flexDirection: 'column' } },
12135
+ h(G.SearchPanel, {
12136
+ root: project?.root ?? null,
12137
+ active: ui.view === 'search',
12138
+ onOpenFile: (path, line, column) => void openFileAt(path, line, column),
12139
+ })),
11766
12140
  h('div', { key: 'git', style: { display: ui.view === 'git' ? 'flex' : 'none', flex: '1 1 auto', minHeight: 0, flexDirection: 'column' } },
11767
12141
  h(G.GitPanel, {
11768
12142
  root: project?.root ?? null,
@@ -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.60</string>
11
- <key>CFBundleVersion</key><string>1.3.60</string>
10
+ <key>CFBundleShortVersionString</key><string>1.3.62</string>
11
+ <key>CFBundleVersion</key><string>1.3.62</string>
12
12
  <key>LSUIElement</key><true/>
13
13
  <key>NSHighResolutionCapable</key><true/>
14
14
  <key>NSPrincipalClass</key><string>NSApplication</string>
@@ -140,6 +140,23 @@ macOS 上 WKWebView 的「复制/粘贴/剪切」是**通过 App 主菜单的 ke
140
140
  验证:悬浮层聊天输入框 Cmd+V → 粘贴成功,Cmd+A+C 后 `pbpaste` 内容正确;
141
141
  编辑器(.gitignore)里 Cmd+V 插入成功并自动保存,Cmd+A+C 后 `pbpaste` 为整个文件文本。
142
142
 
143
+ ## AI 改代码后 Git/资源管理器标识不刷新(1.3.61 修复)
144
+
145
+ 问题:AI(或任何外部进程)改了文件后,Git 面板和资源管理器的修改标识要手动点一下 Git 按钮才出现。
146
+ 原因:之前只在「本插件自己的操作」(保存、新建、删除、切换面板)后刷新 git 状态;
147
+ AI 是通过 Host 工具直接写盘,客户端收不到任何通知。
148
+
149
+ 修复:窗口可见时每 3.5s 轮询一次 `git.status`,计算「分支 + changes 路径/状态」签名,
150
+ 签名变化就自动刷新 Git 面板和资源管理器;非 Git 项目每 6s 静默重读已加载目录。
151
+ 窗口 focus / visibilitychange 时也会立即刷新一次。
152
+
153
+ ## 全局搜索(1.3.62 新增)
154
+
155
+ - Host 侧新增 `fs.search`:Git 项目先用 `git ls-files -z --cached --others --exclude-standard` 拿文件清单(快、尊重 .gitignore、含未跟踪文件),非 Git 项目才目录遍历(BFS,跳过 node_modules/dist/.venv 等,明显二进制扩展名直接跳过)。
156
+ - 搜索有时限(12s)与扫描上限(默认 20000 文件 / 500 命中 / 200 文件),超出返回 `truncated: true`,UI 会提示「结果过多已截断」。
157
+ - 结果行带 `line/column/start/end/text`,前端高亮 `start..end`;点击结果通过 `G.bus 'editor:reveal'` 让 Monaco 跳到对应行列(tab 切换未完成时事件先存到 `pendingRevealRef`)。
158
+ - **坑**:往 `G.CSS` 模板里加规则时一定插在完整规则之后。曾把搜索样式插进 `.gufa-explorer-notice{...}` 规则中间,CSS nesting 把整块样式变成后代选择器,面板渲染成原生输入框。插入后检查 `client.js` 里 `.gufa-explorer-notice{...}` 的闭合括号是否在搜索块之前。
159
+
143
160
  ## 5.1 摸鱼会话框比编辑器黑:官方会话根节点自己又画了一层底
144
161
 
145
162
  - 现象:摸鱼里编辑器/终端都统一了,右侧会话框看起来明显更黑更实。