dsh-gufa-code 1.3.50 → 1.3.51

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 CHANGED
@@ -97,7 +97,8 @@ dsh plugin add dsh-gufa-code
97
97
  列窗口可用 helper 自带 X11 实现,也可安装 `wmctrl` 兜底;
98
98
  - 其它平台(以及 helper 二进制缺失时):摸鱼模式会给出版本/构建提示,其余 IDE 功能不受影响;
99
99
  - macOS helper 为 ad-hoc 签名;首次启动若被系统拦截,在「隐私与安全性」里允许一次即可。
100
- - Windows/Linux helper 已通过 GitHub Actions 编译与 ciProbe 冒烟;**真机交互(吸附/隐藏/退出)仍在验收中**,遇到问题请把 `~/.dsh/gufa-code-debug.log`、helper 日志和系统信息发出来。
100
+ - **摸鱼选择器底部有「自检」按钮**:一键导出平台/helper/WebView2/辅助功能/X11 等现场信息,反馈问题时先复制它。
101
+ - Windows/Linux helper 已随包发布并通过 CI 编译 + ciProbe 冒烟;真机验收请按 [`docs/FLOAT-ACCEPTANCE.md`](docs/FLOAT-ACCEPTANCE.md) 走一遍,遇到问题把自检 JSON + 日志发出来。
101
102
 
102
103
  ### 外观
103
104
 
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.50'
19
+ G.BUILD = '1.3.51'
20
20
  G.PANEL_ID = 'gufa-code'
21
21
  /** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
22
22
  G.pendingEntryWorkspace = null
@@ -1293,6 +1293,9 @@ html[data-gufa-ide] [role="dialog"] {
1293
1293
  .gufa-float-owner{font-size:12.5px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
1294
1294
  .gufa-float-title{font-size:11px;color:var(--gufa-text-dim);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
1295
1295
  .gufa-float-size{flex:0 0 auto;font-size:10.5px;color:var(--gufa-text-dim);font-variant-numeric:tabular-nums}
1296
+ .gufa-doctor{width:min(760px,94vw);max-height:min(720px,86vh);display:flex;flex-direction:column}
1297
+ .gufa-doctor-pre{margin:0;padding:12px 14px;font:11.5px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;
1298
+ white-space:pre-wrap;word-break:break-all;background:transparent;color:var(--gufa-text);overflow:auto;flex:1 1 auto}
1296
1299
  .gufa-float-permission{padding:16px}
1297
1300
  .gufa-float-permission-title{font-size:13px;font-weight:600;margin-bottom:6px}
1298
1301
  .gufa-session-workspace-btn{display:inline-flex;align-items:center;gap:4px;border:1px solid var(--gufa-border);background:var(--gufa-layer2);
@@ -9721,6 +9724,8 @@ G.GufaApp = function GufaApp(props) {
9721
9724
  const [floatBusy, setFloatBusy] = useState(false)
9722
9725
  /* 摸鱼窗口选择器:null | {status:'loading'|'ready'|'permission'|'error', windows:[], error:''} */
9723
9726
  const [floatPicker, setFloatPicker] = useState(null)
9727
+ /* 摸鱼自检:null | {status:'loading'|'ok'|'error', data:null|object, error:''} */
9728
+ const [floatDoctor, setFloatDoctor] = useState(null)
9724
9729
  /* 摸鱼模式(悬浮窗实例)与界面透明度 */
9725
9730
  const [moyuMode] = useState(() => G.isFloatMode())
9726
9731
  const [floatAlpha, setFloatAlpha] = useState(() => {
@@ -10523,6 +10528,20 @@ G.GufaApp = function GufaApp(props) {
10523
10528
  }
10524
10529
  }, [floatBusy])
10525
10530
 
10531
+ /* 摸鱼自检:平台/helper/WebView2/辅助功能/X11 等现场信息,方便真机反馈 */
10532
+ const openFloatDoctor = useCallback(async () => {
10533
+ setFloatDoctor({ status: 'loading', data: null, error: '' })
10534
+ try {
10535
+ const value = await G.api('float.diagnostics')
10536
+ setFloatDoctor({ status: 'ok', data: value ?? null, error: '' })
10537
+ } catch (error) {
10538
+ setFloatDoctor({ status: 'error', data: null, error: G.errorText(error) })
10539
+ }
10540
+ }, [])
10541
+ const floatDoctorText = floatDoctor !== null && floatDoctor.data !== null
10542
+ ? JSON.stringify(floatDoctor.data, null, 2)
10543
+ : (floatDoctor !== null && typeof floatDoctor.error === 'string' ? floatDoctor.error : '')
10544
+
10526
10545
  /* 选中某个 App 窗口 → 启动悬浮层并吸附它 */
10527
10546
  /* 当前编辑器状态快照(进出摸鱼都以它为准) */
10528
10547
  const buildFloatSnapshot = useCallback(() => ({
@@ -12114,6 +12133,7 @@ G.GufaApp = function GufaApp(props) {
12114
12133
  'div',
12115
12134
  { className: 'gufa-modal-foot' },
12116
12135
  h(G.IconButton, { title: '刷新列表', onClick: () => void openFloatPicker() }, h(G.Icon, { name: 'refresh', size: 14 })),
12136
+ h(G.Button, { onClick: () => void openFloatDoctor() }, '自检'),
12117
12137
  h('span', { style: { flex: '1 1 auto' } }),
12118
12138
  h(G.Button, { onClick: () => void startFloatFree() }, '自由悬浮(不吸附)'),
12119
12139
  h(G.Button, { onClick: () => setFloatPicker(null) }, t('common.close')),
@@ -12121,6 +12141,44 @@ G.GufaApp = function GufaApp(props) {
12121
12141
  ),
12122
12142
  )
12123
12143
  : null),
12144
+ G.portal(floatDoctor !== null
12145
+ ? h(
12146
+ 'div',
12147
+ {
12148
+ className: 'gufa-float-backdrop',
12149
+ onMouseDown: (event) => { if (event.target === event.currentTarget) setFloatDoctor(null) },
12150
+ },
12151
+ h(
12152
+ 'div',
12153
+ { className: 'gufa-modal gufa-doctor', role: 'dialog', 'aria-modal': 'true', 'aria-label': '摸鱼自检' },
12154
+ h(
12155
+ 'div',
12156
+ { className: 'gufa-modal-head' },
12157
+ h(G.Icon, { name: 'monitor', size: 15 }),
12158
+ h('span', { style: { flex: '1 1 auto' } }, '摸鱼自检(复制发给开发者排查)'),
12159
+ h(G.IconButton, { title: t('common.close'), onClick: () => setFloatDoctor(null) }, h(G.Icon, { name: 'close', size: 14 })),
12160
+ ),
12161
+ h(
12162
+ 'div',
12163
+ { className: 'gufa-modal-body', style: { padding: 0 } },
12164
+ floatDoctor.status === 'loading'
12165
+ ? h('div', { className: 'gufa-graph-loading', style: { height: 90 } }, h(G.Spinner), '正在检查平台 / helper / 运行时…')
12166
+ : floatDoctor.status === 'error'
12167
+ ? h('div', { className: 'gufa-float-permission' }, h('div', { className: 'gufa-error-banner' }, floatDoctor.error))
12168
+ : h('pre', { className: 'gufa-doctor-pre gufa-scroll' }, floatDoctorText),
12169
+ ),
12170
+ h(
12171
+ 'div',
12172
+ { className: 'gufa-modal-foot' },
12173
+ h('span', { style: { flex: '1 1 auto' } }),
12174
+ floatDoctor.status === 'ok'
12175
+ ? h(G.Button, { onClick: () => { void navigator.clipboard?.writeText(floatDoctorText) } }, '复制')
12176
+ : null,
12177
+ h(G.Button, { onClick: () => setFloatDoctor(null) }, t('common.close')),
12178
+ ),
12179
+ ),
12180
+ )
12181
+ : null),
12124
12182
  G.portal(sessionsOpen ? renderSessionsDialog() : null),
12125
12183
  G.portal(shortcutsOpen ? renderShortcutsDialog() : null),
12126
12184
  )
@@ -39,6 +39,10 @@ static void GufaLog(NSString *format, ...) {
39
39
  }
40
40
  }
41
41
  static void GufaEmitJSON(NSDictionary *out);
42
+
43
+ #ifndef GUFA_FLOAT_VERSION
44
+ #define GUFA_FLOAT_VERSION "dev"
45
+ #endif
42
46
  static BOOL GufaTrustedForAX(void);
43
47
  static NSArray<NSDictionary *> *GufaAXWindows(void);
44
48
  static AXUIElementRef GufaCopyAXWindow(pid_t pid, NSString *title);
@@ -1076,6 +1080,14 @@ static AXUIElementRef GufaCopyAXWindow(pid_t pid, NSString *title) {
1076
1080
  }
1077
1081
 
1078
1082
  int main(int argc, const char *argv[]) {
1083
+ if (argc > 1 && (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-v") == 0)) {
1084
+ printf("gufa-float-macos %s\n", GUFA_FLOAT_VERSION);
1085
+ return 0;
1086
+ }
1087
+ if (argc > 1 && (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0)) {
1088
+ printf("gufa-float-macos %s\n用法: gufa-float-macos '<payload-json>' | --list-windows --out <path> | --version\n", GUFA_FLOAT_VERSION);
1089
+ return 0;
1090
+ }
1079
1091
  if (argc > 1 && strcmp(argv[1], "--list-windows") == 0) {
1080
1092
  @autoreleasepool {
1081
1093
  for (int i = 2; i + 1 < argc; i++) {
@@ -63,8 +63,10 @@ Host 侧不需要为 helper 做额外适配:payload 里的 `appUrl` / `authUrl
63
63
  # 吸附某个 App(pid 来自 Host 的窗口列表;title 可空)
64
64
  ./gufa-float-linux '{"appUrl":"...","authUrl":"...","follow":{"pid":4242,"title":""},"controlPath":"/tmp/gufa-float-exit-xxx"}'
65
65
 
66
- # CI 冒烟:加载完成/失败后 stdout 打一行 JSON 并退出 0
67
- xvfb-run -a ./gufa-float-linux '{"appUrl":"http://127.0.0.1:1/","authUrl":"http://127.0.0.1:1/","ciProbe":true}'
66
+ # CI 冒烟:加载完成/失败后 stdout 打一行 JSON 并退出 0;
67
+ # ciProbeOut 可选:把同一行 JSON 覆盖写入该文件(CI 断言用,父目录不存在会自动创建)
68
+ xvfb-run -a ./gufa-float-linux '{"appUrl":"http://127.0.0.1:1/","authUrl":"http://127.0.0.1:1/","ciProbe":true,"ciProbeOut":"/tmp/gufa-probe.json"}'
69
+ cat /tmp/gufa-probe.json
68
70
 
69
71
  # 窗口列表(Host 目前用 wmctrl,这个模式是给真机排查用的)
70
72
  ./gufa-float-linux --list-windows --out /tmp/win.json
@@ -147,8 +149,12 @@ WEBKIT_DISABLE_COMPOSITING_MODE=1 WEBKIT_DISABLE_DMABUF_RENDERER=1 LIBGL_ALWAYS_
147
149
 
148
150
  ### 3. CI 冒烟(ciProbe)
149
151
  - [x] 创建窗口 + WebKit 环境并加载页面;页面 `LOAD_FINISHED` 或 `load-failed`/8s 超时后,
150
- stdout 打一行 JSON:`{"ok":true,"platform":"linux","urlLoaded":true|false}`,随后恢复主窗口(若有)并 **退出码 0**。
151
- `urlLoaded` 如实反映是否加载成功(CI 用 `http://127.0.0.1:1/` 时会是 false,但启动/webview 初始化成功仍算冒烟通过)。
152
+ stdout 打一行 JSON,随后恢复主窗口(若有)并退出(加载成功/失败/超时都算 probe 完成,**退出码 0**):
153
+ - 成功:`{"ok":true,"platform":"linux","urlLoaded":true}`
154
+ - 失败(加载失败 / 8s 超时 / web process 崩溃 / 加载完成但没有页面):`{"ok":false,"platform":"linux","urlLoaded":false,"reason":"load-failed|load-timeout|web-process-terminated|load-finished-without-page"}`
155
+ - 初始化失败(无显示 / GTK 初始化失败 / WebView 创建失败 / 缺 appUrl)也会写 `{"ok":false,...,"reason":"display-unavailable|gtk-init-failed|window-init-failed|missing-appUrl"}`(stdout + ciProbeOut),此时退出码非 0(2/3)。
156
+ - [x] **`ciProbeOut`(可选字段)**:payload 里传字符串路径时,把和 stdout 完全相同的一行 JSON(含换行、UTF-8)
157
+ **覆盖写入**该文件(父目录不存在会自动创建);stdout 输出保留。CI 可直接 `grep '"ok":true' /tmp/gufa-probe.json` 断言。
152
158
  - [x] ciProbe 模式不隐藏 DSH 主窗口、不保存窗口几何,且自动设置软件渲染环境变量(见上文)。
153
159
 
154
160
  ## CI 构建注意事项
@@ -159,9 +165,16 @@ WEBKIT_DISABLE_COMPOSITING_MODE=1 WEBKIT_DISABLE_DMABUF_RENDERER=1 LIBGL_ALWAYS_
159
165
  - `make -j"$(nproc)"` 在 `desktop/float/linux` 下执行;Makefile 用 pkg-config 探测
160
166
  `webkit2gtk-4.1`,没有时退回 `webkit2gtk-4.0`(分别对应 libsoup-3.0 / libsoup-2.4)。
161
167
  - 产物名固定 `gufa-float-linux`;workflow 会复制到 `desktop/float/bin/linux-x64/` 并上传 artifact。
162
- - 冒烟命令:`timeout 40 xvfb-run -a <binary> '{"appUrl":"http://127.0.0.1:1/","authUrl":"http://127.0.0.1:1/","ciProbe":true}'`。
168
+ - 冒烟命令(可断言版本):
169
+ ```bash
170
+ timeout 40 xvfb-run -a ./desktop/float/bin/linux-x64/gufa-float-linux \
171
+ '{"appUrl":"http://127.0.0.1:PORT/","authUrl":"http://127.0.0.1:PORT/","ciProbe":true,"ciProbeOut":"/tmp/gufa-probe.json"}'
172
+ grep -q '"ok":true' /tmp/gufa-probe.json
173
+ ```
163
174
  Xvfb 下没有合成器,窗口不透明但不影响 ciProbe;WebKit 需要的软件渲染兜底已由 helper 在 ciProbe 模式自动设置。
164
- - 若 CI 想验证「真能加载页面」,把 payload 换成 Host 实际地址或本地静态 HTTP 服务即可(`urlLoaded` 会变 true)。
175
+ - **注意**:`http://127.0.0.1:1/` 是必然连不上的地址,按新语义会得到 `{"ok":false,...,"reason":"load-failed"}`;
176
+ 如果 CI 要断言 `"ok":true`,需要先起一个可访问的本地 HTTP 服务(例如 `python3 -m http.server PORT`)并把 appUrl 指过去。
177
+ - `./gufa-float-linux --version` 打印一行版本(stdout,exit 0),版本号来自 `GUFA_FLOAT_VERSION` 常量(同时出现在 payload 日志里)。
165
178
  - WebKit2GTK 4.1 会在 Ubuntu 小版本里持续升级(jammy 2.36 → 2.50,noble 2.52),
166
179
  代码只用了 2.36 起就存在的稳定 API(`webkit_cookie_manager_add_cookie`、`webkit_web_view_run_javascript` 等),
167
180
  并已分别用 Ubuntu 22.04 的 2.50.4 与 24.04 的 2.52.6 头文件做过交叉语法校验(`-Werror`,含 GTK3/libX11)。
@@ -82,6 +82,7 @@ struct _GufaApp {
82
82
  long owner_pid;
83
83
  int alpha;
84
84
  gboolean ci_probe;
85
+ char *ci_probe_out;
85
86
 
86
87
  /* ── GTK / WebKit ── */
87
88
  GtkWidget *window;
@@ -223,6 +224,7 @@ static gboolean gufa_payload_fill(GufaApp *app, GufaJson *payload) {
223
224
  app->selftest = gufa_json_dup_string(gufa_json_object_get(payload, "selftest"));
224
225
  app->alpha = (int)gufa_json_get_int64(gufa_json_object_get(payload, "alpha"), 55);
225
226
  app->ci_probe = gufa_json_get_bool(gufa_json_object_get(payload, "ciProbe"), FALSE);
227
+ app->ci_probe_out = gufa_json_dup_string(gufa_json_object_get(payload, "ciProbeOut"));
226
228
  app->owner_pid = gufa_json_get_int64(gufa_json_object_get(payload, "ownerPid"), 0);
227
229
  GufaJson *follow = gufa_json_object_get(payload, "follow");
228
230
  if (follow != NULL && gufa_json_get_type(follow) == GUFA_JSON_OBJECT) {
@@ -498,7 +500,8 @@ static void gufa_save_frame(GufaApp *app) {
498
500
 
499
501
  /* ── 鉴权 / 加载 ────────────────────────────────────────────────────── */
500
502
 
501
- static void gufa_emit_probe_result(GufaApp *app, gboolean url_loaded);
503
+ static void gufa_emit_probe_result(GufaApp *app, gboolean ok, gboolean url_loaded, const char *reason);
504
+ static void gufa_probe_fail_early(GufaApp *app, const char *reason);
502
505
 
503
506
  static void gufa_on_cookie_added(GObject *source_object, GAsyncResult *result, gpointer user_data) {
504
507
  GufaApp *app = (GufaApp *)user_data;
@@ -740,25 +743,83 @@ static void gufa_run_js(GufaApp *app, const char *label, const char *script) {
740
743
  webkit_web_view_run_javascript(WEBKIT_WEB_VIEW(app->webview), script, NULL, gufa_on_js_finished, request);
741
744
  }
742
745
 
743
- static void gufa_emit_probe_result(GufaApp *app, gboolean url_loaded) {
746
+ /** 把文本写到 path(覆盖写,UTF-8;父目录不存在时自动创建)。 */
747
+ static gboolean gufa_write_text_file(const char *path, const char *text) {
748
+ if (path == NULL || *path == '\0' || text == NULL) return FALSE;
749
+ GError *error = NULL;
750
+ if (g_file_set_contents(path, text, -1, &error)) return TRUE;
751
+ g_clear_error(&error);
752
+ char *directory = g_path_get_dirname(path);
753
+ gboolean ok = FALSE;
754
+ if (directory != NULL && *directory != '\0' && strcmp(directory, ".") != 0) {
755
+ g_mkdir_with_parents(directory, 0755);
756
+ ok = g_file_set_contents(path, text, -1, &error);
757
+ if (!ok) g_clear_error(&error);
758
+ }
759
+ g_free(directory);
760
+ return ok;
761
+ }
762
+
763
+ /** 生成 ciProbe 结果行(不含换行)。 */
764
+ static char *gufa_probe_line(gboolean ok, gboolean url_loaded, const char *reason) {
765
+ if (ok) {
766
+ return g_strdup("{\"ok\":true,\"platform\":\"linux\",\"urlLoaded\":true}");
767
+ }
768
+ if (reason != NULL && *reason != '\0') {
769
+ return g_strdup_printf(
770
+ "{\"ok\":false,\"platform\":\"linux\",\"urlLoaded\":%s,\"reason\":\"%s\"}",
771
+ url_loaded ? "true" : "false", reason);
772
+ }
773
+ return g_strdup_printf("{\"ok\":false,\"platform\":\"linux\",\"urlLoaded\":%s}",
774
+ url_loaded ? "true" : "false");
775
+ }
776
+
777
+ /** 输出 ciProbe 结果:stdout 一行 + 覆盖写入 ciProbeOut(可选)。 */
778
+ static void gufa_probe_emit(GufaApp *app, gboolean ok, gboolean url_loaded, const char *reason) {
779
+ char *line = gufa_probe_line(ok, url_loaded, reason);
780
+ g_print("%s\n", line);
781
+ fflush(stdout);
782
+ if (app != NULL && app->ci_probe_out != NULL && *app->ci_probe_out != '\0') {
783
+ char *with_newline = g_strdup_printf("%s\n", line);
784
+ if (gufa_write_text_file(app->ci_probe_out, with_newline)) {
785
+ gufa_log("ciProbe: 结果已写入 %s", app->ci_probe_out);
786
+ } else {
787
+ gufa_log("ciProbe: 写入 %s 失败", app->ci_probe_out);
788
+ }
789
+ g_free(with_newline);
790
+ }
791
+ g_free(line);
792
+ }
793
+
794
+ /** ciProbe 完成(加载成功/失败/超时都算完成;按协议退出码 0,成败看 JSON 的 ok)。 */
795
+ static void gufa_emit_probe_result(GufaApp *app, gboolean ok, gboolean url_loaded, const char *reason) {
744
796
  if (app == NULL || app->probe_done) return;
745
797
  app->probe_done = TRUE;
746
798
  gufa_remove_timer(&app->probe_guard);
747
- const char *uri = webkit_web_view_get_uri(WEBKIT_WEB_VIEW(app->webview));
748
- gufa_log("ciProbe: urlLoaded=%s uri=%s", url_loaded ? "true" : "false", uri != NULL ? uri : "(none)");
749
- g_print("{\"ok\":true,\"platform\":\"linux\",\"urlLoaded\":%s}\n", url_loaded ? "true" : "false");
750
- fflush(stdout);
799
+ const char *uri = app->webview != NULL ? webkit_web_view_get_uri(WEBKIT_WEB_VIEW(app->webview)) : NULL;
800
+ gufa_log("ciProbe: ok=%s urlLoaded=%s reason=%s uri=%s", ok ? "true" : "false",
801
+ url_loaded ? "true" : "false", reason != NULL ? reason : "(none)",
802
+ uri != NULL ? uri : "(none)");
803
+ gufa_probe_emit(app, ok, url_loaded, reason);
751
804
  app->exit_code = 0;
752
805
  gufa_request_quit(app, "ciProbe");
753
806
  }
754
807
 
808
+ /** ciProbe 在显示/窗口初始化阶段就失败:写好 ok:false,由 main 返回非 0。 */
809
+ static void gufa_probe_fail_early(GufaApp *app, const char *reason) {
810
+ if (app == NULL || !app->ci_probe || app->probe_done) return;
811
+ app->probe_done = TRUE;
812
+ gufa_log("ciProbe: 初始化失败 reason=%s", reason != NULL ? reason : "?");
813
+ gufa_probe_emit(app, FALSE, FALSE, reason != NULL ? reason : "init-failed");
814
+ }
815
+
755
816
  static gboolean gufa_on_probe_guard(gpointer user_data) {
756
817
  GufaApp *app = (GufaApp *)user_data;
757
818
  if (app == NULL) return G_SOURCE_REMOVE;
758
819
  app->probe_guard = 0;
759
820
  if (app->probe_done) return G_SOURCE_REMOVE;
760
821
  gufa_log("ciProbe: 8s 内页面未加载完成,按超时输出结果");
761
- gufa_emit_probe_result(app, FALSE);
822
+ gufa_emit_probe_result(app, FALSE, FALSE, "load-timeout");
762
823
  return G_SOURCE_REMOVE;
763
824
  }
764
825
 
@@ -830,7 +891,11 @@ static void gufa_on_load_changed(WebKitWebView *web_view, WebKitLoadEvent load_e
830
891
  app->loaded = TRUE;
831
892
  gufa_remove_timer(&app->probe_guard);
832
893
  if (app->ci_probe) {
833
- gufa_emit_probe_result(app, TRUE);
894
+ if (app->loading_failed || uri == NULL) {
895
+ gufa_emit_probe_result(app, FALSE, FALSE, "load-finished-without-page");
896
+ } else {
897
+ gufa_emit_probe_result(app, TRUE, TRUE, NULL);
898
+ }
834
899
  return;
835
900
  }
836
901
  app->page_probe_timer = g_timeout_add(6000, gufa_on_page_probe_timer, app);
@@ -854,7 +919,7 @@ static gboolean gufa_on_load_failed(WebKitWebView *web_view, WebKitLoadEvent loa
854
919
  failing_uri != NULL ? failing_uri : "(none)", error != NULL ? error->message : "?");
855
920
  app->loading_failed = TRUE;
856
921
  if (app->ci_probe) {
857
- gufa_emit_probe_result(app, FALSE);
922
+ gufa_emit_probe_result(app, FALSE, FALSE, "load-failed");
858
923
  return FALSE;
859
924
  }
860
925
  if (app->stage == GUFA_STAGE_AUTH) {
@@ -868,13 +933,16 @@ static gboolean gufa_on_load_failed(WebKitWebView *web_view, WebKitLoadEvent loa
868
933
  static void gufa_on_web_process_terminated(WebKitWebView *web_view, WebKitWebProcessTerminationReason reason,
869
934
  gpointer user_data) {
870
935
  (void)web_view;
871
- (void)user_data;
936
+ GufaApp *app = (GufaApp *)user_data;
872
937
  gufa_log("web: web process 终止 reason=%d", (int)reason);
938
+ if (app != NULL && app->ci_probe) {
939
+ gufa_emit_probe_result(app, FALSE, FALSE, "web-process-terminated");
940
+ }
873
941
  }
874
942
 
875
943
  /* ── 窗口构建 ───────────────────────────────────────────────────────── */
876
944
 
877
- static void gufa_build_window(GufaApp *app) {
945
+ static gboolean gufa_build_window(GufaApp *app) {
878
946
  GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
879
947
  app->window = window;
880
948
  gtk_window_set_title(GTK_WINDOW(window), "古法编程悬浮层");
@@ -909,6 +977,10 @@ static void gufa_build_window(GufaApp *app) {
909
977
 
910
978
  /* document-start 注入脚本:悬浮模式标记 + 主窗口状态快照 */
911
979
  app->content_manager = webkit_user_content_manager_new();
980
+ if (app->content_manager == NULL) {
981
+ gufa_log("window: WebKitUserContentManager 创建失败(WebKit 环境不可用)");
982
+ return FALSE;
983
+ }
912
984
  if (app->bootstrap_js != NULL && *app->bootstrap_js != '\0') {
913
985
  WebKitUserScript *script = webkit_user_script_new(app->bootstrap_js,
914
986
  WEBKIT_USER_CONTENT_INJECT_TOP_FRAME,
@@ -920,6 +992,10 @@ static void gufa_build_window(GufaApp *app) {
920
992
  }
921
993
  }
922
994
  GtkWidget *webview = webkit_web_view_new_with_user_content_manager(app->content_manager);
995
+ if (webview == NULL) {
996
+ gufa_log("window: WebKitWebView 创建失败(WebKit 环境不可用)");
997
+ return FALSE;
998
+ }
923
999
  app->webview = webview;
924
1000
  gtk_widget_set_size_request(webview, GUFA_MIN_WIDTH, GUFA_MIN_HEIGHT);
925
1001
  if (app->transparent) {
@@ -977,6 +1053,7 @@ static void gufa_build_window(GufaApp *app) {
977
1053
  app->own_xid = gufa_own_xid_from_widget(app);
978
1054
  gufa_log("window: %d,%d %dx%d own_xid=0x%lx scale=%d", x, y, width, height,
979
1055
  (unsigned long)app->own_xid, gtk_widget_get_scale_factor(window));
1056
+ return TRUE;
980
1057
  }
981
1058
 
982
1059
  /* ── --list-windows 模式 ────────────────────────────────────────────── */
@@ -1074,22 +1151,27 @@ int main(int argc, char **argv) {
1074
1151
  app.exit_code = 0;
1075
1152
  if (!gufa_payload_fill(&app, payload)) {
1076
1153
  g_printerr("gufa-float-linux: payload 缺少 appUrl,退出\n");
1154
+ gufa_probe_fail_early(&app, "missing-appUrl");
1077
1155
  gufa_json_free(payload);
1078
1156
  g_free(app.app_url);
1079
1157
  return 2;
1080
1158
  }
1081
- gufa_log("start: version=%s build=%s appUrl=%s follow_pid=%ld ownerPid=%ld controlPath=%s ciProbe=%d alpha=%d",
1159
+ gufa_log("start: version=%s build=%s appUrl=%s follow_pid=%ld ownerPid=%ld controlPath=%s ciProbe=%d alpha=%d ciProbeOut=%s",
1082
1160
  GUFA_FLOAT_VERSION, app.build != NULL ? app.build : "?", app.app_url, app.follow_pid,
1083
1161
  app.owner_pid, app.control_path != NULL ? app.control_path : "(none)", app.ci_probe ? 1 : 0,
1084
- app.alpha);
1162
+ app.alpha, app.ci_probe_out != NULL ? app.ci_probe_out : "(none)");
1085
1163
 
1086
- if (!gufa_configure_backend(&app)) return 3;
1164
+ if (!gufa_configure_backend(&app)) {
1165
+ gufa_probe_fail_early(&app, "display-unavailable");
1166
+ return 3;
1167
+ }
1087
1168
  gufa_prepare_probe_env(&app);
1088
1169
 
1089
1170
  int gtk_argc = argc;
1090
1171
  char **gtk_argv = argv;
1091
1172
  if (!gtk_init_check(&gtk_argc, &gtk_argv)) {
1092
1173
  g_printerr("gufa-float-linux: GTK 初始化失败(图形显示不可用)。Linux 版需要 X11 桌面或 XWayland。\n");
1174
+ gufa_probe_fail_early(&app, "gtk-init-failed");
1093
1175
  gufa_json_free(payload);
1094
1176
  return 3;
1095
1177
  }
@@ -1109,7 +1191,11 @@ int main(int argc, char **argv) {
1109
1191
  }
1110
1192
 
1111
1193
  gufa_install_css();
1112
- gufa_build_window(&app);
1194
+ if (!gufa_build_window(&app)) {
1195
+ gufa_probe_fail_early(&app, "window-init-failed");
1196
+ gufa_json_free(payload);
1197
+ return 3;
1198
+ }
1113
1199
 
1114
1200
  if (!app.ci_probe) {
1115
1201
  if (app.x11_ok) {
@@ -1178,6 +1264,7 @@ int main(int argc, char **argv) {
1178
1264
  g_free(app.selftest);
1179
1265
  g_free(app.follow_title);
1180
1266
  g_free(app.bootstrap_js);
1267
+ g_free(app.ci_probe_out);
1181
1268
  g_free(app.hidden_dsh.wins);
1182
1269
  gufa_json_free(app.payload);
1183
1270
  return app.exit_code;