dsh-gufa-code 1.3.186 → 1.3.188
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 +34 -3
- package/desktop/float/bin/win-x64/gufa-float-win.exe +0 -0
- package/desktop/float/win/main.cpp +6 -0
- package/host/git.js +16 -0
- package/package.json +1 -1
- package/src/client/50-panels.js +10 -1
- package/src/client/60-dock.js +4 -1
- package/src/client/90-app.js +19 -0
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.188'
|
|
20
20
|
G.PANEL_ID = 'gufa-code'
|
|
21
21
|
/** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
|
|
22
22
|
G.pendingEntryWorkspace = null
|
|
@@ -9037,6 +9037,15 @@ G.GitPanel = function GitPanel(props) {
|
|
|
9037
9037
|
}
|
|
9038
9038
|
}, [])
|
|
9039
9039
|
|
|
9040
|
+
/* 手动刷新:先 fetch 远端,再读 status(否则 behind 可能是 0) */
|
|
9041
|
+
const refreshRemote = useCallback(async () => {
|
|
9042
|
+
const target = rootRef.current
|
|
9043
|
+
if (target) {
|
|
9044
|
+
try { await G.api('git.fetch', { root: target }) } catch { /* 离线等失败不打扰 */ }
|
|
9045
|
+
}
|
|
9046
|
+
await refresh()
|
|
9047
|
+
}, [refresh])
|
|
9048
|
+
|
|
9040
9049
|
/* 项目变化:清空并重新拉取 */
|
|
9041
9050
|
useEffect(() => {
|
|
9042
9051
|
setStatus(null)
|
|
@@ -9226,7 +9235,7 @@ G.GitPanel = function GitPanel(props) {
|
|
|
9226
9235
|
)
|
|
9227
9236
|
: null,
|
|
9228
9237
|
h(G.IconButton, { title: t('graph.open'), onClick: () => props.onOpenGraph?.() }, h(G.Icon, { name: 'graph', size: 13 })),
|
|
9229
|
-
h(G.IconButton, { title: t('git.refresh'), disabled: pending, onClick: () => void
|
|
9238
|
+
h(G.IconButton, { title: t('git.refresh'), disabled: pending, onClick: () => void refreshRemote() }, h(G.Icon, { name: 'refresh', size: 13 })),
|
|
9230
9239
|
h(G.IconButton, {
|
|
9231
9240
|
title: t('git.more'),
|
|
9232
9241
|
onClick: (event) => {
|
|
@@ -11357,7 +11366,10 @@ function gufaParseMentionButton(button) {
|
|
|
11357
11366
|
|
|
11358
11367
|
async function gufaOpenMention(mention) {
|
|
11359
11368
|
if (mention === null || mention === undefined || typeof mention.path !== 'string' || mention.path === '') return
|
|
11360
|
-
|
|
11369
|
+
/* 必须原样传 Host 登记的 project.root:Windows 上 Host 用反斜杠规范化过,
|
|
11370
|
+
ProjectRegistry.ensure 是精确字符串匹配;改成 / 会被拒绝(project-not-open),
|
|
11371
|
+
表现就是 Windows 上引用点不开。 */
|
|
11372
|
+
const root = typeof G.projectRoot === 'string' ? G.projectRoot.replace(/[\\/]+$/, '') : ''
|
|
11361
11373
|
if (root === '') return
|
|
11362
11374
|
/* Windows 的会话引用可能带 file:///C:/ 前缀、%20 编码或反斜杠;先归一化再让 Host 解析 */
|
|
11363
11375
|
let rawPath = String(mention.path ?? '').trim()
|
|
@@ -12917,6 +12929,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
12917
12929
|
const [gitStatus, setGitStatus] = useState(null)
|
|
12918
12930
|
const gitSignatureRef = useRef('')
|
|
12919
12931
|
const gitInFlightRef = useRef(false)
|
|
12932
|
+
const gitFetchRef = useRef({ root: '', at: 0 })
|
|
12920
12933
|
const [modal, setModal] = useState(null)
|
|
12921
12934
|
const [shortcutsOpen, setShortcutsOpen] = useState(false)
|
|
12922
12935
|
const [definitionPicker, setDefinitionPicker] = useState(null)
|
|
@@ -13102,6 +13115,24 @@ G.GufaApp = function GufaApp(props) {
|
|
|
13102
13115
|
}
|
|
13103
13116
|
}, [project, refreshGit])
|
|
13104
13117
|
|
|
13118
|
+
/* 进入 Git 面板时主动 fetch 一次(限流 15s):否则 behind 只看本地 remote-tracking ref,
|
|
13119
|
+
远端新提交在 fetch 之前永远显示 0。 */
|
|
13120
|
+
useEffect(() => {
|
|
13121
|
+
if (project === null || project.isGit !== true) return undefined
|
|
13122
|
+
if (ui.sidebarOpen !== true || ui.view !== 'git') return undefined
|
|
13123
|
+
const now = Date.now()
|
|
13124
|
+
const last = gitFetchRef.current
|
|
13125
|
+
if (last.root === project.root && now - last.at < 15000) return undefined
|
|
13126
|
+
gitFetchRef.current = { root: project.root, at: now }
|
|
13127
|
+
let cancelled = false
|
|
13128
|
+
void G.api('git.fetch', { root: project.root }).then((value) => {
|
|
13129
|
+
if (cancelled || value?.ok !== true) return
|
|
13130
|
+
setGitRefreshToken((token) => token + 1)
|
|
13131
|
+
setRefreshToken((token) => token + 1)
|
|
13132
|
+
}).catch(() => {})
|
|
13133
|
+
return () => { cancelled = true }
|
|
13134
|
+
}, [project, ui.sidebarOpen, ui.view])
|
|
13135
|
+
|
|
13105
13136
|
const gitStatuses = useMemo(() => {
|
|
13106
13137
|
const map = {}
|
|
13107
13138
|
for (const change of gitStatus?.changes ?? []) map[change.path] = change.status
|
|
Binary file
|
|
@@ -1682,6 +1682,9 @@ bool FloatApp::OnCompositionMouseMessage(UINT message, WPARAM wparam, LPARAM lpa
|
|
|
1682
1682
|
}
|
|
1683
1683
|
|
|
1684
1684
|
LRESULT FloatApp::HandleNcHitTest(HWND hwnd, LPARAM lparam) {
|
|
1685
|
+
/* 鼠标穿透:双击/拖动都不要再命中本窗口,让点击落到下层 App。
|
|
1686
|
+
WS_EX_TRANSPARENT 在部分 WebView2/Composition 窗口上不生效,这里加 HTTRANSPARENT 兜底。 */
|
|
1687
|
+
if (clickThrough_) return HTTRANSPARENT;
|
|
1685
1688
|
POINT point;
|
|
1686
1689
|
point.x = GET_X_LPARAM(lparam);
|
|
1687
1690
|
point.y = GET_Y_LPARAM(lparam);
|
|
@@ -2631,6 +2634,9 @@ LRESULT FloatApp::OnMainMessage(HWND hwnd, UINT message, WPARAM wparam, LPARAM l
|
|
|
2631
2634
|
return TRUE;
|
|
2632
2635
|
}
|
|
2633
2636
|
return DefWindowProcW(hwnd, message, wparam, lparam);
|
|
2637
|
+
case WM_MOUSEACTIVATE:
|
|
2638
|
+
if (clickThrough_) return MA_NOACTIVATE;
|
|
2639
|
+
return DefWindowProcW(hwnd, message, wparam, lparam);
|
|
2634
2640
|
case WM_ACTIVATE:
|
|
2635
2641
|
if (hostingMode_ == HostingMode::Composition && LOWORD(wparam) != WA_INACTIVE &&
|
|
2636
2642
|
controller_.Get() != nullptr) {
|
package/host/git.js
CHANGED
|
@@ -148,6 +148,22 @@ export function register(router, env) {
|
|
|
148
148
|
return { isGit: true, ...parseStatus(await git(project.root, ['status', '--porcelain=v1', '--branch', '--untracked-files=all'])) }
|
|
149
149
|
})
|
|
150
150
|
|
|
151
|
+
/* 主动 fetch:git.status 的 behind 只反映本地已知的 remote-tracking ref,
|
|
152
|
+
远端有新提交但没 fetch 时箭头永远是 0。进 Git 面板/点刷新时先 fetch。 */
|
|
153
|
+
router.method('git.fetch', async (body) => {
|
|
154
|
+
const project = await ensureRepo(env, body)
|
|
155
|
+
if (project.isGit !== true) return { ok: false, reason: 'not-git' }
|
|
156
|
+
try {
|
|
157
|
+
const remotes = (await git(project.root, ['remote']).catch(() => '')).trim()
|
|
158
|
+
.split('\n').map((line) => line.trim()).filter(Boolean)
|
|
159
|
+
const args = remotes.length > 0 ? ['fetch', '--prune', '--quiet', remotes[0]] : ['fetch', '--prune', '--quiet']
|
|
160
|
+
await git(project.root, args, 60_000)
|
|
161
|
+
return { ok: true, remote: remotes[0] ?? '' }
|
|
162
|
+
} catch (error) {
|
|
163
|
+
return { ok: false, reason: String(error?.message ?? error).slice(0, 800) }
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
|
|
151
167
|
router.method('git.stage', async (body) => {
|
|
152
168
|
const project = await projectOf(env, body)
|
|
153
169
|
const paths = Array.isArray(body.paths) ? body.paths.filter((item) => typeof item === 'string' && item !== '') : []
|
package/package.json
CHANGED
package/src/client/50-panels.js
CHANGED
|
@@ -1083,6 +1083,15 @@ G.GitPanel = function GitPanel(props) {
|
|
|
1083
1083
|
}
|
|
1084
1084
|
}, [])
|
|
1085
1085
|
|
|
1086
|
+
/* 手动刷新:先 fetch 远端,再读 status(否则 behind 可能是 0) */
|
|
1087
|
+
const refreshRemote = useCallback(async () => {
|
|
1088
|
+
const target = rootRef.current
|
|
1089
|
+
if (target) {
|
|
1090
|
+
try { await G.api('git.fetch', { root: target }) } catch { /* 离线等失败不打扰 */ }
|
|
1091
|
+
}
|
|
1092
|
+
await refresh()
|
|
1093
|
+
}, [refresh])
|
|
1094
|
+
|
|
1086
1095
|
/* 项目变化:清空并重新拉取 */
|
|
1087
1096
|
useEffect(() => {
|
|
1088
1097
|
setStatus(null)
|
|
@@ -1272,7 +1281,7 @@ G.GitPanel = function GitPanel(props) {
|
|
|
1272
1281
|
)
|
|
1273
1282
|
: null,
|
|
1274
1283
|
h(G.IconButton, { title: t('graph.open'), onClick: () => props.onOpenGraph?.() }, h(G.Icon, { name: 'graph', size: 13 })),
|
|
1275
|
-
h(G.IconButton, { title: t('git.refresh'), disabled: pending, onClick: () => void
|
|
1284
|
+
h(G.IconButton, { title: t('git.refresh'), disabled: pending, onClick: () => void refreshRemote() }, h(G.Icon, { name: 'refresh', size: 13 })),
|
|
1276
1285
|
h(G.IconButton, {
|
|
1277
1286
|
title: t('git.more'),
|
|
1278
1287
|
onClick: (event) => {
|
package/src/client/60-dock.js
CHANGED
|
@@ -475,7 +475,10 @@ function gufaParseMentionButton(button) {
|
|
|
475
475
|
|
|
476
476
|
async function gufaOpenMention(mention) {
|
|
477
477
|
if (mention === null || mention === undefined || typeof mention.path !== 'string' || mention.path === '') return
|
|
478
|
-
|
|
478
|
+
/* 必须原样传 Host 登记的 project.root:Windows 上 Host 用反斜杠规范化过,
|
|
479
|
+
ProjectRegistry.ensure 是精确字符串匹配;改成 / 会被拒绝(project-not-open),
|
|
480
|
+
表现就是 Windows 上引用点不开。 */
|
|
481
|
+
const root = typeof G.projectRoot === 'string' ? G.projectRoot.replace(/[\\/]+$/, '') : ''
|
|
479
482
|
if (root === '') return
|
|
480
483
|
/* Windows 的会话引用可能带 file:///C:/ 前缀、%20 编码或反斜杠;先归一化再让 Host 解析 */
|
|
481
484
|
let rawPath = String(mention.path ?? '').trim()
|
package/src/client/90-app.js
CHANGED
|
@@ -366,6 +366,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
366
366
|
const [gitStatus, setGitStatus] = useState(null)
|
|
367
367
|
const gitSignatureRef = useRef('')
|
|
368
368
|
const gitInFlightRef = useRef(false)
|
|
369
|
+
const gitFetchRef = useRef({ root: '', at: 0 })
|
|
369
370
|
const [modal, setModal] = useState(null)
|
|
370
371
|
const [shortcutsOpen, setShortcutsOpen] = useState(false)
|
|
371
372
|
const [definitionPicker, setDefinitionPicker] = useState(null)
|
|
@@ -551,6 +552,24 @@ G.GufaApp = function GufaApp(props) {
|
|
|
551
552
|
}
|
|
552
553
|
}, [project, refreshGit])
|
|
553
554
|
|
|
555
|
+
/* 进入 Git 面板时主动 fetch 一次(限流 15s):否则 behind 只看本地 remote-tracking ref,
|
|
556
|
+
远端新提交在 fetch 之前永远显示 0。 */
|
|
557
|
+
useEffect(() => {
|
|
558
|
+
if (project === null || project.isGit !== true) return undefined
|
|
559
|
+
if (ui.sidebarOpen !== true || ui.view !== 'git') return undefined
|
|
560
|
+
const now = Date.now()
|
|
561
|
+
const last = gitFetchRef.current
|
|
562
|
+
if (last.root === project.root && now - last.at < 15000) return undefined
|
|
563
|
+
gitFetchRef.current = { root: project.root, at: now }
|
|
564
|
+
let cancelled = false
|
|
565
|
+
void G.api('git.fetch', { root: project.root }).then((value) => {
|
|
566
|
+
if (cancelled || value?.ok !== true) return
|
|
567
|
+
setGitRefreshToken((token) => token + 1)
|
|
568
|
+
setRefreshToken((token) => token + 1)
|
|
569
|
+
}).catch(() => {})
|
|
570
|
+
return () => { cancelled = true }
|
|
571
|
+
}, [project, ui.sidebarOpen, ui.view])
|
|
572
|
+
|
|
554
573
|
const gitStatuses = useMemo(() => {
|
|
555
574
|
const map = {}
|
|
556
575
|
for (const change of gitStatus?.changes ?? []) map[change.path] = change.status
|