dsh-gufa-code 1.3.67 → 1.3.68
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 +59 -21
- 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/host/git.js +1 -1
- package/package.json +1 -1
- package/scripts/selftest-host.mjs +4 -0
- package/src/client/50-panels.js +14 -14
- package/src/client/90-app.js +44 -6
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.
|
|
19
|
+
G.BUILD = '1.3.68'
|
|
20
20
|
G.PANEL_ID = 'gufa-code'
|
|
21
21
|
/** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
|
|
22
22
|
G.pendingEntryWorkspace = null
|
|
@@ -8180,6 +8180,20 @@ G.GitPanel = function GitPanel(props) {
|
|
|
8180
8180
|
h(G.Button, { disabled: pending || message.trim() === '', primary: true, onClick: commit }, pending ? h(G.Spinner) : null, t('git.commit')),
|
|
8181
8181
|
)
|
|
8182
8182
|
: null,
|
|
8183
|
+
staged.length > 0 ? h('div', { className: 'gufa-hint' }, `${t('git.staged')} (${staged.length})`) : null,
|
|
8184
|
+
...staged.map((change) =>
|
|
8185
|
+
h(G.GitChangeRow, {
|
|
8186
|
+
key: `s:${change.path}`,
|
|
8187
|
+
change,
|
|
8188
|
+
pending,
|
|
8189
|
+
staged: true,
|
|
8190
|
+
onOpen: () => props.onOpenDiff?.(change),
|
|
8191
|
+
onContextMenu: (event, rowChange) => setRowMenu({ ...clampMenuPosition(event.clientX, event.clientY, 200, 200), change: rowChange }),
|
|
8192
|
+
onAction: () => void act(async () => G.api('git.unstage', { root, paths: [change.path] })),
|
|
8193
|
+
actionLabel: t('git.unstage'),
|
|
8194
|
+
actionIcon: 'minus',
|
|
8195
|
+
}),
|
|
8196
|
+
),
|
|
8183
8197
|
unstaged.length > 0 ? h('div', { className: 'gufa-hint' }, `${t('git.unstaged')} (${unstaged.length})`) : null,
|
|
8184
8198
|
...unstaged.map((change) =>
|
|
8185
8199
|
h(G.GitChangeRow, {
|
|
@@ -8195,20 +8209,6 @@ G.GitPanel = function GitPanel(props) {
|
|
|
8195
8209
|
actionIcon: 'plus',
|
|
8196
8210
|
}),
|
|
8197
8211
|
),
|
|
8198
|
-
staged.length > 0 ? h('div', { className: 'gufa-hint' }, `${t('git.staged')} (${staged.length})`) : null,
|
|
8199
|
-
...staged.map((change) =>
|
|
8200
|
-
h(G.GitChangeRow, {
|
|
8201
|
-
key: `s:${change.path}`,
|
|
8202
|
-
change,
|
|
8203
|
-
pending,
|
|
8204
|
-
staged: true,
|
|
8205
|
-
onOpen: () => props.onOpenDiff?.(change),
|
|
8206
|
-
onContextMenu: (event, rowChange) => setRowMenu({ ...clampMenuPosition(event.clientX, event.clientY, 200, 200), change: rowChange }),
|
|
8207
|
-
onAction: () => void act(async () => G.api('git.unstage', { root, paths: [change.path] })),
|
|
8208
|
-
actionLabel: t('git.unstage'),
|
|
8209
|
-
actionIcon: 'minus',
|
|
8210
|
-
}),
|
|
8211
|
-
),
|
|
8212
8212
|
),
|
|
8213
8213
|
),
|
|
8214
8214
|
headMenu === null
|
|
@@ -10816,6 +10816,25 @@ G.GufaApp = function GufaApp(props) {
|
|
|
10816
10816
|
return map
|
|
10817
10817
|
}, [gitStatus])
|
|
10818
10818
|
|
|
10819
|
+
/* 暂存/取消暂存/提交后,已失效的 diff 标签自动关闭:
|
|
10820
|
+
工作树 diff 只在文件仍有未暂存改动时有效,暂存区 diff 只在文件仍在暂存区时有效。 */
|
|
10821
|
+
useEffect(() => {
|
|
10822
|
+
if (project === null || project.isGit !== true || gitStatus === null) return
|
|
10823
|
+
const changes = Array.isArray(gitStatus.changes) ? gitStatus.changes : []
|
|
10824
|
+
const stagedPaths = new Set(changes.filter((item) => item?.staged === true).map((item) => item.path))
|
|
10825
|
+
const unstagedPaths = new Set(changes.filter((item) => item?.staged !== true).map((item) => item.path))
|
|
10826
|
+
const current = tabsRef.current ?? []
|
|
10827
|
+
const kept = current.filter((tab) => {
|
|
10828
|
+
if (tab === null || tab === undefined || tab.kind !== 'diff') return true
|
|
10829
|
+
if (tab.diff === null || tab.diff === undefined || tab.diff.compare === true) return true
|
|
10830
|
+
if (tab.diff.staged === true) return stagedPaths.has(tab.path)
|
|
10831
|
+
return unstagedPaths.has(tab.path)
|
|
10832
|
+
})
|
|
10833
|
+
if (kept.length === current.length) return
|
|
10834
|
+
setTabs(kept)
|
|
10835
|
+
setActivePath((active) => (active !== null && kept.some((tab) => tab.path === active) ? active : (kept.length > 0 ? kept[kept.length - 1].path : null)))
|
|
10836
|
+
}, [gitStatus, project])
|
|
10837
|
+
|
|
10819
10838
|
/* ── 文件打开 / 保存 / 关闭 ─────────────────────────────────────────── */
|
|
10820
10839
|
const openFile = useCallback(async (path) => {
|
|
10821
10840
|
if (project === null) return
|
|
@@ -11243,7 +11262,13 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11243
11262
|
return
|
|
11244
11263
|
}
|
|
11245
11264
|
try {
|
|
11246
|
-
|
|
11265
|
+
/* 文件可能已删除(工作树删掉/暂存区删除):读不到就按空处理,仍然展示差异 */
|
|
11266
|
+
let file = null
|
|
11267
|
+
try {
|
|
11268
|
+
file = await G.api('fs.read', { root: project.root, path: change.path })
|
|
11269
|
+
} catch {
|
|
11270
|
+
file = null
|
|
11271
|
+
}
|
|
11247
11272
|
let left = ''
|
|
11248
11273
|
try {
|
|
11249
11274
|
const shown = await G.api('git.show', {
|
|
@@ -11255,16 +11280,26 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11255
11280
|
} catch {
|
|
11256
11281
|
left = ''
|
|
11257
11282
|
}
|
|
11283
|
+
let rightContent = typeof file?.content === 'string' ? file.content : ''
|
|
11284
|
+
if (change.staged === true) {
|
|
11285
|
+
/* 暂存区 diff = HEAD ↔ 索引;右侧必须用索引内容,而不是工作树(工作树可能还有未暂存改动) */
|
|
11286
|
+
try {
|
|
11287
|
+
const indexDoc = await G.api('git.show', { root: project.root, path: change.path, rev: 'index' })
|
|
11288
|
+
rightContent = typeof indexDoc.text === 'string' ? indexDoc.text : ''
|
|
11289
|
+
} catch {
|
|
11290
|
+
rightContent = ''
|
|
11291
|
+
}
|
|
11292
|
+
}
|
|
11258
11293
|
const tab = {
|
|
11259
11294
|
path: change.path,
|
|
11260
11295
|
title: `${G.basename(change.path)}(${change.staged === true ? '暂存区' : '工作树'})`,
|
|
11261
11296
|
kind: 'diff',
|
|
11262
|
-
content:
|
|
11263
|
-
savedContent:
|
|
11264
|
-
revision: file
|
|
11297
|
+
content: rightContent,
|
|
11298
|
+
savedContent: rightContent,
|
|
11299
|
+
revision: file?.revision,
|
|
11265
11300
|
dirty: false,
|
|
11266
|
-
language: file
|
|
11267
|
-
size: file
|
|
11301
|
+
language: file?.language ?? 'plaintext',
|
|
11302
|
+
size: file?.size,
|
|
11268
11303
|
diff: { left, staged: change.staged === true, editable: change.staged !== true },
|
|
11269
11304
|
diffKey: Date.now(),
|
|
11270
11305
|
}
|
|
@@ -11338,6 +11373,9 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11338
11373
|
if (project === null) return
|
|
11339
11374
|
try {
|
|
11340
11375
|
await G.api('git.stage', { root: project.root, paths: [path] })
|
|
11376
|
+
/* 暂存后这个文件已经没有「工作树 vs 索引」差异:关掉当前 diff 标签,刷新后也不会再出现在未暂存区 */
|
|
11377
|
+
setTabs((current) => current.filter((tab) => !(tab.path === path && tab.kind === 'diff' && tab.diff !== null && tab.diff !== undefined && tab.diff.staged !== true)))
|
|
11378
|
+
setActivePath((active) => (active === path ? null : active))
|
|
11341
11379
|
setGitRefreshToken((token) => token + 1)
|
|
11342
11380
|
void refreshGit()
|
|
11343
11381
|
} catch (error) {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -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.
|
|
11
|
-
<key>CFBundleVersion</key><string>1.3.
|
|
10
|
+
<key>CFBundleShortVersionString</key><string>1.3.68</string>
|
|
11
|
+
<key>CFBundleVersion</key><string>1.3.68</string>
|
|
12
12
|
<key>LSUIElement</key><true/>
|
|
13
13
|
<key>NSHighResolutionCapable</key><true/>
|
|
14
14
|
<key>NSPrincipalClass</key><string>NSApplication</string>
|
|
Binary file
|
package/host/git.js
CHANGED
|
@@ -217,7 +217,7 @@ export function register(router, env) {
|
|
|
217
217
|
const project = await projectOf(env, body)
|
|
218
218
|
const path = typeof body.path === 'string' ? body.path : ''
|
|
219
219
|
if (path === '' || path.startsWith('/') || path.includes('..')) throw badRequest('path is invalid')
|
|
220
|
-
const rev = body.rev === 'head' ? 'HEAD' : ':'
|
|
220
|
+
const rev = body.rev === 'head' ? 'HEAD:' : ':'
|
|
221
221
|
let text = ''
|
|
222
222
|
let missing = false
|
|
223
223
|
try {
|
package/package.json
CHANGED
|
@@ -152,6 +152,10 @@ try {
|
|
|
152
152
|
check('working tree clean after commit', clean.changes.length === 0, JSON.stringify(clean.changes))
|
|
153
153
|
const log = await call(router, 'git.log', { root, limit: 5 })
|
|
154
154
|
check('commit in log', log.commits.length === 1 && log.commits[0].subject === 'feat: selftest')
|
|
155
|
+
const headShow = await call(router, 'git.show', { root, path: 'src/main.ts', rev: 'head' })
|
|
156
|
+
check('git.show HEAD content', headShow.text === 'const answer = 42\n', JSON.stringify(headShow.text))
|
|
157
|
+
const indexShow = await call(router, 'git.show', { root, path: 'src/main.ts', rev: 'index' })
|
|
158
|
+
check('git.show index content', indexShow.text === 'const answer = 42\n', JSON.stringify(indexShow.text))
|
|
155
159
|
const gitSearch = await call(router, 'fs.search', { root, query: 'answer' })
|
|
156
160
|
check('search uses git file list', gitSearch.viaGit === true, String(gitSearch.viaGit))
|
|
157
161
|
check('search finds committed file', gitSearch.files.some((file) => file.path === 'src/main.ts'))
|
package/src/client/50-panels.js
CHANGED
|
@@ -1347,6 +1347,20 @@ G.GitPanel = function GitPanel(props) {
|
|
|
1347
1347
|
h(G.Button, { disabled: pending || message.trim() === '', primary: true, onClick: commit }, pending ? h(G.Spinner) : null, t('git.commit')),
|
|
1348
1348
|
)
|
|
1349
1349
|
: null,
|
|
1350
|
+
staged.length > 0 ? h('div', { className: 'gufa-hint' }, `${t('git.staged')} (${staged.length})`) : null,
|
|
1351
|
+
...staged.map((change) =>
|
|
1352
|
+
h(G.GitChangeRow, {
|
|
1353
|
+
key: `s:${change.path}`,
|
|
1354
|
+
change,
|
|
1355
|
+
pending,
|
|
1356
|
+
staged: true,
|
|
1357
|
+
onOpen: () => props.onOpenDiff?.(change),
|
|
1358
|
+
onContextMenu: (event, rowChange) => setRowMenu({ ...clampMenuPosition(event.clientX, event.clientY, 200, 200), change: rowChange }),
|
|
1359
|
+
onAction: () => void act(async () => G.api('git.unstage', { root, paths: [change.path] })),
|
|
1360
|
+
actionLabel: t('git.unstage'),
|
|
1361
|
+
actionIcon: 'minus',
|
|
1362
|
+
}),
|
|
1363
|
+
),
|
|
1350
1364
|
unstaged.length > 0 ? h('div', { className: 'gufa-hint' }, `${t('git.unstaged')} (${unstaged.length})`) : null,
|
|
1351
1365
|
...unstaged.map((change) =>
|
|
1352
1366
|
h(G.GitChangeRow, {
|
|
@@ -1362,20 +1376,6 @@ G.GitPanel = function GitPanel(props) {
|
|
|
1362
1376
|
actionIcon: 'plus',
|
|
1363
1377
|
}),
|
|
1364
1378
|
),
|
|
1365
|
-
staged.length > 0 ? h('div', { className: 'gufa-hint' }, `${t('git.staged')} (${staged.length})`) : null,
|
|
1366
|
-
...staged.map((change) =>
|
|
1367
|
-
h(G.GitChangeRow, {
|
|
1368
|
-
key: `s:${change.path}`,
|
|
1369
|
-
change,
|
|
1370
|
-
pending,
|
|
1371
|
-
staged: true,
|
|
1372
|
-
onOpen: () => props.onOpenDiff?.(change),
|
|
1373
|
-
onContextMenu: (event, rowChange) => setRowMenu({ ...clampMenuPosition(event.clientX, event.clientY, 200, 200), change: rowChange }),
|
|
1374
|
-
onAction: () => void act(async () => G.api('git.unstage', { root, paths: [change.path] })),
|
|
1375
|
-
actionLabel: t('git.unstage'),
|
|
1376
|
-
actionIcon: 'minus',
|
|
1377
|
-
}),
|
|
1378
|
-
),
|
|
1379
1379
|
),
|
|
1380
1380
|
),
|
|
1381
1381
|
headMenu === null
|
package/src/client/90-app.js
CHANGED
|
@@ -453,6 +453,25 @@ G.GufaApp = function GufaApp(props) {
|
|
|
453
453
|
return map
|
|
454
454
|
}, [gitStatus])
|
|
455
455
|
|
|
456
|
+
/* 暂存/取消暂存/提交后,已失效的 diff 标签自动关闭:
|
|
457
|
+
工作树 diff 只在文件仍有未暂存改动时有效,暂存区 diff 只在文件仍在暂存区时有效。 */
|
|
458
|
+
useEffect(() => {
|
|
459
|
+
if (project === null || project.isGit !== true || gitStatus === null) return
|
|
460
|
+
const changes = Array.isArray(gitStatus.changes) ? gitStatus.changes : []
|
|
461
|
+
const stagedPaths = new Set(changes.filter((item) => item?.staged === true).map((item) => item.path))
|
|
462
|
+
const unstagedPaths = new Set(changes.filter((item) => item?.staged !== true).map((item) => item.path))
|
|
463
|
+
const current = tabsRef.current ?? []
|
|
464
|
+
const kept = current.filter((tab) => {
|
|
465
|
+
if (tab === null || tab === undefined || tab.kind !== 'diff') return true
|
|
466
|
+
if (tab.diff === null || tab.diff === undefined || tab.diff.compare === true) return true
|
|
467
|
+
if (tab.diff.staged === true) return stagedPaths.has(tab.path)
|
|
468
|
+
return unstagedPaths.has(tab.path)
|
|
469
|
+
})
|
|
470
|
+
if (kept.length === current.length) return
|
|
471
|
+
setTabs(kept)
|
|
472
|
+
setActivePath((active) => (active !== null && kept.some((tab) => tab.path === active) ? active : (kept.length > 0 ? kept[kept.length - 1].path : null)))
|
|
473
|
+
}, [gitStatus, project])
|
|
474
|
+
|
|
456
475
|
/* ── 文件打开 / 保存 / 关闭 ─────────────────────────────────────────── */
|
|
457
476
|
const openFile = useCallback(async (path) => {
|
|
458
477
|
if (project === null) return
|
|
@@ -880,7 +899,13 @@ G.GufaApp = function GufaApp(props) {
|
|
|
880
899
|
return
|
|
881
900
|
}
|
|
882
901
|
try {
|
|
883
|
-
|
|
902
|
+
/* 文件可能已删除(工作树删掉/暂存区删除):读不到就按空处理,仍然展示差异 */
|
|
903
|
+
let file = null
|
|
904
|
+
try {
|
|
905
|
+
file = await G.api('fs.read', { root: project.root, path: change.path })
|
|
906
|
+
} catch {
|
|
907
|
+
file = null
|
|
908
|
+
}
|
|
884
909
|
let left = ''
|
|
885
910
|
try {
|
|
886
911
|
const shown = await G.api('git.show', {
|
|
@@ -892,16 +917,26 @@ G.GufaApp = function GufaApp(props) {
|
|
|
892
917
|
} catch {
|
|
893
918
|
left = ''
|
|
894
919
|
}
|
|
920
|
+
let rightContent = typeof file?.content === 'string' ? file.content : ''
|
|
921
|
+
if (change.staged === true) {
|
|
922
|
+
/* 暂存区 diff = HEAD ↔ 索引;右侧必须用索引内容,而不是工作树(工作树可能还有未暂存改动) */
|
|
923
|
+
try {
|
|
924
|
+
const indexDoc = await G.api('git.show', { root: project.root, path: change.path, rev: 'index' })
|
|
925
|
+
rightContent = typeof indexDoc.text === 'string' ? indexDoc.text : ''
|
|
926
|
+
} catch {
|
|
927
|
+
rightContent = ''
|
|
928
|
+
}
|
|
929
|
+
}
|
|
895
930
|
const tab = {
|
|
896
931
|
path: change.path,
|
|
897
932
|
title: `${G.basename(change.path)}(${change.staged === true ? '暂存区' : '工作树'})`,
|
|
898
933
|
kind: 'diff',
|
|
899
|
-
content:
|
|
900
|
-
savedContent:
|
|
901
|
-
revision: file
|
|
934
|
+
content: rightContent,
|
|
935
|
+
savedContent: rightContent,
|
|
936
|
+
revision: file?.revision,
|
|
902
937
|
dirty: false,
|
|
903
|
-
language: file
|
|
904
|
-
size: file
|
|
938
|
+
language: file?.language ?? 'plaintext',
|
|
939
|
+
size: file?.size,
|
|
905
940
|
diff: { left, staged: change.staged === true, editable: change.staged !== true },
|
|
906
941
|
diffKey: Date.now(),
|
|
907
942
|
}
|
|
@@ -975,6 +1010,9 @@ G.GufaApp = function GufaApp(props) {
|
|
|
975
1010
|
if (project === null) return
|
|
976
1011
|
try {
|
|
977
1012
|
await G.api('git.stage', { root: project.root, paths: [path] })
|
|
1013
|
+
/* 暂存后这个文件已经没有「工作树 vs 索引」差异:关掉当前 diff 标签,刷新后也不会再出现在未暂存区 */
|
|
1014
|
+
setTabs((current) => current.filter((tab) => !(tab.path === path && tab.kind === 'diff' && tab.diff !== null && tab.diff !== undefined && tab.diff.staged !== true)))
|
|
1015
|
+
setActivePath((active) => (active === path ? null : active))
|
|
978
1016
|
setGitRefreshToken((token) => token + 1)
|
|
979
1017
|
void refreshGit()
|
|
980
1018
|
} catch (error) {
|