dsh-gufa-code 1.3.8 → 1.3.10

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
@@ -1177,7 +1177,16 @@ html[data-gufa-ide] [role="dialog"] {
1177
1177
  /* 层级契约(见 docs/KNOWN-PITFALLS.md):
1178
1178
  1 = 古法覆盖层;2147483040 = 右侧停靠会话;2147483060 = 官方 DSH 菜单/弹窗;
1179
1179
  2147483100 = 古法 portal(所有弹窗/菜单);2147483200 = toast。 */
1180
- #gufa-portal-root{position:fixed;inset:0;z-index:2147483100;pointer-events:none}
1180
+ #gufa-portal-root{position:fixed;inset:0;z-index:2147483100;pointer-events:none;
1181
+ /* portal 在 body 层,拿不到 .gufa-root 上的主题变量;这里补齐一套(固色变量由 60-dock 同步写入 inline) */
1182
+ --gufa-accent:#c0392b;--gufa-accent-soft:color-mix(in srgb, var(--gufa-accent) 16%, transparent);
1183
+ --gufa-bg:var(--gufa-solid-bg, var(--dsw-alias-bg-base, #17181c));--gufa-layer:var(--gufa-solid-layer, var(--dsw-alias-bg-layer-1, #1d1f24));
1184
+ --gufa-layer2:var(--gufa-solid-layer2, var(--dsw-alias-bg-layer-2, #23262c));
1185
+ --gufa-solid-overlay-bg:var(--gufa-solid-overlay, var(--dsw-alias-bg-overlay, #2a2d34));
1186
+ --gufa-border:var(--dsw-alias-border-l1, rgba(255,255,255,0.1));--gufa-border-strong:var(--dsw-alias-border-l2, rgba(255,255,255,0.18));
1187
+ --gufa-text:var(--gufa-solid-text, var(--dsw-alias-label-primary, #f4f1e8));--gufa-text-dim:var(--gufa-solid-text-dim, var(--dsw-alias-label-secondary, rgba(244,241,232,0.66)));
1188
+ --gufa-hover:color-mix(in srgb, var(--gufa-text) 7%, transparent);--gufa-active:color-mix(in srgb, var(--gufa-text) 11%, transparent);
1189
+ color:var(--gufa-text);font-size:13px;line-height:1.45}
1181
1190
  #gufa-portal-root>*{pointer-events:auto}
1182
1191
  /* 摸鱼模式:App 窗口选择器 */
1183
1192
  .gufa-float-backdrop{position:fixed;inset:0;z-index:2147483200;display:flex;align-items:center;justify-content:center;
@@ -8749,6 +8758,21 @@ G.OverlayHost = function OverlayHost(props) {
8749
8758
  root.style.setProperty('--gufa-solid-sidebar', palette.sidebar)
8750
8759
  root.style.setProperty('--gufa-solid-text', palette.text)
8751
8760
  root.style.setProperty('--gufa-solid-text-dim', palette.textDim)
8761
+ /* 弹窗 portal 挂在 body 上,拿不到 root 上的 inline 变量,这里同步一份 */
8762
+ try {
8763
+ const portalHost = document.getElementById('gufa-portal-root')
8764
+ if (portalHost !== null) {
8765
+ portalHost.style.setProperty('--gufa-solid-bg', palette.bg)
8766
+ portalHost.style.setProperty('--gufa-solid-layer', palette.layer)
8767
+ portalHost.style.setProperty('--gufa-solid-layer2', palette.layer2)
8768
+ portalHost.style.setProperty('--gufa-solid-overlay', palette.overlay)
8769
+ portalHost.style.setProperty('--gufa-solid-sidebar', palette.sidebar)
8770
+ portalHost.style.setProperty('--gufa-solid-text', palette.text)
8771
+ portalHost.style.setProperty('--gufa-solid-text-dim', palette.textDim)
8772
+ }
8773
+ } catch {
8774
+ /* ignore */
8775
+ }
8752
8776
  if (typeof G.applyPopupTheme === 'function') G.applyPopupTheme(palette)
8753
8777
  try {
8754
8778
  if (window.__gufaApplyLogs === undefined) window.__gufaApplyLogs = 10
@@ -10275,6 +10299,9 @@ G.GufaApp = function GufaApp(props) {
10275
10299
  }
10276
10300
  }, [floatBusy])
10277
10301
 
10302
+ /* 内部 QA:允许自动化脚本在悬浮窗里打开摸鱼列表(仅供自测,不影响正常交互) */
10303
+ G.debugOpenFloatPicker = openFloatPicker
10304
+
10278
10305
  const toggleFloatWindow = useCallback(() => {
10279
10306
  if (floatRequested === true || floatRunning) void stopFloatWindow()
10280
10307
  else void openFloatPicker()
@@ -370,7 +370,46 @@ static OSStatus GufaHotKeyHandler(EventHandlerCallRef nextHandler, EventRef even
370
370
  [js appendString:@"localStorage.setItem('gufa-code:float','1');location.href='/?gufa-float=1';}catch(e){}"];
371
371
  [self.webView evaluateJavaScript:js completionHandler:nil];
372
372
  };
373
- [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:authUrl]]];
373
+ NSString *cookie = [self.options[@"cookie"] isKindOfClass:[NSString class]] ? self.options[@"cookie"] : nil;
374
+ if (cookie.length > 0) {
375
+ NSRange eq = [cookie rangeOfString:@"="];
376
+ if (eq.location != NSNotFound) {
377
+ NSString *name = [cookie substringToIndex:eq.location];
378
+ NSString *value = [cookie substringFromIndex:eq.location + 1];
379
+ NSDictionary *props = @{
380
+ NSHTTPCookieName: name,
381
+ NSHTTPCookieValue: value,
382
+ NSHTTPCookieDomain: @"127.0.0.1",
383
+ NSHTTPCookiePath: @"/",
384
+ NSHTTPCookieExpires: [NSDate dateWithTimeIntervalSinceNow:86400],
385
+ };
386
+ NSHTTPCookie *httpCookie = [NSHTTPCookie cookieWithProperties:props];
387
+ if (httpCookie != nil) {
388
+ WKHTTPCookieStore *store = [WKWebsiteDataStore defaultDataStore].httpCookieStore;
389
+ [store setCookie:httpCookie completionHandler:^{
390
+ NSURLComponents *components = [NSURLComponents componentsWithString:self.options[@"appUrl"] ?: @""];
391
+ components.queryItems = @[[NSURLQueryItem queryItemWithName:@"gufa-float" value:@"1"]];
392
+ [self.webView loadRequest:[NSURLRequest requestWithURL:components.URL]];
393
+ }];
394
+ }
395
+ }
396
+ } else {
397
+ [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:authUrl]]];
398
+ }
399
+ /* 内部 QA:payload.selftest 是一段 JS,页面打开后在悬浮窗里跑一遍并写回诊断日志(仅开发用,不影响 UI) */
400
+ NSString *selftest = [self.options[@"selftest"] isKindOfClass:[NSString class]] ? self.options[@"selftest"] : nil;
401
+ if (selftest.length > 0) {
402
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
403
+ [self.webView evaluateJavaScript:selftest completionHandler:^(id result, NSError *error) {
404
+ if (error != nil) GufaLog(@"selftest-script-error %@", error.localizedDescription ?: @"?");
405
+ }];
406
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(6.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
407
+ [self.webView evaluateJavaScript:@"JSON.stringify(window.__gufaSelftest||{step:'none'})" completionHandler:^(id result, NSError *error) {
408
+ GufaLog(@"selftest %@", result ?: @"nil");
409
+ }];
410
+ });
411
+ });
412
+ }
374
413
 
375
414
  }
376
415
 
@@ -26,9 +26,24 @@
26
26
  `html[data-gufa-external-modal]` 把停靠会话降到 2、`#gufa-portal-root` 降到 1,保证官方弹窗永远在最上面。
27
27
  4. **禁止**:抬高 `.gufa-overlay-root` 或它的祖先来做层级修正(历史补丁,已删除,最容易造成“弹窗层级混乱”)。
28
28
 
29
- **验收方式**:改完浮层后,在有右侧会话、且 IDE 里有打开文件的情况下,逐一点一遍:
29
+ **自动化验收**:悬浮层 helper 支持 payload 里的 `selftest`(一段 JS,页面加载 5s 后在悬浮窗内执行,结果写 `/tmp/gufa-float-debug.log`);
30
+ `G.debugOpenFloatPicker` 可在脚本里打开摸鱼列表。用它跑过一轮 DOM 命中测试(`document.elementsFromPoint` 验证弹层是否在最上层、
31
+ 是否盖住右侧会话区域),比人眼截图可靠,后续改层级务必先跑一遍。
32
+
33
+ **人工验收方式**:改完浮层后,在有右侧会话、且 IDE 里有打开文件的情况下,逐一点一遍:
30
34
  资源管理器右键菜单 / Git 菜单 / 摸鱼列表 / 切换会话 / 工作区切换 / 设置弹窗,确认都能完整显示、能点、能关。
31
35
 
36
+
37
+ ### 1.1 portal 弹窗必须自带主题变量(易漏,表现为“弹窗像一层空蒙层”)
38
+
39
+ - 现象:弹窗打开后,弹窗区域只看到变暗的遮罩、面板内容是透明的,像整个屏幕盖了一层膜。
40
+ - 原因:弹窗被 portal 到 `#gufa-portal-root`(body 层),**拿不到 `.gufa-root` 上定义/内联的 `--gufa-*` 主题变量**
41
+ (包括 60-dock 写入的固色变量),于是 `background:var(--gufa-solid-layer2, ...)` 解析失败 → 背景透明。
42
+ - 修法(已做):
43
+ 1. `#gufa-portal-root` 在 CSS 里补一套完整的 `--gufa-*` 变量(带 `--dsw-*` 和固色回退);
44
+ 2. `60-dock.js` 的 `applyPalette` 把 `--gufa-solid-*` 同步写入 portal host;
45
+ 3. 新增/修改弹窗时,样式尽量只依赖这套变量,不要假设能继承 `.gufa-root` 的其它属性。
46
+
32
47
  ## 2. macOS 屏幕录制权限 + 悬浮层 helper
33
48
 
34
49
  - helper 每次重新编译(代码签名变化)后,TCC 里旧的「屏幕录制」授权可能失效;
package/host/dev.js CHANGED
@@ -46,6 +46,7 @@ export function register(router, env) {
46
46
  const ctx = env?.ctx ?? router.ctx
47
47
 
48
48
 
49
+
49
50
  /* ── 桌面悬浮层 / 摸鱼模式(macOS) ────────────────────────────────
50
51
  * 通过 .app bundle 启动 helper:TCC(屏幕录制)按 bundle 身份授权,
51
52
  * 用户在「系统设置 → 隐私与安全性 → 屏幕录制」里添加「古法编程悬浮层.app」即可。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-gufa-code",
3
- "version": "1.3.8",
3
+ "version": "1.3.10",
4
4
  "description": "古法编程 · AI 辅助:一键把 DSH 主面板变成 VS Code 风格 IDE(Monaco 编辑器、文件树、Git、SSH、真实终端 + 右侧官方会话);主张亲手写、每个改动心中有数,AI 是助理、你是第一责任人",
5
5
  "icon": "icon.svg",
6
6
  "keywords": [
@@ -1169,7 +1169,16 @@ html[data-gufa-ide] [role="dialog"] {
1169
1169
  /* 层级契约(见 docs/KNOWN-PITFALLS.md):
1170
1170
  1 = 古法覆盖层;2147483040 = 右侧停靠会话;2147483060 = 官方 DSH 菜单/弹窗;
1171
1171
  2147483100 = 古法 portal(所有弹窗/菜单);2147483200 = toast。 */
1172
- #gufa-portal-root{position:fixed;inset:0;z-index:2147483100;pointer-events:none}
1172
+ #gufa-portal-root{position:fixed;inset:0;z-index:2147483100;pointer-events:none;
1173
+ /* portal 在 body 层,拿不到 .gufa-root 上的主题变量;这里补齐一套(固色变量由 60-dock 同步写入 inline) */
1174
+ --gufa-accent:#c0392b;--gufa-accent-soft:color-mix(in srgb, var(--gufa-accent) 16%, transparent);
1175
+ --gufa-bg:var(--gufa-solid-bg, var(--dsw-alias-bg-base, #17181c));--gufa-layer:var(--gufa-solid-layer, var(--dsw-alias-bg-layer-1, #1d1f24));
1176
+ --gufa-layer2:var(--gufa-solid-layer2, var(--dsw-alias-bg-layer-2, #23262c));
1177
+ --gufa-solid-overlay-bg:var(--gufa-solid-overlay, var(--dsw-alias-bg-overlay, #2a2d34));
1178
+ --gufa-border:var(--dsw-alias-border-l1, rgba(255,255,255,0.1));--gufa-border-strong:var(--dsw-alias-border-l2, rgba(255,255,255,0.18));
1179
+ --gufa-text:var(--gufa-solid-text, var(--dsw-alias-label-primary, #f4f1e8));--gufa-text-dim:var(--gufa-solid-text-dim, var(--dsw-alias-label-secondary, rgba(244,241,232,0.66)));
1180
+ --gufa-hover:color-mix(in srgb, var(--gufa-text) 7%, transparent);--gufa-active:color-mix(in srgb, var(--gufa-text) 11%, transparent);
1181
+ color:var(--gufa-text);font-size:13px;line-height:1.45}
1173
1182
  #gufa-portal-root>*{pointer-events:auto}
1174
1183
  /* 摸鱼模式:App 窗口选择器 */
1175
1184
  .gufa-float-backdrop{position:fixed;inset:0;z-index:2147483200;display:flex;align-items:center;justify-content:center;
@@ -580,6 +580,21 @@ G.OverlayHost = function OverlayHost(props) {
580
580
  root.style.setProperty('--gufa-solid-sidebar', palette.sidebar)
581
581
  root.style.setProperty('--gufa-solid-text', palette.text)
582
582
  root.style.setProperty('--gufa-solid-text-dim', palette.textDim)
583
+ /* 弹窗 portal 挂在 body 上,拿不到 root 上的 inline 变量,这里同步一份 */
584
+ try {
585
+ const portalHost = document.getElementById('gufa-portal-root')
586
+ if (portalHost !== null) {
587
+ portalHost.style.setProperty('--gufa-solid-bg', palette.bg)
588
+ portalHost.style.setProperty('--gufa-solid-layer', palette.layer)
589
+ portalHost.style.setProperty('--gufa-solid-layer2', palette.layer2)
590
+ portalHost.style.setProperty('--gufa-solid-overlay', palette.overlay)
591
+ portalHost.style.setProperty('--gufa-solid-sidebar', palette.sidebar)
592
+ portalHost.style.setProperty('--gufa-solid-text', palette.text)
593
+ portalHost.style.setProperty('--gufa-solid-text-dim', palette.textDim)
594
+ }
595
+ } catch {
596
+ /* ignore */
597
+ }
583
598
  if (typeof G.applyPopupTheme === 'function') G.applyPopupTheme(palette)
584
599
  try {
585
600
  if (window.__gufaApplyLogs === undefined) window.__gufaApplyLogs = 10
@@ -919,6 +919,9 @@ G.GufaApp = function GufaApp(props) {
919
919
  }
920
920
  }, [floatBusy])
921
921
 
922
+ /* 内部 QA:允许自动化脚本在悬浮窗里打开摸鱼列表(仅供自测,不影响正常交互) */
923
+ G.debugOpenFloatPicker = openFloatPicker
924
+
922
925
  const toggleFloatWindow = useCallback(() => {
923
926
  if (floatRequested === true || floatRunning) void stopFloatWindow()
924
927
  else void openFloatPicker()