dsh-gufa-code 1.3.9 → 1.3.48

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
@@ -15,6 +15,8 @@ const GUFA_NS = 'gufa-code'
15
15
  /** 全局命名空间:所有零件通过 G.xxx 共享能力与组件。 */
16
16
  const G = {}
17
17
  G.NS = GUFA_NS
18
+ /** 客户端构建标记(排查页面是否加载了新代码时看标题栏) */
19
+ G.BUILD = '1.3.48'
18
20
  G.PANEL_ID = 'gufa-code'
19
21
  /** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
20
22
  G.pendingEntryWorkspace = null
@@ -47,6 +49,16 @@ G.portal = (function createPortalHelper() {
47
49
  G.hooks = { useState, useEffect, useRef, useMemo, useCallback, useLayoutEffect }
48
50
 
49
51
  /* ── 悬浮层状态:helper 通过 URL 参数 ?gufa-state=<base64url(JSON)> 传主窗口快照 ── */
52
+ /** 三种界面状态:classic(无标记)/ gufa(data-gufa-ide)/ moyu(data-gufa-float)。
53
+ * 判断一律用 DOM 标记,不要用 localStorage 或状态对象,避免主窗口被摸鱼状态污染。 */
54
+ G.isFloatMode = function isFloatMode() {
55
+ try {
56
+ return typeof document !== 'undefined' && document.documentElement.hasAttribute('data-gufa-float')
57
+ } catch {
58
+ return false
59
+ }
60
+ }
61
+
50
62
  G.floatState = (function readFloatState() {
51
63
  if (typeof window === 'undefined' || typeof document === 'undefined') return null
52
64
  try {
@@ -1074,24 +1086,101 @@ G.errorText = (error) => {
1074
1086
  G.CSS = `
1075
1087
  .gufa-overlay-root{position:fixed;inset:0;z-index:1;display:flex;box-sizing:border-box;background:var(--gufa-solid-bg, var(--dsw-alias-bg-base));pointer-events:auto;overflow:hidden}
1076
1088
  .gufa-backdrop{position:absolute;inset:0;z-index:0;overflow:hidden;pointer-events:none}
1077
- /* 桌面悬浮层模式:整窗半透明(0.55),顶部留出 22px 拖动条 */
1089
+ /* 桌面悬浮层(摸鱼)模式:整窗半透明,透明度由 --gufa-float-alpha 控制(标题栏滑块) */
1090
+ html[data-gufa-float]{--gufa-float-alpha:0.55}
1078
1091
  html[data-gufa-float] body{background:transparent!important}
1079
1092
  html[data-gufa-float] .gufa-overlay-root,
1080
1093
  html[data-gufa-float] .gufa-root{
1081
- --gufa-solid-bg:rgba(13,15,19,0.55);--gufa-bg:rgba(13,15,19,0.55);
1082
- --gufa-solid-layer:rgba(20,22,27,0.55);--gufa-layer:rgba(20,22,27,0.55);
1083
- --gufa-solid-layer2:rgba(26,28,34,0.55);--gufa-layer2:rgba(26,28,34,0.55);
1084
- --gufa-solid-overlay:rgba(30,33,40,0.72);
1094
+ --gufa-solid-bg:rgba(13,15,19,var(--gufa-float-alpha))!important;--gufa-bg:rgba(13,15,19,var(--gufa-float-alpha))!important;
1095
+ --gufa-solid-layer:rgba(20,22,27,var(--gufa-float-alpha))!important;--gufa-layer:rgba(20,22,27,var(--gufa-float-alpha))!important;
1096
+ --gufa-solid-layer2:rgba(26,28,34,var(--gufa-float-alpha))!important;--gufa-layer2:rgba(26,28,34,var(--gufa-float-alpha))!important;
1097
+ --gufa-solid-overlay:rgba(30,33,40,calc(var(--gufa-float-alpha) + 0.17))!important;
1098
+ --gufa-solid-sidebar:rgba(18,20,24,var(--gufa-float-alpha))!important;
1099
+ /* 官方组件用 --dsw-alias-*:在覆盖层内也统一成同一个透明度,100% 时完全遮住底层 */
1100
+ --dsw-alias-bg-base:rgba(13,15,19,var(--gufa-float-alpha))!important;
1101
+ --dsw-alias-bg-layer-1:rgba(20,22,27,var(--gufa-float-alpha))!important;
1102
+ --dsw-alias-bg-layer-2:rgba(26,28,34,var(--gufa-float-alpha))!important;
1103
+ --dsw-alias-bg-overlay:rgba(30,33,40,calc(var(--gufa-float-alpha) + 0.17))!important;
1104
+ }
1105
+ /* 顶部 22px 拖动条区域也跟随透明度,否则 100% 时仍能透出被吸附 App(实测 1.3.27 的破绽) */
1106
+ html[data-gufa-float] .gufa-overlay-root::before{
1107
+ content:'';position:fixed;top:0;left:0;right:0;height:22px;pointer-events:none;
1108
+ background:rgba(13,15,19,var(--gufa-float-alpha));z-index:1;
1085
1109
  }
1086
1110
  html[data-gufa-float] .gufa-overlay-root{background:transparent!important;padding-top:22px;box-sizing:border-box}
1087
- html[data-gufa-float] .gufa-backdrop{opacity:0.5}
1088
- /* 悬浮模式:右侧停靠的官方会话内部也半透明(DSH 主题变量在停靠根上覆盖) */
1111
+ /* 摸鱼:整窗只保留「覆盖层根节点」这一层半透明底,其余面板/会话/终端全部透明,
1112
+ 保证编辑器、会话框、终端框看到的透明度完全一致(都等于滑块的 alpha)。 */
1113
+ html[data-gufa-float] .gufa-overlay-root{background:rgba(13,15,19,var(--gufa-float-alpha))!important}
1114
+ html[data-gufa-float] .gufa-root,
1115
+ html[data-gufa-float] .gufa-shell,
1116
+ html[data-gufa-float] .gufa-main,
1117
+ html[data-gufa-float] .gufa-main-row,
1118
+ html[data-gufa-float] .gufa-sidepanel,
1119
+ html[data-gufa-float] .gufa-editor-area,
1120
+ html[data-gufa-float] .gufa-chatpane,
1121
+ html[data-gufa-float] .gufa-termpane,
1122
+ html[data-gufa-float] .gufa-termhead,
1123
+ html[data-gufa-float] .gufa-termbody,
1124
+ html[data-gufa-float] .gufa-termview,
1125
+ html[data-gufa-float] .gufa-titlebar,
1126
+ html[data-gufa-float] .gufa-activity,
1127
+ html[data-gufa-float] .gufa-tabs,
1128
+ html[data-gufa-float] .gufa-statusbar,
1129
+ html[data-gufa-float] [data-gufa-dock],
1130
+ html[data-gufa-float] [data-gufa-dock] > *{background:transparent!important}
1131
+ /* 官方会话停靠层(toolbar/host)自带底色,摸鱼里一并透明,避免会话框叠两层 */
1132
+ html[data-gufa-float] .gufa-dock-toolbar,
1133
+ html[data-gufa-float] .gufa-dock-host,
1134
+ html[data-gufa-float] .gufa-chatdock{background:transparent!important}
1135
+ /* 官方会话/组件在摸鱼里也用透明 token,避免和覆盖层底叠成两层 */
1136
+ html[data-gufa-float] .gufa-root,
1137
+ html[data-gufa-float] .gufa-overlay-root,
1089
1138
  html[data-gufa-float] [data-gufa-dock]{
1090
- --dsw-alias-bg-base:rgba(13,15,19,0.55);
1091
- --dsw-alias-bg-layer-1:rgba(20,22,27,0.55);
1092
- --dsw-alias-bg-layer-2:rgba(26,28,34,0.55);
1093
- --dsw-alias-bg-overlay:rgba(30,33,40,0.72);
1094
- background:rgba(13,15,19,0.55)!important;
1139
+ --dsw-alias-bg-base:transparent!important;
1140
+ --dsw-alias-bg-layer-1:transparent!important;
1141
+ --dsw-alias-bg-layer-2:transparent!important;
1142
+ --dsw-alias-bg-overlay:transparent!important;
1143
+ }
1144
+ /* 终端面板:古法编程(带皮肤背景)时和编辑器区域一样透出背景;摸鱼时跟随滑块 */
1145
+ .gufa-termpane{background:var(--gufa-bg)}
1146
+ .gufa-termhead{background:var(--gufa-layer)}
1147
+ .gufa-termbody,
1148
+ .gufa-termview{background:transparent!important}
1149
+ .gufa-root[data-backdrop="on"] .gufa-termpane{background:color-mix(in srgb, var(--gufa-bg) 46%, transparent)}
1150
+ .gufa-root[data-backdrop="on"] .gufa-termhead{background:color-mix(in srgb, var(--gufa-layer) 64%, transparent)}
1151
+ html[data-gufa-float] .gufa-termpane{background:transparent!important}
1152
+ html[data-gufa-float] .gufa-termhead{background:transparent!important}
1153
+ /* xterm 自带的黑色底(xterm.css 默认 .xterm-viewport{background:#000})必须清掉,
1154
+ 否则古法编程和摸鱼里的终端内容区永远是黑的(外层透明也没用) */
1155
+ .gufa-termview .xterm,
1156
+ .gufa-termview .xterm .xterm-viewport,
1157
+ .gufa-termview .xterm .xterm-screen{background-color:transparent!important;background-image:none!important}
1158
+ /* 摸鱼模式不显示皮肤(梁圣)背景:包括古法自己的复刻层和第三方皮肤插件在 body/html 上画的层 */
1159
+ html[data-gufa-float],
1160
+ html[data-gufa-float] body,
1161
+ html[data-gufa-float] #root{background-image:none!important;background-color:transparent!important}
1162
+ /* 皮肤插件可能用 html::before/::after 画背景层,摸鱼里一并清掉 */
1163
+ html[data-gufa-float]::before,
1164
+ html[data-gufa-float]::after{display:none!important;content:none!important;background:none!important}
1165
+ html[data-gufa-float] .liang-skin-backdrop,
1166
+ html[data-gufa-float] .liang-ambient,
1167
+ html[data-gufa-float] .liang-skin-portrait,
1168
+ html[data-gufa-float] .liang-skin-root,
1169
+ html[data-gufa-float] #root>[class*="skin"],
1170
+ html[data-gufa-float] #root>[class*="backdrop"]{display:none!important}
1171
+ /* 摸鱼模式不显示皮肤(梁圣)背景 */
1172
+ html[data-gufa-float] .gufa-backdrop,
1173
+ html[data-gufa-float] .gufa-backdrop-page,
1174
+ html[data-gufa-float] .gufa-backdrop-glow,
1175
+ html[data-gufa-float] .gufa-backdrop-portrait{display:none!important}
1176
+ /* 悬浮模式:右侧停靠的官方会话根节点不再自己画底(整窗只有覆盖层那一层),
1177
+ 否则会和覆盖层叠成两层,会话框看起来明显更黑更实 */
1178
+ html[data-gufa-float] [data-gufa-dock]{
1179
+ --dsw-alias-bg-base:transparent!important;
1180
+ --dsw-alias-bg-layer-1:transparent!important;
1181
+ --dsw-alias-bg-layer-2:transparent!important;
1182
+ --dsw-alias-bg-overlay:transparent!important;
1183
+ background:transparent!important;
1095
1184
  }
1096
1185
  html[data-gufa-float] [data-gufa-dock] [data-conversation-scroll],
1097
1186
  html[data-gufa-float] [data-gufa-dock] [data-conversation-content]{background:transparent!important}
@@ -1177,7 +1266,16 @@ html[data-gufa-ide] [role="dialog"] {
1177
1266
  /* 层级契约(见 docs/KNOWN-PITFALLS.md):
1178
1267
  1 = 古法覆盖层;2147483040 = 右侧停靠会话;2147483060 = 官方 DSH 菜单/弹窗;
1179
1268
  2147483100 = 古法 portal(所有弹窗/菜单);2147483200 = toast。 */
1180
- #gufa-portal-root{position:fixed;inset:0;z-index:2147483100;pointer-events:none}
1269
+ #gufa-portal-root{position:fixed;inset:0;z-index:2147483100;pointer-events:none;
1270
+ /* portal 在 body 层,拿不到 .gufa-root 上的主题变量;这里补齐一套(固色变量由 60-dock 同步写入 inline) */
1271
+ --gufa-accent:#c0392b;--gufa-accent-soft:color-mix(in srgb, var(--gufa-accent) 16%, transparent);
1272
+ --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));
1273
+ --gufa-layer2:var(--gufa-solid-layer2, var(--dsw-alias-bg-layer-2, #23262c));
1274
+ --gufa-solid-overlay-bg:var(--gufa-solid-overlay, var(--dsw-alias-bg-overlay, #2a2d34));
1275
+ --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));
1276
+ --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)));
1277
+ --gufa-hover:color-mix(in srgb, var(--gufa-text) 7%, transparent);--gufa-active:color-mix(in srgb, var(--gufa-text) 11%, transparent);
1278
+ color:var(--gufa-text);font-size:13px;line-height:1.45}
1181
1279
  #gufa-portal-root>*{pointer-events:auto}
1182
1280
  /* 摸鱼模式:App 窗口选择器 */
1183
1281
  .gufa-float-backdrop{position:fixed;inset:0;z-index:2147483200;display:flex;align-items:center;justify-content:center;
@@ -1405,9 +1503,29 @@ html[data-windows-titlebar] .gufa-overlay-root{padding-top:var(--dsh-windows-tit
1405
1503
  html[data-platform=darwin] .gufa-titlebar{height:48px;padding-left:86px}
1406
1504
  html[data-platform=darwin][data-fullscreen] .gufa-titlebar{height:44px;padding-left:16px}
1407
1505
  .gufa-titlebar button,.gufa-titlebar input,.gufa-titlebar .gufa-project,.gufa-titlebar-action{-webkit-app-region:no-drag}
1506
+ /* 摸鱼入口按钮:带框的两个字 */
1507
+ .gufa-moyu-btn{display:inline-flex;align-items:center;justify-content:center;height:26px;padding:0 12px;border-radius:8px;
1508
+ border:1px solid var(--gufa-border-strong);background:color-mix(in srgb, var(--gufa-accent) 14%, transparent);
1509
+ color:var(--gufa-text);font-size:12px;font-weight:600;letter-spacing:1px;cursor:pointer;white-space:nowrap}
1510
+ .gufa-moyu-btn:hover{background:color-mix(in srgb, var(--gufa-accent) 24%, transparent);border-color:var(--gufa-accent)}
1511
+ .gufa-moyu-btn:disabled{opacity:.55;cursor:default}
1512
+ /* 退出摸鱼按钮(原「返回经典模式」位置) */
1513
+ .gufa-moyu-exit{display:inline-flex;align-items:center;justify-content:center;height:28px;padding:0 14px;border-radius:8px;
1514
+ border:1px solid color-mix(in srgb, var(--gufa-accent) 60%, transparent);
1515
+ background:color-mix(in srgb, var(--gufa-accent) 20%, transparent);color:var(--gufa-text);
1516
+ font-size:12px;font-weight:600;cursor:pointer;white-space:nowrap}
1517
+ .gufa-moyu-exit:hover{background:color-mix(in srgb, var(--gufa-accent) 34%, transparent)}
1518
+ .gufa-moyu-exit:disabled{opacity:.55;cursor:default}
1519
+ /* 摸鱼界面透明度滑块 */
1520
+ .gufa-moyu-alpha{display:inline-flex;align-items:center;gap:8px;height:26px;padding:0 10px;border-radius:8px;
1521
+ border:1px solid var(--gufa-border);background:color-mix(in srgb, var(--gufa-layer2) 70%, transparent);font-size:11.5px;color:var(--gufa-text-dim)}
1522
+ .gufa-moyu-alpha-label{white-space:nowrap}
1523
+ .gufa-moyu-alpha-range{width:120px;accent-color:var(--gufa-accent);cursor:pointer}
1524
+ .gufa-moyu-alpha-value{min-width:34px;text-align:right;font-variant-numeric:tabular-nums}
1408
1525
  .gufa-brand{display:flex;align-items:center;gap:8px;min-width:0}
1409
1526
  .gufa-brand-logo{width:24px;height:24px;flex:0 0 auto}
1410
1527
  .gufa-brand-name{font-weight:650;font-size:14px;letter-spacing:.02em;white-space:nowrap}
1528
+ .gufa-build-tag{font-size:9.5px;color:var(--gufa-text-dim);opacity:.6;letter-spacing:.3px;flex:0 0 auto}
1411
1529
  .gufa-brand-sub{font-size:10px;letter-spacing:.18em;color:var(--gufa-text-dim);white-space:nowrap}
1412
1530
  .gufa-project{appearance:none;border:0;background:transparent;font:inherit;color:inherit;cursor:pointer}
1413
1531
  .gufa-project:hover{background:var(--gufa-hover)}
@@ -3700,6 +3818,17 @@ function gufaTermPalette(props) {
3700
3818
  * @param {string} mode 'dark' | 'light'
3701
3819
  * @param {object|null} palette 插件合成的实色调色板(优先于 mode)
3702
3820
  */
3821
+ function gufaTermFloatMode() {
3822
+ try {
3823
+ return typeof G.isFloatMode === 'function' && G.isFloatMode() === true
3824
+ } catch {
3825
+ return false
3826
+ }
3827
+ }
3828
+
3829
+ /** 摸鱼窗口里终端容器的半透明底色(跟随标题栏透明度滑块) */
3830
+ const GUFA_TERM_FLOAT_BG = 'rgba(30,30,30,var(--gufa-float-alpha))'
3831
+
3703
3832
  function gufaTermTheme(mode, palette) {
3704
3833
  const dark = palette !== null && palette !== undefined && typeof palette.isDark === 'boolean' ? palette.isDark : mode === 'dark'
3705
3834
  if (dark) {
@@ -3726,7 +3855,11 @@ function gufaTermTheme(mode, palette) {
3726
3855
  brightCyan: '#29b8db',
3727
3856
  brightWhite: '#e5e5e5',
3728
3857
  }
3729
- return gufaApplyPaletteToTermTheme(darkTheme, palette)
3858
+ const themed = gufaApplyPaletteToTermTheme(darkTheme, palette)
3859
+ /* xterm 自身永远画透明底:背景色由外层容器用 IDE 调色板/透明度变量统一上色 */
3860
+ themed.background = 'rgba(0,0,0,0)'
3861
+ themed.cursorAccent = 'rgba(0,0,0,0)'
3862
+ return themed
3730
3863
  }
3731
3864
  const light = {
3732
3865
  background: '#ffffff',
@@ -3751,7 +3884,10 @@ function gufaTermTheme(mode, palette) {
3751
3884
  brightCyan: '#0598bc',
3752
3885
  brightWhite: '#a5a5a5',
3753
3886
  }
3754
- return gufaApplyPaletteToTermTheme(light, palette)
3887
+ const themed = gufaApplyPaletteToTermTheme(light, palette)
3888
+ themed.background = 'rgba(0,0,0,0)'
3889
+ themed.cursorAccent = 'rgba(0,0,0,0)'
3890
+ return themed
3755
3891
  }
3756
3892
 
3757
3893
  /** 把皮肤实色调色板叠加到 xterm 主题(背景/前景/光标/选区跟随滑动变祖)。 */
@@ -4229,6 +4365,7 @@ function GufaTerminalView(props) {
4229
4365
  try {
4230
4366
  const terminal = new props.assets.Terminal({
4231
4367
  allowProposedApi: false,
4368
+ allowTransparency: true,
4232
4369
  convertEol: false,
4233
4370
  cursorBlink: true,
4234
4371
  cursorStyle: 'bar',
@@ -4470,7 +4607,9 @@ function GufaTerminalView(props) {
4470
4607
 
4471
4608
  const monoFont = 'ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace'
4472
4609
  const fallbackTheme = gufaTermTheme(props.theme, palette)
4473
- const background = fallbackTheme.background
4610
+ /* 终端背景由外层 .gufa-termpane 统一提供(和编辑器区域同一套透明度规则) */
4611
+ const shellBackground = 'transparent'
4612
+ const background = 'transparent'
4474
4613
  const foreground = fallbackTheme.foreground
4475
4614
 
4476
4615
  const body = fallback
@@ -4542,6 +4681,7 @@ function GufaTerminalView(props) {
4542
4681
  return h(
4543
4682
  'div',
4544
4683
  {
4684
+ className: 'gufa-termview',
4545
4685
  style: {
4546
4686
  display: props.active === true ? 'flex' : 'none',
4547
4687
  flexDirection: 'column',
@@ -4549,7 +4689,6 @@ function GufaTerminalView(props) {
4549
4689
  minHeight: 0,
4550
4690
  minWidth: 0,
4551
4691
  position: 'relative',
4552
- background,
4553
4692
  },
4554
4693
  },
4555
4694
  body,
@@ -4601,6 +4740,9 @@ G.TerminalPane = function TerminalPane(props) {
4601
4740
  const theme = props.theme === 'light' ? 'light' : 'dark'
4602
4741
  const visible = props.visible !== false
4603
4742
  const [assets, setAssets] = useState({ status: 'loading', Terminal: null, FitAddon: null, error: '' })
4743
+ /* 未显式传 palette 时(例如古法编程主模式),从 IDE 主题 token 算一份实色调色板,
4744
+ 让 xterm 的文字/选区颜色与周围面板一致,而不是永远用浅色主题 */
4745
+ const [computedPalette, setComputedPalette] = useState(null)
4604
4746
  const [sessions, setSessions] = useState([])
4605
4747
  const [activeId, setActiveId] = useState(null)
4606
4748
  const [error, setError] = useState('')
@@ -4620,6 +4762,25 @@ G.TerminalPane = function TerminalPane(props) {
4620
4762
  useEffect(() => {
4621
4763
  sessionsRef.current = sessions
4622
4764
  }, [sessions])
4765
+ useEffect(() => {
4766
+ if (props.palette !== null && props.palette !== undefined) return undefined
4767
+ let cancelled = false
4768
+ const compute = () => {
4769
+ try {
4770
+ const el = sizeRef.current
4771
+ const value = typeof G.resolveSolidPalette === 'function' ? G.resolveSolidPalette(el) : null
4772
+ if (!cancelled && value !== null && value !== undefined) setComputedPalette(value)
4773
+ } catch {
4774
+ /* ignore */
4775
+ }
4776
+ }
4777
+ compute()
4778
+ const timer = window.setTimeout(compute, 400)
4779
+ return () => {
4780
+ cancelled = true
4781
+ window.clearTimeout(timer)
4782
+ }
4783
+ }, [props.palette])
4623
4784
  useEffect(() => {
4624
4785
  activeRef.current = activeId
4625
4786
  }, [activeId])
@@ -4868,7 +5029,7 @@ G.TerminalPane = function TerminalPane(props) {
4868
5029
  active: session.id === activeId,
4869
5030
  visible,
4870
5031
  theme,
4871
- palette: props.palette,
5032
+ palette: props.palette !== null && props.palette !== undefined ? props.palette : computedPalette,
4872
5033
  assets,
4873
5034
  register: registerChannel,
4874
5035
  unregister: unregisterChannel,
@@ -4885,6 +5046,7 @@ G.TerminalPane = function TerminalPane(props) {
4885
5046
  return h(
4886
5047
  'div',
4887
5048
  {
5049
+ className: 'gufa-termpane',
4888
5050
  style: {
4889
5051
  height,
4890
5052
  flex: '0 0 auto',
@@ -4893,12 +5055,12 @@ G.TerminalPane = function TerminalPane(props) {
4893
5055
  minHeight: 0,
4894
5056
  minWidth: 0,
4895
5057
  borderTop: '1px solid var(--gufa-border)',
4896
- background: 'var(--gufa-bg)',
4897
5058
  },
4898
5059
  },
4899
5060
  h(
4900
5061
  'div',
4901
5062
  {
5063
+ className: 'gufa-termhead',
4902
5064
  style: {
4903
5065
  display: 'flex',
4904
5066
  alignItems: 'center',
@@ -4907,7 +5069,6 @@ G.TerminalPane = function TerminalPane(props) {
4907
5069
  padding: '0 6px 0 8px',
4908
5070
  flex: '0 0 auto',
4909
5071
  borderBottom: '1px solid var(--gufa-border)',
4910
- background: 'var(--gufa-layer)',
4911
5072
  minWidth: 0,
4912
5073
  },
4913
5074
  },
@@ -4944,7 +5105,7 @@ G.TerminalPane = function TerminalPane(props) {
4944
5105
  : null,
4945
5106
  h(
4946
5107
  'div',
4947
- { ref: sizeRef, style: { position: 'relative', flex: '1 1 auto', display: 'flex', flexDirection: 'column', minHeight: 0, minWidth: 0, background: theme === 'dark' ? '#1e1e1e' : '#ffffff' } },
5108
+ { ref: sizeRef, className: 'gufa-termbody', style: { position: 'relative', flex: '1 1 auto', display: 'flex', flexDirection: 'column', minHeight: 0, minWidth: 0 } },
4948
5109
  body,
4949
5110
  ),
4950
5111
  )
@@ -7765,7 +7926,10 @@ G.BackdropParticles = function BackdropParticles(props) {
7765
7926
  const canvasRef = useRef(null)
7766
7927
  const strengthRaw = typeof props.strength === 'number' && Number.isFinite(props.strength) ? props.strength : 1
7767
7928
  const strength = Math.max(0, Math.min(1, strengthRaw))
7929
+ /* 摸鱼窗口里背景层是被 CSS 隐藏的:完全不要创建 canvas / 跑动画,省 CPU 与内存 */
7930
+ const skipFloat = typeof G.isFloatMode === 'function' && G.isFloatMode() === true
7768
7931
  useEffect(() => {
7932
+ if (skipFloat) return undefined
7769
7933
  const canvas = canvasRef.current
7770
7934
  if (canvas === null || canvas === undefined) return undefined
7771
7935
  const context = canvas.getContext('2d')
@@ -7778,7 +7942,7 @@ G.BackdropParticles = function BackdropParticles(props) {
7778
7942
  }
7779
7943
  if (reduced) return undefined
7780
7944
 
7781
- const dpr = Math.min(1.5, window.devicePixelRatio || 1)
7945
+ const dpr = Math.min(1.25, window.devicePixelRatio || 1)
7782
7946
  let width = 0
7783
7947
  let height = 0
7784
7948
  const resize = () => {
@@ -7834,9 +7998,11 @@ G.BackdropParticles = function BackdropParticles(props) {
7834
7998
  const pointer = { x: -1e4, y: -1e4, down: false }
7835
7999
  let last = 0
7836
8000
  let raf = 0
8001
+ let paused = document.visibilityState === 'hidden'
7837
8002
  const tick = (now) => {
8003
+ if (paused) { raf = 0; return }
7838
8004
  raf = window.requestAnimationFrame(tick)
7839
- if (now - last < 33) return
8005
+ if (now - last < 40) return
7840
8006
  const dt = Math.min(0.048, (last === 0 ? 0.016 : (now - last) / 1000))
7841
8007
  last = now
7842
8008
  context.clearRect(0, 0, width, height)
@@ -7893,13 +8059,28 @@ G.BackdropParticles = function BackdropParticles(props) {
7893
8059
  }
7894
8060
  const onPointerDown = () => { pointer.down = true }
7895
8061
  const onPointerUp = () => { pointer.down = false }
8062
+ const resume = () => {
8063
+ paused = false
8064
+ last = 0
8065
+ if (raf === 0) raf = window.requestAnimationFrame(tick)
8066
+ }
8067
+ const pause = () => {
8068
+ paused = true
8069
+ if (raf !== 0) { window.cancelAnimationFrame(raf); raf = 0 }
8070
+ }
8071
+ const onVisibility = () => { if (document.visibilityState === 'hidden') pause(); else resume() }
8072
+ const onBlur = () => pause()
8073
+ const onFocus = () => resume()
8074
+ document.addEventListener('visibilitychange', onVisibility)
8075
+ window.addEventListener('blur', onBlur)
8076
+ window.addEventListener('focus', onFocus)
7896
8077
  window.addEventListener('pointermove', onPointerMove)
7897
8078
  window.addEventListener('pointerdown', onPointerDown)
7898
8079
  window.addEventListener('pointerup', onPointerUp)
7899
8080
  window.addEventListener('pointerleave', onPointerLeave)
7900
8081
  window.addEventListener('resize', resize)
7901
8082
  resize()
7902
- raf = window.requestAnimationFrame(tick)
8083
+ if (!paused) raf = window.requestAnimationFrame(tick)
7903
8084
  try {
7904
8085
  void G.api('dev.log', { message: `particles-start count=${activeCount} size=2-5.2css dpr=${dpr} canvas=${width}x${height}` }).catch(() => {})
7905
8086
  } catch {
@@ -7907,13 +8088,17 @@ G.BackdropParticles = function BackdropParticles(props) {
7907
8088
  }
7908
8089
  return () => {
7909
8090
  if (raf !== 0) window.cancelAnimationFrame(raf)
8091
+ document.removeEventListener('visibilitychange', onVisibility)
8092
+ window.removeEventListener('blur', onBlur)
8093
+ window.removeEventListener('focus', onFocus)
7910
8094
  window.removeEventListener('pointermove', onPointerMove)
7911
8095
  window.removeEventListener('pointerdown', onPointerDown)
7912
8096
  window.removeEventListener('pointerup', onPointerUp)
7913
8097
  window.removeEventListener('pointerleave', onPointerLeave)
7914
8098
  window.removeEventListener('resize', resize)
7915
8099
  }
7916
- }, [strength])
8100
+ }, [strength, skipFloat])
8101
+ if (skipFloat) return null
7917
8102
  return h('canvas', { ref: canvasRef, className: 'gufa-backdrop-particles', 'aria-hidden': 'true', style: { mixBlendMode: 'screen' } })
7918
8103
  }
7919
8104
 
@@ -8749,6 +8934,21 @@ G.OverlayHost = function OverlayHost(props) {
8749
8934
  root.style.setProperty('--gufa-solid-sidebar', palette.sidebar)
8750
8935
  root.style.setProperty('--gufa-solid-text', palette.text)
8751
8936
  root.style.setProperty('--gufa-solid-text-dim', palette.textDim)
8937
+ /* 弹窗 portal 挂在 body 上,拿不到 root 上的 inline 变量,这里同步一份 */
8938
+ try {
8939
+ const portalHost = document.getElementById('gufa-portal-root')
8940
+ if (portalHost !== null) {
8941
+ portalHost.style.setProperty('--gufa-solid-bg', palette.bg)
8942
+ portalHost.style.setProperty('--gufa-solid-layer', palette.layer)
8943
+ portalHost.style.setProperty('--gufa-solid-layer2', palette.layer2)
8944
+ portalHost.style.setProperty('--gufa-solid-overlay', palette.overlay)
8945
+ portalHost.style.setProperty('--gufa-solid-sidebar', palette.sidebar)
8946
+ portalHost.style.setProperty('--gufa-solid-text', palette.text)
8947
+ portalHost.style.setProperty('--gufa-solid-text-dim', palette.textDim)
8948
+ }
8949
+ } catch {
8950
+ /* ignore */
8951
+ }
8752
8952
  if (typeof G.applyPopupTheme === 'function') G.applyPopupTheme(palette)
8753
8953
  try {
8754
8954
  if (window.__gufaApplyLogs === undefined) window.__gufaApplyLogs = 10
@@ -9115,21 +9315,23 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
9115
9315
  try {
9116
9316
  if (typeof window !== 'undefined' && window !== null) {
9117
9317
  if (wrapped.length < expected) {
9118
- if (service.__gufaIntegrationTimer === undefined || service.__gufaIntegrationTimer === null) {
9119
- let attempts = 0
9120
- service.__gufaIntegrationTimer = window.setInterval(() => {
9121
- attempts += 1
9122
- if (attempts > 40) {
9123
- window.clearInterval(service.__gufaIntegrationTimer)
9124
- service.__gufaIntegrationTimer = null
9125
- return
9126
- }
9127
- try {
9128
- G.installShortcutIntegration(service)
9129
- } catch {
9130
- /* ignore */
9131
- }
9132
- }, 500)
9318
+ /* 累计尝试次数上限:配置变更会反复触发安装,不能每次都重新开 40 次重试(之前会变成常驻 2Hz 循环) */
9319
+ if ((service.__gufaIntegrationAttempts ?? 0) < 40) {
9320
+ if (service.__gufaIntegrationTimer === undefined || service.__gufaIntegrationTimer === null) {
9321
+ service.__gufaIntegrationTimer = window.setInterval(() => {
9322
+ service.__gufaIntegrationAttempts = (service.__gufaIntegrationAttempts ?? 0) + 1
9323
+ if (service.__gufaIntegrationAttempts > 40) {
9324
+ window.clearInterval(service.__gufaIntegrationTimer)
9325
+ service.__gufaIntegrationTimer = null
9326
+ return
9327
+ }
9328
+ try {
9329
+ G.installShortcutIntegration(service)
9330
+ } catch {
9331
+ /* ignore */
9332
+ }
9333
+ }, 500)
9334
+ }
9133
9335
  }
9134
9336
  } else {
9135
9337
  if (service.__gufaIntegrationTimer !== undefined && service.__gufaIntegrationTimer !== null) {
@@ -9251,7 +9453,11 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
9251
9453
  } catch {
9252
9454
  edrvIds = []
9253
9455
  }
9254
- void G.api('dev.log', { message: `shortcut-integration wrapped=${JSON.stringify(wrapped)} total=${totalCommands} configStatus=${configStatus} edrv=${JSON.stringify(edrvIds).slice(0, 1500)} edrvBindings=${JSON.stringify(edrvBindings).slice(0, 2500)}` }).catch(() => {})
9456
+ const signature = `${JSON.stringify(wrapped)}|${totalCommands}|${configStatus}|${edrvIds.length}|${edrvBindings.length}`
9457
+ if (service.__gufaLastIntegrationSignature !== signature) {
9458
+ service.__gufaLastIntegrationSignature = signature
9459
+ void G.api('dev.log', { message: `shortcut-integration wrapped=${JSON.stringify(wrapped)} total=${totalCommands} configStatus=${configStatus} edrv=${JSON.stringify(edrvIds).slice(0, 1500)} edrvBindings=${JSON.stringify(edrvBindings).slice(0, 2500)}` }).catch(() => {})
9460
+ }
9255
9461
  } catch {
9256
9462
  /* ignore */
9257
9463
  }
@@ -9515,6 +9721,50 @@ G.GufaApp = function GufaApp(props) {
9515
9721
  const [floatBusy, setFloatBusy] = useState(false)
9516
9722
  /* 摸鱼窗口选择器:null | {status:'loading'|'ready'|'permission'|'error', windows:[], error:''} */
9517
9723
  const [floatPicker, setFloatPicker] = useState(null)
9724
+ /* 摸鱼模式(悬浮窗实例)与界面透明度 */
9725
+ const [moyuMode] = useState(() => G.isFloatMode())
9726
+ const [floatAlpha, setFloatAlpha] = useState(() => {
9727
+ try {
9728
+ const saved = Number(localStorage.getItem('gufa-code:float-alpha'))
9729
+ if (Number.isFinite(saved) && saved >= 20 && saved <= 100) return Math.round(saved)
9730
+ } catch {
9731
+ /* ignore */
9732
+ }
9733
+ return 55
9734
+ })
9735
+ useEffect(() => {
9736
+ try {
9737
+ document.documentElement.style.setProperty('--gufa-float-alpha', String(floatAlpha / 100))
9738
+ localStorage.setItem('gufa-code:float-alpha', String(floatAlpha))
9739
+ } catch {
9740
+ /* ignore */
9741
+ }
9742
+ /* 摸鱼窗口里调整透明度时同步到 Host,下次新建摸鱼窗口沿用 */
9743
+ if (moyuMode) {
9744
+ const timer = window.setTimeout(() => {
9745
+ void G.api('float.setPrefs', { alpha: floatAlpha }).catch(() => {})
9746
+ }, 400)
9747
+ return () => window.clearTimeout(timer)
9748
+ }
9749
+ return undefined
9750
+ }, [floatAlpha, moyuMode])
9751
+ /* 摸鱼窗口启动时优先使用 Host 偏好里的透明度 */
9752
+ useEffect(() => {
9753
+ if (!moyuMode) return
9754
+ let cancelled = false
9755
+ void (async () => {
9756
+ try {
9757
+ const prefs = await G.api('float.getPrefs')
9758
+ const alpha = Number(prefs?.alpha)
9759
+ if (!cancelled && Number.isFinite(alpha) && alpha >= 20 && alpha <= 100) setFloatAlpha(Math.round(alpha))
9760
+ } catch {
9761
+ /* ignore */
9762
+ }
9763
+ })()
9764
+ return () => {
9765
+ cancelled = true
9766
+ }
9767
+ }, [moyuMode])
9518
9768
  /* 会话弹窗里选中的工作区(null = 跟随当前 IDE 项目) */
9519
9769
  const [sessionWorkspacePath, setSessionWorkspacePath] = useState(null)
9520
9770
  const [sessionWorkspacePicker, setSessionWorkspacePicker] = useState(false)
@@ -9529,8 +9779,16 @@ G.GufaApp = function GufaApp(props) {
9529
9779
  return Array.isArray(parsed) ? parsed : []
9530
9780
  }, [recentSessionsJson])
9531
9781
 
9782
+ /* 摸鱼窗口:主窗口注入的状态(项目/UI/标签页/会话) */
9783
+ const floatState = G.floatState
9784
+ const appInstanceId = useRef(0)
9785
+ if (appInstanceId.current === 0) {
9786
+ appInstanceId.current = Math.random().toString(36).slice(2, 8)
9787
+ void G.api('dev.log', { message: `app-mount id=${appInstanceId.current} float=${G.isFloatMode()} href=${String(location.href).slice(0, 80)}` }).catch(() => {})
9788
+ }
9532
9789
  const [ui, setUi] = useState(() => {
9533
- const saved = readJson(GUFA_LS.ui) ?? {}
9790
+ const fromFloat = floatState !== null && floatState !== undefined && floatState.ui !== null && typeof floatState.ui === 'object' ? floatState.ui : null
9791
+ const saved = fromFloat ?? readJson(GUFA_LS.ui) ?? {}
9534
9792
  return {
9535
9793
  view: typeof saved.view === 'string' ? saved.view : 'explorer',
9536
9794
  chatOpen: saved.chatOpen !== false,
@@ -9609,6 +9867,22 @@ G.GufaApp = function GufaApp(props) {
9609
9867
  bootedRef.current = true
9610
9868
  let cancelled = false
9611
9869
  void (async () => {
9870
+ /* 从工作区菜单点进来的:跳过「恢复上次项目」,直接按入口工作区打开 */
9871
+ const pendingEntry = G.pendingEntryWorkspace
9872
+ if (pendingEntry !== null && pendingEntry !== undefined && typeof pendingEntry.key === 'string') {
9873
+ try {
9874
+ const listValue = await G.api('workspaces.list', {})
9875
+ const list = Array.isArray(listValue?.workspaces) ? listValue.workspaces : []
9876
+ const matched = list.find((item) => item !== null && item.id === pendingEntry.key)
9877
+ if (matched !== undefined && typeof matched.path === 'string' && matched.path !== '') {
9878
+ const value = await G.api('project.open', { path: matched.path })
9879
+ if (!cancelled) applyProject(value)
9880
+ return
9881
+ }
9882
+ } catch {
9883
+ /* 回落到恢复上次项目 */
9884
+ }
9885
+ }
9612
9886
  const saved = floatState !== null && floatState !== undefined && typeof floatState.projectRoot === 'string' && floatState.projectRoot !== ''
9613
9887
  ? floatState.projectRoot
9614
9888
  : readJson(GUFA_LS.project)
@@ -9621,7 +9895,7 @@ G.GufaApp = function GufaApp(props) {
9621
9895
  writeJson(GUFA_LS.project, null)
9622
9896
  }
9623
9897
  }
9624
- if (G.floatState !== null && G.floatState !== undefined) return
9898
+ if (G.isFloatMode()) return
9625
9899
  if (typeof sessionCwd === 'string' && sessionCwd !== '') {
9626
9900
  try {
9627
9901
  const value = await G.api('project.open', { path: sessionCwd })
@@ -9686,13 +9960,38 @@ G.GufaApp = function GufaApp(props) {
9686
9960
  }
9687
9961
  try {
9688
9962
  const doc = await G.api('fs.read', { root: project.root, path })
9689
- setTabs((current) => [...current, { ...doc, savedContent: doc.content, dirty: false, savedRevision: doc.revision }])
9963
+ /* 用函数式更新去重:并发/恢复场景下闭包里的 tabs 可能还没刷新,直接追加会产生重复标签 */
9964
+ setTabs((current) => (
9965
+ current.some((tab) => tab.path === path)
9966
+ ? current
9967
+ : [...current, { ...doc, savedContent: doc.content, dirty: false, savedRevision: doc.revision }]
9968
+ ))
9690
9969
  setActivePath(path)
9691
9970
  } catch (error) {
9692
9971
  setBanner(G.errorText(error))
9693
9972
  }
9694
9973
  }, [project, tabs])
9695
9974
 
9975
+ /* 原子恢复标签集合:按快照顺序、去重、最后激活指定文件(避免 openFile 并发产生重复标签) */
9976
+ const applyTabs = useCallback(async (paths, active) => {
9977
+ if (project === null || !Array.isArray(paths)) return
9978
+ const docs = []
9979
+ const seen = new Set()
9980
+ for (const path of paths.slice(0, 12)) {
9981
+ if (typeof path !== 'string' || path === '' || seen.has(path)) continue
9982
+ seen.add(path)
9983
+ try {
9984
+ const doc = await G.api('fs.read', { root: project.root, path })
9985
+ docs.push({ ...doc, savedContent: doc.content, dirty: false, savedRevision: doc.revision })
9986
+ } catch {
9987
+ /* 快照里的文件可能已被删除:忽略 */
9988
+ }
9989
+ }
9990
+ setTabs(docs)
9991
+ const wanted = typeof active === 'string' && docs.some((doc) => doc.path === active) ? active : (docs.length > 0 ? docs[docs.length - 1].path : null)
9992
+ setActivePath(wanted)
9993
+ }, [project])
9994
+
9696
9995
  const activeTab = useMemo(() => tabs.find((tab) => tab.path === activePath) ?? null, [tabs, activePath])
9697
9996
 
9698
9997
  const patchTab = useCallback((path, patch) => {
@@ -10197,7 +10496,6 @@ G.GufaApp = function GufaApp(props) {
10197
10496
  try {
10198
10497
  await G.api('float.stop')
10199
10498
  setFloatRunning(false)
10200
- setBanner('已退出摸鱼:主窗口已恢复')
10201
10499
  } catch (error) {
10202
10500
  setBanner(G.errorText(error))
10203
10501
  } finally {
@@ -10226,20 +10524,25 @@ G.GufaApp = function GufaApp(props) {
10226
10524
  }, [floatBusy])
10227
10525
 
10228
10526
  /* 选中某个 App 窗口 → 启动悬浮层并吸附它 */
10527
+ /* 当前编辑器状态快照(进出摸鱼都以它为准) */
10528
+ const buildFloatSnapshot = useCallback(() => ({
10529
+ /* 诊断:快照里项目字段 */
10530
+ projectRoot: project !== null && typeof project.root === 'string' ? project.root : null,
10531
+ activePath: typeof activePath === 'string' ? activePath : null,
10532
+ tabs: tabs
10533
+ .filter((tab) => tab !== null && tab !== undefined && typeof tab.path === 'string' && tab.kind !== 'diff' && tab.kind !== 'graph')
10534
+ .map((tab) => tab.path)
10535
+ .slice(0, 10),
10536
+ ui: ui,
10537
+ sessionId: typeof currentSessionId === 'string' ? currentSessionId : null,
10538
+ }), [project, activePath, tabs, ui, currentSessionId])
10539
+
10229
10540
  const startFloatForWindow = useCallback(async (target) => {
10230
10541
  if (floatBusy || target === null || target === undefined) return
10231
10542
  setFloatBusy(true)
10232
10543
  try {
10233
- const floatState = {
10234
- projectRoot: project !== null && typeof project.root === 'string' ? project.root : null,
10235
- activePath: typeof activePath === 'string' ? activePath : null,
10236
- tabs: tabs
10237
- .filter((tab) => tab !== null && tab !== undefined && typeof tab.path === 'string' && tab.kind !== 'diff' && tab.kind !== 'graph')
10238
- .map((tab) => tab.path)
10239
- .slice(0, 10),
10240
- ui: readJson(GUFA_LS.ui) ?? {},
10241
- sessionId: typeof currentSessionId === 'string' ? currentSessionId : null,
10242
- }
10544
+ const floatState = buildFloatSnapshot()
10545
+ void G.api('dev.log', { message: `float-start-instance id=${appInstanceId.current} project=${String(floatState.projectRoot)} tabs=${floatState.tabs.length}` }).catch(() => {})
10243
10546
  const value = await G.api('float.start', {
10244
10547
  follow: {
10245
10548
  pid: Number(target.pid) || 0,
@@ -10250,24 +10553,21 @@ G.GufaApp = function GufaApp(props) {
10250
10553
  })
10251
10554
  setFloatRunning(value?.running === true)
10252
10555
  setFloatPicker(null)
10253
- const name = typeof target.owner === 'string' && target.owner !== '' ? target.owner : '所选窗口'
10254
- setBanner(`摸鱼模式已开启:已吸附 ${name};⌃⌥⌘G 切换点击穿透,菜单栏「古法」可退出`)
10255
10556
  } catch (error) {
10256
10557
  setBanner(G.errorText(error))
10257
10558
  } finally {
10258
10559
  setFloatBusy(false)
10259
10560
  }
10260
- }, [floatBusy])
10561
+ }, [floatBusy, buildFloatSnapshot])
10261
10562
 
10262
- /* 自由悬浮(不吸附窗口) */
10563
+ /* 自由悬浮(不吸附窗口):同样带上当前编辑器状态快照 */
10263
10564
  const startFloatFree = useCallback(async () => {
10264
10565
  if (floatBusy) return
10265
10566
  setFloatBusy(true)
10266
10567
  try {
10267
- const value = await G.api('float.start')
10568
+ const value = await G.api('float.start', { state: buildFloatSnapshot() })
10268
10569
  setFloatRunning(value?.running === true)
10269
10570
  setFloatPicker(null)
10270
- setBanner('悬浮层已启动(自由悬浮)')
10271
10571
  } catch (error) {
10272
10572
  setBanner(G.errorText(error))
10273
10573
  } finally {
@@ -10278,10 +10578,140 @@ G.GufaApp = function GufaApp(props) {
10278
10578
  /* 内部 QA:允许自动化脚本在悬浮窗里打开摸鱼列表(仅供自测,不影响正常交互) */
10279
10579
  G.debugOpenFloatPicker = openFloatPicker
10280
10580
 
10281
- const toggleFloatWindow = useCallback(() => {
10282
- if (floatRequested === true || floatRunning) void stopFloatWindow()
10581
+ /* 悬浮窗里点「退出摸鱼」:把当前状态交还主窗口,再关闭悬浮层 */
10582
+ const exitMoyu = useCallback(async () => {
10583
+ if (floatBusy) return
10584
+ setFloatBusy(true)
10585
+ try {
10586
+ const state = {
10587
+ projectRoot: project !== null && typeof project.root === 'string' ? project.root : null,
10588
+ activePath: typeof activePath === 'string' ? activePath : null,
10589
+ tabs: tabs
10590
+ .filter((tab) => tab !== null && tab !== undefined && typeof tab.path === 'string' && tab.kind !== 'diff' && tab.kind !== 'graph')
10591
+ .map((tab) => tab.path)
10592
+ .slice(0, 10),
10593
+ ui: ui,
10594
+ sessionId: typeof currentSessionId === 'string' ? currentSessionId : null,
10595
+ }
10596
+ await G.api('float.saveExitState', { state })
10597
+ await G.api('float.stop')
10598
+ setFloatRunning(false)
10599
+ } catch (error) {
10600
+ setBanner(G.errorText(error))
10601
+ } finally {
10602
+ setFloatBusy(false)
10603
+ }
10604
+ }, [floatBusy, project, activePath, tabs, currentSessionId, ui])
10605
+
10606
+ /* 主窗口回到前台时:取回退出摸鱼时的状态(项目/标签页/会话) */
10607
+ const consumeExitStateRef = useRef(false)
10608
+ useEffect(() => {
10609
+ if (G.isFloatMode()) return undefined
10610
+ let running = false
10611
+ const consume = async () => {
10612
+ if (running) return
10613
+ running = true
10614
+ try {
10615
+ const value = await G.api('float.consumeExitState')
10616
+ const state = value?.state ?? null
10617
+ if (state !== null && typeof state === 'object') {
10618
+ void G.api('dev.log', { message: `moyu-exit-state consume project=${String(state.projectRoot)} tabs=${Array.isArray(state.tabs) ? state.tabs.length : 0} session=${String(state.sessionId)}` }).catch(() => {})
10619
+ const restore = G.floatRestoreRef
10620
+ if (restore === null || restore === undefined) {
10621
+ /* 主窗口当前不在 IDE 模式:把状态写进 localStorage,等下次进 IDE 时恢复 */
10622
+ try {
10623
+ if (typeof state.projectRoot === 'string' && state.projectRoot !== '') localStorage.setItem('gufa-code:project', JSON.stringify(state.projectRoot))
10624
+ localStorage.setItem('gufa-code:float-state', JSON.stringify(state))
10625
+ } catch {
10626
+ /* ignore */
10627
+ }
10628
+ return
10629
+ }
10630
+ let projectValue = null
10631
+ if (typeof state.projectRoot === 'string' && state.projectRoot !== '') {
10632
+ try {
10633
+ projectValue = await G.api('project.open', { path: state.projectRoot })
10634
+ } catch {
10635
+ projectValue = null
10636
+ }
10637
+ }
10638
+ if (projectValue !== null && restore !== null && restore !== undefined && typeof restore.applyProject === 'function') {
10639
+ restore.applyProject(projectValue)
10640
+ }
10641
+ try {
10642
+ if (typeof G.floatApplyUiRef === 'function' && state.ui !== null && typeof state.ui === 'object') G.floatApplyUiRef(state.ui)
10643
+ } catch {
10644
+ /* ignore */
10645
+ }
10646
+ await new Promise((resolve) => setTimeout(resolve, 500))
10647
+ const paths = Array.isArray(state.tabs) ? state.tabs.filter((path) => typeof path === 'string' && path !== '') : []
10648
+ const ordered = paths
10649
+ const activeOne = typeof state.activePath === 'string' && state.activePath !== '' ? state.activePath : null
10650
+ /* applyProject 后 App 已重渲染:重新取恢复入口,原子恢复标签集合 */
10651
+ const latest = G.floatRestoreRef
10652
+ if (latest !== null && latest !== undefined && typeof latest.applyTabs === 'function') {
10653
+ await latest.applyTabs(ordered, activeOne)
10654
+ }
10655
+ const openedCount = ordered.length
10656
+ void G.api('dev.log', { message: `moyu-exit-applied project=${String(state.projectRoot)} tabs=${openedCount} ui=${JSON.stringify(state.ui ?? null)}` }).catch(() => {})
10657
+ if (typeof state.sessionId === 'string' && state.sessionId !== '') {
10658
+ try {
10659
+ const workspace = G.ctx === null || G.ctx === undefined ? undefined : G.ctx.get('uiWorkspace')
10660
+ if (workspace !== undefined && workspace !== null && typeof workspace.openSession === 'function') workspace.openSession(state.sessionId)
10661
+ } catch {
10662
+ /* ignore */
10663
+ }
10664
+ }
10665
+ }
10666
+ } catch {
10667
+ /* ignore */
10668
+ } finally {
10669
+ running = false
10670
+ }
10671
+ }
10672
+ const syncFloatStatus = async () => {
10673
+ try {
10674
+ const value = await G.api('float.status')
10675
+ const next = value?.running === true
10676
+ setFloatRunning((current) => (current === next ? current : next))
10677
+ } catch {
10678
+ /* ignore */
10679
+ }
10680
+ }
10681
+ const onFocus = () => { void syncFloatStatus(); void consume() }
10682
+ window.addEventListener('focus', onFocus)
10683
+ /* 摸鱼退出后主窗口可能因隐藏/恢复丢失 focus 事件,低频轮询兜底 */
10684
+ const pollTimer = window.setInterval(() => {
10685
+ if (document.visibilityState !== 'visible') return
10686
+ void consume()
10687
+ void syncFloatStatus()
10688
+ }, 5000)
10689
+ const onVisible = () => { if (document.visibilityState === 'visible') { void syncFloatStatus(); void consume() } }
10690
+ document.addEventListener('visibilitychange', onVisible)
10691
+ if (consumeExitStateRef.current !== true) {
10692
+ consumeExitStateRef.current = true
10693
+ void consume()
10694
+ }
10695
+ return () => {
10696
+ window.removeEventListener('focus', onFocus)
10697
+ document.removeEventListener('visibilitychange', onVisible)
10698
+ window.clearInterval(pollTimer)
10699
+ }
10700
+ }, [])
10701
+
10702
+ const toggleFloatWindow = useCallback(async () => {
10703
+ if (floatBusy) return
10704
+ /* 以 Host 的真实运行状态为准:避免退出摸鱼后主窗口状态残留,第一次点击失效 */
10705
+ let running = floatRunning
10706
+ try {
10707
+ const status = await G.api('float.status')
10708
+ running = status?.running === true
10709
+ } catch {
10710
+ running = false
10711
+ }
10712
+ if (floatRequested === true || running) await stopFloatWindow()
10283
10713
  else void openFloatPicker()
10284
- }, [floatRequested, floatRunning, stopFloatWindow, openFloatPicker])
10714
+ }, [floatBusy, floatRequested, floatRunning, stopFloatWindow, openFloatPicker])
10285
10715
 
10286
10716
  /* ── 右侧 AI 面板与当前工作区保持一致 ─────────────────────────────────
10287
10717
  * ChatDock 停靠的是 DSH「主视图会话」,但主视图会话可能属于别的工作区
@@ -10289,7 +10719,7 @@ G.GufaApp = function GufaApp(props) {
10289
10719
  const dockSyncRef = useRef('')
10290
10720
  useEffect(() => {
10291
10721
  if (sessionPinnedRef.current === true) return undefined
10292
- if (G.floatState !== null && G.floatState !== undefined) return undefined
10722
+ if (G.isFloatMode()) return undefined
10293
10723
  if (project === null || typeof project.root !== 'string' || project.root === '') return undefined
10294
10724
  if (dockSyncRef.current === project.root) return undefined
10295
10725
  if (typeof sessionCwd === 'string' && sessionCwd !== '' && sessionCwd === project.root) {
@@ -10334,20 +10764,24 @@ G.GufaApp = function GufaApp(props) {
10334
10764
  const entryWorkspaceSyncedRef = useRef(false)
10335
10765
  useEffect(() => {
10336
10766
  if (entryWorkspaceSyncedRef.current) return
10337
- /* 悬浮层:项目/会话由主窗口状态注入,不做「入口工作区」同步,避免被会话 cwd 覆盖 */
10338
- if (G.floatState !== null && G.floatState !== undefined) {
10767
+ /* 悬浮层(摸鱼):项目/会话由主窗口状态注入,不做「入口工作区」同步 */
10768
+ if (G.isFloatMode()) {
10339
10769
  entryWorkspaceSyncedRef.current = true
10340
10770
  return
10341
10771
  }
10342
- if (project === null) return
10772
+ if (project === null && (G.pendingEntryWorkspace === null || G.pendingEntryWorkspace === undefined)) return
10343
10773
  const pending = G.pendingEntryWorkspace
10344
10774
  if (pending === null || pending === undefined || typeof pending.key !== 'string') {
10345
10775
  if (typeof sessionCwd !== 'string' || sessionCwd === '') return
10346
10776
  entryWorkspaceSyncedRef.current = true
10347
- if (project.root !== sessionCwd) void openProjectPath(sessionCwd).catch((error) => setBanner(G.errorText(error)))
10777
+ if (project !== null && typeof project.root === 'string' && project.root !== sessionCwd) {
10778
+ void openProjectPath(sessionCwd).catch((error) => setBanner(G.errorText(error)))
10779
+ }
10348
10780
  return
10349
10781
  }
10350
10782
  entryWorkspaceSyncedRef.current = true
10783
+ const currentRoot = project !== null && typeof project.root === 'string' ? project.root : ''
10784
+ void G.api('dev.log', { message: `entry-sync pending=${String(pending.key)} project=${currentRoot === '' ? 'null' : currentRoot} sessionCwd=${typeof sessionCwd === 'string' ? sessionCwd : ''}` }).catch(() => {})
10351
10785
  void (async () => {
10352
10786
  try {
10353
10787
  let targetPath = ''
@@ -10363,7 +10797,7 @@ G.GufaApp = function GufaApp(props) {
10363
10797
  const sameWorkspace = typeof sessionCwd === 'string' && sessionCwd !== '' && targetPath !== '' && sessionCwd === targetPath
10364
10798
  if (sameWorkspace) {
10365
10799
  /* 当前正在聊的会话就在这个工作区:直接用它,只把项目根对齐 */
10366
- if (project.root !== targetPath) await openProjectPath(targetPath)
10800
+ if (currentRoot !== targetPath) await openProjectPath(targetPath)
10367
10801
  return
10368
10802
  }
10369
10803
  /* 会话属于别的工作区:切到目标工作区最近的会话,再对齐项目根 */
@@ -10381,7 +10815,7 @@ G.GufaApp = function GufaApp(props) {
10381
10815
  setBanner(G.errorText(error))
10382
10816
  }
10383
10817
  })()
10384
- }, [project, sessionCwd, openProjectPath, setBanner])
10818
+ }, [project, sessionCwd, openProjectPath, setBanner, gufaModeVisible])
10385
10819
 
10386
10820
  /* ── 已删除文件的标签自动关闭 ──────────────────────────────────────── */
10387
10821
  const pruneMissingTabs = useCallback(async () => {
@@ -10658,7 +11092,7 @@ G.GufaApp = function GufaApp(props) {
10658
11092
  useEffect(() => {
10659
11093
  if (sessionPinnedRef.current === true) return
10660
11094
  /* 悬浮层里项目由主窗口状态注入,不跟随(Web 版客户端自己的)会话 cwd 切换 */
10661
- if (G.floatState !== null && G.floatState !== undefined) {
11095
+ if (G.isFloatMode()) {
10662
11096
  lastSessionCwdRef.current = sessionCwd
10663
11097
  return
10664
11098
  }
@@ -10863,6 +11297,14 @@ G.GufaApp = function GufaApp(props) {
10863
11297
  if (project === null) return
10864
11298
  let state = null
10865
11299
  state = G.floatState
11300
+ if (state === null || state === undefined) {
11301
+ try {
11302
+ const raw = localStorage.getItem('gufa-code:float-state')
11303
+ state = raw === null ? null : JSON.parse(raw)
11304
+ } catch {
11305
+ state = null
11306
+ }
11307
+ }
10866
11308
  if (state === null || typeof state !== 'object') return
10867
11309
  floatTabsRestoredRef.current = true
10868
11310
  const paths = Array.isArray(state.tabs) ? state.tabs.filter((path) => typeof path === 'string' && path !== '') : []
@@ -10882,11 +11324,21 @@ G.GufaApp = function GufaApp(props) {
10882
11324
 
10883
11325
  /* 悬浮层恢复入口:主窗口把状态带过来后,由 99-main 显式调用(不依赖 App 自己的启动时序) */
10884
11326
  useEffect(() => {
10885
- G.floatRestoreRef = { applyProject, openFile }
11327
+ G.floatRestoreRef = { applyProject, openFile, applyTabs }
11328
+ G.floatGetTabs = () => tabs
11329
+ G.floatApplyUiRef = (nextUi) => {
11330
+ if (nextUi === null || nextUi === undefined || typeof nextUi !== 'object') return
11331
+ patchUi({
11332
+ view: typeof nextUi.view === 'string' ? nextUi.view : undefined,
11333
+ chatOpen: typeof nextUi.chatOpen === 'boolean' ? nextUi.chatOpen : undefined,
11334
+ terminalOpen: typeof nextUi.terminalOpen === 'boolean' ? nextUi.terminalOpen : undefined,
11335
+ sidebarOpen: typeof nextUi.sidebarOpen === 'boolean' ? nextUi.sidebarOpen : undefined,
11336
+ })
11337
+ }
10886
11338
  return () => {
10887
11339
  if (G.floatRestoreRef !== undefined && G.floatRestoreRef !== null && G.floatRestoreRef.applyProject === applyProject) G.floatRestoreRef = null
10888
11340
  }
10889
- }, [applyProject, openFile])
11341
+ }, [applyProject, openFile, applyTabs, tabs])
10890
11342
 
10891
11343
  const activeFileForChat = useMemo(() => {
10892
11344
  if (activeTab === null || activeTab.kind === 'diff' || activeTab.kind === 'graph') return null
@@ -11192,6 +11644,7 @@ G.GufaApp = function GufaApp(props) {
11192
11644
  h(G.Seal, { size: 24, className: 'gufa-brand-logo' }),
11193
11645
  h('span', { className: 'gufa-brand-name' }, t('app.title')),
11194
11646
  h('span', { className: 'gufa-brand-sub' }, t('app.subtitle')),
11647
+ h('span', { className: 'gufa-build-tag', title: '古法编程客户端版本(排查缓存用)' }, G.BUILD !== undefined ? G.BUILD : ''),
11195
11648
  ),
11196
11649
  h(
11197
11650
  'button',
@@ -11210,8 +11663,24 @@ G.GufaApp = function GufaApp(props) {
11210
11663
  h(
11211
11664
  'div',
11212
11665
  { className: 'gufa-titlebar-actions' },
11213
- h(G.Button, { icon: 'plus', title: t('app.newWorkspace'), disabled: workspaceBusy, onClick: () => void createWorkspace() }, t('app.newWorkspace')),
11214
- skinBackdrop.available === true && backdropActive
11666
+ moyuMode
11667
+ ? h(
11668
+ 'label',
11669
+ { className: 'gufa-moyu-alpha', title: '摸鱼界面透明度' },
11670
+ h('span', { className: 'gufa-moyu-alpha-label' }, '透明度'),
11671
+ h('input', {
11672
+ className: 'gufa-moyu-alpha-range',
11673
+ type: 'range',
11674
+ min: 20,
11675
+ max: 100,
11676
+ step: 1,
11677
+ value: floatAlpha,
11678
+ onChange: (event) => setFloatAlpha(Number(event.target.value)),
11679
+ }),
11680
+ h('span', { className: 'gufa-moyu-alpha-value' }, `${floatAlpha}%`),
11681
+ )
11682
+ : h(G.Button, { icon: 'plus', title: t('app.newWorkspace'), disabled: workspaceBusy, onClick: () => void createWorkspace() }, t('app.newWorkspace')),
11683
+ moyuMode === false && skinBackdrop.available === true && backdropActive
11215
11684
  ? h(G.BackdropStrengthSlider, {
11216
11685
  value: backdropStrength === null || backdropStrength === undefined ? Math.round((skinBackdrop.portraitOpacity ?? 1) * 100) : backdropStrength,
11217
11686
  onChange: (value) => {
@@ -11224,7 +11693,7 @@ G.GufaApp = function GufaApp(props) {
11224
11693
  },
11225
11694
  })
11226
11695
  : null,
11227
- skinBackdrop.available === true
11696
+ moyuMode === false && skinBackdrop.available === true
11228
11697
  ? h(G.IconButton, {
11229
11698
  title: backdropActive ? t('app.backdropOff') : t('app.backdropOn'),
11230
11699
  'data-active': backdropActive ? '' : undefined,
@@ -11235,19 +11704,32 @@ G.GufaApp = function GufaApp(props) {
11235
11704
  }),
11236
11705
  }, h(G.Icon, { name: 'image', size: 16 }))
11237
11706
  : null,
11238
- h(G.IconButton, {
11239
- title: floatRequested === true || floatRunning ? '退出摸鱼(关闭悬浮层,回主窗口)' : '进入摸鱼模式:选择一个 App 吸附并悬浮',
11240
- 'data-active': floatRunning ? '' : undefined,
11241
- disabled: floatBusy,
11242
- onClick: () => void toggleFloatWindow(),
11243
- }, h(G.Icon, { name: 'monitor', size: 15 })),
11244
- h(G.IconButton, { title: t('app.refresh'), onClick: () => { setRefreshToken((token) => token + 1); setGitRefreshToken((token) => token + 1); setSshRefreshToken((token) => token + 1) } }, h(G.Icon, { name: 'refresh', size: 15 })),
11707
+ moyuMode === false
11708
+ ? h('button', {
11709
+ type: 'button',
11710
+ className: 'gufa-moyu-btn',
11711
+ title: '摸鱼模式:选择一个 App 吸附并悬浮',
11712
+ disabled: floatBusy,
11713
+ onClick: () => void toggleFloatWindow(),
11714
+ }, '摸鱼')
11715
+ : null,
11716
+ moyuMode === false
11717
+ ? h(G.IconButton, { title: t('app.refresh'), onClick: () => { setRefreshToken((token) => token + 1); setGitRefreshToken((token) => token + 1); setSshRefreshToken((token) => token + 1) } }, h(G.Icon, { name: 'refresh', size: 15 }))
11718
+ : null,
11245
11719
  h(G.IconButton, {
11246
11720
  title: ui.chatOpen ? t('activity.collapseChat') : t('activity.expandChat'),
11247
11721
  'data-active': ui.chatOpen ? '' : undefined,
11248
11722
  onClick: () => patchUi({ chatOpen: !ui.chatOpen }),
11249
11723
  }, h(G.Icon, { name: 'panel-right', size: 16 })),
11250
- h(G.Button, { icon: 'arrow-left', title: t('app.exitHint'), onClick: exitMode }, t('app.exit')),
11724
+ moyuMode
11725
+ ? h('button', {
11726
+ type: 'button',
11727
+ className: 'gufa-moyu-exit',
11728
+ title: '退出摸鱼:关闭悬浮层,回到主窗口并带回当前状态',
11729
+ disabled: floatBusy,
11730
+ onClick: () => void exitMoyu(),
11731
+ }, '退出摸鱼')
11732
+ : h(G.Button, { icon: 'arrow-left', title: t('app.exitHint'), onClick: exitMode }, t('app.exit')),
11251
11733
  ),
11252
11734
  ),
11253
11735
  /* 主体 */
@@ -12235,6 +12717,23 @@ const GUFA_PLUGIN = {
12235
12717
  if (floatMode) {
12236
12718
  document.documentElement.setAttribute('data-gufa-float', '1')
12237
12719
  document.documentElement.setAttribute('data-gufa-booting', '1')
12720
+ /* 摸鱼窗口不需要皮肤:关掉皮肤插件的动画开关并移除其背景节点,
12721
+ 否则它仍在 rAF 里持续写 body.style / 画 canvas(看不见但耗 CPU、占内存) */
12722
+ const disableSkin = () => {
12723
+ try {
12724
+ const root = document.documentElement
12725
+ if (root.getAttribute('data-liang-skin') === 'on') root.setAttribute('data-liang-skin', 'off')
12726
+ root.removeAttribute('data-liang-stage')
12727
+ root.removeAttribute('data-gufa-skin-live')
12728
+ for (const node of document.querySelectorAll('.liang-skin-backdrop, .liang-ambient, .liang-skin-portrait, .liang-skin-root')) {
12729
+ node.remove()
12730
+ }
12731
+ } catch {
12732
+ /* ignore */
12733
+ }
12734
+ }
12735
+ disableSkin()
12736
+ for (const delay of [400, 1200, 2600, 5000]) window.setTimeout(disableSkin, delay)
12238
12737
  let attempts = 0
12239
12738
  const timer = window.setInterval(() => {
12240
12739
  attempts += 1
@@ -12248,10 +12747,100 @@ const GUFA_PLUGIN = {
12248
12747
  window.clearInterval(timer)
12249
12748
  /* 显式恢复主窗口状态(项目 → 标签页 → 会话),避免依赖 Web 版 App 的启动时序 */
12250
12749
  try {
12750
+ /* 诊断:找出某个点上所有「会画背景」的元素(含 pointer-events:none 的覆盖层) */
12751
+ try {
12752
+ const describe = (el) => {
12753
+ const cs = window.getComputedStyle(el)
12754
+ const cls = typeof el.className === 'string' ? el.className.replace(/\s+/g, '.').slice(0, 32) : ''
12755
+ const r = el.getBoundingClientRect()
12756
+ return `${el.tagName.toLowerCase()}.${cls}[bg=${cs.backgroundColor} op=${cs.opacity} z=${cs.zIndex} pe=${cs.pointerEvents} bf=${cs.backdropFilter !== 'none' ? 'Y' : ''} img=${cs.backgroundImage !== 'none' ? 'Y' : ''}]@${Math.round(r.left)},${Math.round(r.top)} ${Math.round(r.width)}x${Math.round(r.height)}`
12757
+ }
12758
+ const paintersAt = (x, y) => {
12759
+ const out = []
12760
+ for (const el of document.querySelectorAll('body *')) {
12761
+ const r = el.getBoundingClientRect()
12762
+ if (!(x >= r.left && x <= r.right && y >= r.top && y <= r.bottom)) continue
12763
+ const cs = window.getComputedStyle(el)
12764
+ if (cs.backgroundColor !== 'rgba(0, 0, 0, 0)' || cs.backgroundImage !== 'none' || cs.backdropFilter !== 'none') {
12765
+ out.push(describe(el) + (el.closest('.gufa-overlay-root') === null ? ' [OUTSIDE]' : ''))
12766
+ if (out.length >= 18) break
12767
+ }
12768
+ }
12769
+ return out.join(' || ')
12770
+ }
12771
+ const w = window.innerWidth
12772
+ const h = window.innerHeight
12773
+ void G.api('dev.log', { message: `float-painters chat=[${paintersAt(Math.round(w * 0.92), Math.round(h * 0.35))}]` }).catch(() => {})
12774
+ } catch {
12775
+ /* ignore */
12776
+ }
12777
+ /* 诊断:从像素点反查元素链,找出右侧会话框多出来的深色层 */
12778
+ try {
12779
+ const desc = (el) => {
12780
+ if (el === null || el === undefined) return 'null'
12781
+ const cs = window.getComputedStyle(el)
12782
+ const cls = typeof el.className === 'string' ? el.className.replace(/\s+/g, '.').slice(0, 40) : ''
12783
+ const img = cs.backgroundImage === 'none' ? '' : ` img=${cs.backgroundImage.slice(0, 50)}`
12784
+ const bf = cs.backdropFilter === 'none' ? '' : ` bf=${cs.backdropFilter}`
12785
+ return `${el.tagName.toLowerCase()}.${cls}[bg=${cs.backgroundColor} op=${cs.opacity}${img}${bf}]`
12786
+ }
12787
+ const chain = (x, y) => {
12788
+ let el = document.elementFromPoint(x, y)
12789
+ const parts = []
12790
+ for (let i = 0; i < 7 && el !== null; i += 1) {
12791
+ parts.push(desc(el))
12792
+ const before = window.getComputedStyle(el, '::before').backgroundColor
12793
+ if (before !== 'rgba(0, 0, 0, 0)' && before !== 'transparent') parts.push(`::before=${before}`)
12794
+ el = el.parentElement
12795
+ }
12796
+ return parts.join(' <- ')
12797
+ }
12798
+ const w = window.innerWidth
12799
+ const h = window.innerHeight
12800
+ void G.api('dev.log', {
12801
+ message: `float-probe editor=[${chain(Math.round(w * 0.45), Math.round(h * 0.55))}] chat=[${chain(Math.round(w * 0.92), Math.round(h * 0.4))}]`,
12802
+ }).catch(() => {})
12803
+ } catch {
12804
+ /* ignore */
12805
+ }
12806
+ /* 诊断:找出会话框里非透明的背景元素(排查透明度不一致) */
12807
+ try {
12808
+ const chat = document.querySelector('.gufa-chatpane')
12809
+ const found = []
12810
+ if (chat !== null) {
12811
+ for (const el of chat.querySelectorAll('*')) {
12812
+ const bg = window.getComputedStyle(el).backgroundColor
12813
+ if (bg !== 'rgba(0, 0, 0, 0)' && bg !== 'transparent') {
12814
+ found.push(`${el.tagName.toLowerCase()}.${String(el.className || '').replace(/\s+/g, '.').slice(0, 60)}=${bg}`)
12815
+ if (found.length >= 10) break
12816
+ }
12817
+ }
12818
+ }
12819
+ void G.api('dev.log', { message: `float-chat-bgs ${found.join(' | ') || 'none'}` }).catch(() => {})
12820
+ } catch {
12821
+ /* ignore */
12822
+ }
12823
+ /* 诊断:摸鱼窗口里各面板的实际底色(排查透明度不一致) */
12824
+ try {
12825
+ const pick = (sel) => {
12826
+ const el = document.querySelector(sel)
12827
+ if (el === null) return `${sel}=none`
12828
+ const cs = window.getComputedStyle(el)
12829
+ return `${sel}=${cs.backgroundColor}/${cs.opacity}`
12830
+ }
12831
+ const root = document.querySelector('.gufa-root')
12832
+ void G.api('dev.log', {
12833
+ message: `float-styles backdrop=${root === null ? '?' : root.getAttribute('data-backdrop')} ${pick('.gufa-overlay-root')} ${pick('.gufa-editor-area')} ${pick('.gufa-chatpane')} ${pick('.gufa-termpane')} ${pick('.gufa-termhead')} ${pick('.gufa-sidepanel')} ${pick('.gufa-main')} alphaVar=${window.getComputedStyle(document.documentElement).getPropertyValue('--gufa-float-alpha')}`,
12834
+ }).catch(() => {})
12835
+ } catch {
12836
+ /* ignore */
12837
+ }
12838
+ void G.api('dev.log', { message: `float-boot hasState=${G.floatState !== null && G.floatState !== undefined} restoreRef=${G.floatRestoreRef !== null && G.floatRestoreRef !== undefined} state=${G.floatState === null || G.floatState === undefined ? 'null' : JSON.stringify({ projectRoot: G.floatState.projectRoot, tabs: Array.isArray(G.floatState.tabs) ? G.floatState.tabs.length : 0, activePath: G.floatState.activePath })}` }).catch(() => {})
12251
12839
  if (window.__gufaFloatRestored !== true && G.floatState !== null && G.floatState !== undefined) {
12252
12840
  window.__gufaFloatRestored = true
12253
12841
  void (async () => {
12254
12842
  const state = G.floatState
12843
+ const paths = Array.isArray(state.tabs) ? state.tabs.filter((path) => typeof path === 'string' && path !== '') : []
12255
12844
  let projectValue = null
12256
12845
  if (typeof state.projectRoot === 'string' && state.projectRoot !== '') {
12257
12846
  try {
@@ -12263,20 +12852,28 @@ const GUFA_PLUGIN = {
12263
12852
  const restore = G.floatRestoreRef
12264
12853
  if (projectValue !== null && restore !== null && restore !== undefined && typeof restore.applyProject === 'function') {
12265
12854
  restore.applyProject(projectValue)
12855
+ void G.api('dev.log', { message: `float-restore project=${String(projectValue.root)} tabs=${paths.length}` }).catch(() => {})
12856
+ } else {
12857
+ void G.api('dev.log', { message: `float-restore-failed projectValue=${projectValue === null ? 'null' : 'ok'} ref=${restore !== null && restore !== undefined}` }).catch(() => {})
12266
12858
  }
12267
- await new Promise((resolve) => setTimeout(resolve, 350))
12268
- const paths = Array.isArray(state.tabs) ? state.tabs.filter((path) => typeof path === 'string' && path !== '') : []
12269
- const ordered = typeof state.activePath === 'string' && state.activePath !== ''
12270
- ? paths.filter((path) => path !== state.activePath).concat([state.activePath])
12271
- : paths
12272
- const openFile = restore !== null && restore !== undefined && typeof restore.openFile === 'function' ? restore.openFile : null
12273
- if (openFile !== null) {
12859
+ /* 先恢复 UI 面板状态(终端/视图等) */
12860
+ try {
12861
+ if (typeof G.floatApplyUiRef === 'function' && state.ui !== null && typeof state.ui === 'object') G.floatApplyUiRef(state.ui)
12862
+ } catch {
12863
+ /* ignore */
12864
+ }
12865
+ await new Promise((resolve) => setTimeout(resolve, 500))
12866
+ /* 按快照里的标签顺序打开,最后再激活 activePath,避免顺序漂移 */
12867
+ const ordered = paths
12868
+ const activeOne = typeof state.activePath === 'string' && state.activePath !== '' ? state.activePath : null
12869
+ /* 关键:applyProject 之后 App 已重渲染,取最新恢复入口;优先原子恢复标签集合 */
12870
+ await new Promise((resolve) => setTimeout(resolve, 250))
12871
+ const latest = G.floatRestoreRef
12872
+ if (latest !== null && latest !== undefined && typeof latest.applyTabs === 'function') {
12873
+ await latest.applyTabs(ordered, activeOne)
12874
+ } else if (latest !== null && latest !== undefined && typeof latest.openFile === 'function') {
12274
12875
  for (const path of ordered.slice(0, 10)) {
12275
- try {
12276
- await openFile(path)
12277
- } catch {
12278
- /* ignore */
12279
- }
12876
+ try { await latest.openFile(path) } catch { /* ignore */ }
12280
12877
  }
12281
12878
  }
12282
12879
  if (typeof state.sessionId === 'string' && state.sessionId !== '') {
@@ -12396,7 +12993,7 @@ const GUFA_PLUGIN = {
12396
12993
  try {
12397
12994
  const transport = typeof globalThis.__DSH_TRANSPORT__ === 'object' && globalThis.__DSH_TRANSPORT__ !== null ? globalThis.__DSH_TRANSPORT__ : null
12398
12995
  void G.api('dev.log', {
12399
- message: `boot href=${location.href} base=${G.serverBase()} transport=${transport === null ? 'none' : JSON.stringify(transport)}`,
12996
+ message: `boot build=${G.BUILD || '?'} href=${location.href} base=${G.serverBase()} transport=${transport === null ? 'none' : JSON.stringify(transport)}`,
12400
12997
  }).catch(() => {})
12401
12998
  } catch {
12402
12999
  /* 诊断失败不影响启动 */