dsh-gufa-code 1.3.2 → 1.3.3

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 CHANGED
@@ -8137,11 +8137,41 @@ G.installPopupLayerWatch = function installPopupLayerWatch(ctx) {
8137
8137
  '.gufa-shortcuts-backdrop',
8138
8138
  ].join(',')
8139
8139
 
8140
+ /* 真正需要抬的是 overlay root 的 body 级祖先:它和停靠会话都是 body 的直接子节点,
8141
+ 在祖先上设 z-index 才能压过会话的 2147483040;只抬 .gufa-overlay-root 出不了
8142
+ 它自己的层叠上下文。 */
8143
+ let liftedNodes = []
8144
+ const lift = (open) => {
8145
+ try {
8146
+ if (open) {
8147
+ if (liftedNodes.length > 0) return
8148
+ let node = document.querySelector('.gufa-overlay-root')
8149
+ if (node === null) return
8150
+ while (node.parentElement !== null && node.parentElement !== document.body) node = node.parentElement
8151
+ if (node.parentElement !== document.body) return
8152
+ const saved = { node, zIndex: node.style.zIndex, position: node.style.position }
8153
+ node.style.zIndex = '2147483300'
8154
+ if (window.getComputedStyle(node).position === 'static') node.style.position = 'relative'
8155
+ liftedNodes.push(saved)
8156
+ if (node.parentElement !== document.body) return
8157
+ } else {
8158
+ for (const saved of liftedNodes) {
8159
+ saved.node.style.zIndex = saved.zIndex
8160
+ saved.node.style.position = saved.position
8161
+ }
8162
+ liftedNodes = []
8163
+ }
8164
+ } catch {
8165
+ /* ignore */
8166
+ }
8167
+ }
8168
+
8140
8169
  const sync = () => {
8141
8170
  try {
8142
8171
  const root = document.querySelector('.gufa-root')
8143
8172
  const popup = root === null ? null : root.querySelector(SELECTOR)
8144
8173
  const open = popup !== null
8174
+ lift(open)
8145
8175
  if ((document.documentElement.getAttribute(ATTR) === '1') === open) return
8146
8176
  if (open) document.documentElement.setAttribute(ATTR, '1')
8147
8177
  else document.documentElement.removeAttribute(ATTR)
@@ -8162,6 +8192,7 @@ G.installPopupLayerWatch = function installPopupLayerWatch(ctx) {
8162
8192
  return () => {
8163
8193
  if (observer !== null) observer.disconnect()
8164
8194
  window.clearInterval(timer)
8195
+ lift(false)
8165
8196
  document.documentElement.removeAttribute(ATTR)
8166
8197
  }
8167
8198
  }
package/host/dev.js CHANGED
@@ -125,9 +125,9 @@ export function register(router, env) {
125
125
  router.method('float.windows', async () => {
126
126
  if (process.platform !== 'darwin') throw new ApiError('unsupported', '摸鱼模式目前只支持 macOS', 400)
127
127
  if (appBundlePath() === null) throw new ApiError('missing-helper', '悬浮层 App 未构建,请先运行 scripts/build-float-macos.sh', 500)
128
+ const binary = floatBinaryPath()
128
129
  const outPath = join(tmpdir(), `gufa-float-windows-${process.pid}-${Date.now()}.json`)
129
- try {
130
- await openApp(['--list-windows', '--out', outPath])
130
+ const readResult = async () => {
131
131
  const deadline = Date.now() + 10_000
132
132
  let raw = ''
133
133
  while (Date.now() < deadline) {
@@ -139,12 +139,29 @@ export function register(router, env) {
139
139
  }
140
140
  await new Promise((resolve) => setTimeout(resolve, 120))
141
141
  }
142
- let parsed = null
143
142
  try {
144
- parsed = JSON.parse(raw.trim())
143
+ return JSON.parse(raw.trim())
145
144
  } catch {
146
- parsed = null
145
+ return null
147
146
  }
147
+ }
148
+ try {
149
+ /* 路线 A:直接从 Host 进程 spawn(responsible app = DeepSeek Harness,可继承 DSH 的屏幕录制授权) */
150
+ if (binary !== null) {
151
+ try {
152
+ await runFile(binary, ['--list-windows', '--out', outPath], { timeout: 12_000 })
153
+ } catch {
154
+ /* 走读取兜底 */
155
+ }
156
+ const parsed = await readResult()
157
+ debugLog(`float-windows route=direct ok=${String(parsed !== null && parsed.ok === true)} permission=${String(parsed !== null ? parsed.permission : 'none')}`)
158
+ if (parsed !== null && parsed.ok === true) return parsed
159
+ try { await rm(outPath, { force: true }) } catch { /* ignore */ }
160
+ }
161
+ /* 路线 B:通过 .app 身份启动(用户给「古法编程悬浮层.app」单独授权) */
162
+ await openApp(['--list-windows', '--out', outPath])
163
+ const parsed = await readResult()
164
+ debugLog(`float-windows route=app ok=${String(parsed !== null && parsed.ok === true)} permission=${String(parsed !== null ? parsed.permission : 'none')}`)
148
165
  if (parsed === null) throw new ApiError('list-failed', '读取窗口列表失败(helper 无输出)', 500)
149
166
  return parsed
150
167
  } finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-gufa-code",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "古法编程 · AI 辅助:一键把 DSH 主面板变成 VS Code 风格 IDE(Monaco 编辑器、文件树、Git、SSH、真实终端 + 右侧官方会话);主张亲手写、每个改动心中有数,AI 是助理、你是第一责任人",
5
5
  "icon": "icon.svg",
6
6
  "keywords": [
@@ -25,11 +25,41 @@ G.installPopupLayerWatch = function installPopupLayerWatch(ctx) {
25
25
  '.gufa-shortcuts-backdrop',
26
26
  ].join(',')
27
27
 
28
+ /* 真正需要抬的是 overlay root 的 body 级祖先:它和停靠会话都是 body 的直接子节点,
29
+ 在祖先上设 z-index 才能压过会话的 2147483040;只抬 .gufa-overlay-root 出不了
30
+ 它自己的层叠上下文。 */
31
+ let liftedNodes = []
32
+ const lift = (open) => {
33
+ try {
34
+ if (open) {
35
+ if (liftedNodes.length > 0) return
36
+ let node = document.querySelector('.gufa-overlay-root')
37
+ if (node === null) return
38
+ while (node.parentElement !== null && node.parentElement !== document.body) node = node.parentElement
39
+ if (node.parentElement !== document.body) return
40
+ const saved = { node, zIndex: node.style.zIndex, position: node.style.position }
41
+ node.style.zIndex = '2147483300'
42
+ if (window.getComputedStyle(node).position === 'static') node.style.position = 'relative'
43
+ liftedNodes.push(saved)
44
+ if (node.parentElement !== document.body) return
45
+ } else {
46
+ for (const saved of liftedNodes) {
47
+ saved.node.style.zIndex = saved.zIndex
48
+ saved.node.style.position = saved.position
49
+ }
50
+ liftedNodes = []
51
+ }
52
+ } catch {
53
+ /* ignore */
54
+ }
55
+ }
56
+
28
57
  const sync = () => {
29
58
  try {
30
59
  const root = document.querySelector('.gufa-root')
31
60
  const popup = root === null ? null : root.querySelector(SELECTOR)
32
61
  const open = popup !== null
62
+ lift(open)
33
63
  if ((document.documentElement.getAttribute(ATTR) === '1') === open) return
34
64
  if (open) document.documentElement.setAttribute(ATTR, '1')
35
65
  else document.documentElement.removeAttribute(ATTR)
@@ -50,6 +80,7 @@ G.installPopupLayerWatch = function installPopupLayerWatch(ctx) {
50
80
  return () => {
51
81
  if (observer !== null) observer.disconnect()
52
82
  window.clearInterval(timer)
83
+ lift(false)
53
84
  document.documentElement.removeAttribute(ATTR)
54
85
  }
55
86
  }