dsh-gufa-code 1.3.213 → 1.3.215
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 -1
- package/client.js +133 -19
- package/host/git.js +43 -2
- package/package.json +1 -1
- package/scripts/selftest-host.mjs +16 -0
- package/src/client/00-core.js +10 -0
- package/src/client/10-icons.js +1 -0
- package/src/client/85-shortcuts.js +67 -0
- package/src/client/90-app.js +54 -18
package/README.md
CHANGED
|
@@ -117,12 +117,14 @@ dsh plugin add dsh-gufa-code
|
|
|
117
117
|
|
|
118
118
|
## 更新日志
|
|
119
119
|
|
|
120
|
-
### 1.3.
|
|
120
|
+
### 1.3.215(最新)
|
|
121
121
|
|
|
122
122
|
- **Git 面板支持多个仓库**:自动列出工作区根目录和一级子目录里的全部 Git 仓库,可逐个查看状态、暂存、提交、推送、拉取、切换分支、查看 diff / Git Graph;子目录仓库摘要每 5 秒自动刷新。
|
|
123
123
|
- **Git 还原逻辑修正**:未跟踪的新文件不再报 `pathspec ... did not match`,改为删除文件并二次确认;未跟踪状态显示为 `U`;「撤销所有改动」会连同未跟踪新文件一起删除(保留 `.gitignore` 忽略的文件)。
|
|
124
124
|
- **资源管理器支持系统剪贴板粘贴**:在 Finder / 资源管理器里复制的文件或文件夹,可直接 `Cmd/Ctrl+V` 或右键「粘贴」进当前目录;支持多选、文件夹、同名自动生成「副本」(macOS / Windows / Linux)。
|
|
125
125
|
- **切换会话弹窗显示会话状态**:与经典侧边栏一致——运行中显示 spinner,待审批 / 计划待审 / 待回答显示黄色状态点和紧凑文案,已完成显示绿点,空闲留空。
|
|
126
|
+
- **分支弹窗显示远端分支**:本地分支/远程分支分组展示,点远端分支会自动创建同名本地跟踪分支并切换;无远端时只显示本地分支。
|
|
127
|
+
- **Cmd+K 自愈**:DSH 重连/切换会话/热重载后如果命令表或 dispatch 补丁丢失,IDE 模式下每 1.5s 自检并自动重装,不再需要重启客户端。
|
|
126
128
|
- **修复 Cmd+K 清空终端失效**:命令改派支持懒注册命令、按当前快捷键目录动态识别实际绑定「主修饰键+K」的命令,并在 dispatch 层兜底;DSH 快捷键冲突或命令 id 变化时 IDE 内仍能接管为「清空终端」。
|
|
127
129
|
- **作者的话调整**:精简第 6 条结尾的表述,保留「想清楚自己到底要什么,AI 交付的必须完完全全符合预期,包括每一处细节」。
|
|
128
130
|
|
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.215'
|
|
20
20
|
G.PANEL_ID = 'gufa-code'
|
|
21
21
|
/** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
|
|
22
22
|
G.pendingEntryWorkspace = null
|
|
@@ -299,6 +299,9 @@ const DICT_ZH = {
|
|
|
299
299
|
'git.branchCurrent': '当前',
|
|
300
300
|
'git.branchNamePlaceholder': '新分支名',
|
|
301
301
|
'git.branchCreate': '新建并切换',
|
|
302
|
+
'git.branchesLocal': '本地分支',
|
|
303
|
+
'git.branchesRemote': '远程分支',
|
|
304
|
+
'git.branchRemoteTag': '远端',
|
|
302
305
|
'git.undoLastCommit': '撤回上次提交(保留改动)',
|
|
303
306
|
'diff.prev': '上一处差异',
|
|
304
307
|
'diff.next': '下一处差异',
|
|
@@ -565,6 +568,9 @@ const DICT_EN = {
|
|
|
565
568
|
'git.branchCurrent': 'current',
|
|
566
569
|
'git.branchNamePlaceholder': 'New branch name',
|
|
567
570
|
'git.branchCreate': 'Create & switch',
|
|
571
|
+
'git.branchesLocal': 'Local branches',
|
|
572
|
+
'git.branchesRemote': 'Remote branches',
|
|
573
|
+
'git.branchRemoteTag': 'remote',
|
|
568
574
|
'git.undoLastCommit': 'Undo last commit (keep changes)',
|
|
569
575
|
'diff.prev': 'Previous change',
|
|
570
576
|
'diff.next': 'Next change',
|
|
@@ -1947,6 +1953,10 @@ html[data-platform=darwin][data-fullscreen] .gufa-titlebar{height:44px;padding-l
|
|
|
1947
1953
|
.gufa-branch-row{display:flex;align-items:center;gap:8px;width:100%;height:30px;padding:0 8px;border:0;border-radius:7px;
|
|
1948
1954
|
background:transparent;color:var(--gufa-text);cursor:pointer;font-size:12px;text-align:left}
|
|
1949
1955
|
.gufa-branch-row:hover{background:var(--gufa-hover)}
|
|
1956
|
+
.gufa-branch-group{padding:8px 10px 3px;font-size:10.5px;font-weight:600;letter-spacing:.03em;color:var(--gufa-text-dim);text-transform:uppercase}
|
|
1957
|
+
.gufa-branch-row[data-remote]{color:var(--gufa-text-dim)}
|
|
1958
|
+
.gufa-branch-row[data-remote]:hover{color:var(--gufa-text)}
|
|
1959
|
+
.gufa-branch-tag[data-kind="remote"]{color:var(--gufa-text-dim);border:0.5px solid var(--gufa-border);background:transparent}
|
|
1950
1960
|
.gufa-branch-row[data-current]{background:color-mix(in srgb, var(--gufa-accent) 16%, transparent)}
|
|
1951
1961
|
.gufa-branch-name{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1952
1962
|
.gufa-branch-tag{font-size:10px;padding:1px 6px;border-radius:8px;color:var(--gufa-accent);
|
|
@@ -2261,6 +2271,7 @@ const ICON_PATHS = {
|
|
|
2261
2271
|
['path', { d: 'M8 3h7l4 4v10a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z' }],
|
|
2262
2272
|
['path', { d: 'M15 3v4h4M3 8v12a1 1 0 0 0 1 1h9' }, { opacity: 0.55 }],
|
|
2263
2273
|
],
|
|
2274
|
+
cloud: [['path', { d: 'M7 18h10a4 4 0 0 0 .4-8A6 6 0 0 0 6 11.2 3.6 3.6 0 0 0 7 18z' }]],
|
|
2264
2275
|
git: [
|
|
2265
2276
|
['circle', { cx: 6, cy: 6, r: 2.2 }],
|
|
2266
2277
|
['circle', { cx: 6, cy: 18, r: 2.2 }],
|
|
@@ -12692,6 +12703,14 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
|
|
|
12692
12703
|
const mac = G.isMacPlatform()
|
|
12693
12704
|
const primary = mac ? gesture?.meta === true && gesture?.control !== true : gesture?.control === true
|
|
12694
12705
|
if (primary && gesture?.code === 'KeyK' && gesture?.shift !== true && gesture?.alt !== true) {
|
|
12706
|
+
try {
|
|
12707
|
+
if ((window.__gufaDispatchRemapLogs ?? 0) < 20) {
|
|
12708
|
+
window.__gufaDispatchRemapLogs = (window.__gufaDispatchRemapLogs ?? 0) + 1
|
|
12709
|
+
void G.api('dev.log', { message: 'command-remap-dispatch KeyK -> clearTerminal' }).catch(() => {})
|
|
12710
|
+
}
|
|
12711
|
+
} catch {
|
|
12712
|
+
/* ignore */
|
|
12713
|
+
}
|
|
12695
12714
|
if (typeof consume === 'function') consume()
|
|
12696
12715
|
if (gesture?.repeat !== true) {
|
|
12697
12716
|
try { window.__gufaIdeShortcutDispatch('clearTerminal') } catch { /* ignore */ }
|
|
@@ -12759,6 +12778,65 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
|
|
|
12759
12778
|
/* 重试安装失败不影响主流程 */
|
|
12760
12779
|
}
|
|
12761
12780
|
|
|
12781
|
+
/* ── 自愈:DSH 重连/切换会话/热重载可能重建命令表或丢掉 dispatch 补丁,
|
|
12782
|
+
表现为「一开始 Cmd+K 好用,操作一阵后失效、重启客户端才恢复」。
|
|
12783
|
+
每 1.5s 检查一次,发现补丁丢失就在 IDE 模式下自动重装。 ── */
|
|
12784
|
+
try {
|
|
12785
|
+
if (typeof window !== 'undefined' && window !== null) {
|
|
12786
|
+
if (service.__gufaHealthTimer === undefined || service.__gufaHealthTimer === null) {
|
|
12787
|
+
service.__gufaHealthTimer = window.setInterval(() => {
|
|
12788
|
+
try {
|
|
12789
|
+
if (G.mode.get() !== true) return
|
|
12790
|
+
const registryNow = service.registry
|
|
12791
|
+
if (registryNow === null || registryNow === undefined) return
|
|
12792
|
+
const dispatchOk = registryNow.__gufaDispatchPatched === true
|
|
12793
|
+
let wrapMissing = false
|
|
12794
|
+
const commandsNow = registryNow.commands
|
|
12795
|
+
if (commandsNow !== null && commandsNow !== undefined && typeof commandsNow.get === 'function') {
|
|
12796
|
+
for (const id of Object.keys(service.__gufaCommandActions ?? {})) {
|
|
12797
|
+
const command = commandsNow.get(id)
|
|
12798
|
+
if (command !== null && command !== undefined && command.__gufaWrapped !== true) {
|
|
12799
|
+
wrapMissing = true
|
|
12800
|
+
break
|
|
12801
|
+
}
|
|
12802
|
+
}
|
|
12803
|
+
}
|
|
12804
|
+
if (dispatchOk && !wrapMissing) return
|
|
12805
|
+
if ((service.__gufaHealthLogs ?? 0) < 20) {
|
|
12806
|
+
service.__gufaHealthLogs = (service.__gufaHealthLogs ?? 0) + 1
|
|
12807
|
+
void G.api('dev.log', {
|
|
12808
|
+
message: `shortcut-health-heal dispatch=${dispatchOk} wrapMissing=${wrapMissing} mode=${G.mode.get() === true}`,
|
|
12809
|
+
}).catch(() => {})
|
|
12810
|
+
}
|
|
12811
|
+
try {
|
|
12812
|
+
G.installShortcutIntegration(service)
|
|
12813
|
+
} catch {
|
|
12814
|
+
/* ignore */
|
|
12815
|
+
}
|
|
12816
|
+
} catch {
|
|
12817
|
+
/* ignore */
|
|
12818
|
+
}
|
|
12819
|
+
}, 1500)
|
|
12820
|
+
}
|
|
12821
|
+
if (service.__gufaCatalogSubscribed !== true && service.catalog !== null && service.catalog !== undefined && typeof service.catalog.subscribe === 'function') {
|
|
12822
|
+
service.__gufaCatalogSubscribed = true
|
|
12823
|
+
try {
|
|
12824
|
+
service.catalog.subscribe(() => {
|
|
12825
|
+
try {
|
|
12826
|
+
if (G.mode.get() === true) G.installShortcutIntegration(service)
|
|
12827
|
+
} catch {
|
|
12828
|
+
/* ignore */
|
|
12829
|
+
}
|
|
12830
|
+
})
|
|
12831
|
+
} catch {
|
|
12832
|
+
/* ignore */
|
|
12833
|
+
}
|
|
12834
|
+
}
|
|
12835
|
+
}
|
|
12836
|
+
} catch {
|
|
12837
|
+
/* ignore */
|
|
12838
|
+
}
|
|
12839
|
+
|
|
12762
12840
|
// ── 一次性自检:确认改派在 IDE 模式下真的会执行(不会影响经典模式)──
|
|
12763
12841
|
try {
|
|
12764
12842
|
if (typeof window !== 'undefined' && window !== null && window.sessionStorage !== undefined) {
|
|
@@ -14075,13 +14153,25 @@ G.GufaApp = function GufaApp(props) {
|
|
|
14075
14153
|
}
|
|
14076
14154
|
setBranchInput('')
|
|
14077
14155
|
setBranchMenu({ ...placement, repo: repoPath, loading: true, branches: [], error: '' })
|
|
14078
|
-
|
|
14156
|
+
const loadBranches = () => G.api('git.branches', { root: project.root, repo: repoPath })
|
|
14079
14157
|
.then((value) => {
|
|
14080
|
-
setBranchMenu((current) => (current === null
|
|
14158
|
+
setBranchMenu((current) => (current === null
|
|
14159
|
+
? current
|
|
14160
|
+
: {
|
|
14161
|
+
...current,
|
|
14162
|
+
loading: false,
|
|
14163
|
+
branches: Array.isArray(value?.branches) ? value.branches : [],
|
|
14164
|
+
remotes: Array.isArray(value?.remotes) ? value.remotes : [],
|
|
14165
|
+
}))
|
|
14081
14166
|
})
|
|
14082
14167
|
.catch((error) => {
|
|
14083
14168
|
setBranchMenu((current) => (current === null ? current : { ...current, loading: false, error: G.errorText(error) }))
|
|
14084
14169
|
})
|
|
14170
|
+
void loadBranches()
|
|
14171
|
+
/* 远端分支可能只在远端、本地还没 fetch:打开弹窗时后台 fetch 一次再刷新列表 */
|
|
14172
|
+
void G.api('git.fetch', { root: project.root, repo: repoPath })
|
|
14173
|
+
.catch(() => {})
|
|
14174
|
+
.then(() => loadBranches())
|
|
14085
14175
|
}, [project])
|
|
14086
14176
|
|
|
14087
14177
|
const closeBranchMenu = useCallback(() => {
|
|
@@ -14107,10 +14197,10 @@ G.GufaApp = function GufaApp(props) {
|
|
|
14107
14197
|
}
|
|
14108
14198
|
}, [branchMenu, closeBranchMenu])
|
|
14109
14199
|
|
|
14110
|
-
const checkoutBranch = useCallback(async (name) => {
|
|
14200
|
+
const checkoutBranch = useCallback(async (name, remote) => {
|
|
14111
14201
|
if (project === null || typeof name !== 'string' || name === '') return
|
|
14112
14202
|
try {
|
|
14113
|
-
await G.api('git.checkout', { root: project.root, repo: branchMenu?.repo, branch: name })
|
|
14203
|
+
await G.api('git.checkout', { root: project.root, repo: branchMenu?.repo, branch: name, remote: remote === true })
|
|
14114
14204
|
closeBranchMenu()
|
|
14115
14205
|
setGitRefreshToken((token) => token + 1)
|
|
14116
14206
|
setRefreshToken((token) => token + 1)
|
|
@@ -16167,21 +16257,45 @@ G.GufaApp = function GufaApp(props) {
|
|
|
16167
16257
|
{ className: 'gufa-branch-dialog-list gufa-scroll' },
|
|
16168
16258
|
...(branchMenu.loading === true
|
|
16169
16259
|
? []
|
|
16170
|
-
:
|
|
16171
|
-
|
|
16172
|
-
'
|
|
16173
|
-
|
|
16174
|
-
|
|
16175
|
-
|
|
16176
|
-
|
|
16177
|
-
|
|
16178
|
-
|
|
16179
|
-
|
|
16180
|
-
|
|
16181
|
-
|
|
16182
|
-
|
|
16260
|
+
: [
|
|
16261
|
+
branchMenu.branches.length > 0
|
|
16262
|
+
? h('div', { className: 'gufa-branch-group' }, t('git.branchesLocal'))
|
|
16263
|
+
: null,
|
|
16264
|
+
...branchMenu.branches.map((branch) =>
|
|
16265
|
+
h(
|
|
16266
|
+
'button',
|
|
16267
|
+
{
|
|
16268
|
+
key: `l:${branch.name}`,
|
|
16269
|
+
type: 'button',
|
|
16270
|
+
className: 'gufa-branch-row',
|
|
16271
|
+
'data-current': branch.current === true ? '' : undefined,
|
|
16272
|
+
onClick: () => void checkoutBranch(branch.name),
|
|
16273
|
+
},
|
|
16274
|
+
h(G.Icon, { name: branch.current === true ? 'check' : 'branch', size: 13 }),
|
|
16275
|
+
h('span', { className: 'gufa-branch-name' }, branch.name),
|
|
16276
|
+
branch.current === true ? h('span', { className: 'gufa-branch-tag' }, t('git.branchCurrent')) : null,
|
|
16277
|
+
),
|
|
16278
|
+
),
|
|
16279
|
+
Array.isArray(branchMenu.remotes) && branchMenu.remotes.length > 0
|
|
16280
|
+
? h('div', { className: 'gufa-branch-group' }, t('git.branchesRemote'))
|
|
16281
|
+
: null,
|
|
16282
|
+
...(Array.isArray(branchMenu.remotes) ? branchMenu.remotes : []).map((branch) =>
|
|
16283
|
+
h(
|
|
16284
|
+
'button',
|
|
16285
|
+
{
|
|
16286
|
+
key: `r:${branch.name}`,
|
|
16287
|
+
type: 'button',
|
|
16288
|
+
className: 'gufa-branch-row',
|
|
16289
|
+
'data-remote': '',
|
|
16290
|
+
title: `${branch.name} → ${branch.short}(创建本地跟踪分支)`,
|
|
16291
|
+
onClick: () => void checkoutBranch(branch.name, true),
|
|
16292
|
+
},
|
|
16293
|
+
h(G.Icon, { name: 'cloud', size: 13 }),
|
|
16294
|
+
h('span', { className: 'gufa-branch-name' }, branch.name),
|
|
16295
|
+
h('span', { className: 'gufa-branch-tag', 'data-kind': 'remote' }, t('git.branchRemoteTag')),
|
|
16296
|
+
),
|
|
16183
16297
|
),
|
|
16184
|
-
)
|
|
16298
|
+
]),
|
|
16185
16299
|
),
|
|
16186
16300
|
h(
|
|
16187
16301
|
'div',
|
package/host/git.js
CHANGED
|
@@ -489,7 +489,26 @@ export function register(router, env) {
|
|
|
489
489
|
.map((line) => line.trim())
|
|
490
490
|
.filter((name) => name !== '')
|
|
491
491
|
.map((name) => ({ name, current: name === current }))
|
|
492
|
-
|
|
492
|
+
/* 远端分支:refs/remotes/<remote>/<branch>;排除 origin/HEAD 这类符号引用。
|
|
493
|
+
用于分支弹窗展示与从远端分支创建本地跟踪分支。 */
|
|
494
|
+
const remotes = (await git(root, ['remote']).catch(() => '')).trim()
|
|
495
|
+
.split('\n').map((line) => line.trim()).filter(Boolean)
|
|
496
|
+
const remoteRefs = await git(root, ['for-each-ref', '--format=%(refname:short)', 'refs/remotes']).catch(() => '')
|
|
497
|
+
const remoteBranches = remoteRefs
|
|
498
|
+
.split('\n')
|
|
499
|
+
.map((line) => line.trim())
|
|
500
|
+
.filter((name) => name !== '' && !name.endsWith('/HEAD'))
|
|
501
|
+
.map((name) => {
|
|
502
|
+
const remote = remotes.find((item) => name.startsWith(`${item}/`)) ?? name.split('/')[0]
|
|
503
|
+
return {
|
|
504
|
+
name,
|
|
505
|
+
short: name.slice(remote.length + 1),
|
|
506
|
+
remote,
|
|
507
|
+
current: false,
|
|
508
|
+
}
|
|
509
|
+
})
|
|
510
|
+
.filter((branch) => branch.short !== '')
|
|
511
|
+
return { branches, remotes: remoteBranches }
|
|
493
512
|
})
|
|
494
513
|
|
|
495
514
|
/** 新建并切换到新分支。 */
|
|
@@ -513,8 +532,30 @@ export function register(router, env) {
|
|
|
513
532
|
router.method('git.checkout', async (body) => {
|
|
514
533
|
const { root } = await repoContext(env, body)
|
|
515
534
|
if (typeof body.branch !== 'string' || body.branch === '') throw badRequest('branch is required')
|
|
535
|
+
if (body.remote === true) {
|
|
536
|
+
/* 从远端分支切出本地跟踪分支:origin/feat → feat。
|
|
537
|
+
若本地已有同名分支则直接切本地分支,不覆盖。 */
|
|
538
|
+
const remoteRef = body.branch
|
|
539
|
+
const remotes = (await git(root, ['remote']).catch(() => '')).trim()
|
|
540
|
+
.split('\n').map((line) => line.trim()).filter(Boolean)
|
|
541
|
+
const remote = remotes.find((item) => remoteRef.startsWith(`${item}/`))
|
|
542
|
+
if (remote === undefined) throw badRequest(`无效的远端分支:${remoteRef}`)
|
|
543
|
+
const short = remoteRef.slice(remote.length + 1)
|
|
544
|
+
if (short === '') throw badRequest(`无效的远端分支:${remoteRef}`)
|
|
545
|
+
const localExists = (await git(root, ['branch', '--list', '--format=%(refname:short)', short]).catch(() => '')).trim() !== ''
|
|
546
|
+
if (localExists) {
|
|
547
|
+
await git(root, ['checkout', short])
|
|
548
|
+
return { ok: true, branch: short, tracking: false }
|
|
549
|
+
}
|
|
550
|
+
try {
|
|
551
|
+
await git(root, ['switch', '--track', '-c', short, remoteRef], 60_000)
|
|
552
|
+
} catch {
|
|
553
|
+
await git(root, ['checkout', '-b', short, '--track', remoteRef], 60_000)
|
|
554
|
+
}
|
|
555
|
+
return { ok: true, branch: short, tracking: true }
|
|
556
|
+
}
|
|
516
557
|
await git(root, ['checkout', body.branch])
|
|
517
|
-
return { ok: true }
|
|
558
|
+
return { ok: true, branch: body.branch }
|
|
518
559
|
})
|
|
519
560
|
|
|
520
561
|
router.method('git.isRepo', async (body) => {
|
package/package.json
CHANGED
|
@@ -340,6 +340,22 @@ try {
|
|
|
340
340
|
check('discardAll deletes untracked files', allUntrackedGone)
|
|
341
341
|
check('discardAll restores tracked files', restoredMain.content === 'const answer = 42\n', JSON.stringify(restoredMain.content))
|
|
342
342
|
|
|
343
|
+
/* 远端分支:列出远端分支,并能从远端分支切出本地跟踪分支 */
|
|
344
|
+
const bareRemote = join(sandbox, 'origin.git')
|
|
345
|
+
execFileSync('git', ['init', '--bare', '-q', bareRemote], { cwd: sandbox })
|
|
346
|
+
execFileSync('git', ['remote', 'add', 'origin', bareRemote], { cwd: projectDir })
|
|
347
|
+
const baseBranch = execFileSync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { cwd: projectDir, encoding: 'utf8' }).trim()
|
|
348
|
+
execFileSync('git', ['push', '-q', 'origin', baseBranch], { cwd: projectDir })
|
|
349
|
+
execFileSync('git', ['branch', 'feature-remote'], { cwd: projectDir })
|
|
350
|
+
execFileSync('git', ['push', '-q', 'origin', 'feature-remote'], { cwd: projectDir })
|
|
351
|
+
execFileSync('git', ['branch', '-D', 'feature-remote'], { cwd: projectDir })
|
|
352
|
+
const branchList = await call(router, 'git.branches', { root })
|
|
353
|
+
check('git.branches lists remote branches', branchList.remotes.some((branch) => branch.name === 'origin/feature-remote'), JSON.stringify(branchList.remotes.map((branch) => branch.name)))
|
|
354
|
+
await call(router, 'git.checkout', { root, branch: 'origin/feature-remote', remote: true })
|
|
355
|
+
const trackedBranches = await call(router, 'git.branches', { root })
|
|
356
|
+
check('checkout remote creates tracking branch', trackedBranches.branches.some((branch) => branch.name === 'feature-remote' && branch.current === true), JSON.stringify(trackedBranches.branches))
|
|
357
|
+
await call(router, 'git.checkout', { root, branch: baseBranch })
|
|
358
|
+
|
|
343
359
|
const gitSearch = await call(router, 'fs.search', { root, query: 'answer' })
|
|
344
360
|
check('search uses git file list', gitSearch.viaGit === true, String(gitSearch.viaGit))
|
|
345
361
|
check('search finds committed file', gitSearch.files.some((file) => file.path === 'src/main.ts'))
|
package/src/client/00-core.js
CHANGED
|
@@ -291,6 +291,9 @@ const DICT_ZH = {
|
|
|
291
291
|
'git.branchCurrent': '当前',
|
|
292
292
|
'git.branchNamePlaceholder': '新分支名',
|
|
293
293
|
'git.branchCreate': '新建并切换',
|
|
294
|
+
'git.branchesLocal': '本地分支',
|
|
295
|
+
'git.branchesRemote': '远程分支',
|
|
296
|
+
'git.branchRemoteTag': '远端',
|
|
294
297
|
'git.undoLastCommit': '撤回上次提交(保留改动)',
|
|
295
298
|
'diff.prev': '上一处差异',
|
|
296
299
|
'diff.next': '下一处差异',
|
|
@@ -557,6 +560,9 @@ const DICT_EN = {
|
|
|
557
560
|
'git.branchCurrent': 'current',
|
|
558
561
|
'git.branchNamePlaceholder': 'New branch name',
|
|
559
562
|
'git.branchCreate': 'Create & switch',
|
|
563
|
+
'git.branchesLocal': 'Local branches',
|
|
564
|
+
'git.branchesRemote': 'Remote branches',
|
|
565
|
+
'git.branchRemoteTag': 'remote',
|
|
560
566
|
'git.undoLastCommit': 'Undo last commit (keep changes)',
|
|
561
567
|
'diff.prev': 'Previous change',
|
|
562
568
|
'diff.next': 'Next change',
|
|
@@ -1939,6 +1945,10 @@ html[data-platform=darwin][data-fullscreen] .gufa-titlebar{height:44px;padding-l
|
|
|
1939
1945
|
.gufa-branch-row{display:flex;align-items:center;gap:8px;width:100%;height:30px;padding:0 8px;border:0;border-radius:7px;
|
|
1940
1946
|
background:transparent;color:var(--gufa-text);cursor:pointer;font-size:12px;text-align:left}
|
|
1941
1947
|
.gufa-branch-row:hover{background:var(--gufa-hover)}
|
|
1948
|
+
.gufa-branch-group{padding:8px 10px 3px;font-size:10.5px;font-weight:600;letter-spacing:.03em;color:var(--gufa-text-dim);text-transform:uppercase}
|
|
1949
|
+
.gufa-branch-row[data-remote]{color:var(--gufa-text-dim)}
|
|
1950
|
+
.gufa-branch-row[data-remote]:hover{color:var(--gufa-text)}
|
|
1951
|
+
.gufa-branch-tag[data-kind="remote"]{color:var(--gufa-text-dim);border:0.5px solid var(--gufa-border);background:transparent}
|
|
1942
1952
|
.gufa-branch-row[data-current]{background:color-mix(in srgb, var(--gufa-accent) 16%, transparent)}
|
|
1943
1953
|
.gufa-branch-name{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1944
1954
|
.gufa-branch-tag{font-size:10px;padding:1px 6px;border-radius:8px;color:var(--gufa-accent);
|
package/src/client/10-icons.js
CHANGED
|
@@ -42,6 +42,7 @@ const ICON_PATHS = {
|
|
|
42
42
|
['path', { d: 'M8 3h7l4 4v10a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z' }],
|
|
43
43
|
['path', { d: 'M15 3v4h4M3 8v12a1 1 0 0 0 1 1h9' }, { opacity: 0.55 }],
|
|
44
44
|
],
|
|
45
|
+
cloud: [['path', { d: 'M7 18h10a4 4 0 0 0 .4-8A6 6 0 0 0 6 11.2 3.6 3.6 0 0 0 7 18z' }]],
|
|
45
46
|
git: [
|
|
46
47
|
['circle', { cx: 6, cy: 6, r: 2.2 }],
|
|
47
48
|
['circle', { cx: 6, cy: 18, r: 2.2 }],
|
|
@@ -432,6 +432,14 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
|
|
|
432
432
|
const mac = G.isMacPlatform()
|
|
433
433
|
const primary = mac ? gesture?.meta === true && gesture?.control !== true : gesture?.control === true
|
|
434
434
|
if (primary && gesture?.code === 'KeyK' && gesture?.shift !== true && gesture?.alt !== true) {
|
|
435
|
+
try {
|
|
436
|
+
if ((window.__gufaDispatchRemapLogs ?? 0) < 20) {
|
|
437
|
+
window.__gufaDispatchRemapLogs = (window.__gufaDispatchRemapLogs ?? 0) + 1
|
|
438
|
+
void G.api('dev.log', { message: 'command-remap-dispatch KeyK -> clearTerminal' }).catch(() => {})
|
|
439
|
+
}
|
|
440
|
+
} catch {
|
|
441
|
+
/* ignore */
|
|
442
|
+
}
|
|
435
443
|
if (typeof consume === 'function') consume()
|
|
436
444
|
if (gesture?.repeat !== true) {
|
|
437
445
|
try { window.__gufaIdeShortcutDispatch('clearTerminal') } catch { /* ignore */ }
|
|
@@ -499,6 +507,65 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
|
|
|
499
507
|
/* 重试安装失败不影响主流程 */
|
|
500
508
|
}
|
|
501
509
|
|
|
510
|
+
/* ── 自愈:DSH 重连/切换会话/热重载可能重建命令表或丢掉 dispatch 补丁,
|
|
511
|
+
表现为「一开始 Cmd+K 好用,操作一阵后失效、重启客户端才恢复」。
|
|
512
|
+
每 1.5s 检查一次,发现补丁丢失就在 IDE 模式下自动重装。 ── */
|
|
513
|
+
try {
|
|
514
|
+
if (typeof window !== 'undefined' && window !== null) {
|
|
515
|
+
if (service.__gufaHealthTimer === undefined || service.__gufaHealthTimer === null) {
|
|
516
|
+
service.__gufaHealthTimer = window.setInterval(() => {
|
|
517
|
+
try {
|
|
518
|
+
if (G.mode.get() !== true) return
|
|
519
|
+
const registryNow = service.registry
|
|
520
|
+
if (registryNow === null || registryNow === undefined) return
|
|
521
|
+
const dispatchOk = registryNow.__gufaDispatchPatched === true
|
|
522
|
+
let wrapMissing = false
|
|
523
|
+
const commandsNow = registryNow.commands
|
|
524
|
+
if (commandsNow !== null && commandsNow !== undefined && typeof commandsNow.get === 'function') {
|
|
525
|
+
for (const id of Object.keys(service.__gufaCommandActions ?? {})) {
|
|
526
|
+
const command = commandsNow.get(id)
|
|
527
|
+
if (command !== null && command !== undefined && command.__gufaWrapped !== true) {
|
|
528
|
+
wrapMissing = true
|
|
529
|
+
break
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
if (dispatchOk && !wrapMissing) return
|
|
534
|
+
if ((service.__gufaHealthLogs ?? 0) < 20) {
|
|
535
|
+
service.__gufaHealthLogs = (service.__gufaHealthLogs ?? 0) + 1
|
|
536
|
+
void G.api('dev.log', {
|
|
537
|
+
message: `shortcut-health-heal dispatch=${dispatchOk} wrapMissing=${wrapMissing} mode=${G.mode.get() === true}`,
|
|
538
|
+
}).catch(() => {})
|
|
539
|
+
}
|
|
540
|
+
try {
|
|
541
|
+
G.installShortcutIntegration(service)
|
|
542
|
+
} catch {
|
|
543
|
+
/* ignore */
|
|
544
|
+
}
|
|
545
|
+
} catch {
|
|
546
|
+
/* ignore */
|
|
547
|
+
}
|
|
548
|
+
}, 1500)
|
|
549
|
+
}
|
|
550
|
+
if (service.__gufaCatalogSubscribed !== true && service.catalog !== null && service.catalog !== undefined && typeof service.catalog.subscribe === 'function') {
|
|
551
|
+
service.__gufaCatalogSubscribed = true
|
|
552
|
+
try {
|
|
553
|
+
service.catalog.subscribe(() => {
|
|
554
|
+
try {
|
|
555
|
+
if (G.mode.get() === true) G.installShortcutIntegration(service)
|
|
556
|
+
} catch {
|
|
557
|
+
/* ignore */
|
|
558
|
+
}
|
|
559
|
+
})
|
|
560
|
+
} catch {
|
|
561
|
+
/* ignore */
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
} catch {
|
|
566
|
+
/* ignore */
|
|
567
|
+
}
|
|
568
|
+
|
|
502
569
|
// ── 一次性自检:确认改派在 IDE 模式下真的会执行(不会影响经典模式)──
|
|
503
570
|
try {
|
|
504
571
|
if (typeof window !== 'undefined' && window !== null && window.sessionStorage !== undefined) {
|
package/src/client/90-app.js
CHANGED
|
@@ -1098,13 +1098,25 @@ G.GufaApp = function GufaApp(props) {
|
|
|
1098
1098
|
}
|
|
1099
1099
|
setBranchInput('')
|
|
1100
1100
|
setBranchMenu({ ...placement, repo: repoPath, loading: true, branches: [], error: '' })
|
|
1101
|
-
|
|
1101
|
+
const loadBranches = () => G.api('git.branches', { root: project.root, repo: repoPath })
|
|
1102
1102
|
.then((value) => {
|
|
1103
|
-
setBranchMenu((current) => (current === null
|
|
1103
|
+
setBranchMenu((current) => (current === null
|
|
1104
|
+
? current
|
|
1105
|
+
: {
|
|
1106
|
+
...current,
|
|
1107
|
+
loading: false,
|
|
1108
|
+
branches: Array.isArray(value?.branches) ? value.branches : [],
|
|
1109
|
+
remotes: Array.isArray(value?.remotes) ? value.remotes : [],
|
|
1110
|
+
}))
|
|
1104
1111
|
})
|
|
1105
1112
|
.catch((error) => {
|
|
1106
1113
|
setBranchMenu((current) => (current === null ? current : { ...current, loading: false, error: G.errorText(error) }))
|
|
1107
1114
|
})
|
|
1115
|
+
void loadBranches()
|
|
1116
|
+
/* 远端分支可能只在远端、本地还没 fetch:打开弹窗时后台 fetch 一次再刷新列表 */
|
|
1117
|
+
void G.api('git.fetch', { root: project.root, repo: repoPath })
|
|
1118
|
+
.catch(() => {})
|
|
1119
|
+
.then(() => loadBranches())
|
|
1108
1120
|
}, [project])
|
|
1109
1121
|
|
|
1110
1122
|
const closeBranchMenu = useCallback(() => {
|
|
@@ -1130,10 +1142,10 @@ G.GufaApp = function GufaApp(props) {
|
|
|
1130
1142
|
}
|
|
1131
1143
|
}, [branchMenu, closeBranchMenu])
|
|
1132
1144
|
|
|
1133
|
-
const checkoutBranch = useCallback(async (name) => {
|
|
1145
|
+
const checkoutBranch = useCallback(async (name, remote) => {
|
|
1134
1146
|
if (project === null || typeof name !== 'string' || name === '') return
|
|
1135
1147
|
try {
|
|
1136
|
-
await G.api('git.checkout', { root: project.root, repo: branchMenu?.repo, branch: name })
|
|
1148
|
+
await G.api('git.checkout', { root: project.root, repo: branchMenu?.repo, branch: name, remote: remote === true })
|
|
1137
1149
|
closeBranchMenu()
|
|
1138
1150
|
setGitRefreshToken((token) => token + 1)
|
|
1139
1151
|
setRefreshToken((token) => token + 1)
|
|
@@ -3190,21 +3202,45 @@ G.GufaApp = function GufaApp(props) {
|
|
|
3190
3202
|
{ className: 'gufa-branch-dialog-list gufa-scroll' },
|
|
3191
3203
|
...(branchMenu.loading === true
|
|
3192
3204
|
? []
|
|
3193
|
-
:
|
|
3194
|
-
|
|
3195
|
-
'
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3205
|
+
: [
|
|
3206
|
+
branchMenu.branches.length > 0
|
|
3207
|
+
? h('div', { className: 'gufa-branch-group' }, t('git.branchesLocal'))
|
|
3208
|
+
: null,
|
|
3209
|
+
...branchMenu.branches.map((branch) =>
|
|
3210
|
+
h(
|
|
3211
|
+
'button',
|
|
3212
|
+
{
|
|
3213
|
+
key: `l:${branch.name}`,
|
|
3214
|
+
type: 'button',
|
|
3215
|
+
className: 'gufa-branch-row',
|
|
3216
|
+
'data-current': branch.current === true ? '' : undefined,
|
|
3217
|
+
onClick: () => void checkoutBranch(branch.name),
|
|
3218
|
+
},
|
|
3219
|
+
h(G.Icon, { name: branch.current === true ? 'check' : 'branch', size: 13 }),
|
|
3220
|
+
h('span', { className: 'gufa-branch-name' }, branch.name),
|
|
3221
|
+
branch.current === true ? h('span', { className: 'gufa-branch-tag' }, t('git.branchCurrent')) : null,
|
|
3222
|
+
),
|
|
3223
|
+
),
|
|
3224
|
+
Array.isArray(branchMenu.remotes) && branchMenu.remotes.length > 0
|
|
3225
|
+
? h('div', { className: 'gufa-branch-group' }, t('git.branchesRemote'))
|
|
3226
|
+
: null,
|
|
3227
|
+
...(Array.isArray(branchMenu.remotes) ? branchMenu.remotes : []).map((branch) =>
|
|
3228
|
+
h(
|
|
3229
|
+
'button',
|
|
3230
|
+
{
|
|
3231
|
+
key: `r:${branch.name}`,
|
|
3232
|
+
type: 'button',
|
|
3233
|
+
className: 'gufa-branch-row',
|
|
3234
|
+
'data-remote': '',
|
|
3235
|
+
title: `${branch.name} → ${branch.short}(创建本地跟踪分支)`,
|
|
3236
|
+
onClick: () => void checkoutBranch(branch.name, true),
|
|
3237
|
+
},
|
|
3238
|
+
h(G.Icon, { name: 'cloud', size: 13 }),
|
|
3239
|
+
h('span', { className: 'gufa-branch-name' }, branch.name),
|
|
3240
|
+
h('span', { className: 'gufa-branch-tag', 'data-kind': 'remote' }, t('git.branchRemoteTag')),
|
|
3241
|
+
),
|
|
3206
3242
|
),
|
|
3207
|
-
)
|
|
3243
|
+
]),
|
|
3208
3244
|
),
|
|
3209
3245
|
h(
|
|
3210
3246
|
'div',
|