dsh-gufa-code 1.3.56 → 1.3.58
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 +122 -13
- package/desktop/float/GufaFloat.m +10 -1
- package/desktop/float/bin/gufa-float-macos-arm64 +0 -0
- package/desktop/float/bin/gufa-float-macos-universal +0 -0
- package/desktop/float/bin/gufa-float-macos-x64 +0 -0
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/Info.plist +2 -2
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/MacOS/gufa-float +0 -0
- package/docs/KNOWN-PITFALLS.md +13 -0
- package/docs/PERFORMANCE.md +14 -0
- package/package.json +1 -1
- package/src/client/00-core.js +46 -1
- package/src/client/20-editor.js +16 -6
- package/src/client/90-app.js +9 -5
- package/src/client/99-main.js +50 -0
package/client.js
CHANGED
|
@@ -16,7 +16,7 @@ const GUFA_NS = 'gufa-code'
|
|
|
16
16
|
const G = {}
|
|
17
17
|
G.NS = GUFA_NS
|
|
18
18
|
/** 客户端构建标记(排查页面是否加载了新代码时看标题栏) */
|
|
19
|
-
G.BUILD = '1.3.
|
|
19
|
+
G.BUILD = '1.3.58'
|
|
20
20
|
G.PANEL_ID = 'gufa-code'
|
|
21
21
|
/** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
|
|
22
22
|
G.pendingEntryWorkspace = null
|
|
@@ -832,6 +832,19 @@ G.compositeColor = function compositeColor(foreground, background) {
|
|
|
832
832
|
* @returns {{bg:string, layer:string, layer2:string, overlay:string, sidebar:string}}
|
|
833
833
|
*/
|
|
834
834
|
G.resolveSolidPalette = function resolveSolidPalette(container) {
|
|
835
|
+
/* 摸鱼悬浮窗是独立的 http origin,拿不到主窗口的 DSH 主题(默认会是浅色);
|
|
836
|
+
摸鱼整窗本来就是深色半透明,这里强制返回深色实色板,避免出现浅色面板/看不清的弹窗。 */
|
|
837
|
+
try {
|
|
838
|
+
if (typeof document !== 'undefined' && document.documentElement !== null && document.documentElement.hasAttribute('data-gufa-float')) {
|
|
839
|
+
return {
|
|
840
|
+
bg: 'rgb(13, 15, 19)', layer: 'rgb(20, 22, 27)', layer2: 'rgb(26, 28, 34)', overlay: 'rgb(30, 33, 40)',
|
|
841
|
+
sidebar: 'rgb(18, 20, 24)', text: 'rgb(244, 241, 232)', textDim: 'rgb(166, 170, 176)',
|
|
842
|
+
accent: 'rgb(192, 57, 43)', isDark: true,
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
} catch {
|
|
846
|
+
/* ignore */
|
|
847
|
+
}
|
|
835
848
|
const dark = G.theme() === 'dark'
|
|
836
849
|
const fallbackPage = dark ? [26, 27, 31, 1] : [250, 250, 252, 1]
|
|
837
850
|
const fallbackSurface = dark ? [45, 46, 51, 1] : [255, 255, 255, 1]
|
|
@@ -1088,7 +1101,16 @@ G.CSS = `
|
|
|
1088
1101
|
.gufa-backdrop{position:absolute;inset:0;z-index:0;overflow:hidden;pointer-events:none}
|
|
1089
1102
|
/* 桌面悬浮层(摸鱼)模式:整窗半透明,透明度由 --gufa-float-alpha 控制(标题栏滑块) */
|
|
1090
1103
|
html[data-gufa-float]{--gufa-float-alpha:0.55}
|
|
1091
|
-
html[data-gufa-float] body{background:transparent!important
|
|
1104
|
+
html[data-gufa-float] body{background:transparent!important;color-scheme:dark;
|
|
1105
|
+
--dsw-alias-label-primary:#f4f1e8!important;--dsw-alias-label-secondary:rgba(244,241,232,0.72)!important;
|
|
1106
|
+
--dsw-alias-bg-base:#0d0f13!important;--dsw-alias-bg-layer-1:#14161b!important;--dsw-alias-bg-layer-2:#1a1e24!important;
|
|
1107
|
+
--dsw-alias-bg-overlay:#22262e!important;
|
|
1108
|
+
--dsw-alias-border-l1:rgba(255,255,255,0.12)!important;--dsw-alias-border-l2:rgba(255,255,255,0.2)!important;
|
|
1109
|
+
}
|
|
1110
|
+
html[data-gufa-float] .gufa-root,
|
|
1111
|
+
html[data-gufa-float] .gufa-overlay-root{
|
|
1112
|
+
--gufa-solid-text:#f4f1e8!important;--gufa-solid-text-dim:rgba(244,241,232,0.68)!important;
|
|
1113
|
+
}
|
|
1092
1114
|
html[data-gufa-float] .gufa-overlay-root,
|
|
1093
1115
|
html[data-gufa-float] .gufa-root{
|
|
1094
1116
|
--gufa-solid-bg:rgba(13,15,19,var(--gufa-float-alpha))!important;--gufa-bg:rgba(13,15,19,var(--gufa-float-alpha))!important;
|
|
@@ -1108,6 +1130,29 @@ html[data-gufa-float] .gufa-overlay-root::before{
|
|
|
1108
1130
|
background:rgba(13,15,19,var(--gufa-float-alpha));z-index:1;
|
|
1109
1131
|
}
|
|
1110
1132
|
html[data-gufa-float] .gufa-overlay-root{background:transparent!important;padding-top:22px;box-sizing:border-box}
|
|
1133
|
+
/* 摸鱼模式:弹窗/菜单都在 body 级 portal 里,拿不到摸鱼覆盖层的深色主题;
|
|
1134
|
+
强制给 portal 一套深色可读变量,避免出现「浅色弹窗 + 浅色文字」看不清的问题。 */
|
|
1135
|
+
html[data-gufa-float] #gufa-portal-root{
|
|
1136
|
+
--gufa-solid-bg:#121418!important;--gufa-solid-layer:#191c21!important;--gufa-solid-layer2:#1e2228!important;--gufa-solid-overlay:#23272e!important;
|
|
1137
|
+
--gufa-solid-text:#f4f1e8!important;--gufa-solid-text-dim:rgba(244,241,232,0.68)!important;
|
|
1138
|
+
--dsw-alias-bg-base:#121418!important;--dsw-alias-bg-layer-1:#191c21!important;--dsw-alias-bg-layer-2:#1e2228!important;--dsw-alias-bg-overlay:#23272e!important;
|
|
1139
|
+
--dsw-alias-label-primary:#f4f1e8!important;--dsw-alias-label-secondary:rgba(244,241,232,0.68)!important;
|
|
1140
|
+
--dsw-alias-border-l1:rgba(255,255,255,0.12)!important;--dsw-alias-border-l2:rgba(255,255,255,0.2)!important;
|
|
1141
|
+
color:#f4f1e8!important;
|
|
1142
|
+
}
|
|
1143
|
+
html[data-gufa-float] #gufa-portal-root .gufa-modal,
|
|
1144
|
+
html[data-gufa-float] #gufa-portal-root .gufa-sessions-dialog,
|
|
1145
|
+
html[data-gufa-float] #gufa-portal-root .gufa-workspace-dialog,
|
|
1146
|
+
html[data-gufa-float] #gufa-portal-root .gufa-float-picker,
|
|
1147
|
+
html[data-gufa-float] #gufa-portal-root .gufa-shortcuts-dialog,
|
|
1148
|
+
html[data-gufa-float] #gufa-portal-root .gufa-graph-dialog{background:#1b1f26!important;color:#f4f1e8!important}
|
|
1149
|
+
html[data-gufa-float] #gufa-portal-root .gufa-modal-backdrop,
|
|
1150
|
+
html[data-gufa-float] .gufa-float-backdrop{
|
|
1151
|
+
background:rgba(0,0,0,0.66)!important;backdrop-filter:none!important;-webkit-backdrop-filter:none!important;
|
|
1152
|
+
}
|
|
1153
|
+
/* 摸鱼:所有 portal 弹窗/菜单/输入框不透明,保证字看得清 */
|
|
1154
|
+
html[data-gufa-float] #gufa-portal-root *{color:inherit}
|
|
1155
|
+
html[data-gufa-float] #gufa-portal-root .gufa-hint{color:rgba(244,241,232,0.72)!important}
|
|
1111
1156
|
/* 摸鱼:整窗只保留「覆盖层根节点」这一层半透明底,其余面板/会话/终端全部透明,
|
|
1112
1157
|
保证编辑器、会话框、终端框看到的透明度完全一致(都等于滑块的 alpha)。 */
|
|
1113
1158
|
html[data-gufa-float] .gufa-overlay-root{background:rgba(13,15,19,var(--gufa-float-alpha))!important}
|
|
@@ -3115,14 +3160,24 @@ G.FooterAction = function FooterAction(props) {
|
|
|
3115
3160
|
lastPropContentRef.current.set(tab.path, content)
|
|
3116
3161
|
continue
|
|
3117
3162
|
}
|
|
3118
|
-
|
|
3163
|
+
const knownContent = lastPropContentRef.current.get(tab.path)
|
|
3164
|
+
if (knownContent !== content) {
|
|
3119
3165
|
lastPropContentRef.current.set(tab.path, content)
|
|
3120
3166
|
if (model.getValue() !== content) {
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3167
|
+
/* 用户在编辑器里持续输入时,App 的 tabs 状态可能落后(内容缓冲/React 批处理)。
|
|
3168
|
+
如果当前 model 正好还是上次上报的内容,说明这是「状态落后」而不是外部修改,
|
|
3169
|
+
绝不能 setValue 回灌旧内容——否则光标会跳回开头、刚输入的字符也会被覆盖。
|
|
3170
|
+
外部修改(如切回文件、外部刷新)通常发生在编辑器没有焦点时,仍然照常同步。 */
|
|
3171
|
+
const modelValue = model.getValue()
|
|
3172
|
+
const modelMatchesKnown = knownContent === undefined || knownContent === null || knownContent === modelValue
|
|
3173
|
+
const focused = typeof editor.hasTextFocus === 'function' ? editor.hasTextFocus() : false
|
|
3174
|
+
if (!(focused && modelMatchesKnown)) {
|
|
3175
|
+
suppressChangeRef.current = true
|
|
3176
|
+
try {
|
|
3177
|
+
model.setValue(content)
|
|
3178
|
+
} finally {
|
|
3179
|
+
suppressChangeRef.current = false
|
|
3180
|
+
}
|
|
3126
3181
|
}
|
|
3127
3182
|
}
|
|
3128
3183
|
}
|
|
@@ -10115,10 +10170,12 @@ G.GufaApp = function GufaApp(props) {
|
|
|
10115
10170
|
let changed = false
|
|
10116
10171
|
const next = current.map((item) => {
|
|
10117
10172
|
if (item === null || item.path !== path) return item
|
|
10118
|
-
|
|
10173
|
+
/* 用缓冲里的最新内容而不是本次按键的内容:避免 React 批处理时把「第一次按键」的旧内容回灌给编辑器。 */
|
|
10174
|
+
const latest = editorBuffersRef.current.has(path) ? editorBuffersRef.current.get(path) : content
|
|
10175
|
+
const dirty = latest !== item.savedContent
|
|
10119
10176
|
if (item.dirty === dirty) return item
|
|
10120
10177
|
changed = true
|
|
10121
|
-
return { ...item, dirty }
|
|
10178
|
+
return { ...item, content: latest, dirty }
|
|
10122
10179
|
})
|
|
10123
10180
|
if (!changed) return current
|
|
10124
10181
|
tabsRef.current = next
|
|
@@ -11795,6 +11852,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11795
11852
|
if (selectionTimerRef.current !== null) { window.clearTimeout(selectionTimerRef.current); selectionTimerRef.current = null }
|
|
11796
11853
|
}, [])
|
|
11797
11854
|
|
|
11855
|
+
const uiTheme = moyuMode ? 'dark' : theme
|
|
11798
11856
|
const statusBranch = project?.isGit === true && gitStatus?.branch ? gitStatus.branch : null
|
|
11799
11857
|
const lineCount = activeTab === null || activeTab.kind === 'graph' ? 0 : String(activeTab.content ?? '').split('\n').length
|
|
11800
11858
|
|
|
@@ -11985,7 +12043,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11985
12043
|
: h(G.EditorPane, {
|
|
11986
12044
|
tabs,
|
|
11987
12045
|
activePath,
|
|
11988
|
-
theme,
|
|
12046
|
+
theme: uiTheme,
|
|
11989
12047
|
palette: solidPalette,
|
|
11990
12048
|
root: project?.root ?? '',
|
|
11991
12049
|
onSelectTab: handleSelectTab,
|
|
@@ -12008,7 +12066,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
12008
12066
|
root: project?.root ?? null,
|
|
12009
12067
|
visible: true,
|
|
12010
12068
|
height: terminalHeight,
|
|
12011
|
-
theme,
|
|
12069
|
+
theme: uiTheme,
|
|
12012
12070
|
palette: solidPalette,
|
|
12013
12071
|
onToggleHeight: () => patchUi({ terminalOpen: false }),
|
|
12014
12072
|
}),
|
|
@@ -12028,11 +12086,12 @@ G.GufaApp = function GufaApp(props) {
|
|
|
12028
12086
|
project,
|
|
12029
12087
|
activeFile: activeFileForChat,
|
|
12030
12088
|
selection: selectionForChat,
|
|
12031
|
-
theme,
|
|
12089
|
+
theme: uiTheme,
|
|
12032
12090
|
width: chatWidth,
|
|
12033
12091
|
active: true,
|
|
12034
12092
|
paused: sessionsOpen,
|
|
12035
12093
|
backdrop: backdropActive,
|
|
12094
|
+
theme: uiTheme,
|
|
12036
12095
|
sessionTitle,
|
|
12037
12096
|
onOpenSessions: () => setSessionsOpen(true),
|
|
12038
12097
|
onInsertCode: insertCode,
|
|
@@ -13217,6 +13276,56 @@ const GUFA_PLUGIN = {
|
|
|
13217
13276
|
}
|
|
13218
13277
|
}
|
|
13219
13278
|
|
|
13279
|
+
// 临时诊断(1.3.57):摸鱼窗口里点不到左树/编辑器时,看看点击落到了哪个元素
|
|
13280
|
+
try {
|
|
13281
|
+
if (document.documentElement.hasAttribute('data-gufa-float') || /[?&]gufa-float=1/.test(location.search)) {
|
|
13282
|
+
setTimeout(() => {
|
|
13283
|
+
const probeAt = (x, y) => {
|
|
13284
|
+
try {
|
|
13285
|
+
const node = document.elementFromPoint(x, y)
|
|
13286
|
+
if (node === null) return `${x},${y}:none`
|
|
13287
|
+
const cls = typeof node.className === 'string' ? node.className : ''
|
|
13288
|
+
return `${x},${y}:${node.tagName}.${String(cls).slice(0, 60)}`
|
|
13289
|
+
} catch (error) {
|
|
13290
|
+
return `${x},${y}:err`
|
|
13291
|
+
}
|
|
13292
|
+
}
|
|
13293
|
+
// 模态框深色可读性:往 portal 里塞一个临时 .gufa-modal 读计算样式
|
|
13294
|
+
let modalInfo = 'none'
|
|
13295
|
+
try {
|
|
13296
|
+
const host = document.getElementById('gufa-portal-root')
|
|
13297
|
+
if (host !== null) {
|
|
13298
|
+
const probe = document.createElement('div')
|
|
13299
|
+
probe.className = 'gufa-modal'
|
|
13300
|
+
probe.style.cssText = 'position:fixed;left:-9999px;top:0;width:120px;height:60px'
|
|
13301
|
+
host.appendChild(probe)
|
|
13302
|
+
const cs = window.getComputedStyle(probe)
|
|
13303
|
+
modalInfo = `bg=${cs.backgroundColor} color=${cs.color}`
|
|
13304
|
+
probe.remove()
|
|
13305
|
+
}
|
|
13306
|
+
} catch {
|
|
13307
|
+
modalInfo = 'err'
|
|
13308
|
+
}
|
|
13309
|
+
// 找树行实际坐标(摸鱼窗半透明,肉眼看不清哪些行是古法的)
|
|
13310
|
+
const rows = []
|
|
13311
|
+
for (let y = 80; y < 1000; y += 22) {
|
|
13312
|
+
try {
|
|
13313
|
+
const node = document.elementFromPoint(100, y)
|
|
13314
|
+
if (node !== null && typeof node.closest === 'function') {
|
|
13315
|
+
const row = node.closest('.gufa-tree-row')
|
|
13316
|
+
if (row !== null) rows.push(`${y}:${String(row.textContent ?? '').trim().slice(0, 24)}`)
|
|
13317
|
+
}
|
|
13318
|
+
} catch {
|
|
13319
|
+
/* ignore */
|
|
13320
|
+
}
|
|
13321
|
+
}
|
|
13322
|
+
void G.api('dev.log', { message: `float-hittest ${probeAt(135, 713)} | ${probeAt(300, 713)} | ${probeAt(900, 500)} | ${probeAt(1500, 60)} | modal[${modalInfo}] | rows[${rows.slice(0, 12).join(' ; ')}]` }).catch(() => {})
|
|
13323
|
+
}, 5000)
|
|
13324
|
+
}
|
|
13325
|
+
} catch {
|
|
13326
|
+
/* ignore */
|
|
13327
|
+
}
|
|
13328
|
+
|
|
13220
13329
|
// 启动诊断:记录页面地址、真实 Host 基址与传输信息(排查桌面壳 dsh-app:// 连接问题)。
|
|
13221
13330
|
try {
|
|
13222
13331
|
const transport = typeof globalThis.__DSH_TRANSPORT__ === 'object' && globalThis.__DSH_TRANSPORT__ !== null ? globalThis.__DSH_TRANSPORT__ : null
|
|
@@ -63,6 +63,15 @@ static void GufaInstallTermHandler(void);
|
|
|
63
63
|
|
|
64
64
|
static OSStatus GufaHotKeyHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData);
|
|
65
65
|
|
|
66
|
+
/* 无边框窗口默认 canBecomeKeyWindow=NO;显式允许成为 key/main 窗口,
|
|
67
|
+
否则悬浮层里的终端/编辑器/聊天输入都收不到键盘事件。 */
|
|
68
|
+
@interface GufaFloatWindow : NSWindow
|
|
69
|
+
@end
|
|
70
|
+
@implementation GufaFloatWindow
|
|
71
|
+
- (BOOL)canBecomeKeyWindow { return YES; }
|
|
72
|
+
- (BOOL)canBecomeMainWindow { return YES; }
|
|
73
|
+
@end
|
|
74
|
+
|
|
66
75
|
@interface GufaDragStrip : NSView
|
|
67
76
|
@end
|
|
68
77
|
|
|
@@ -341,7 +350,7 @@ static OSStatus GufaHotKeyHandler(EventHandlerCallRef nextHandler, EventRef even
|
|
|
341
350
|
}
|
|
342
351
|
}
|
|
343
352
|
|
|
344
|
-
self.window = [[
|
|
353
|
+
self.window = [[GufaFloatWindow alloc] initWithContentRect:frame
|
|
345
354
|
styleMask:(NSWindowStyleMaskBorderless | NSWindowStyleMaskResizable)
|
|
346
355
|
backing:NSBackingStoreBuffered
|
|
347
356
|
defer:NO];
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
<key>CFBundleDisplayName</key><string>古法编程悬浮层</string>
|
|
8
8
|
<key>CFBundleExecutable</key><string>gufa-float</string>
|
|
9
9
|
<key>CFBundlePackageType</key><string>APPL</string>
|
|
10
|
-
<key>CFBundleShortVersionString</key><string>1.3.
|
|
11
|
-
<key>CFBundleVersion</key><string>1.3.
|
|
10
|
+
<key>CFBundleShortVersionString</key><string>1.3.58</string>
|
|
11
|
+
<key>CFBundleVersion</key><string>1.3.58</string>
|
|
12
12
|
<key>LSUIElement</key><true/>
|
|
13
13
|
<key>NSHighResolutionCapable</key><true/>
|
|
14
14
|
<key>NSPrincipalClass</key><string>NSApplication</string>
|
|
Binary file
|
package/docs/KNOWN-PITFALLS.md
CHANGED
|
@@ -104,6 +104,19 @@
|
|
|
104
104
|
`SLSAddWindowsToSpaces` 把自己的窗口加进去(实测 `use-active-space=8234 err=0`)。
|
|
105
105
|
3. 私有 API 全部 dlsym,符号缺失时只记日志不影响主流程。
|
|
106
106
|
|
|
107
|
+
## 摸鱼窗口里的两个系统性问题(1.3.57 修复)
|
|
108
|
+
|
|
109
|
+
1. **摸鱼窗口是独立 http origin,DSH 主题默认是浅色**:主窗口(dsh-app://)的深色主题在悬浮窗里不存在,
|
|
110
|
+
导致 IDE 面板/弹窗呈现浅色:深色半透明底 + 浅色文字/弹窗,字看不清。
|
|
111
|
+
- 修复:`G.resolveSolidPalette` 在 `html[data-gufa-float]` 下强制返回深色实色板;
|
|
112
|
+
`html[data-gufa-float] body` 与 `#gufa-portal-root` 强制深色 `--dsw-alias-*` token;
|
|
113
|
+
App 在摸鱼模式把 `theme` 固定为 `dark`(Monaco/终端)。
|
|
114
|
+
- 注意:portal/弹窗在 body 层,CSS 变量要用 `!important`,因为 `applyPalette` 会往 portal 上写 inline 变量。
|
|
115
|
+
2. **无边框 NSWindow 默认 `canBecomeKeyWindow=NO`**:悬浮窗收不到键盘事件,终端/编辑器/聊天都输入不了。
|
|
116
|
+
- 修复:`GufaFloatWindow` 子类覆写 `canBecomeKeyWindow/canBecomeMainWindow` 返回 YES。
|
|
117
|
+
- 排查要点:`float-hittest` 日志会打印 elementFromPoint 与临时 `.gufa-modal` 的计算样式(bg/color),
|
|
118
|
+
`float-styles` 打印覆盖层透明度;终端输入问题优先看窗口是否 key,而不是 transport。
|
|
119
|
+
|
|
107
120
|
## 5.1 摸鱼会话框比编辑器黑:官方会话根节点自己又画了一层底
|
|
108
121
|
|
|
109
122
|
- 现象:摸鱼里编辑器/终端都统一了,右侧会话框看起来明显更黑更实。
|
package/docs/PERFORMANCE.md
CHANGED
|
@@ -30,6 +30,20 @@ Monaco 本身很快;古法编程编辑器之前卡顿的主要原因是 **Reac
|
|
|
30
30
|
- `Cmd+Z` 撤销后自动保存把文件恢复为原始内容(与 baseline 全等);
|
|
31
31
|
- 三套测试 99 / 44 / 19 全过。
|
|
32
32
|
|
|
33
|
+
## 坑:内容缓冲不能把旧内容回灌给 Monaco(1.3.58 修复)
|
|
34
|
+
|
|
35
|
+
缓冲方案第一版在「干净→脏」的状态更新里只改了 `dirty`、没带最新 `content`,
|
|
36
|
+
导致 App 用旧的 `tabs.content` 重渲染 → EditorPane 的 model 同步逻辑误判为外部修改并
|
|
37
|
+
`model.setValue(旧内容)` → 用户刚输入的内容被覆盖、光标跳回开头。
|
|
38
|
+
|
|
39
|
+
修复:
|
|
40
|
+
1. 脏标记更新时把**缓冲里最新内容**一起写进 tabs;
|
|
41
|
+
2. EditorPane 同步 model 时增加保护:如果编辑器有焦点、且 model 内容仍等于上次上报内容,
|
|
42
|
+
就认定是 App 状态暂时落后,**不 setValue**;只有非焦点场景/真正外部更新才同步。
|
|
43
|
+
|
|
44
|
+
回归验证:主窗口 113 行文件输入 `abcdef` → 内容保留、光标不跳;自动保存写入 +6 字节;
|
|
45
|
+
`Cmd+Z` 后恢复原始内容(1498 字节逐字节相等)。
|
|
46
|
+
|
|
33
47
|
## 后续可继续优化(未做)
|
|
34
48
|
|
|
35
49
|
- 超大文件(数万行)时 Monaco `model.getValue()` 每次变更复制整个字符串,可改为增量取内容/仅在 flush 时取;
|
package/package.json
CHANGED
package/src/client/00-core.js
CHANGED
|
@@ -824,6 +824,19 @@ G.compositeColor = function compositeColor(foreground, background) {
|
|
|
824
824
|
* @returns {{bg:string, layer:string, layer2:string, overlay:string, sidebar:string}}
|
|
825
825
|
*/
|
|
826
826
|
G.resolveSolidPalette = function resolveSolidPalette(container) {
|
|
827
|
+
/* 摸鱼悬浮窗是独立的 http origin,拿不到主窗口的 DSH 主题(默认会是浅色);
|
|
828
|
+
摸鱼整窗本来就是深色半透明,这里强制返回深色实色板,避免出现浅色面板/看不清的弹窗。 */
|
|
829
|
+
try {
|
|
830
|
+
if (typeof document !== 'undefined' && document.documentElement !== null && document.documentElement.hasAttribute('data-gufa-float')) {
|
|
831
|
+
return {
|
|
832
|
+
bg: 'rgb(13, 15, 19)', layer: 'rgb(20, 22, 27)', layer2: 'rgb(26, 28, 34)', overlay: 'rgb(30, 33, 40)',
|
|
833
|
+
sidebar: 'rgb(18, 20, 24)', text: 'rgb(244, 241, 232)', textDim: 'rgb(166, 170, 176)',
|
|
834
|
+
accent: 'rgb(192, 57, 43)', isDark: true,
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
} catch {
|
|
838
|
+
/* ignore */
|
|
839
|
+
}
|
|
827
840
|
const dark = G.theme() === 'dark'
|
|
828
841
|
const fallbackPage = dark ? [26, 27, 31, 1] : [250, 250, 252, 1]
|
|
829
842
|
const fallbackSurface = dark ? [45, 46, 51, 1] : [255, 255, 255, 1]
|
|
@@ -1080,7 +1093,16 @@ G.CSS = `
|
|
|
1080
1093
|
.gufa-backdrop{position:absolute;inset:0;z-index:0;overflow:hidden;pointer-events:none}
|
|
1081
1094
|
/* 桌面悬浮层(摸鱼)模式:整窗半透明,透明度由 --gufa-float-alpha 控制(标题栏滑块) */
|
|
1082
1095
|
html[data-gufa-float]{--gufa-float-alpha:0.55}
|
|
1083
|
-
html[data-gufa-float] body{background:transparent!important
|
|
1096
|
+
html[data-gufa-float] body{background:transparent!important;color-scheme:dark;
|
|
1097
|
+
--dsw-alias-label-primary:#f4f1e8!important;--dsw-alias-label-secondary:rgba(244,241,232,0.72)!important;
|
|
1098
|
+
--dsw-alias-bg-base:#0d0f13!important;--dsw-alias-bg-layer-1:#14161b!important;--dsw-alias-bg-layer-2:#1a1e24!important;
|
|
1099
|
+
--dsw-alias-bg-overlay:#22262e!important;
|
|
1100
|
+
--dsw-alias-border-l1:rgba(255,255,255,0.12)!important;--dsw-alias-border-l2:rgba(255,255,255,0.2)!important;
|
|
1101
|
+
}
|
|
1102
|
+
html[data-gufa-float] .gufa-root,
|
|
1103
|
+
html[data-gufa-float] .gufa-overlay-root{
|
|
1104
|
+
--gufa-solid-text:#f4f1e8!important;--gufa-solid-text-dim:rgba(244,241,232,0.68)!important;
|
|
1105
|
+
}
|
|
1084
1106
|
html[data-gufa-float] .gufa-overlay-root,
|
|
1085
1107
|
html[data-gufa-float] .gufa-root{
|
|
1086
1108
|
--gufa-solid-bg:rgba(13,15,19,var(--gufa-float-alpha))!important;--gufa-bg:rgba(13,15,19,var(--gufa-float-alpha))!important;
|
|
@@ -1100,6 +1122,29 @@ html[data-gufa-float] .gufa-overlay-root::before{
|
|
|
1100
1122
|
background:rgba(13,15,19,var(--gufa-float-alpha));z-index:1;
|
|
1101
1123
|
}
|
|
1102
1124
|
html[data-gufa-float] .gufa-overlay-root{background:transparent!important;padding-top:22px;box-sizing:border-box}
|
|
1125
|
+
/* 摸鱼模式:弹窗/菜单都在 body 级 portal 里,拿不到摸鱼覆盖层的深色主题;
|
|
1126
|
+
强制给 portal 一套深色可读变量,避免出现「浅色弹窗 + 浅色文字」看不清的问题。 */
|
|
1127
|
+
html[data-gufa-float] #gufa-portal-root{
|
|
1128
|
+
--gufa-solid-bg:#121418!important;--gufa-solid-layer:#191c21!important;--gufa-solid-layer2:#1e2228!important;--gufa-solid-overlay:#23272e!important;
|
|
1129
|
+
--gufa-solid-text:#f4f1e8!important;--gufa-solid-text-dim:rgba(244,241,232,0.68)!important;
|
|
1130
|
+
--dsw-alias-bg-base:#121418!important;--dsw-alias-bg-layer-1:#191c21!important;--dsw-alias-bg-layer-2:#1e2228!important;--dsw-alias-bg-overlay:#23272e!important;
|
|
1131
|
+
--dsw-alias-label-primary:#f4f1e8!important;--dsw-alias-label-secondary:rgba(244,241,232,0.68)!important;
|
|
1132
|
+
--dsw-alias-border-l1:rgba(255,255,255,0.12)!important;--dsw-alias-border-l2:rgba(255,255,255,0.2)!important;
|
|
1133
|
+
color:#f4f1e8!important;
|
|
1134
|
+
}
|
|
1135
|
+
html[data-gufa-float] #gufa-portal-root .gufa-modal,
|
|
1136
|
+
html[data-gufa-float] #gufa-portal-root .gufa-sessions-dialog,
|
|
1137
|
+
html[data-gufa-float] #gufa-portal-root .gufa-workspace-dialog,
|
|
1138
|
+
html[data-gufa-float] #gufa-portal-root .gufa-float-picker,
|
|
1139
|
+
html[data-gufa-float] #gufa-portal-root .gufa-shortcuts-dialog,
|
|
1140
|
+
html[data-gufa-float] #gufa-portal-root .gufa-graph-dialog{background:#1b1f26!important;color:#f4f1e8!important}
|
|
1141
|
+
html[data-gufa-float] #gufa-portal-root .gufa-modal-backdrop,
|
|
1142
|
+
html[data-gufa-float] .gufa-float-backdrop{
|
|
1143
|
+
background:rgba(0,0,0,0.66)!important;backdrop-filter:none!important;-webkit-backdrop-filter:none!important;
|
|
1144
|
+
}
|
|
1145
|
+
/* 摸鱼:所有 portal 弹窗/菜单/输入框不透明,保证字看得清 */
|
|
1146
|
+
html[data-gufa-float] #gufa-portal-root *{color:inherit}
|
|
1147
|
+
html[data-gufa-float] #gufa-portal-root .gufa-hint{color:rgba(244,241,232,0.72)!important}
|
|
1103
1148
|
/* 摸鱼:整窗只保留「覆盖层根节点」这一层半透明底,其余面板/会话/终端全部透明,
|
|
1104
1149
|
保证编辑器、会话框、终端框看到的透明度完全一致(都等于滑块的 alpha)。 */
|
|
1105
1150
|
html[data-gufa-float] .gufa-overlay-root{background:rgba(13,15,19,var(--gufa-float-alpha))!important}
|
package/src/client/20-editor.js
CHANGED
|
@@ -919,14 +919,24 @@
|
|
|
919
919
|
lastPropContentRef.current.set(tab.path, content)
|
|
920
920
|
continue
|
|
921
921
|
}
|
|
922
|
-
|
|
922
|
+
const knownContent = lastPropContentRef.current.get(tab.path)
|
|
923
|
+
if (knownContent !== content) {
|
|
923
924
|
lastPropContentRef.current.set(tab.path, content)
|
|
924
925
|
if (model.getValue() !== content) {
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
926
|
+
/* 用户在编辑器里持续输入时,App 的 tabs 状态可能落后(内容缓冲/React 批处理)。
|
|
927
|
+
如果当前 model 正好还是上次上报的内容,说明这是「状态落后」而不是外部修改,
|
|
928
|
+
绝不能 setValue 回灌旧内容——否则光标会跳回开头、刚输入的字符也会被覆盖。
|
|
929
|
+
外部修改(如切回文件、外部刷新)通常发生在编辑器没有焦点时,仍然照常同步。 */
|
|
930
|
+
const modelValue = model.getValue()
|
|
931
|
+
const modelMatchesKnown = knownContent === undefined || knownContent === null || knownContent === modelValue
|
|
932
|
+
const focused = typeof editor.hasTextFocus === 'function' ? editor.hasTextFocus() : false
|
|
933
|
+
if (!(focused && modelMatchesKnown)) {
|
|
934
|
+
suppressChangeRef.current = true
|
|
935
|
+
try {
|
|
936
|
+
model.setValue(content)
|
|
937
|
+
} finally {
|
|
938
|
+
suppressChangeRef.current = false
|
|
939
|
+
}
|
|
930
940
|
}
|
|
931
941
|
}
|
|
932
942
|
}
|
package/src/client/90-app.js
CHANGED
|
@@ -500,10 +500,12 @@ G.GufaApp = function GufaApp(props) {
|
|
|
500
500
|
let changed = false
|
|
501
501
|
const next = current.map((item) => {
|
|
502
502
|
if (item === null || item.path !== path) return item
|
|
503
|
-
|
|
503
|
+
/* 用缓冲里的最新内容而不是本次按键的内容:避免 React 批处理时把「第一次按键」的旧内容回灌给编辑器。 */
|
|
504
|
+
const latest = editorBuffersRef.current.has(path) ? editorBuffersRef.current.get(path) : content
|
|
505
|
+
const dirty = latest !== item.savedContent
|
|
504
506
|
if (item.dirty === dirty) return item
|
|
505
507
|
changed = true
|
|
506
|
-
return { ...item, dirty }
|
|
508
|
+
return { ...item, content: latest, dirty }
|
|
507
509
|
})
|
|
508
510
|
if (!changed) return current
|
|
509
511
|
tabsRef.current = next
|
|
@@ -2180,6 +2182,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2180
2182
|
if (selectionTimerRef.current !== null) { window.clearTimeout(selectionTimerRef.current); selectionTimerRef.current = null }
|
|
2181
2183
|
}, [])
|
|
2182
2184
|
|
|
2185
|
+
const uiTheme = moyuMode ? 'dark' : theme
|
|
2183
2186
|
const statusBranch = project?.isGit === true && gitStatus?.branch ? gitStatus.branch : null
|
|
2184
2187
|
const lineCount = activeTab === null || activeTab.kind === 'graph' ? 0 : String(activeTab.content ?? '').split('\n').length
|
|
2185
2188
|
|
|
@@ -2370,7 +2373,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2370
2373
|
: h(G.EditorPane, {
|
|
2371
2374
|
tabs,
|
|
2372
2375
|
activePath,
|
|
2373
|
-
theme,
|
|
2376
|
+
theme: uiTheme,
|
|
2374
2377
|
palette: solidPalette,
|
|
2375
2378
|
root: project?.root ?? '',
|
|
2376
2379
|
onSelectTab: handleSelectTab,
|
|
@@ -2393,7 +2396,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2393
2396
|
root: project?.root ?? null,
|
|
2394
2397
|
visible: true,
|
|
2395
2398
|
height: terminalHeight,
|
|
2396
|
-
theme,
|
|
2399
|
+
theme: uiTheme,
|
|
2397
2400
|
palette: solidPalette,
|
|
2398
2401
|
onToggleHeight: () => patchUi({ terminalOpen: false }),
|
|
2399
2402
|
}),
|
|
@@ -2413,11 +2416,12 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2413
2416
|
project,
|
|
2414
2417
|
activeFile: activeFileForChat,
|
|
2415
2418
|
selection: selectionForChat,
|
|
2416
|
-
theme,
|
|
2419
|
+
theme: uiTheme,
|
|
2417
2420
|
width: chatWidth,
|
|
2418
2421
|
active: true,
|
|
2419
2422
|
paused: sessionsOpen,
|
|
2420
2423
|
backdrop: backdropActive,
|
|
2424
|
+
theme: uiTheme,
|
|
2421
2425
|
sessionTitle,
|
|
2422
2426
|
onOpenSessions: () => setSessionsOpen(true),
|
|
2423
2427
|
onInsertCode: insertCode,
|
package/src/client/99-main.js
CHANGED
|
@@ -503,6 +503,56 @@ const GUFA_PLUGIN = {
|
|
|
503
503
|
}
|
|
504
504
|
}
|
|
505
505
|
|
|
506
|
+
// 临时诊断(1.3.57):摸鱼窗口里点不到左树/编辑器时,看看点击落到了哪个元素
|
|
507
|
+
try {
|
|
508
|
+
if (document.documentElement.hasAttribute('data-gufa-float') || /[?&]gufa-float=1/.test(location.search)) {
|
|
509
|
+
setTimeout(() => {
|
|
510
|
+
const probeAt = (x, y) => {
|
|
511
|
+
try {
|
|
512
|
+
const node = document.elementFromPoint(x, y)
|
|
513
|
+
if (node === null) return `${x},${y}:none`
|
|
514
|
+
const cls = typeof node.className === 'string' ? node.className : ''
|
|
515
|
+
return `${x},${y}:${node.tagName}.${String(cls).slice(0, 60)}`
|
|
516
|
+
} catch (error) {
|
|
517
|
+
return `${x},${y}:err`
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
// 模态框深色可读性:往 portal 里塞一个临时 .gufa-modal 读计算样式
|
|
521
|
+
let modalInfo = 'none'
|
|
522
|
+
try {
|
|
523
|
+
const host = document.getElementById('gufa-portal-root')
|
|
524
|
+
if (host !== null) {
|
|
525
|
+
const probe = document.createElement('div')
|
|
526
|
+
probe.className = 'gufa-modal'
|
|
527
|
+
probe.style.cssText = 'position:fixed;left:-9999px;top:0;width:120px;height:60px'
|
|
528
|
+
host.appendChild(probe)
|
|
529
|
+
const cs = window.getComputedStyle(probe)
|
|
530
|
+
modalInfo = `bg=${cs.backgroundColor} color=${cs.color}`
|
|
531
|
+
probe.remove()
|
|
532
|
+
}
|
|
533
|
+
} catch {
|
|
534
|
+
modalInfo = 'err'
|
|
535
|
+
}
|
|
536
|
+
// 找树行实际坐标(摸鱼窗半透明,肉眼看不清哪些行是古法的)
|
|
537
|
+
const rows = []
|
|
538
|
+
for (let y = 80; y < 1000; y += 22) {
|
|
539
|
+
try {
|
|
540
|
+
const node = document.elementFromPoint(100, y)
|
|
541
|
+
if (node !== null && typeof node.closest === 'function') {
|
|
542
|
+
const row = node.closest('.gufa-tree-row')
|
|
543
|
+
if (row !== null) rows.push(`${y}:${String(row.textContent ?? '').trim().slice(0, 24)}`)
|
|
544
|
+
}
|
|
545
|
+
} catch {
|
|
546
|
+
/* ignore */
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
void G.api('dev.log', { message: `float-hittest ${probeAt(135, 713)} | ${probeAt(300, 713)} | ${probeAt(900, 500)} | ${probeAt(1500, 60)} | modal[${modalInfo}] | rows[${rows.slice(0, 12).join(' ; ')}]` }).catch(() => {})
|
|
550
|
+
}, 5000)
|
|
551
|
+
}
|
|
552
|
+
} catch {
|
|
553
|
+
/* ignore */
|
|
554
|
+
}
|
|
555
|
+
|
|
506
556
|
// 启动诊断:记录页面地址、真实 Host 基址与传输信息(排查桌面壳 dsh-app:// 连接问题)。
|
|
507
557
|
try {
|
|
508
558
|
const transport = typeof globalThis.__DSH_TRANSPORT__ === 'object' && globalThis.__DSH_TRANSPORT__ !== null ? globalThis.__DSH_TRANSPORT__ : null
|