dsh-ris-ide 1.6.9 → 1.6.11
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 +3 -3
- package/lib/client.js +358 -119
- package/lib/index.js +13 -5
- package/package.json +1 -1
- package/test/client-viewer.test.mjs +174 -13
package/README.md
CHANGED
|
@@ -25,14 +25,14 @@ DSH(DeepSeek Harness)Web GUI 右侧栏里的 **RIS-IDE 本地开发面板**
|
|
|
25
25
|
|
|
26
26
|
## 功能
|
|
27
27
|
|
|
28
|
-
- **日志实时跟随**:`.log` 不停在打开那一刻;按行着色(ANSI / ERROR-WARN-INFO
|
|
28
|
+
- **日志实时跟随**:`.log` 不停在打开那一刻;按行着色(ANSI / ERROR-WARN-INFO)、自动换行(标题栏的换行开关真正在 `pre-wrap`/`pre` 之间切换,关掉就是横向滚动)、字号调节、暂停/到底;默认**只看本次启动**(重启后自动切到新一段),历史仍可加载。启动/停止/重启/调试后日志面板会**立刻补齐**(不再停在启动命令行上、等下一次重连才刷新),点项目行也不再是「唯一能让它动一下」的办法。日志标题栏显示服务状态(`运行中 (pid N)` / `已停止`),可直接停止服务。编辑器与日志的滚动条在内容溢出时**常驻可见**(不再是宿主题那条几乎看不见的 5px 细缝)。
|
|
29
29
|
- **侧栏「RIS控制台」**:右侧栏的面板只保留**控制台 + 实时日志**上下两段——上面每行一个程序(状态点 / 内存 / ▶ ■ / 🐞),点程序名(或整行任意位置)下面就跟它的日志;分隔条可拖动,**默认 240px**、双击恢复、高度会记住;两段标题栏各有 **⤢ 最大化/还原**,日志标题栏还有 **A− / A+ 字号**(与 IDE 日志窗格共用一份偏好)与 **跟随/暂停**。文件树 / 编辑器 / 调试都在独立窗口里,面板自身很轻、能一直挂着。
|
|
30
30
|
- **独立窗口**:聊天页右上角(VS Code 按钮右侧)的 **⧉ RIS-IDE** 按钮可在自己的窗口里打开完整工作台(面板右上角也有同样入口),**打开即填满屏幕**(按工作区尺寸定位到 0,0,不再是固定 1500×960)——该窗口**不加载 DSH 界面、不带会话**(只用插件自己的约 435KB 客户端 + DSH 提供的 React + 一条 SSE),长期开着也不随会话历史变重;与侧栏面板是同一条 `/dsh-ris-ide/*` 路由、同一个 cookie,没有新端口。窗口名按工作空间固定,再点只聚焦复用同一个窗口;窗口名按工作空间(而非当前目录)固定,所以从程序目录进调试也不会开出第二个窗口;若确实检测到另一个窗口,会提示「关闭这个窗口 / 仍然在这里打开」,不会自动关。
|
|
31
31
|
- **本地实例**:扫描工作区里的 Spring Boot 入口与前端 `package.json` 脚本,一键**启动 / 停止 / 重启 / 看日志**(启停未返回前该行盖上 loading 遮罩,点不到第二次);首次打开自动生成 `.dsh-ris-ide.json` 保存启动参数(JVM 参数、env、日志名、停止宽限),之后按配置启动,配置漂移时提示更新。
|
|
32
32
|
- **JDWP 调试(仅 Java)**:点行号加断点、双击红点删除(空行与注释行自动忽略);启动/调试时日志自动跟随该程序(其它窗口也会跟着切),F8 连按不会报取栈失败;调试自动打开的文件在调试行离开后自动关闭(有未保存修改的保留),断点列表与调用栈用类名标识位置,断点信息全局同步(其它程序的历史点不会残留、取消后立即消失);断点 / 线程 / 调用栈 / 变量 / 单步 / 继续;对象与数组变量可点开懒加载查看(含继承字段、空值也列出;步进刷新后展开状态保留),基础类型不显示展开图标;依赖 jar 里的类会自动从 `-sources.jar` 提取源码、否则用 `javap` 反汇编,也可在调试面板 ⚙ 里**可选**填一个反编译工具 jar(如 CFR);缓存按依赖 jar 指纹失效(jar 重建即重取),并有 64MB/30 天上限自动回收;命中后自动切到「参数」页签,并打开源码、高亮当前行(行不在可见区时自动滚动居中;单步/继续后行号跟随),调试面板与 agent 共用同一个会话;前端程序只能启停和看日志。
|
|
33
|
-
- **文件树 + 编辑器**:git 口径的目录树与文件名搜索(结果显示工作空间相对路径、悬停看全路径;Ctrl+R
|
|
33
|
+
- **文件树 + 编辑器**:git 口径的目录树与文件名搜索(结果显示工作空间相对路径、悬停看全路径;Ctrl+R 有单行选区时直接搜该文本,**Ctrl+Shift+R 同 Ctrl+R**——不再触发浏览器硬刷新;结果下拉支持**上下键移动 + Enter 打开**,默认指向文件名完全匹配的那一行、否则第一行,移动高亮时搜索框的光标不受影响、可以接着打字(聚焦且输入为空时的「最近打开」下拉同样默认选中第一行、可上下键 + Enter);编辑器/日志里 Ctrl+F 会把选中的文本带入各自的查找框,不占用这个文件检索框)、选中树里的文件按 **Ctrl+C 复制、Ctrl+A 全选树**(光标不会跑进编辑器)、内置 CodeMirror(Java 等语法高亮;切换文件时页签自动滚入可视区、编辑器失焦后不残留全选色、点选区里的任何位置(含搜索命中的橙色块)当次就把光标放进去)、保存、新建/复制/移动/删除、多页签、拖放移动(拖到**文件**上 = 移到该文件所在目录)、从系统粘贴/拖入文件导入;`src/main/java` 下可直接**新建包名**(`cn.com.x` 按点建多级目录),新建文件也只填一个名字(`cloud.test` 自动建包并补 `.java`);超过整读上限的大文本文件以**只读分页预览**打开(滚到接近底部才取下一页,内存超上限后释放前面的内容、可从头重载,不能编辑)。
|
|
34
34
|
- **文件树自动跟随**:工作区里新建/删除/重命名会经侧栏**同一条 SSE**自动更新,只重读变化的目录、行没变就不重绘;标题栏 **⟳** 可强制按 git 口径重新读取(结果会弹提示)。
|
|
35
|
-
- **预览与复制粘贴**:`.md/.markdown/.html/.htm`
|
|
35
|
+
- **预览与复制粘贴**:`.md/.markdown/.html/.htm` 在编辑区域上方有「预览」开关(点后编辑器变预览、按钮变「编辑」,预览当前内容含未保存修改);树右键「复制」是普通复制(树顶不再有剪贴板横条),粘贴到**文件**上 = 粘进它所在目录,遇到同名直接弹「粘贴为」要求**改个文件名**(预填「A - 副本.java」;复制贴回自身也同样走改名,等于生成副本);从系统文件管理器复制/拖入的文件可直接导入当前目录(`/fs/upload` 原始字节、`/fs/import` 路径导入)。
|
|
36
36
|
- **给 agent 用**:内置 `ris_dev_*` 工具(列程序 / 状态 / 启动 / 重启 / 停止 / 读日志 / 调试 / 安装 skill),agent 可以直接操作同一个面板。
|
|
37
37
|
- **跨平台**:Linux / macOS 用 bash 包装;Windows 自动选 Git Bash 或原生 PowerShell 包装(`taskkill /T` 杀整棵进程树)。
|
|
38
38
|
|
package/lib/client.js
CHANGED
|
@@ -227,12 +227,44 @@ window.__ModuleLoader__.load({
|
|
|
227
227
|
]
|
|
228
228
|
var RIS_STREAM_HUB = null
|
|
229
229
|
|
|
230
|
+
/**
|
|
231
|
+
* Which frames a subscriber gets.
|
|
232
|
+
*
|
|
233
|
+
* The socket carries the UNION of everyone's topics and ONE tail path, but not
|
|
234
|
+
* every frame belongs to its own topic: the host opens the file for whoever
|
|
235
|
+
* asked for `tail` and then pushes the bytes as `append` (plus `service` /
|
|
236
|
+
* `tail-error` for that same file). Filtering strictly on `sub.topics` dropped
|
|
237
|
+
* every one of those frames, so a log pane kept the single snapshot it mounted
|
|
238
|
+
* with — "启动后日志只有启动命令,最大化/点项目行(重挂载)才出后续内容".
|
|
239
|
+
* `stream-error` is a connection-wide report and goes to every subscriber.
|
|
240
|
+
*
|
|
241
|
+
* @param {string[]} topics - the topics this subscriber asked for.
|
|
242
|
+
* @param {string} topic - the frame's event name.
|
|
243
|
+
* @param {string} [subTail] - the tail path this subscriber follows.
|
|
244
|
+
* @param {string} [servedTail] - the tail path the live socket carries ('' = none).
|
|
245
|
+
* @returns {boolean} whether this frame belongs to that subscriber.
|
|
246
|
+
*/
|
|
247
|
+
function risFrameWanted(topics, topic, subTail, servedTail) {
|
|
248
|
+
var list = Array.isArray(topics) ? topics : []
|
|
249
|
+
if (list.indexOf(topic) !== -1) return true
|
|
250
|
+
if (topic === 'stream-error') return true
|
|
251
|
+
if (topic !== 'append' && topic !== 'service' && topic !== 'tail-error') return false
|
|
252
|
+
if (list.indexOf('tail') === -1) return false
|
|
253
|
+
// One socket follows one file: only the pane showing that file may apply the
|
|
254
|
+
// bytes (a pane on another file polls instead — see the LogTail fallback).
|
|
255
|
+
if (typeof servedTail === 'string' && servedTail !== '' &&
|
|
256
|
+
typeof subTail === 'string' && subTail !== '' && subTail !== servedTail) return false
|
|
257
|
+
return true
|
|
258
|
+
}
|
|
259
|
+
|
|
230
260
|
/** Subscribe an object `{topics, sessionId?, cwd?, handlers, onOpen?}` to the hub. */
|
|
231
261
|
function risStreamHub() {
|
|
232
262
|
if (RIS_STREAM_HUB !== null) return RIS_STREAM_HUB
|
|
233
263
|
var subscribers = new Set()
|
|
234
264
|
var source = null
|
|
235
265
|
var signature = ''
|
|
266
|
+
/** The tail path the CURRENT connection carries ('' when none). */
|
|
267
|
+
var servedTail = ''
|
|
236
268
|
var rebuildTimer = null
|
|
237
269
|
var retryTimer = null
|
|
238
270
|
var retryDelay = 3000
|
|
@@ -265,9 +297,17 @@ window.__ModuleLoader__.load({
|
|
|
265
297
|
})
|
|
266
298
|
topics.sort()
|
|
267
299
|
var next = topics.join(',') + '|' + [sessionId || '', cwd || '', tail || '', tailBytes || '', debugPath || ''].join('|')
|
|
268
|
-
if (source !== null && next === signature)
|
|
300
|
+
if (source !== null && next === signature) {
|
|
301
|
+
// Same shape as the live socket — but a viewer may have JOINED it since,
|
|
302
|
+
// and the host picked its tail path when it connected. Report that path
|
|
303
|
+
// so a viewer wanting another file can fall back to polling instead of
|
|
304
|
+
// sitting on a stream that carries someone else's text.
|
|
305
|
+
notifyOpen()
|
|
306
|
+
return
|
|
307
|
+
}
|
|
269
308
|
closeSource()
|
|
270
309
|
signature = next
|
|
310
|
+
servedTail = tail || ''
|
|
271
311
|
var url = routeUrl('dsh-ris-ide/stream')
|
|
272
312
|
url.searchParams.set('topics', topics.join(','))
|
|
273
313
|
if (sessionId !== undefined) url.searchParams.set('sessionId', sessionId)
|
|
@@ -279,9 +319,7 @@ window.__ModuleLoader__.load({
|
|
|
279
319
|
source.addEventListener('open', function () {
|
|
280
320
|
failures = 0
|
|
281
321
|
retryDelay = 3000
|
|
282
|
-
|
|
283
|
-
if (typeof sub.onOpen === 'function') sub.onOpen()
|
|
284
|
-
})
|
|
322
|
+
notifyOpen()
|
|
285
323
|
})
|
|
286
324
|
source.onerror = function () {
|
|
287
325
|
// EventSource retries by itself; tell subscribers so a panel that needs a
|
|
@@ -309,13 +347,21 @@ window.__ModuleLoader__.load({
|
|
|
309
347
|
var payload
|
|
310
348
|
try { payload = JSON.parse(event.data) } catch { return }
|
|
311
349
|
subscribers.forEach(function (sub) {
|
|
312
|
-
|
|
350
|
+
// A frame does not always belong to its own topic (tail bytes arrive
|
|
351
|
+
// as `append`): risFrameWanted owns that mapping.
|
|
352
|
+
if (!risFrameWanted(sub.topics, topic, sub.tail, servedTail)) return
|
|
313
353
|
var handler = sub.handlers !== undefined ? sub.handlers[topic] : undefined
|
|
314
354
|
if (typeof handler === 'function') handler(payload)
|
|
315
355
|
})
|
|
316
356
|
})
|
|
317
357
|
})
|
|
318
358
|
}
|
|
359
|
+
/** Tell subscribers the connection is up, and WHICH tail it carries. */
|
|
360
|
+
function notifyOpen() {
|
|
361
|
+
subscribers.forEach(function (sub) {
|
|
362
|
+
if (typeof sub.onOpen === 'function') sub.onOpen({ tail: servedTail })
|
|
363
|
+
})
|
|
364
|
+
}
|
|
319
365
|
function scheduleRetry() {
|
|
320
366
|
if (retryTimer !== null || subscribers.size === 0) return
|
|
321
367
|
retryTimer = setTimeout(function () {
|
|
@@ -361,6 +407,8 @@ window.__ModuleLoader__.load({
|
|
|
361
407
|
window.addEventListener('focus', reconnectIfDown)
|
|
362
408
|
}
|
|
363
409
|
RIS_STREAM_HUB = {
|
|
410
|
+
/** The tail path the live connection is following ('' when none). */
|
|
411
|
+
tailPath: function () { return servedTail },
|
|
364
412
|
/**
|
|
365
413
|
* @param {{topics: string[], sessionId?: string, cwd?: string, handlers: object, onOpen?: Function}} sub - the subscription.
|
|
366
414
|
* @returns {Function} unsubscribe.
|
|
@@ -1116,6 +1164,14 @@ window.__ModuleLoader__.load({
|
|
|
1116
1164
|
flex: 1, minHeight: 0, margin: 0, padding: '6px 8px', overflow: 'auto',
|
|
1117
1165
|
tabSize: 4, lineHeight: 1.5, overflowWrap: 'anywhere',
|
|
1118
1166
|
},
|
|
1167
|
+
/**
|
|
1168
|
+
* The wrap toggle used to be a dead button: neither style existed, so both
|
|
1169
|
+
* modes rendered with the browser default and nothing changed. `pre` keeps
|
|
1170
|
+
* the log's own long lines intact and lets the body scroll horizontally;
|
|
1171
|
+
* `pre-wrap` breaks them at the pane edge.
|
|
1172
|
+
*/
|
|
1173
|
+
logWrap: { whiteSpace: 'pre-wrap', overflowWrap: 'anywhere', wordBreak: 'break-word' },
|
|
1174
|
+
logPre: { whiteSpace: 'pre', overflowWrap: 'normal', wordBreak: 'normal' },
|
|
1119
1175
|
line: { minHeight: '1.5em' },
|
|
1120
1176
|
timestamp: { opacity: 0.55 },
|
|
1121
1177
|
level: { fontWeight: 600 },
|
|
@@ -1241,6 +1297,8 @@ window.__ModuleLoader__.load({
|
|
|
1241
1297
|
display: 'flex', gap: 4, alignItems: 'center', padding: '1px 6px', cursor: 'pointer',
|
|
1242
1298
|
whiteSpace: 'nowrap', overflow: 'hidden',
|
|
1243
1299
|
},
|
|
1300
|
+
/** The row under the dropdown's keyboard/hover highlight (same box, tinted). */
|
|
1301
|
+
searchRowOn: { background: 'color-mix(in srgb, currentColor 18%, transparent)' },
|
|
1244
1302
|
editorPaneHead: {
|
|
1245
1303
|
display: 'flex', alignItems: 'center', gap: 4, padding: '1px 4px', flex: '0 0 auto',
|
|
1246
1304
|
// NOT `overflow: hidden`: this row is the search box's anchor, and clipping it
|
|
@@ -1786,7 +1844,11 @@ window.__ModuleLoader__.load({
|
|
|
1786
1844
|
tail: path,
|
|
1787
1845
|
tailBytes: TAIL_BYTES,
|
|
1788
1846
|
handlers: {
|
|
1789
|
-
tail: function (payload) {
|
|
1847
|
+
tail: function (payload) {
|
|
1848
|
+
// Another viewer's snapshot (two panes, one socket): ignore it.
|
|
1849
|
+
if (payload !== null && payload !== undefined && typeof payload.path === 'string' && payload.path !== path) return
|
|
1850
|
+
setView(stateFromPayload(payload))
|
|
1851
|
+
},
|
|
1790
1852
|
append: function (payload) {
|
|
1791
1853
|
var text = typeof payload.text === 'string' ? payload.text : ''
|
|
1792
1854
|
if (text === '') return
|
|
@@ -1830,9 +1892,14 @@ window.__ModuleLoader__.load({
|
|
|
1830
1892
|
})
|
|
1831
1893
|
},
|
|
1832
1894
|
},
|
|
1833
|
-
onOpen: function () {
|
|
1895
|
+
onOpen: function (info) {
|
|
1834
1896
|
failures = 0
|
|
1835
|
-
|
|
1897
|
+
// The panel shares ONE streaming socket and that socket carries ONE
|
|
1898
|
+
// tail path. When the host bound it to another file (another log viewer
|
|
1899
|
+
// mounted first), this pane would never see its own file on the stream
|
|
1900
|
+
// — poll `/tail` for it instead of waiting forever.
|
|
1901
|
+
var served = info !== null && info !== undefined && typeof info.tail === 'string' ? info.tail : ''
|
|
1902
|
+
setStreamOk(served === '' || served === path)
|
|
1836
1903
|
},
|
|
1837
1904
|
onError: function (readyState) {
|
|
1838
1905
|
failures += 1
|
|
@@ -1842,6 +1909,17 @@ window.__ModuleLoader__.load({
|
|
|
1842
1909
|
})
|
|
1843
1910
|
}, [tailVisible, streamOk, path, sessionId, cwd, props.customData])
|
|
1844
1911
|
|
|
1912
|
+
useEffect(function () {
|
|
1913
|
+
// First paint: read the tail once even when the shared stream is already
|
|
1914
|
+
// connected. A live connection only pushes what is written from NOW on, so
|
|
1915
|
+
// a pane mounting onto an existing socket would start empty and stay behind
|
|
1916
|
+
// (the "log freezes on the start command until I click the row" bug).
|
|
1917
|
+
if (!tailVisible) return
|
|
1918
|
+
if (props.customData !== undefined) return
|
|
1919
|
+
if (typeof EventSource !== 'function') return
|
|
1920
|
+
void refresh()
|
|
1921
|
+
}, [])
|
|
1922
|
+
|
|
1845
1923
|
useEffect(function () {
|
|
1846
1924
|
// The stream is authoritative while it is connected; polling resumes only
|
|
1847
1925
|
// when it failed (old host, buffering proxy, tab restored from bfcache).
|
|
@@ -2265,16 +2343,17 @@ window.__ModuleLoader__.load({
|
|
|
2265
2343
|
*
|
|
2266
2344
|
* The panel must suppress both forms even while an editor/input has focus
|
|
2267
2345
|
* (Ctrl+R there would otherwise reload the whole GUI and lose the IDE state).
|
|
2268
|
-
* @param {{key?: string, ctrlKey?: boolean, metaKey?: boolean, altKey?: boolean}} event - key facts.
|
|
2346
|
+
* @param {{key?: string, ctrlKey?: boolean, metaKey?: boolean, altKey?: boolean, shiftKey?: boolean}} event - key facts.
|
|
2269
2347
|
* @returns {boolean} true for Ctrl/Cmd+R and Ctrl/Cmd+Shift+R.
|
|
2270
2348
|
*/
|
|
2271
2349
|
function isBrowserReloadChord(event) {
|
|
2272
2350
|
var facts = event === undefined || event === null ? {} : event
|
|
2273
2351
|
var meta = facts.ctrlKey === true || facts.metaKey === true
|
|
2274
|
-
if (!meta || facts.altKey === true
|
|
2352
|
+
if (!meta || facts.altKey === true) return false
|
|
2275
2353
|
var key = String(facts.key === undefined || facts.key === null ? '' : facts.key).toLowerCase()
|
|
2276
|
-
//
|
|
2277
|
-
//
|
|
2354
|
+
// Both forms are the IDE's: plain Ctrl+R is the find chord, and Ctrl+Shift+R
|
|
2355
|
+
// (the browser's hard reload) is swallowed by the same net so it cannot throw
|
|
2356
|
+
// the IDE away. event.key is 'R' while Shift is held, hence toLowerCase().
|
|
2278
2357
|
return key === 'r'
|
|
2279
2358
|
}
|
|
2280
2359
|
|
|
@@ -2344,24 +2423,17 @@ window.__ModuleLoader__.load({
|
|
|
2344
2423
|
return DSH_CHORDS.has(chord)
|
|
2345
2424
|
}
|
|
2346
2425
|
|
|
2347
|
-
/**
|
|
2348
|
-
* Whether the browser would treat the keydown as a reload.
|
|
2349
|
-
*
|
|
2350
|
-
* The panel must suppress both forms even while an editor/input has focus
|
|
2351
|
-
* (Ctrl+R there would otherwise reload the whole GUI and lose the IDE state).
|
|
2352
|
-
* @param {{key?: string, ctrlKey?: boolean, metaKey?: boolean, altKey?: boolean}} event - key facts.
|
|
2353
|
-
* @returns {boolean} true for Ctrl/Cmd+R and Ctrl/Cmd+Shift+R.
|
|
2354
|
-
*/
|
|
2355
|
-
|
|
2356
2426
|
/**
|
|
2357
2427
|
* Whether a keydown is the IDE's workspace-search chord (Ctrl/Cmd+R).
|
|
2428
|
+
*
|
|
2429
|
+
* Ctrl+Shift+R counts as the same chord: it is the browser's HARD reload, and a
|
|
2430
|
+
* reload would throw the whole IDE away, so it has to land in the search box too.
|
|
2358
2431
|
* Ctrl+F stays with the editor's own find panel.
|
|
2359
2432
|
* @param {object} event - a KeyboardEvent-like object.
|
|
2360
|
-
* @returns {boolean} true for Ctrl+R / Cmd+R
|
|
2433
|
+
* @returns {boolean} true for Ctrl+R / Cmd+R (Shift allowed).
|
|
2361
2434
|
*/
|
|
2362
2435
|
function isGlobalFindChord(event) {
|
|
2363
2436
|
var facts = event === undefined || event === null ? {} : event
|
|
2364
|
-
if (facts.shiftKey === true) return false
|
|
2365
2437
|
var key = String(facts.key === undefined || facts.key === null ? '' : facts.key).toLowerCase()
|
|
2366
2438
|
var meta = facts.ctrlKey === true || facts.metaKey === true
|
|
2367
2439
|
if (meta && facts.altKey !== true && key === GLOBAL_FIND_KEY) return true
|
|
@@ -2706,7 +2778,7 @@ window.__ModuleLoader__.load({
|
|
|
2706
2778
|
{ keys: 'Del', desc: '删除(移入回收站,可撤销)' },
|
|
2707
2779
|
{ keys: 'Ctrl+Z', desc: '撤销文件操作:删除 / 新建 / 粘贴 / 移动' },
|
|
2708
2780
|
{ keys: 'Ctrl+C / X / V', desc: '复制 / 剪切 / 粘贴' },
|
|
2709
|
-
{ keys: '拖放', desc: '
|
|
2781
|
+
{ keys: '拖放', desc: '拖到文件夹或文件上移动(文件 = 移到它所在目录);拖到树空白处移到工作区根' },
|
|
2710
2782
|
{ keys: '⟳ / ⌖', desc: '标题栏:刷新文件树 / 定位当前文件' },
|
|
2711
2783
|
],
|
|
2712
2784
|
},
|
|
@@ -2924,16 +2996,59 @@ window.__ModuleLoader__.load({
|
|
|
2924
2996
|
return segments.join('/')
|
|
2925
2997
|
}
|
|
2926
2998
|
|
|
2999
|
+
/**
|
|
3000
|
+
* The row the workspace-search dropdown highlights when results arrive.
|
|
3001
|
+
*
|
|
3002
|
+
* The host answers in `git ls-files` order, so the full file name the user typed
|
|
3003
|
+
* (`ModelHelper.java`) is not necessarily row 0 — the row whose NAME matches the
|
|
3004
|
+
* query exactly is what they mean, and only when there is none does row 0 win.
|
|
3005
|
+
* @param {{matches?: string[], dirs?: object}|null|undefined} hits - dropdown payload.
|
|
3006
|
+
* @param {string} query - the search box text.
|
|
3007
|
+
* @returns {number} index into `hits.matches`; -1 when there is nothing to highlight.
|
|
3008
|
+
*/
|
|
3009
|
+
function searchHitActiveIndex(hits, query) {
|
|
3010
|
+
var matches = hits !== null && hits !== undefined && Array.isArray(hits.matches) ? hits.matches : []
|
|
3011
|
+
if (matches.length === 0) return -1
|
|
3012
|
+
var wanted = String(query === undefined || query === null ? '' : query).trim().toLowerCase()
|
|
3013
|
+
if (wanted !== '') {
|
|
3014
|
+
var dirs = hits.dirs !== null && hits.dirs !== undefined && typeof hits.dirs === 'object' ? hits.dirs : {}
|
|
3015
|
+
for (var index = 0; index < matches.length; index += 1) {
|
|
3016
|
+
var path = String(matches[index] === undefined || matches[index] === null ? '' : matches[index])
|
|
3017
|
+
if (dirs[path] === true) continue
|
|
3018
|
+
if (fileBaseName(path).toLowerCase() === wanted) return index
|
|
3019
|
+
}
|
|
3020
|
+
}
|
|
3021
|
+
return 0
|
|
3022
|
+
}
|
|
3023
|
+
|
|
2927
3024
|
/**
|
|
2928
3025
|
* The toolbar search's dropdown: results hang directly UNDER the search box
|
|
2929
3026
|
* (an absolutely-positioned panel), not inside the tree. Clicking a file opens
|
|
2930
3027
|
* it and reveals it in the tree; clicking a directory just expands the tree to
|
|
2931
3028
|
* it. `hits` is `{matches, dirs}` or `{error}`; `null` renders nothing.
|
|
3029
|
+
*
|
|
3030
|
+
* The highlighted row is `props.active` (an index into `hits.matches`), owned by
|
|
3031
|
+
* the panel so the arrow keys work while the SEARCH BOX keeps focus: hovering a
|
|
3032
|
+
* row only reports itself (`props.onHover`), it never touches focus or the caret.
|
|
2932
3033
|
*/
|
|
2933
3034
|
function SearchResults(props) {
|
|
2934
3035
|
var S = stylesFor(props && typeof props.fontRatio === 'number' ? props.fontRatio : 1)
|
|
2935
3036
|
var hits = props.hits
|
|
2936
3037
|
var cwd = typeof props.cwd === 'string' ? props.cwd : ''
|
|
3038
|
+
var active = typeof props.active === 'number' ? props.active : -1
|
|
3039
|
+
// Keep the highlighted row inside the dropdown's OWN scroll box: the list is
|
|
3040
|
+
// `overflow:auto`, so its scrollTop moves and the page never scrolls.
|
|
3041
|
+
var listRef = useRef(null)
|
|
3042
|
+
useEffect(function () {
|
|
3043
|
+
var list = listRef.current
|
|
3044
|
+
if (list === null || list === undefined || typeof list.getBoundingClientRect !== 'function') return
|
|
3045
|
+
var row = typeof list.querySelector === 'function' ? list.querySelector('[data-search-hit-active="1"]') : null
|
|
3046
|
+
if (row === null) return
|
|
3047
|
+
var box = list.getBoundingClientRect()
|
|
3048
|
+
var rect = row.getBoundingClientRect()
|
|
3049
|
+
var next = revealScrollTop(rect.top, rect.bottom, box.top, box.bottom, list.scrollTop)
|
|
3050
|
+
if (next !== list.scrollTop) list.scrollTop = next
|
|
3051
|
+
}, [active, hits])
|
|
2937
3052
|
if (hits === null || hits === undefined) return null
|
|
2938
3053
|
var rows
|
|
2939
3054
|
if (hits.error !== undefined) {
|
|
@@ -2941,19 +3056,31 @@ window.__ModuleLoader__.load({
|
|
|
2941
3056
|
} else if (!Array.isArray(hits.matches) || hits.matches.length === 0) {
|
|
2942
3057
|
rows = [h('div', { key: 'none', style: S.idePlaceholder }, '没有匹配的文件')]
|
|
2943
3058
|
} else {
|
|
2944
|
-
rows = hits.matches.map(function (path) {
|
|
3059
|
+
rows = hits.matches.map(function (path, index) {
|
|
2945
3060
|
var isDir = hits.dirs !== undefined && hits.dirs !== null && hits.dirs[path] === true
|
|
3061
|
+
var isActive = index === active
|
|
2946
3062
|
return h('div', {
|
|
2947
|
-
key: path,
|
|
3063
|
+
key: path,
|
|
3064
|
+
style: isActive ? Object.assign({}, S.searchRow, S.searchRowOn) : S.searchRow,
|
|
3065
|
+
title: path,
|
|
2948
3066
|
'data-search-hit': isDir ? 'dir' : 'file',
|
|
2949
3067
|
'data-search-hit-path': path,
|
|
3068
|
+
'data-search-hit-active': isActive ? '1' : '0',
|
|
3069
|
+
onMouseEnter: function () { if (typeof props.onHover === 'function') props.onHover(index) },
|
|
2950
3070
|
onClick: function () { props.onPick(path, isDir) },
|
|
2951
3071
|
},
|
|
2952
3072
|
h('span', { style: { opacity: 0.55, flex: '0 0 auto' } }, isDir ? '▸' : '·'),
|
|
2953
3073
|
h('span', { style: { overflow: 'hidden', textOverflow: 'ellipsis' } }, displayWorkspacePath(path, cwd)))
|
|
2954
3074
|
})
|
|
2955
3075
|
}
|
|
2956
|
-
return h('div', {
|
|
3076
|
+
return h('div', {
|
|
3077
|
+
ref: listRef,
|
|
3078
|
+
style: S.searchDropdown, 'data-search-results': '1',
|
|
3079
|
+
// Swallow the mousedown so picking a row cannot blur the search box: the
|
|
3080
|
+
// caret stays put and the user can keep typing (same trick as the history
|
|
3081
|
+
// list above).
|
|
3082
|
+
onMouseDown: function (event) { event.preventDefault() },
|
|
3083
|
+
},
|
|
2957
3084
|
h('div', { style: S.searchHeader }, props.busy === true ? '检索中…' : ('匹配 ' + (hits.matches ? hits.matches.length : 0) + ' 个')),
|
|
2958
3085
|
rows)
|
|
2959
3086
|
}
|
|
@@ -3492,12 +3619,6 @@ window.__ModuleLoader__.load({
|
|
|
3492
3619
|
var [pendingDelete, setPendingDelete] = useState(null)
|
|
3493
3620
|
/** Clipboard for copy/cut: `{mode, path, isDir, name}`. */
|
|
3494
3621
|
var [clipboard, setClipboard] = useState(null)
|
|
3495
|
-
/**
|
|
3496
|
-
* A paste that collided with an existing entry: `{dir, name, source}`.
|
|
3497
|
-
* `source` is `{kind:'clipboard'|'file'|'path', …}`; the dialog offers 覆盖 /
|
|
3498
|
-
* 改名 / 取消, and 改名 reuses the shared prompt with `mode:'paste'`.
|
|
3499
|
-
*/
|
|
3500
|
-
var [pasteConflict, setPasteConflict] = useState(null)
|
|
3501
3622
|
var [selectedPath, setSelectedPath] = useState(null)
|
|
3502
3623
|
var [dropTarget, setDropTarget] = useState(null)
|
|
3503
3624
|
/** LIFO of invertible file operations (Ctrl+Z). Ref: no re-render needed. */
|
|
@@ -3747,8 +3868,14 @@ window.__ModuleLoader__.load({
|
|
|
3747
3868
|
}
|
|
3748
3869
|
var pasteDir = prompt.dir
|
|
3749
3870
|
var pasteSource = prompt.source
|
|
3871
|
+
// A colliding paste asked for a DIFFERENT name: keeping the old one
|
|
3872
|
+
// would just bounce back to this prompt forever.
|
|
3873
|
+
if (prompt.conflict !== undefined && name === prompt.conflict) {
|
|
3874
|
+
notify('「' + name + '」已存在,请改个名字')
|
|
3875
|
+
return
|
|
3876
|
+
}
|
|
3750
3877
|
setPrompt(null)
|
|
3751
|
-
await runPaste(pasteSource, pasteDir, name
|
|
3878
|
+
await runPaste(pasteSource, pasteDir, name)
|
|
3752
3879
|
return
|
|
3753
3880
|
}
|
|
3754
3881
|
if (prompt.mode === 'package') {
|
|
@@ -3837,8 +3964,13 @@ window.__ModuleLoader__.load({
|
|
|
3837
3964
|
}
|
|
3838
3965
|
|
|
3839
3966
|
function beginCopy(mode) {
|
|
3840
|
-
|
|
3841
|
-
|
|
3967
|
+
// Ctrl+C / Ctrl+X arrive with no context menu open, so resolve the entry
|
|
3968
|
+
// from the tree selection as well — the keyboard used to no-op silently
|
|
3969
|
+
// (only the right-click menu ever worked).
|
|
3970
|
+
var entry = treeMenu !== null && treeMenu.entry !== null && treeMenu.entry !== undefined
|
|
3971
|
+
? treeMenu.entry
|
|
3972
|
+
: (selectedPath === null ? null : findEntry(selectedPath))
|
|
3973
|
+
if (entry === null || entry === undefined) return
|
|
3842
3974
|
setClipboard({ mode: mode, path: entry.path, isDir: entry.isDir === true, name: entry.name || entry.path })
|
|
3843
3975
|
setTreeMenu(null)
|
|
3844
3976
|
notify((mode === 'copy' ? '已复制 ' : '已剪切 ') + (entry.name || entry.path))
|
|
@@ -3858,45 +3990,64 @@ window.__ModuleLoader__.load({
|
|
|
3858
3990
|
return ''
|
|
3859
3991
|
}
|
|
3860
3992
|
|
|
3993
|
+
/**
|
|
3994
|
+
* Park a colliding paste and ask for a different leaf name.
|
|
3995
|
+
*
|
|
3996
|
+
* A collision is not a failure and not a 覆盖 question: the source is still
|
|
3997
|
+
* on disk, so the only way forward is a new name. The prompt is prefilled with
|
|
3998
|
+
* the tree's own 副本 convention (`A.java` → `A - 副本.java`) and refuses to
|
|
3999
|
+
* resubmit the colliding name (see the prompt's `paste` branch).
|
|
4000
|
+
* @param {object} source - the paste source (`clipboard` | `file` | `path`).
|
|
4001
|
+
* @param {string} dir - absolute destination directory.
|
|
4002
|
+
* @param {string} name - the leaf name that already exists there.
|
|
4003
|
+
*/
|
|
4004
|
+
function parkPasteName(source, dir, name) {
|
|
4005
|
+
notify('「' + name + '」已存在,请改个名字')
|
|
4006
|
+
setPrompt({ mode: 'paste', dir: dir, ext: '', title: '粘贴为', source: source, conflict: name })
|
|
4007
|
+
setPromptName(duplicateName(name, false))
|
|
4008
|
+
}
|
|
4009
|
+
|
|
3861
4010
|
/**
|
|
3862
4011
|
* Perform ONE paste (tree clipboard, an uploaded `File`, or an outside path).
|
|
3863
4012
|
*
|
|
3864
|
-
* A collision does not just fail: it
|
|
3865
|
-
*
|
|
3866
|
-
*
|
|
3867
|
-
* not an error, and it must never be mistaken for "overwrite
|
|
4013
|
+
* A collision does not just fail: it opens the 粘贴为 prompt with a 副本 name,
|
|
4014
|
+
* because the source is still on disk and the only way forward is a different
|
|
4015
|
+
* leaf name. Pasting a CUT entry back into its own folder is silently ignored —
|
|
4016
|
+
* that is a no-op, not an error, and it must never be mistaken for "overwrite
|
|
4017
|
+
* the source". Pasting a COPY onto its own path is NOT a no-op either: it falls
|
|
4018
|
+
* through to the same prompt, i.e. "duplicate under a new name".
|
|
3868
4019
|
* @param {object} source - `{kind:'clipboard'}` | `{kind:'file', file}` |
|
|
3869
4020
|
* `{kind:'path', path}`.
|
|
3870
4021
|
* @param {string} dir - absolute destination directory.
|
|
3871
4022
|
* @param {string} [requestedName] - explicit leaf name (改名 flow), else derived.
|
|
3872
|
-
* @param {boolean} [overwrite] - the user already chose 覆盖.
|
|
3873
4023
|
* @returns {Promise<string|undefined>} the created path, or undefined.
|
|
3874
4024
|
*/
|
|
3875
|
-
async function runPaste(source, dir, requestedName
|
|
4025
|
+
async function runPaste(source, dir, requestedName) {
|
|
3876
4026
|
var name = pasteEntryName(source, requestedName)
|
|
3877
4027
|
if (name === '') return undefined
|
|
3878
4028
|
var trimmedDir = dir.replace(/[\\/]+$/, '')
|
|
3879
4029
|
var target = trimmedDir + '/' + name
|
|
3880
4030
|
var from = source.kind === 'clipboard' && clipboard !== null ? clipboard.path : ''
|
|
3881
|
-
if (source.kind === 'clipboard' && target === from) {
|
|
3882
|
-
// Cut → its own folder,
|
|
4031
|
+
if (source.kind === 'clipboard' && target === from && clipboard.mode !== 'copy') {
|
|
4032
|
+
// Cut → its own folder: a no-op, not an error. A copy onto its own path is
|
|
4033
|
+
// the user asking for a duplicate, so it falls through to the 409 below.
|
|
3883
4034
|
return undefined
|
|
3884
4035
|
}
|
|
3885
4036
|
try {
|
|
3886
4037
|
if (source.kind === 'clipboard') {
|
|
3887
4038
|
if (clipboard.mode === 'copy') {
|
|
3888
|
-
await fsCopyEntry(scope, from, dir, name
|
|
4039
|
+
await fsCopyEntry(scope, from, dir, name)
|
|
3889
4040
|
} else {
|
|
3890
|
-
await fsMoveEntry(scope, from, dir, name
|
|
4041
|
+
await fsMoveEntry(scope, from, dir, name)
|
|
3891
4042
|
}
|
|
3892
4043
|
} else if (source.kind === 'file') {
|
|
3893
|
-
await fsUpload(scope, dir, name, source.file
|
|
4044
|
+
await fsUpload(scope, dir, name, source.file)
|
|
3894
4045
|
} else {
|
|
3895
|
-
await fsImportPath(scope, dir, source.path, name
|
|
4046
|
+
await fsImportPath(scope, dir, source.path, name)
|
|
3896
4047
|
}
|
|
3897
4048
|
} catch (problem) {
|
|
3898
|
-
if (isExistsProblem(problem)
|
|
3899
|
-
|
|
4049
|
+
if (isExistsProblem(problem)) {
|
|
4050
|
+
parkPasteName(source, dir, name)
|
|
3900
4051
|
return undefined
|
|
3901
4052
|
}
|
|
3902
4053
|
notify('粘贴失败:' + messageOf(problem))
|
|
@@ -3927,31 +4078,14 @@ window.__ModuleLoader__.load({
|
|
|
3927
4078
|
/** Paste the tree's own clipboard into `dirPath`. */
|
|
3928
4079
|
async function pasteInto(dirPath) {
|
|
3929
4080
|
if (clipboard === null) return
|
|
3930
|
-
await runPaste({ kind: 'clipboard' }, dirPath, undefined
|
|
3931
|
-
}
|
|
3932
|
-
|
|
3933
|
-
/** The conflict dialog's 覆盖 button: run the parked paste destructively. */
|
|
3934
|
-
async function pasteConflictOverwrite() {
|
|
3935
|
-
if (pasteConflict === null) return
|
|
3936
|
-
var conflict = pasteConflict
|
|
3937
|
-
setPasteConflict(null)
|
|
3938
|
-
await runPaste(conflict.source, conflict.dir, conflict.name, true)
|
|
3939
|
-
}
|
|
3940
|
-
|
|
3941
|
-
/** The conflict dialog's 改名 button: reopen the name prompt for THIS paste. */
|
|
3942
|
-
function pasteConflictRename() {
|
|
3943
|
-
if (pasteConflict === null) return
|
|
3944
|
-
var conflict = pasteConflict
|
|
3945
|
-
setPasteConflict(null)
|
|
3946
|
-
setPrompt({ mode: 'paste', dir: conflict.dir, ext: '', title: '粘贴为', source: conflict.source })
|
|
3947
|
-
setPromptName(conflict.name)
|
|
4081
|
+
await runPaste({ kind: 'clipboard' }, dirPath, undefined)
|
|
3948
4082
|
}
|
|
3949
4083
|
|
|
3950
4084
|
/**
|
|
3951
4085
|
* Import OS-clipboard content (a `paste` with no tree clipboard): `File`
|
|
3952
4086
|
* blobs go up as raw bytes, `file://`/path text goes through `/fs/import`.
|
|
3953
|
-
* Files that already exist stop at the first collision and
|
|
3954
|
-
*
|
|
4087
|
+
* Files that already exist stop at the first collision and open the same
|
|
4088
|
+
* 粘贴为 prompt as a tree paste.
|
|
3955
4089
|
* @param {string} dir - absolute destination directory.
|
|
3956
4090
|
* @param {File[]} files - pasted blobs (may be empty).
|
|
3957
4091
|
* @param {string[]} paths - parseClipboardPaths() result (may be empty).
|
|
@@ -3963,7 +4097,7 @@ window.__ModuleLoader__.load({
|
|
|
3963
4097
|
var source = index < files.length
|
|
3964
4098
|
? { kind: 'file', file: files[index] }
|
|
3965
4099
|
: { kind: 'path', path: paths[index - files.length] }
|
|
3966
|
-
var created = await runPaste(source, dir, undefined
|
|
4100
|
+
var created = await runPaste(source, dir, undefined)
|
|
3967
4101
|
if (created === undefined) break
|
|
3968
4102
|
imported += 1
|
|
3969
4103
|
}
|
|
@@ -4100,6 +4234,13 @@ window.__ModuleLoader__.load({
|
|
|
4100
4234
|
void undoLast()
|
|
4101
4235
|
return
|
|
4102
4236
|
}
|
|
4237
|
+
if (meta && (event.key === 'a' || event.key === 'A')) {
|
|
4238
|
+
// The tree is single-selection, so 全选 has nothing to expand into.
|
|
4239
|
+
// Claim the key anyway: unclaimed, the browser selected the whole page
|
|
4240
|
+
// and the following Ctrl+C copied that page text instead of the file.
|
|
4241
|
+
event.preventDefault()
|
|
4242
|
+
return
|
|
4243
|
+
}
|
|
4103
4244
|
if (meta && (event.key === 'c' || event.key === 'C')) {
|
|
4104
4245
|
event.preventDefault()
|
|
4105
4246
|
beginCopy('copy')
|
|
@@ -4197,7 +4338,10 @@ window.__ModuleLoader__.load({
|
|
|
4197
4338
|
var isRevealed = reveal !== null && reveal.path === entry.path
|
|
4198
4339
|
var isSelected = selectedPath === entry.path
|
|
4199
4340
|
&& (entry.isDir === true || !Array.isArray(props.openFiles) || props.openFiles.indexOf(entry.path) !== -1)
|
|
4200
|
-
|
|
4341
|
+
// Dropping ON a file means "into the folder that file lives in" — a row
|
|
4342
|
+
// is always a drop target; only the expand/collapse toggle is dir-only.
|
|
4343
|
+
var dropDir = entry.isDir === true ? entry.path : parentOf(entry.path)
|
|
4344
|
+
var isDropTarget = dropTarget === entry.path
|
|
4201
4345
|
out.push(h('div', {
|
|
4202
4346
|
key: entry.path,
|
|
4203
4347
|
style: Object.assign({}, isActive || isRevealed || isSelected ? S.treeRowOn : S.treeRow, {
|
|
@@ -4219,30 +4363,30 @@ window.__ModuleLoader__.load({
|
|
|
4219
4363
|
}
|
|
4220
4364
|
setSelectedPath(entry.path)
|
|
4221
4365
|
},
|
|
4222
|
-
onDragOver:
|
|
4366
|
+
onDragOver: function (event) {
|
|
4223
4367
|
event.preventDefault()
|
|
4224
4368
|
try { event.dataTransfer.dropEffect = 'move' } catch { /* ignore */ }
|
|
4225
4369
|
if (dropTarget !== entry.path) setDropTarget(entry.path)
|
|
4226
|
-
}
|
|
4227
|
-
onDragLeave:
|
|
4370
|
+
},
|
|
4371
|
+
onDragLeave: function () {
|
|
4228
4372
|
if (dropTarget === entry.path) setDropTarget(null)
|
|
4229
|
-
}
|
|
4230
|
-
onDrop:
|
|
4373
|
+
},
|
|
4374
|
+
onDrop: function (event) {
|
|
4231
4375
|
event.preventDefault()
|
|
4232
4376
|
event.stopPropagation()
|
|
4233
4377
|
var external = []
|
|
4234
4378
|
try { external = Array.prototype.slice.call(event.dataTransfer.files || []) } catch { external = [] }
|
|
4235
4379
|
if (external.length > 0) {
|
|
4236
|
-
void importExternal(
|
|
4380
|
+
void importExternal(dropDir, external, [])
|
|
4237
4381
|
setDropTarget(null)
|
|
4238
4382
|
return
|
|
4239
4383
|
}
|
|
4240
4384
|
var from = ''
|
|
4241
4385
|
try { from = event.dataTransfer.getData('text/plain') } catch { from = '' }
|
|
4242
4386
|
if (from === '') from = selectedPath === null ? '' : selectedPath
|
|
4243
|
-
if (from !== '' && from !== entry.path) void moveInto(from,
|
|
4387
|
+
if (from !== '' && from !== entry.path) void moveInto(from, dropDir)
|
|
4244
4388
|
setDropTarget(null)
|
|
4245
|
-
}
|
|
4389
|
+
},
|
|
4246
4390
|
onClick: function () {
|
|
4247
4391
|
setSelectedPath(entry.path)
|
|
4248
4392
|
toggle(entry)
|
|
@@ -4440,24 +4584,6 @@ window.__ModuleLoader__.load({
|
|
|
4440
4584
|
h('button', { type: 'button', style: Object.assign({}, S.button, { color: '#e5534b' }), 'data-tree-confirm-ok': '1', onClick: function () { void removeEntry(pendingDelete) } }, '删除'))))
|
|
4441
4585
|
}
|
|
4442
4586
|
|
|
4443
|
-
/** The paste-collision dialog: 覆盖 / 改名 / 取消. */
|
|
4444
|
-
function renderPasteConflict() {
|
|
4445
|
-
if (pasteConflict === null) return null
|
|
4446
|
-
var conflict = pasteConflict
|
|
4447
|
-
return h('div', {
|
|
4448
|
-
style: { position: 'fixed', inset: 0, zIndex: 950, background: 'rgba(0,0,0,0.32)', display: 'flex', alignItems: 'center', justifyContent: 'center' },
|
|
4449
|
-
'data-tree-paste-conflict': '1',
|
|
4450
|
-
onMouseDown: function (event) { if (event.target === event.currentTarget) setPasteConflict(null) },
|
|
4451
|
-
},
|
|
4452
|
-
h('div', { style: { width: 380, maxWidth: '92vw', background: 'Canvas', color: 'inherit', border: '1px solid color-mix(in srgb, currentColor 25%, transparent)', borderRadius: 6, boxShadow: '0 18px 48px rgba(0,0,0,0.4)', padding: 10, display: 'flex', flexDirection: 'column', gap: 8, fontFamily: 'system-ui, sans-serif', fontSize: 12 } },
|
|
4453
|
-
h('div', { style: { fontWeight: 600 } }, '已存在同名条目'),
|
|
4454
|
-
h('div', { style: { opacity: 0.75, wordBreak: 'break-all' } }, conflict.dir.replace(/[\\/]+$/, '') + '/' + conflict.name),
|
|
4455
|
-
h('div', { style: { display: 'flex', justifyContent: 'flex-end', gap: 6 } },
|
|
4456
|
-
h('button', { type: 'button', style: S.buttonOff, onClick: function () { setPasteConflict(null) } }, '取消'),
|
|
4457
|
-
h('button', { type: 'button', style: S.buttonOff, 'data-tree-paste-rename': '1', onClick: pasteConflictRename }, '改名…'),
|
|
4458
|
-
h('button', { type: 'button', style: Object.assign({}, S.button, { color: '#e5534b' }), 'data-tree-paste-overwrite': '1', onClick: function () { void pasteConflictOverwrite() } }, '覆盖'))))
|
|
4459
|
-
}
|
|
4460
|
-
|
|
4461
4587
|
return h('div', { style: S.treeWrap, 'data-ide-tree': '1' },
|
|
4462
4588
|
degraded === true && treeDismissals.isOpen('tree-degraded', 'v1')
|
|
4463
4589
|
? h(ClosableNotice, {
|
|
@@ -4476,10 +4602,6 @@ window.__ModuleLoader__.load({
|
|
|
4476
4602
|
onClick: function () { setError(undefined) },
|
|
4477
4603
|
}, '×'))
|
|
4478
4604
|
: null,
|
|
4479
|
-
clipboard === null
|
|
4480
|
-
? null
|
|
4481
|
-
: h('div', { style: Object.assign({}, S.meta, { padding: '0 6px 2px', opacity: 0.7 }), 'data-tree-clipboard': clipboard.mode },
|
|
4482
|
-
(clipboard.mode === 'copy' ? '已复制 ' : '已剪切 ') + clipboard.name + ' · Ctrl+V 粘贴'),
|
|
4483
4605
|
h('div', {
|
|
4484
4606
|
ref: treeListRef, style: Object.assign({}, S.treeList, { outline: 'none' }), 'data-tree-root': rootPath,
|
|
4485
4607
|
tabIndex: -1,
|
|
@@ -4500,8 +4622,7 @@ window.__ModuleLoader__.load({
|
|
|
4500
4622
|
}, rowsFor(rootPath, 0, {}, {})),
|
|
4501
4623
|
renderTreeMenu(),
|
|
4502
4624
|
renderTreePrompt(),
|
|
4503
|
-
renderTreeConfirm()
|
|
4504
|
-
renderPasteConflict())
|
|
4625
|
+
renderTreeConfirm())
|
|
4505
4626
|
}
|
|
4506
4627
|
|
|
4507
4628
|
/**
|
|
@@ -4838,14 +4959,40 @@ window.__ModuleLoader__.load({
|
|
|
4838
4959
|
var DEBUG_LINE_CSS = '[data-workbench="ris-ide"] .' + DEBUG_LINE_CLASS
|
|
4839
4960
|
+ '{background:color-mix(in srgb, #d29922 26%, transparent) !important;box-shadow:inset 2px 0 0 #d29922}'
|
|
4840
4961
|
|
|
4962
|
+
/**
|
|
4963
|
+
* Scrollbars in the IDE. The editor scrolls with plain `auto` overflow
|
|
4964
|
+
* (CM6's `.cm-scroller{overflowX:auto}` makes the other axis `auto` too): the
|
|
4965
|
+
* bars are classic, non-overlay and appear only when content overflows — which
|
|
4966
|
+
* is what we want. What they LOOK like, though, comes from the host theme
|
|
4967
|
+
* (5px wide, transparent track, near-invisible thumb), so an overflowing editor
|
|
4968
|
+
* shows a 5px sliver that reads as "no scrollbar at all". Give it a real one and
|
|
4969
|
+
* keep `auto`: neither `overflow-y:scroll` nor `scrollbar-gutter:stable` here —
|
|
4970
|
+
* both would reserve an empty gutter on files that do not overflow.
|
|
4971
|
+
*/
|
|
4972
|
+
var SCROLLBAR_CSS = '[data-workbench="ris-ide"] ::-webkit-scrollbar{width:10px;height:10px}'
|
|
4973
|
+
+ '[data-workbench="ris-ide"] ::-webkit-scrollbar-track{background:rgba(127,127,127,0.14);border-radius:999px}'
|
|
4974
|
+
+ '[data-workbench="ris-ide"] ::-webkit-scrollbar-thumb'
|
|
4975
|
+
+ '{background:rgba(86,182,194,0.55);border:2px solid transparent;border-radius:999px;background-clip:content-box}'
|
|
4976
|
+
+ '[data-workbench="ris-ide"] ::-webkit-scrollbar-thumb:hover{background:rgba(86,182,194,0.80);background-clip:content-box}'
|
|
4977
|
+
+ '[data-workbench="ris-ide"] ::-webkit-scrollbar-corner{background:0 0}'
|
|
4978
|
+
+ '@supports not selector(::-webkit-scrollbar){'
|
|
4979
|
+
+ '[data-workbench="ris-ide"] *{scrollbar-width:thin;scrollbar-color:rgba(86,182,194,0.65) rgba(127,127,127,0.14)}}'
|
|
4980
|
+
|
|
4841
4981
|
/**
|
|
4842
4982
|
* Selection colours for the embedded editor, injected from the panel itself.
|
|
4843
4983
|
* CodeMirror draws the selection into its own layer, and the page's stylesheet
|
|
4844
4984
|
* can win that fight — the result was "other matches are highlighted, the text
|
|
4845
4985
|
* I selected is not". The selected range is teal, the other matches amber, so
|
|
4846
4986
|
* the selection always reads as the stronger one.
|
|
4847
|
-
|
|
4848
|
-
|
|
4987
|
+
*
|
|
4988
|
+
* Raising the layer paints the selection ABOVE `.cm-content`, so it has to be
|
|
4989
|
+
* transparent to the pointer as well: the layer is a plain `<div>` spanning the
|
|
4990
|
+
* whole scroller (CM only does this for its cursor layer), and without
|
|
4991
|
+
* `pointer-events:none` a click on a highlighted range stopped there — the
|
|
4992
|
+
* caret never moved into the selection, nor into the amber "current match" of
|
|
4993
|
+
* the search panel (which is a selection too). Both needed a second click.
|
|
4994
|
+
*/
|
|
4995
|
+
var SELECTION_CSS = '[data-workbench="ris-ide"] .cm-selectionLayer{z-index:5 !important;pointer-events:none !important}'
|
|
4849
4996
|
// While anything is selected the active-line tint is switched off: it is
|
|
4850
4997
|
// painted on the line itself and used to hide the selection colour on the
|
|
4851
4998
|
// current line (both for a single range and for a multi-line selection).
|
|
@@ -5249,6 +5396,8 @@ var [ui, setUi] = useState(function () {
|
|
|
5249
5396
|
/** Dropdown payload for the toolbar search: null | {matches,dirs} | {error}. */
|
|
5250
5397
|
var [searchHits, setSearchHits] = useState(null)
|
|
5251
5398
|
var [searchBusy, setSearchBusy] = useState(false)
|
|
5399
|
+
/** Dropdown highlight: an index into `searchHits.matches`, -1 when there is none. */
|
|
5400
|
+
var [searchActive, setSearchActive] = useState(-1)
|
|
5252
5401
|
/** One-shot "reveal this hit in the tree" request (nonce makes repeats work). */
|
|
5253
5402
|
var [locateRequest, setLocateRequest] = useState(null)
|
|
5254
5403
|
var locateNonceRef = useRef(0)
|
|
@@ -5525,7 +5674,7 @@ var [ui, setUi] = useState(function () {
|
|
|
5525
5674
|
var parsed
|
|
5526
5675
|
try { parsed = JSON.parse(event.newValue) } catch (error) { return }
|
|
5527
5676
|
var path = parsed !== null && typeof parsed.path === 'string' ? parsed.path : ''
|
|
5528
|
-
if (path === ''
|
|
5677
|
+
if (path === '') return
|
|
5529
5678
|
var found
|
|
5530
5679
|
for (var index = 0; index < programs.length; index += 1) {
|
|
5531
5680
|
if (programs[index] !== null && programs[index] !== undefined && programs[index].logPath === path) {
|
|
@@ -5533,9 +5682,14 @@ var [ui, setUi] = useState(function () {
|
|
|
5533
5682
|
break
|
|
5534
5683
|
}
|
|
5535
5684
|
}
|
|
5536
|
-
if (found !== undefined)
|
|
5537
|
-
|
|
5538
|
-
|
|
5685
|
+
if (found !== undefined) selectProgram(found)
|
|
5686
|
+
else {
|
|
5687
|
+
setActivePath(path)
|
|
5688
|
+
activePathRef.current = path
|
|
5689
|
+
}
|
|
5690
|
+
// Even when the pane already shows this log: `selectProgram` is a no-op
|
|
5691
|
+
// for the same path, and the start that sent this broadcast may already
|
|
5692
|
+
// have written lines that no frame delivered. Re-read once.
|
|
5539
5693
|
setLogNonce(function (value) { return value + 1 })
|
|
5540
5694
|
}
|
|
5541
5695
|
window.addEventListener('storage', onStorage)
|
|
@@ -6053,6 +6207,12 @@ var [ui, setUi] = useState(function () {
|
|
|
6053
6207
|
// view has to switch at click time, not after the spawn settles.
|
|
6054
6208
|
selectProgram(program)
|
|
6055
6209
|
broadcastLogFocus(program.logPath)
|
|
6210
|
+
var logPath = typeof program.logPath === 'string' ? program.logPath : ''
|
|
6211
|
+
// Same first-output watch as the debug path. Without it the pane can sit on
|
|
6212
|
+
// the wrapper's marker/command line forever: a start's output arrives as
|
|
6213
|
+
// live frames onto an already-open stream, and one missed frame (or a
|
|
6214
|
+
// viewer mounted a moment too late) is never recovered by a snapshot.
|
|
6215
|
+
var baseline = logPath === '' ? undefined : await logSizeOf(logPath)
|
|
6056
6216
|
setUi(function (prev) { return Object.assign({}, prev, { busy: true, note: '' }) })
|
|
6057
6217
|
statusNote('正在启动 ' + program.name + '…', 0)
|
|
6058
6218
|
setConsoleBusy(program.id)
|
|
@@ -6063,6 +6223,10 @@ var [ui, setUi] = useState(function () {
|
|
|
6063
6223
|
setConsoleBusy('')
|
|
6064
6224
|
}
|
|
6065
6225
|
setUi(function (prev) { return Object.assign({}, prev, { busy: false }) })
|
|
6226
|
+
if (logPath !== '') {
|
|
6227
|
+
setLogNonce(function (value) { return value + 1 })
|
|
6228
|
+
watchLogOutput(logPath, baseline)
|
|
6229
|
+
}
|
|
6066
6230
|
if (result.ok !== true) return note('启动失败:' + result.error)
|
|
6067
6231
|
}
|
|
6068
6232
|
/** Any program with a pidfile can be stopped, frontend included. */
|
|
@@ -6680,6 +6844,15 @@ var [ui, setUi] = useState(function () {
|
|
|
6680
6844
|
return function () { cancelled = true; clearTimeout(timer) }
|
|
6681
6845
|
}, [treeQuery, cwd])
|
|
6682
6846
|
|
|
6847
|
+
/**
|
|
6848
|
+
* New results (and every keystroke) reset the highlight: the row whose file
|
|
6849
|
+
* name matches the query exactly, else the first row — so the dropdown opens
|
|
6850
|
+
* with a visible target and Enter is never a no-op.
|
|
6851
|
+
*/
|
|
6852
|
+
useEffect(function () {
|
|
6853
|
+
setSearchActive(searchHitActiveIndex(searchHits, treeQuery))
|
|
6854
|
+
}, [searchHits, treeQuery])
|
|
6855
|
+
|
|
6683
6856
|
/** A dropdown pick: open files, reveal either kind in the tree, close the list. */
|
|
6684
6857
|
function pickSearchHit(path, isDir) {
|
|
6685
6858
|
setTreeQuery('')
|
|
@@ -7637,6 +7810,19 @@ var [ui, setUi] = useState(function () {
|
|
|
7637
7810
|
// The editor pane's header IS the toolbar now (no workbench-level top bar):
|
|
7638
7811
|
// the search box grows, the fixed action group holds the layout/font/theme
|
|
7639
7812
|
// controls, and the pane's own maximiser stays at the far right.
|
|
7813
|
+
// Both dropdowns share ONE highlighted index (`searchActive`): the recent-file
|
|
7814
|
+
// list while the box is empty, the result list once a query is typed. Either
|
|
7815
|
+
// way the arrow keys move the ROW and never the caret, so typing can go on.
|
|
7816
|
+
var searchHistoryRows = searchFocused === true && treeQuery.trim() === ''
|
|
7817
|
+
? searchHistoryEntries(recentFiles, openFiles, SEARCH_RECENT_LIMIT)
|
|
7818
|
+
: []
|
|
7819
|
+
// Landing on the box highlights the first recent file, ready for Enter — the
|
|
7820
|
+
// same "default row" the result list gets from its own reset effect.
|
|
7821
|
+
useEffect(function () {
|
|
7822
|
+
if (searchHistoryRows.length === 0) return
|
|
7823
|
+
setSearchActive(0)
|
|
7824
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- keyed by list shape
|
|
7825
|
+
}, [searchFocused, treeQuery, searchHistoryRows.length])
|
|
7640
7826
|
var paneSearch = h('span', { style: S.searchWrap, 'data-search-box': '1' },
|
|
7641
7827
|
h('input', {
|
|
7642
7828
|
ref: searchInputRef,
|
|
@@ -7648,23 +7834,57 @@ var [ui, setUi] = useState(function () {
|
|
|
7648
7834
|
onFocus: function () { setSearchFocused(true) },
|
|
7649
7835
|
onBlur: function () { setSearchFocused(false) },
|
|
7650
7836
|
onKeyDown: function (event) {
|
|
7651
|
-
if (event.key === 'Escape') { event.preventDefault(); setTreeQuery(''); setSearchFocused(false) }
|
|
7837
|
+
if (event.key === 'Escape') { event.preventDefault(); setTreeQuery(''); setSearchFocused(false); return }
|
|
7838
|
+
// Whichever dropdown is open is the walkable list: the recent-file list
|
|
7839
|
+
// while the box is empty, the results once a query is typed.
|
|
7840
|
+
var matches = searchHits !== null && searchHits !== undefined && Array.isArray(searchHits.matches) ? searchHits.matches : []
|
|
7841
|
+
var inHistory = searchHistoryRows.length > 0
|
|
7842
|
+
var count = inHistory ? searchHistoryRows.length : matches.length
|
|
7843
|
+
if (count === 0) return
|
|
7844
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
7845
|
+
// The arrow moves the highlighted ROW, not the caret: the box keeps
|
|
7846
|
+
// focus and the cursor position, so typing can go on right after a look.
|
|
7847
|
+
event.preventDefault()
|
|
7848
|
+
var step = event.key === 'ArrowDown' ? 1 : -1
|
|
7849
|
+
setSearchActive(function (current) {
|
|
7850
|
+
var from = current >= 0 && current < count ? current : 0
|
|
7851
|
+
return (from + step + count) % count
|
|
7852
|
+
})
|
|
7853
|
+
return
|
|
7854
|
+
}
|
|
7855
|
+
if (event.key !== 'Enter') return
|
|
7856
|
+
event.preventDefault()
|
|
7857
|
+
var index = searchActive >= 0 && searchActive < count ? searchActive : 0
|
|
7858
|
+
if (inHistory) {
|
|
7859
|
+
var row = searchHistoryRows[index]
|
|
7860
|
+
if (row === undefined) return
|
|
7861
|
+
setTreeQuery('')
|
|
7862
|
+
setSearchFocused(false)
|
|
7863
|
+
void openRecentPath(row.path)
|
|
7864
|
+
return
|
|
7865
|
+
}
|
|
7866
|
+
var chosen = matches[index]
|
|
7867
|
+
pickSearchHit(chosen, searchHits.dirs !== undefined && searchHits.dirs !== null && searchHits.dirs[chosen] === true)
|
|
7652
7868
|
},
|
|
7653
7869
|
}),
|
|
7654
7870
|
searchFocused === true && treeQuery.trim() === ''
|
|
7655
7871
|
? (function () {
|
|
7656
|
-
|
|
7657
|
-
if (historyRows.length === 0) return null
|
|
7872
|
+
if (searchHistoryRows.length === 0) return null
|
|
7658
7873
|
return h('div', {
|
|
7659
7874
|
style: S.searchDropdown, 'data-search-history': '1',
|
|
7660
7875
|
// Keep the input focused so the blur does not eat the click.
|
|
7661
7876
|
onMouseDown: function (event) { event.preventDefault() },
|
|
7662
7877
|
},
|
|
7663
|
-
h('div', { style: S.searchHeader }, '最近打开 · ' +
|
|
7664
|
-
|
|
7878
|
+
h('div', { style: S.searchHeader }, '最近打开 · ' + searchHistoryRows.length + ' 个(↑↓ 选择,Enter 打开)'),
|
|
7879
|
+
searchHistoryRows.map(function (row, index) {
|
|
7880
|
+
var on = index === searchActive
|
|
7665
7881
|
return h('div', {
|
|
7666
|
-
key: 'history:' + row.path,
|
|
7882
|
+
key: 'history:' + row.path,
|
|
7883
|
+
style: on ? Object.assign({}, S.searchRow, S.searchRowOn) : S.searchRow,
|
|
7884
|
+
title: row.path,
|
|
7667
7885
|
'data-search-history-row': row.path,
|
|
7886
|
+
'data-search-history-active': on ? '1' : '0',
|
|
7887
|
+
onMouseEnter: function () { setSearchActive(index) },
|
|
7668
7888
|
onClick: function () {
|
|
7669
7889
|
setTreeQuery('')
|
|
7670
7890
|
setSearchFocused(false)
|
|
@@ -7675,7 +7895,11 @@ var [ui, setUi] = useState(function () {
|
|
|
7675
7895
|
h('span', { style: { overflow: 'hidden', textOverflow: 'ellipsis' } }, displayWorkspacePath(row.path, cwd)))
|
|
7676
7896
|
}))
|
|
7677
7897
|
})()
|
|
7678
|
-
: h(SearchResults, {
|
|
7898
|
+
: h(SearchResults, {
|
|
7899
|
+
hits: searchHits, busy: searchBusy, onPick: pickSearchHit,
|
|
7900
|
+
active: searchActive, onHover: setSearchActive,
|
|
7901
|
+
fontRatio: fontRatio, cwd: cwd,
|
|
7902
|
+
}))
|
|
7679
7903
|
// Panel-wide net: while the IDE is on screen the host's shortcut adapter and
|
|
7680
7904
|
// the browser's own context menu never see events that belong to this panel.
|
|
7681
7905
|
useEffect(function () {
|
|
@@ -7923,7 +8147,7 @@ var [ui, setUi] = useState(function () {
|
|
|
7923
8147
|
},
|
|
7924
8148
|
// The sidebar's CodeMirror theme pins 13px, so the embedded viewer needs
|
|
7925
8149
|
// this rule, not inheritance, to follow A−/A+.
|
|
7926
|
-
h('style', { key: 'ide-font' }, viewerFontCss(uiFont) + viewerThemeCss(pageDark) + DEBUG_LINE_CSS + PREVIEW_CSS + SELECTION_CSS + TOAST_CSS + PROGRAM_LOADING_CSS),
|
|
8150
|
+
h('style', { key: 'ide-font' }, viewerFontCss(uiFont) + viewerThemeCss(pageDark) + DEBUG_LINE_CSS + PREVIEW_CSS + SELECTION_CSS + SCROLLBAR_CSS + TOAST_CSS + PROGRAM_LOADING_CSS),
|
|
7927
8151
|
(function () {
|
|
7928
8152
|
var panes = {
|
|
7929
8153
|
tree: h(IdeTree, {
|
|
@@ -9904,6 +10128,11 @@ var [ui, setUi] = useState(function () {
|
|
|
9904
10128
|
|
|
9905
10129
|
function ProgramsPanel(props) {
|
|
9906
10130
|
var [active, setActive] = useState(function () { return pendingProgram })
|
|
10131
|
+
/**
|
|
10132
|
+
* Bumped when a start/stop may have moved this pane's log beyond the frames
|
|
10133
|
+
* already delivered: the log viewer re-reads the tail once (see `reloadNonce`).
|
|
10134
|
+
*/
|
|
10135
|
+
var [compactLogNonce, setCompactLogNonce] = useState(0)
|
|
9907
10136
|
useEffect(function () {
|
|
9908
10137
|
if (pendingProgram === null) return undefined
|
|
9909
10138
|
setActive(pendingProgram)
|
|
@@ -10061,7 +10290,7 @@ var [ui, setUi] = useState(function () {
|
|
|
10061
10290
|
// Show this program's log from the first moment: the start call waits for
|
|
10062
10291
|
// a pidfile (up to START_WAIT_MS), and Maven compile is silent. The same
|
|
10063
10292
|
// event moves the standalone IDE window's log pane right away.
|
|
10064
|
-
if (kind === 'start') { setActive(program); broadcastLogFocus(program.logPath) }
|
|
10293
|
+
if (kind === 'start') { setActive(program); broadcastLogFocus(program.logPath); setCompactLogNonce(function (value) { return value + 1 }) }
|
|
10065
10294
|
var scopeArg = { sessionId: sessionId, cwd: cwd }
|
|
10066
10295
|
var task = kind === 'start' ? requestStart(program.id, scopeArg) : requestStop(program.logPath, scopeArg)
|
|
10067
10296
|
task.then(function (result) {
|
|
@@ -10074,6 +10303,9 @@ var [ui, setUi] = useState(function () {
|
|
|
10074
10303
|
else if (result.alreadyStopped === true) note = program.name + ' 此前已停止'
|
|
10075
10304
|
else note = program.name + ' 已停止'
|
|
10076
10305
|
setState(function (prev) { return Object.assign({}, prev, { note: note }) })
|
|
10306
|
+
// The start/stop settled and the wrapper wrote its marker: re-read once
|
|
10307
|
+
// so the pane cannot stay on the pre-start text.
|
|
10308
|
+
setCompactLogNonce(function (value) { return value + 1 })
|
|
10077
10309
|
void refresh(false)
|
|
10078
10310
|
}).catch(function (error) {
|
|
10079
10311
|
setBusyId(undefined)
|
|
@@ -10423,6 +10655,8 @@ var [ui, setUi] = useState(function () {
|
|
|
10423
10655
|
fontSize: compactFont,
|
|
10424
10656
|
// A parked log pane must not poll `/tail` either.
|
|
10425
10657
|
visible: props.visible !== false && maxed !== 'console',
|
|
10658
|
+
// A start/stop that settled re-reads the tail once (see act()).
|
|
10659
|
+
reloadNonce: compactLogNonce,
|
|
10426
10660
|
})
|
|
10427
10661
|
: h('div', { style: S.compactEmpty }, '点上面的程序名,这里显示它的实时日志'))
|
|
10428
10662
|
)
|
|
@@ -10643,6 +10877,11 @@ var [ui, setUi] = useState(function () {
|
|
|
10643
10877
|
viewerThemeCss: viewerThemeCss,
|
|
10644
10878
|
stylesFor: stylesFor,
|
|
10645
10879
|
SearchResults: SearchResults,
|
|
10880
|
+
searchHitActiveIndex: searchHitActiveIndex,
|
|
10881
|
+
// Which frames the single stream socket delivers to which subscriber: the
|
|
10882
|
+
// tail bytes ride in `append` frames, so a strict topic match starved every
|
|
10883
|
+
// log pane. Directly testable, and the shape of the bug is easy to regress.
|
|
10884
|
+
risFrameWanted: risFrameWanted,
|
|
10646
10885
|
mergeGlobalBreakpoints: mergeGlobalBreakpoints,
|
|
10647
10886
|
/** Test seam: seed the global breakpoint list (no host/session needed). */
|
|
10648
10887
|
__setGlobalBreakpoints: function (list) { GLOBAL_BREAKPOINTS = Array.isArray(list) ? list : [] },
|
package/lib/index.js
CHANGED
|
@@ -2815,15 +2815,18 @@ async function serveStream(ctx, req, res, options) {
|
|
|
2815
2815
|
let closed = false
|
|
2816
2816
|
const cleanups = []
|
|
2817
2817
|
const send = (event, payload) => {
|
|
2818
|
-
if (closed) return
|
|
2818
|
+
if (closed) return false
|
|
2819
2819
|
// Backpressure: a browser tab that is throttled (background/minimized) must
|
|
2820
|
-
// not make the host buffer log frames without bound.
|
|
2821
|
-
// next
|
|
2822
|
-
|
|
2820
|
+
// not make the host buffer log frames without bound. A dropped frame is NOT
|
|
2821
|
+
// recovered by the next tick — the tail tick only reads from `previousSize`
|
|
2822
|
+
// onwards — so the caller below re-snapshots instead of leaving a gap.
|
|
2823
|
+
if (shouldDropSseFrame(res.writableLength)) return false
|
|
2823
2824
|
try {
|
|
2824
2825
|
res.write(`event: ${event}\ndata: ${JSON.stringify(payload)}\n\n`)
|
|
2826
|
+
return true
|
|
2825
2827
|
} catch {
|
|
2826
2828
|
closed = true
|
|
2829
|
+
return false
|
|
2827
2830
|
}
|
|
2828
2831
|
}
|
|
2829
2832
|
send('hello', { ok: true, version: PKG_VERSION, root: cwd, topics })
|
|
@@ -3020,7 +3023,12 @@ async function serveStream(ctx, req, res, options) {
|
|
|
3020
3023
|
await snapshot()
|
|
3021
3024
|
return
|
|
3022
3025
|
}
|
|
3023
|
-
if (text !== ''
|
|
3026
|
+
if (text !== '' && send('append', { ok: true, text }) === false) {
|
|
3027
|
+
// The delta was dropped: resend the whole window so the pane cannot
|
|
3028
|
+
// stay frozen behind a permanent gap.
|
|
3029
|
+
await snapshot()
|
|
3030
|
+
return
|
|
3031
|
+
}
|
|
3024
3032
|
const service = await readService(target)
|
|
3025
3033
|
send('service', service === undefined ? { serviceKnown: true } : { service, serviceKnown: true })
|
|
3026
3034
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ris-ide",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.11",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "RIS-IDE local dev panel for the DSH web GUI: live log tail, one-click start/stop of workspace programs, JDWP debugging, file tree + editor, and a standalone IDE window that carries no session history. · DSH 右侧栏本地开发面板:日志实时跟随、一键启停本地程序、Java 断点调试、文件树与编辑器、独立 IDE 窗口。",
|
|
6
6
|
"keywords": [
|
|
@@ -202,8 +202,9 @@ test('only invisible outcomes and failures raise a toast', async () => {
|
|
|
202
202
|
// so it keeps a short confirmation toast.
|
|
203
203
|
assert.ok(source.includes('文件树已刷新'), 'manual tree refresh confirms with a toast')
|
|
204
204
|
// The clipboard and the trash are not visible anywhere else: keep telling them.
|
|
205
|
+
// (The strip at the top of the tree is gone — the toast alone carries the state.)
|
|
205
206
|
assert.ok(source.includes("'已复制 ' : '已剪切 '"), 'clipboard state is invisible: keep it')
|
|
206
|
-
assert.
|
|
207
|
+
assert.equal(source.includes('data-tree-clipboard'), false, 'no clipboard strip above the tree')
|
|
207
208
|
assert.ok(source.includes('已移到回收站'))
|
|
208
209
|
})
|
|
209
210
|
|
|
@@ -862,6 +863,24 @@ test('the log viewer is read-only: no stop button, no redundant 到底部', { sk
|
|
|
862
863
|
assert.ok(!none.includes('data-action="stop"'))
|
|
863
864
|
})
|
|
864
865
|
|
|
866
|
+
// 1.6.10: the title-bar wrap toggle was a dead button — neither body style
|
|
867
|
+
// existed, so both modes fell back to the browser default and nothing moved.
|
|
868
|
+
test('the log wrap toggle really changes the body flow', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
|
|
869
|
+
const { renderToStaticMarkup } = require(`${REACT_ROOT}/react-dom/server`)
|
|
870
|
+
const render = (wrap) => renderToStaticMarkup(React.createElement(T.LogTail, {
|
|
871
|
+
scope: { sessionId: 's1', cwd: '/tmp' },
|
|
872
|
+
path: 'service.log',
|
|
873
|
+
wrap,
|
|
874
|
+
customData: { ok: true, content: 'BOOT-OK\n', mode: 'tail', serviceKnown: true },
|
|
875
|
+
}))
|
|
876
|
+
const wrapped = render(true)
|
|
877
|
+
assert.match(wrapped, /data-wrap="on"/)
|
|
878
|
+
assert.match(wrapped, /white-space:pre-wrap/, 'wrap on breaks long lines at the pane edge')
|
|
879
|
+
const plain = render(false)
|
|
880
|
+
assert.match(plain, /data-wrap="off"/)
|
|
881
|
+
assert.match(plain, /white-space:pre/, 'wrap off keeps lines intact and scrolls horizontally')
|
|
882
|
+
})
|
|
883
|
+
|
|
865
884
|
test('requestStop posts the scope and reports the outcome', async () => {
|
|
866
885
|
await withLogServer(async ({ file, state }) => {
|
|
867
886
|
const ok = await T.requestStop(file, { sessionId: 's1', cwd: '/tmp' })
|
|
@@ -1245,7 +1264,8 @@ test('the selected range is highlighted stronger than the other matches', async
|
|
|
1245
1264
|
assert.match(source, /var SELECTION_CSS = /)
|
|
1246
1265
|
assert.match(source, /rgba\(86,182,194,0\.42\)/, 'selection is opaque teal')
|
|
1247
1266
|
// the active-line tint must not cover the selection on the current line(s)
|
|
1248
|
-
assert.match(source, /cm-selectionLayer\{z-index:5 !important\}
|
|
1267
|
+
assert.match(source, /cm-selectionLayer\{z-index:5 !important;pointer-events:none !important\}/,
|
|
1268
|
+
'the raised selection layer must not swallow clicks meant for the caret')
|
|
1249
1269
|
assert.match(source, /dsh-ris-ide-has-selection \.cm-activeLine/, 'selection hides the current-line tint')
|
|
1250
1270
|
assert.match(source, /dsh-ris-ide-has-selection \.cm-activeLineGutter/)
|
|
1251
1271
|
assert.match(source, /rgba\(86,182,194,0\.50\)/, 'focused selection is stronger')
|
|
@@ -1265,6 +1285,33 @@ test('the tree clipboard keys only fire while the tree owns the focus', async ()
|
|
|
1265
1285
|
assert.match(source, /tabIndex: -1/)
|
|
1266
1286
|
})
|
|
1267
1287
|
|
|
1288
|
+
// 1.6.10: Ctrl+C / Ctrl+X used to read the context-menu state only, so the
|
|
1289
|
+
// keyboard silently copied nothing; 全选 has no meaning in a single-selection
|
|
1290
|
+
// tree and must not hand the page a text selection either.
|
|
1291
|
+
test('Ctrl+C copies the selected tree row without the context menu', async () => {
|
|
1292
|
+
const { readFile } = await import('node:fs/promises')
|
|
1293
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
1294
|
+
assert.match(source, /var entry = treeMenu !== null && treeMenu\.entry !== null && treeMenu\.entry !== undefined/,
|
|
1295
|
+
'the context-menu entry still wins when the menu is open')
|
|
1296
|
+
assert.match(source, /: \(selectedPath === null \? null : findEntry\(selectedPath\)\)/,
|
|
1297
|
+
'the keyboard falls back to the tree selection')
|
|
1298
|
+
assert.match(source, /if \(entry === null \|\| entry === undefined\) return/)
|
|
1299
|
+
assert.match(source, /event\.key === 'a' \|\| event\.key === 'A'/, 'Ctrl+A is claimed while the tree owns the keys')
|
|
1300
|
+
})
|
|
1301
|
+
|
|
1302
|
+
test('a file row is a drop target for the directory it lives in', async () => {
|
|
1303
|
+
const { readFile } = await import('node:fs/promises')
|
|
1304
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
1305
|
+
assert.match(source, /var dropDir = entry\.isDir === true \? entry\.path : parentOf\(entry\.path\)/)
|
|
1306
|
+
assert.match(source, /var isDropTarget = dropTarget === entry\.path/, 'file rows highlight too')
|
|
1307
|
+
assert.match(source, /void moveInto\(from, dropDir\)/, 'dropping on a file moves into its parent')
|
|
1308
|
+
assert.match(source, /void importExternal\(dropDir, external, \[\]\)/)
|
|
1309
|
+
// The row handlers must not be dir-gated any more (the bug: `undefined` let the
|
|
1310
|
+
// list container's "blank area = workspace root" drop swallow the event).
|
|
1311
|
+
assert.doesNotMatch(source, /onDrop: entry\.isDir === true \?/)
|
|
1312
|
+
assert.doesNotMatch(source, /onDragOver: entry\.isDir === true \?/)
|
|
1313
|
+
})
|
|
1314
|
+
|
|
1268
1315
|
test('a forced tree read asks the host for a fresh listing', async () => {
|
|
1269
1316
|
const { readFile } = await import('node:fs/promises')
|
|
1270
1317
|
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
@@ -1289,14 +1336,39 @@ test('the tree 复制 menu copies, while 创建副本 makes the duplicate', asyn
|
|
|
1289
1336
|
assert.match(source, /setPrompt\(\{ mode: 'duplicate'/)
|
|
1290
1337
|
assert.match(source, /setPromptName\(duplicateName\(/)
|
|
1291
1338
|
assert.match(source, /副本名称不能与原文件相同/)
|
|
1292
|
-
// A paste collision
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
assert.match(source, /
|
|
1339
|
+
// A paste collision asks for a NEW name (the 副本 convention prefilled), it does
|
|
1340
|
+
// not park a 覆盖/改名/取消 dialog any more — and the copy banner at the top of
|
|
1341
|
+
// the tree is gone.
|
|
1342
|
+
assert.match(source, /function parkPasteName\(source, dir, name\)/)
|
|
1343
|
+
assert.match(source, /setPrompt\(\{ mode: 'paste', dir: dir, ext: '', title: '粘贴为', source: source, conflict: name \}\)/)
|
|
1344
|
+
assert.match(source, /setPromptName\(duplicateName\(name, false\)\)/)
|
|
1345
|
+
assert.match(source, /if \(prompt\.conflict !== undefined && name === prompt\.conflict\)/)
|
|
1346
|
+
assert.match(source, /if \(isExistsProblem\(problem\)\) \{\n\s+parkPasteName\(source, dir, name\)/)
|
|
1347
|
+
assert.doesNotMatch(source, /data-tree-paste-conflict/)
|
|
1348
|
+
assert.doesNotMatch(source, /data-tree-clipboard/)
|
|
1349
|
+
// A COPY onto its own path is a duplicate request (falls through to the prompt),
|
|
1350
|
+
// while CUT → its own folder stays a silent no-op.
|
|
1351
|
+
assert.match(source, /if \(source\.kind === 'clipboard' && target === from && clipboard\.mode !== 'copy'\)/)
|
|
1296
1352
|
// …and moving an entry into its own folder stays a silent no-op.
|
|
1297
1353
|
assert.match(source, /if \(from === dirPath \|\| parentOf\(from\) === dirPath\) return/)
|
|
1298
1354
|
})
|
|
1299
1355
|
|
|
1356
|
+
test('the recent-file dropdown is walkable like the result list', async () => {
|
|
1357
|
+
const { readFile } = await import('node:fs/promises')
|
|
1358
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
1359
|
+
// One highlighted index drives both dropdowns.
|
|
1360
|
+
assert.match(source, /var inHistory = searchHistoryRows\.length > 0/)
|
|
1361
|
+
assert.match(source, /var count = inHistory \? searchHistoryRows\.length : matches\.length/)
|
|
1362
|
+
// Landing on the box highlights row 0 of the history list.
|
|
1363
|
+
assert.match(source, /if \(searchHistoryRows\.length === 0\) return\n\s+setSearchActive\(0\)/)
|
|
1364
|
+
// …and the row can be opened with Enter without touching the caret.
|
|
1365
|
+
assert.match(source, /if \(inHistory\) \{\n\s+var row = searchHistoryRows\[index\]/)
|
|
1366
|
+
assert.match(source, /void openRecentPath\(row\.path\)/)
|
|
1367
|
+
assert.match(source, /'data-search-history-active': on \? '1' : '0'/)
|
|
1368
|
+
assert.match(source, /onMouseEnter: function \(\) \{ setSearchActive\(index\) \}/)
|
|
1369
|
+
assert.match(source, /最近打开 · ' \+ searchHistoryRows\.length \+ ' 个(↑↓ 选择,Enter 打开)/)
|
|
1370
|
+
})
|
|
1371
|
+
|
|
1300
1372
|
test('renaming a file or folder keeps tabs, drafts and history pointing at it', async () => {
|
|
1301
1373
|
// paths under a renamed folder follow it; unrelated paths stay untouched
|
|
1302
1374
|
assert.equal(T.remapPath('/w/a.java', '/w/a.java', '/w/b.java'), '/w/b.java')
|
|
@@ -1704,10 +1776,10 @@ test('only DSH\'s own chords are swallowed inside the IDE', () => {
|
|
|
1704
1776
|
assert.equal(T.shouldBlockHostChord(undefined, false), false)
|
|
1705
1777
|
})
|
|
1706
1778
|
|
|
1707
|
-
test('
|
|
1779
|
+
test('both reload forms are swallowed; Ctrl+Shift+R is the find chord too', () => {
|
|
1708
1780
|
assert.equal(T.isBrowserReloadChord({ ctrlKey: true, key: 'r' }), true)
|
|
1709
1781
|
assert.equal(T.isBrowserReloadChord({ metaKey: true, key: 'R' }), true)
|
|
1710
|
-
assert.equal(T.isBrowserReloadChord({ ctrlKey: true, shiftKey: true, key: '
|
|
1782
|
+
assert.equal(T.isBrowserReloadChord({ ctrlKey: true, shiftKey: true, key: 'R' }), true, 'the browser hard reload is suppressed as well')
|
|
1711
1783
|
assert.equal(T.isBrowserReloadChord({ ctrlKey: true, key: 'f5' }), false)
|
|
1712
1784
|
assert.equal(T.isBrowserReloadChord({ key: 'F5' }), false)
|
|
1713
1785
|
assert.equal(T.isBrowserReloadChord({ ctrlKey: true, altKey: true, key: 'r' }), false)
|
|
@@ -1727,14 +1799,15 @@ test('the shielded set is exactly DSH\'s catalog', () => {
|
|
|
1727
1799
|
assert.equal(T.chordOf({ key: 'F5' }), '', 'no modifier: not a chord')
|
|
1728
1800
|
})
|
|
1729
1801
|
|
|
1730
|
-
test('Ctrl+R focuses the workspace search (and
|
|
1802
|
+
test('Ctrl+R focuses the workspace search (and both browser reloads are suppressed)', () => {
|
|
1731
1803
|
assert.equal(T.GLOBAL_FIND_KEY, 'r')
|
|
1732
1804
|
assert.equal(T.GLOBAL_FIND_LABEL, 'Ctrl+R / F3')
|
|
1733
1805
|
assert.equal(T.isGlobalFindChord({ ctrlKey: true, key: 'r' }), true)
|
|
1734
1806
|
assert.equal(T.isGlobalFindChord({ metaKey: true, key: 'R' }), true)
|
|
1735
1807
|
assert.equal(T.isGlobalFindChord({ key: 'F3' }), true)
|
|
1736
|
-
// Ctrl+Shift+R (
|
|
1737
|
-
|
|
1808
|
+
// Ctrl+Shift+R (the browser's HARD reload) is the same chord: it must land in the
|
|
1809
|
+
// search box instead of throwing the whole IDE away.
|
|
1810
|
+
assert.equal(T.isGlobalFindChord({ ctrlKey: true, shiftKey: true, key: 'R' }), true)
|
|
1738
1811
|
assert.equal(T.isGlobalFindChord({ ctrlKey: true, altKey: true, key: 'f' }), false, 'Ctrl+Alt+F is DSH fork')
|
|
1739
1812
|
assert.equal(T.isGlobalFindChord({ ctrlKey: true, key: 'f' }), false, 'Ctrl+F belongs to editors')
|
|
1740
1813
|
assert.equal(T.isGlobalFindChord(undefined), false)
|
|
@@ -1912,7 +1985,7 @@ test('Ctrl+R turns a single-line editor selection into the search query', async
|
|
|
1912
1985
|
assert.match(source, /if \(text === '' \|\| text\.indexOf\('\\n'\) !== -1 \|\| text\.length > GLOBAL_FIND_SELECTION_MAX\) return ''/, 'multiline / oversized selections are ignored')
|
|
1913
1986
|
assert.match(source, /if \(element\.closest\('\.cm-content'\) === null\) return ''/, 'only editor selections count')
|
|
1914
1987
|
assert.match(source, /var picked = selectedEditorText\(\)[\s\S]{0,400}?setTreeQuery\(picked\)/, 'the pick becomes the query')
|
|
1915
|
-
assert.match(source, /h\(SearchResults, \{
|
|
1988
|
+
assert.match(source, /h\(SearchResults, \{[\s\S]{0,240}?active: searchActive, onHover: setSearchActive,[\s\S]{0,120}?fontRatio: fontRatio, cwd: cwd,/, 'results know the workspace root and the highlighted row')
|
|
1916
1989
|
})
|
|
1917
1990
|
|
|
1918
1991
|
test('an unfocused editor stops painting its selection', async () => {
|
|
@@ -2275,6 +2348,69 @@ test('the search dropdown renders hits, empty state and errors', { skip: !reactI
|
|
|
2275
2348
|
assert.match(render({ error: 'boom' }), /检索失败:boom/)
|
|
2276
2349
|
})
|
|
2277
2350
|
|
|
2351
|
+
test('the dropdown highlights the exact file-name match, else the first row', () => {
|
|
2352
|
+
const hits = { matches: ['/w/x/Alpha.java', '/w/y/ModelHelper.java'], dirs: {} }
|
|
2353
|
+
assert.equal(T.searchHitActiveIndex(hits, 'ModelHelper.java'), 1, 'the full name the user typed wins over row 0')
|
|
2354
|
+
assert.equal(T.searchHitActiveIndex(hits, 'modelhelper.JAVA'), 1, 'case does not matter')
|
|
2355
|
+
assert.equal(T.searchHitActiveIndex(hits, 'Missing.java'), 0, 'no exact name: the first row')
|
|
2356
|
+
assert.equal(T.searchHitActiveIndex(hits, ''), 0)
|
|
2357
|
+
// A directory whose basename matches is never the "file name" target.
|
|
2358
|
+
assert.equal(T.searchHitActiveIndex({ matches: ['/w/src', '/w/z/src'], dirs: { '/w/src': true } }, 'src'), 1, 'a directory is skipped when matching a name')
|
|
2359
|
+
assert.equal(T.searchHitActiveIndex({ matches: [], dirs: {} }, 'a'), -1)
|
|
2360
|
+
assert.equal(T.searchHitActiveIndex(null, 'a'), -1)
|
|
2361
|
+
assert.equal(T.searchHitActiveIndex(undefined, undefined), -1)
|
|
2362
|
+
})
|
|
2363
|
+
|
|
2364
|
+
test('the one stream socket delivers tail bytes to a viewer that asked for `tail`', async () => {
|
|
2365
|
+
// The host opens the tail FILE for whoever asked for `tail` and pushes the
|
|
2366
|
+
// bytes as `append` (plus `service` / `tail-error` for the same file). A strict
|
|
2367
|
+
// topic match dropped every one of those frames, so a log pane froze on the one
|
|
2368
|
+
// snapshot it mounted with ("只有在最大化/点项目行重挂载后才有后续内容").
|
|
2369
|
+
assert.equal(T.risFrameWanted(['tail'], 'append', '/w/a.log', '/w/a.log'), true, 'append rides the tail subscription')
|
|
2370
|
+
assert.equal(T.risFrameWanted(['tail'], 'service', '/w/a.log', '/w/a.log'), true, 'service rides the tail subscription')
|
|
2371
|
+
assert.equal(T.risFrameWanted(['tail'], 'tail-error', '/w/a.log', '/w/a.log'), true, 'a tail failure reaches its viewer')
|
|
2372
|
+
assert.equal(T.risFrameWanted(['tail'], 'tail', '/w/a.log', '/w/a.log'), true)
|
|
2373
|
+
assert.equal(T.risFrameWanted(['tree'], 'append', '/w/a.log', '/w/a.log'), false, 'a tree subscriber never sees tail bytes')
|
|
2374
|
+
assert.equal(T.risFrameWanted(['tail'], 'append', '/w/b.log', '/w/a.log'), false, 'only the pane on the served file applies the bytes')
|
|
2375
|
+
assert.equal(T.risFrameWanted(['tail'], 'append', '/w/b.log', ''), true, 'an unknown served tail still delivers')
|
|
2376
|
+
assert.equal(T.risFrameWanted(['tail'], 'tree', '/w/a.log', '/w/a.log'), false, 'unrelated frames stay filtered')
|
|
2377
|
+
assert.equal(T.risFrameWanted(['programs'], 'stream-error'), true, 'a connection-wide failure reaches everyone')
|
|
2378
|
+
assert.equal(T.risFrameWanted(undefined, 'tree'), false)
|
|
2379
|
+
assert.equal(T.risFrameWanted(undefined, 'stream-error'), true)
|
|
2380
|
+
// The dispatcher must route through it instead of the old strict comparison.
|
|
2381
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
2382
|
+
assert.match(source, /if \(!risFrameWanted\(sub\.topics, topic, sub\.tail, servedTail\)\) return/)
|
|
2383
|
+
assert.doesNotMatch(source, /if \(\(sub\.topics \|\| \[\]\)\.indexOf\(topic\) === -1\) return/, 'the strict topic match is the bug')
|
|
2384
|
+
})
|
|
2385
|
+
|
|
2386
|
+
test('the highlighted search row is marked, tinted and hover-driven', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
|
|
2387
|
+
const { renderToStaticMarkup } = require(`${REACT_ROOT}/react-dom/server`)
|
|
2388
|
+
const markup = renderToStaticMarkup(React.createElement(T.SearchResults, {
|
|
2389
|
+
hits: { matches: ['/w/a.java', '/w/b.java'], dirs: {} },
|
|
2390
|
+
active: 1,
|
|
2391
|
+
fontRatio: 1,
|
|
2392
|
+
onPick: () => {},
|
|
2393
|
+
onHover: () => {},
|
|
2394
|
+
}))
|
|
2395
|
+
assert.match(markup, /data-search-hit-path="\/w\/a\.java"[^>]*data-search-hit-active="0"/)
|
|
2396
|
+
assert.match(markup, /data-search-hit-path="\/w\/b\.java"[^>]*data-search-hit-active="1"/)
|
|
2397
|
+
assert.match(markup, /style="[^"]*background:color-mix\(in srgb, currentColor 18%, transparent\)"[^>]*data-search-hit-active="1"/, 'the active row is tinted')
|
|
2398
|
+
})
|
|
2399
|
+
|
|
2400
|
+
test('the workspace search keeps its caret while the dropdown is walked', async () => {
|
|
2401
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
2402
|
+
// Arrows move the ROW, and preventDefault keeps the caret where it was.
|
|
2403
|
+
assert.match(source, /if \(event\.key === 'ArrowDown' \|\| event\.key === 'ArrowUp'\) \{[\s\S]{0,600}?event\.preventDefault\(\)[\s\S]{0,200}?setSearchActive\(function \(current\)/, 'arrows walk the results')
|
|
2404
|
+
assert.match(source, /\(from \+ step \+ count\) % count/, 'the walk wraps around')
|
|
2405
|
+
assert.match(source, /if \(event\.key !== 'Enter'\) return[\s\S]{0,1200}?pickSearchHit\(chosen,/, 'Enter picks the highlighted row')
|
|
2406
|
+
assert.match(source, /if \(inHistory\) \{\n\s+var row = searchHistoryRows\[index\][\s\S]{0,300}?void openRecentPath\(row\.path\)/, 'Enter opens the highlighted recent file')
|
|
2407
|
+
// A click on a row must not blur the box.
|
|
2408
|
+
assert.match(source, /'data-search-results': '1',[\s\S]{0,400}?onMouseDown: function \(event\) \{ event\.preventDefault\(\) \}/, 'the dropdown swallows mousedown')
|
|
2409
|
+
// The payload arrives with a highlight already computed.
|
|
2410
|
+
assert.match(source, /setSearchActive\(searchHitActiveIndex\(searchHits, treeQuery\)\)/)
|
|
2411
|
+
assert.match(source, /function searchHitActiveIndex\(hits, query\)/)
|
|
2412
|
+
})
|
|
2413
|
+
|
|
2278
2414
|
test('the log pane title bar holds icon buttons (no refresh, no find button)', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
|
|
2279
2415
|
const tab = { id: T.PROGRAM_TAB_ID, type: T.PROGRAM_TAB_ID, title: 'workspace', meta: { logPath: '/w/logs/a.log', name: 'a-biz', kind: 'spring' } }
|
|
2280
2416
|
const programs = [{ id: 'spring:a#A', name: 'a-biz', kind: 'spring', logPath: '/w/logs/a.log', hasLog: true, running: { pid: 42, alive: true } }]
|
|
@@ -3254,7 +3390,7 @@ test('a start switches to that program log before waiting for the spawn', async
|
|
|
3254
3390
|
// block for START_WAIT_MS, and Maven compile prints nothing for tens of seconds.
|
|
3255
3391
|
assert.match(source, /async function consoleStart\(program\) \{\n\s*\/\/[\s\S]*?\n\s*selectProgram\(program\)[\s\S]*?setConsoleBusy\(program\.id\)[\s\S]*?requestStart\(program\.id, scopeRef\.current\)/)
|
|
3256
3392
|
// The sidebar rows do the same before awaiting requestStart.
|
|
3257
|
-
assert.match(source, /if \(kind === 'start'\) \{ setActive\(program\); broadcastLogFocus\(program\.logPath\)
|
|
3393
|
+
assert.match(source, /if \(kind === 'start'\) \{ setActive\(program\); broadcastLogFocus\(program\.logPath\); setCompactLogNonce/)
|
|
3258
3394
|
// …and every window watching another log is moved by the same broadcast.
|
|
3259
3395
|
assert.match(source, /function broadcastLogFocus\(logPath\)/)
|
|
3260
3396
|
})
|
|
@@ -3555,3 +3691,28 @@ test('trimLargeTextFront frees whole lines and keeps the line count aligned', ()
|
|
|
3555
3691
|
assert.deepEqual(T.trimLargeTextFront('short', 100), { text: 'short', droppedLines: 0, droppedChars: 0 })
|
|
3556
3692
|
assert.deepEqual(T.trimLargeTextFront('', 100), { text: '', droppedLines: 0, droppedChars: 0 })
|
|
3557
3693
|
})
|
|
3694
|
+
|
|
3695
|
+
test('the editor scrollbars are visible and a start re-reads its log', async () => {
|
|
3696
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
3697
|
+
// BUG3: the host theme paints a 5px near-invisible scrollbar; the panel gives
|
|
3698
|
+
// the editor/log/tree real bars without reserving a gutter on short files.
|
|
3699
|
+
assert.match(source, /var SCROLLBAR_CSS = /)
|
|
3700
|
+
assert.match(source, /::-webkit-scrollbar\{width:10px;height:10px\}/)
|
|
3701
|
+
assert.match(source, /::-webkit-scrollbar-thumb/)
|
|
3702
|
+
assert.match(source, /SELECTION_CSS \+ SCROLLBAR_CSS \+ TOAST_CSS/, 'injected with the panel styles')
|
|
3703
|
+
assert.doesNotMatch(source, /SCROLLBAR_CSS[\s\S]{0,800}?scrollbar-gutter/, 'no empty gutter on files that do not overflow')
|
|
3704
|
+
// BUG6: a start records a size baseline and watches for its first new byte …
|
|
3705
|
+
assert.match(source, /async function consoleStart\(program\) \{[\s\S]{0,700}?await logSizeOf\(logPath\)/, 'the start records a size baseline')
|
|
3706
|
+
assert.match(source, /async function consoleStart\(program\) \{[\s\S]{0,2400}?watchLogOutput\(logPath, baseline\)/, 'and watches the first new byte')
|
|
3707
|
+
// … a pane mounting on an already-open socket reads its tail once …
|
|
3708
|
+
assert.match(source, /if \(typeof EventSource !== 'function'\) return\n\s*void refresh\(\)/, 'first paint reads the tail')
|
|
3709
|
+
// … and the shared socket reports which file it follows, so a second log pane
|
|
3710
|
+
// polls instead of waiting on someone else's stream.
|
|
3711
|
+
assert.match(source, /var servedTail = ''/, 'the connection remembers its tail path')
|
|
3712
|
+
assert.match(source, /notifyOpen\(\)/)
|
|
3713
|
+
assert.match(source, /setStreamOk\(served === '' \|\| served === path\)/, 'a pane the socket does not carry falls back to polling')
|
|
3714
|
+
assert.match(source, /setCompactLogNonce\(function \(value\) \{ return value \+ 1 \}\)/, 'the sidebar pane re-reads after start/stop')
|
|
3715
|
+
// … and the host never drops a delta without re-snapshotting.
|
|
3716
|
+
const host = await readFile(new URL('../lib/index.js', import.meta.url), 'utf8')
|
|
3717
|
+
assert.match(host, /if \(text !== '' && send\('append', \{ ok: true, text \}\) === false\) \{[\s\S]{0,200}?await snapshot\(\)/, 'a dropped frame re-snapshots')
|
|
3718
|
+
})
|