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 +3 -2
- package/client.js +375 -1
- package/desktop/float/bin/gufa-float-macos-arm64 +0 -0
- package/desktop/float/bin/gufa-float-macos-universal +0 -0
- package/desktop/float/bin/gufa-float-macos-x64 +0 -0
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/Info.plist +2 -2
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/MacOS/gufa-float +0 -0
- package/docs/KNOWN-PITFALLS.md +17 -0
- package/host/fs.js +193 -1
- package/package.json +1 -1
- package/scripts/selftest-client.mjs +1 -0
- package/scripts/selftest-host.mjs +29 -0
- package/src/client/00-core.js +47 -0
- package/src/client/20-editor.js +37 -0
- package/src/client/50-panels.js +213 -0
- package/src/client/85-shortcuts.js +3 -0
- package/src/client/90-app.js +74 -0
package/src/client/90-app.js
CHANGED
|
@@ -263,6 +263,8 @@ G.GufaApp = function GufaApp(props) {
|
|
|
263
263
|
const [gitRefreshToken, setGitRefreshToken] = useState(0)
|
|
264
264
|
const [sshRefreshToken, setSshRefreshToken] = useState(0)
|
|
265
265
|
const [gitStatus, setGitStatus] = useState(null)
|
|
266
|
+
const gitSignatureRef = useRef('')
|
|
267
|
+
const gitInFlightRef = useRef(false)
|
|
266
268
|
const [modal, setModal] = useState(null)
|
|
267
269
|
const [shortcutsOpen, setShortcutsOpen] = useState(false)
|
|
268
270
|
const [trashUndo, setTrashUndo] = useState([])
|
|
@@ -386,13 +388,31 @@ G.GufaApp = function GufaApp(props) {
|
|
|
386
388
|
const refreshGit = useCallback(async () => {
|
|
387
389
|
if (project === null || project.isGit !== true) {
|
|
388
390
|
setGitStatus(null)
|
|
391
|
+
gitSignatureRef.current = ''
|
|
389
392
|
return
|
|
390
393
|
}
|
|
394
|
+
if (gitInFlightRef.current) return
|
|
395
|
+
gitInFlightRef.current = true
|
|
391
396
|
try {
|
|
392
397
|
const value = await G.api('git.status', { root: project.root })
|
|
393
398
|
setGitStatus(value)
|
|
399
|
+
/* 轮询时如果发现工作区状态变化(AI/外部修改了文件),顺带刷新资源管理器与 Git 面板 */
|
|
400
|
+
const signature = JSON.stringify({
|
|
401
|
+
branch: value?.branch ?? '',
|
|
402
|
+
changes: (Array.isArray(value?.changes) ? value.changes : [])
|
|
403
|
+
.map((change) => `${String(change?.path ?? '')}:${String(change?.status ?? '')}`)
|
|
404
|
+
.sort(),
|
|
405
|
+
})
|
|
406
|
+
const previous = gitSignatureRef.current
|
|
407
|
+
gitSignatureRef.current = signature
|
|
408
|
+
if (previous !== '' && previous !== signature) {
|
|
409
|
+
setRefreshToken((token) => token + 1)
|
|
410
|
+
setGitRefreshToken((token) => token + 1)
|
|
411
|
+
}
|
|
394
412
|
} catch {
|
|
395
413
|
setGitStatus(null)
|
|
414
|
+
} finally {
|
|
415
|
+
gitInFlightRef.current = false
|
|
396
416
|
}
|
|
397
417
|
}, [project])
|
|
398
418
|
|
|
@@ -400,6 +420,34 @@ G.GufaApp = function GufaApp(props) {
|
|
|
400
420
|
void refreshGit()
|
|
401
421
|
}, [refreshGit, gitRefreshToken])
|
|
402
422
|
|
|
423
|
+
/* AI/外部进程改了文件时,Git 面板与资源管理器要能自动出现标识,不需要手动点 Git 按钮。
|
|
424
|
+
- 3.5s 轮询 git.status(窗口可见时);状态签名变化 → 刷新 Git 面板 + 资源管理器
|
|
425
|
+
- 非 Git 项目:6s 静默重读已加载目录,至少能看到外部新建/删除的文件 */
|
|
426
|
+
useEffect(() => {
|
|
427
|
+
if (project === null) return undefined
|
|
428
|
+
const tickGit = () => {
|
|
429
|
+
if (document.visibilityState !== 'visible') return
|
|
430
|
+
void refreshGit()
|
|
431
|
+
}
|
|
432
|
+
const tickTree = () => {
|
|
433
|
+
if (document.visibilityState !== 'visible') return
|
|
434
|
+
if (project.isGit !== true) setRefreshToken((token) => token + 1)
|
|
435
|
+
}
|
|
436
|
+
const onVisible = () => {
|
|
437
|
+
if (document.visibilityState === 'visible') void refreshGit()
|
|
438
|
+
}
|
|
439
|
+
const gitTimer = window.setInterval(tickGit, 3500)
|
|
440
|
+
const treeTimer = window.setInterval(tickTree, 6000)
|
|
441
|
+
window.addEventListener('focus', onVisible)
|
|
442
|
+
document.addEventListener('visibilitychange', onVisible)
|
|
443
|
+
return () => {
|
|
444
|
+
window.clearInterval(gitTimer)
|
|
445
|
+
window.clearInterval(treeTimer)
|
|
446
|
+
window.removeEventListener('focus', onVisible)
|
|
447
|
+
document.removeEventListener('visibilitychange', onVisible)
|
|
448
|
+
}
|
|
449
|
+
}, [project, refreshGit])
|
|
450
|
+
|
|
403
451
|
const gitStatuses = useMemo(() => {
|
|
404
452
|
const map = {}
|
|
405
453
|
for (const change of gitStatus?.changes ?? []) map[change.path] = change.status
|
|
@@ -429,6 +477,21 @@ G.GufaApp = function GufaApp(props) {
|
|
|
429
477
|
}
|
|
430
478
|
}, [project, tabs])
|
|
431
479
|
|
|
480
|
+
/* 从搜索/定位结果打开文件并跳到指定行列(等 tab 切换完成后再触发编辑器 reveal) */
|
|
481
|
+
const openFileAt = useCallback(async (path, line, column) => {
|
|
482
|
+
if (typeof path !== 'string' || path === '') return
|
|
483
|
+
await openFile(path)
|
|
484
|
+
const targetLine = Number.isFinite(Number(line)) ? Math.max(1, Math.trunc(Number(line))) : 1
|
|
485
|
+
const targetColumn = Number.isFinite(Number(column)) ? Math.max(1, Math.trunc(Number(column))) : 1
|
|
486
|
+
window.setTimeout(() => {
|
|
487
|
+
try {
|
|
488
|
+
G.bus.emit('editor:reveal', { path, line: targetLine, column: targetColumn })
|
|
489
|
+
} catch {
|
|
490
|
+
/* ignore */
|
|
491
|
+
}
|
|
492
|
+
}, 120)
|
|
493
|
+
}, [openFile])
|
|
494
|
+
|
|
432
495
|
/* 原子恢复标签集合:按快照顺序、去重、最后激活指定文件(避免 openFile 并发产生重复标签) */
|
|
433
496
|
const applyTabs = useCallback(async (paths, active) => {
|
|
434
497
|
if (project === null || !Array.isArray(paths)) return
|
|
@@ -1929,6 +1992,10 @@ G.GufaApp = function GufaApp(props) {
|
|
|
1929
1992
|
if (activePath !== null) closeTabWithConfirm(activePath)
|
|
1930
1993
|
},
|
|
1931
1994
|
panelExplorer: () => patchUi({ view: 'explorer', sidebarOpen: true }),
|
|
1995
|
+
panelSearch: () => {
|
|
1996
|
+
patchUi({ view: 'search', sidebarOpen: true })
|
|
1997
|
+
window.setTimeout(() => { G.bus.emit('search:focus') }, 0)
|
|
1998
|
+
},
|
|
1932
1999
|
panelGit: () => {
|
|
1933
2000
|
patchUi({ view: 'git', sidebarOpen: true })
|
|
1934
2001
|
setGitRefreshToken((token) => token + 1)
|
|
@@ -2036,6 +2103,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2036
2103
|
/* ── 渲染 ─────────────────────────────────────────────────────────── */
|
|
2037
2104
|
const activityItems = [
|
|
2038
2105
|
{ id: 'explorer', icon: 'files', label: t('activity.explorer'), onClick: () => patchUi({ view: 'explorer', sidebarOpen: true }) },
|
|
2106
|
+
{ id: 'search', icon: 'search', label: t('activity.search'), onClick: () => { patchUi({ view: 'search', sidebarOpen: true }); G.bus.emit('search:focus') } },
|
|
2039
2107
|
{ id: 'git', icon: 'git', label: t('activity.git'), badge: gitStatus?.changes?.length ?? 0, onClick: () => { patchUi({ view: 'git', sidebarOpen: true }); setGitRefreshToken((token) => token + 1) } },
|
|
2040
2108
|
{ id: 'ssh', icon: 'server', label: t('activity.ssh'), onClick: () => { patchUi({ view: 'ssh', sidebarOpen: true }); setSshRefreshToken((token) => token + 1) } },
|
|
2041
2109
|
{ id: 'terminal', icon: 'terminal', label: t('activity.terminal'), active: ui.terminalOpen, onClick: () => patchUi({ terminalOpen: !ui.terminalOpen }) },
|
|
@@ -2062,6 +2130,12 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2062
2130
|
onRename: (path) => setModal({ type: 'rename', path }),
|
|
2063
2131
|
onDelete: (path) => void deleteEntry(path),
|
|
2064
2132
|
})),
|
|
2133
|
+
h('div', { key: 'search', style: { display: ui.view === 'search' ? 'flex' : 'none', flex: '1 1 auto', minHeight: 0, flexDirection: 'column' } },
|
|
2134
|
+
h(G.SearchPanel, {
|
|
2135
|
+
root: project?.root ?? null,
|
|
2136
|
+
active: ui.view === 'search',
|
|
2137
|
+
onOpenFile: (path, line, column) => void openFileAt(path, line, column),
|
|
2138
|
+
})),
|
|
2065
2139
|
h('div', { key: 'git', style: { display: ui.view === 'git' ? 'flex' : 'none', flex: '1 1 auto', minHeight: 0, flexDirection: 'column' } },
|
|
2066
2140
|
h(G.GitPanel, {
|
|
2067
2141
|
root: project?.root ?? null,
|