dsh-ris-ide 1.8.1 → 1.8.2

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.
Files changed (47) hide show
  1. package/README.md +2 -2
  2. package/lib/client.js +311 -72
  3. package/lib/debug/vendor/README.md +14 -0
  4. package/lib/debug/vendor/jdwp/client.js +9 -4
  5. package/lib/debug/vendor/src/jdwp/client.ts +12 -5
  6. package/lib/index.js +794 -48
  7. package/lib/redirector.js +42 -2
  8. package/lib/risd/lifecycle.js +9 -3
  9. package/lib/risd/server.js +308 -13
  10. package/lib/risd/ui.js +149 -112
  11. package/lib/risd-client.js +4 -1
  12. package/lib/startup.js +27 -7
  13. package/package.json +2 -2
  14. package/test/client-viewer.test.mjs +188 -95
  15. package/test/clipboard.test.mjs +259 -0
  16. package/test/debug-engine.test.mjs +3 -1
  17. package/test/dsh-origin.test.mjs +4 -11
  18. package/test/dsh-window-refresh.test.mjs +166 -1
  19. package/test/harness.test.mjs +1 -1
  20. package/test/helpers/cmd.mjs +29 -0
  21. package/test/helpers/tgz.mjs +71 -0
  22. package/test/host-search.test.mjs +18 -11
  23. package/test/host-tail.test.mjs +119 -24
  24. package/test/proxy-route.test.mjs +61 -0
  25. package/test/proxy-window.test.mjs +5 -0
  26. package/test/proxy.test.mjs +13 -1
  27. package/test/proxybridge-bundle.test.mjs +1 -59
  28. package/test/redirector-bundle.test.mjs +21 -67
  29. package/test/redirector.test.mjs +41 -4
  30. package/test/risd-api.test.mjs +81 -28
  31. package/test/risd-bridge-degrade.test.mjs +3 -29
  32. package/test/risd-engine.test.mjs +13 -50
  33. package/test/risd-entry.test.mjs +0 -37
  34. package/test/risd-follow-start.test.mjs +101 -0
  35. package/test/risd-git.test.mjs +7 -5
  36. package/test/risd-handoff.test.mjs +6 -50
  37. package/test/risd-helpers.mjs +150 -3
  38. package/test/risd-host-p2.test.mjs +2 -30
  39. package/test/risd-lifecycle.test.mjs +25 -0
  40. package/test/risd-programs.test.mjs +4 -34
  41. package/test/risd-review-p2.test.mjs +0 -13
  42. package/test/risd-shutdown.test.mjs +5 -38
  43. package/test/risd-teardown.test.mjs +8 -27
  44. package/test/risd-ui.test.mjs +169 -13
  45. package/test/risd-write.test.mjs +2 -1
  46. package/test/startup-reconcile.test.mjs +44 -8
  47. package/test/proxy-restart.test.mjs +0 -39
@@ -20,6 +20,7 @@ import { join } from 'node:path'
20
20
  import { fileURLToPath } from 'node:url'
21
21
 
22
22
  import { __test as hostTest } from '../lib/index.js'
23
+ import { HAS_GIT, skipWithout } from './helpers/cmd.mjs'
23
24
 
24
25
  const require = createRequire(import.meta.url)
25
26
  const ROOT = fileURLToPath(new URL('..', import.meta.url))
@@ -189,7 +190,7 @@ test('one proxy control governs engine, interception and git together', async ()
189
190
  const host = await readFile(new URL('../lib/index.js', import.meta.url), 'utf8')
190
191
  // Start/stop drive all three layers, and so does the host exit hook. The UI that
191
192
  // used to say so lives on the risd page now (the panel dialog is deleted).
192
- assert.ok(host.includes('const redirector = await startRedirectors()'), 'start brings the interception up')
193
+ assert.ok(host.includes('const redirector = await startRedirectors({ interactive })'), 'start brings the interception up (a local fallback keeps the click interactive)')
193
194
  assert.ok(host.includes('syncGitProxy({ cwd, host: gitHost, enabled: true })'), 'start writes the git entry')
194
195
  assert.ok(host.includes('syncGitProxy({ cwd, host: gitHost, enabled: false })'), 'stop clears the git entry')
195
196
  assert.ok(host.includes('const redirector = await stopRedirector()'), 'stop brings the interception down')
@@ -218,7 +219,7 @@ test('the console follows the live sidebar session, not the one it opened in', a
218
219
  'the chrome stack must match what the IDE theme resolves to, not a mono list')
219
220
  })
220
221
 
221
- test('only invisible outcomes and failures raise a toast', async () => {
222
+ test('only invisible outcomes and failures raise a toast, and progress goes to the status bar', async () => {
222
223
  const { readFile } = await import('node:fs/promises')
223
224
  const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
224
225
  // Visible-in-the-UI successes stay silent: the row/tab/marker already changed.
@@ -242,6 +243,20 @@ test('only invisible outcomes and failures raise a toast', async () => {
242
243
  assert.ok(source.includes("'已复制 ' : '已剪切 '"), 'clipboard state is invisible: keep it')
243
244
  assert.equal(source.includes('data-tree-clipboard'), false, 'no clipboard strip above the tree')
244
245
  assert.ok(source.includes('已移到回收站'))
246
+ // The sidebar console's success notes are gone too (its row settles in place);
247
+ // failures still say which action failed.
248
+ assert.doesNotMatch(source, /program\.name \+ ' 已(启动|重启|停止)'/, 'no success note in the sidebar console')
249
+ assert.doesNotMatch(source, /program\.name \+ ' 已在运行'/, 'already-running stays silent too')
250
+ assert.match(source, /'启动失败:' : kind === 'restart' \? '重启失败:' : '停止失败:'/, 'failures still surface')
251
+ // Progress lives in a status channel of its own, not in a toast; the static
252
+ // bottom shortcut hint moved into the ? panel.
253
+ assert.ok(!source.includes('Ctrl+S 保存 · Ctrl+W 关页签 · 拖分隔条调大小 · 双击标题最大化'))
254
+ assert.ok(!source.includes("' · F5 步入 · F6 单步 · F7 步出 · F8 继续'"))
255
+ assert.ok(source.includes("var [statusText, setStatusText] = useState('')"))
256
+ assert.ok(source.includes("statusNote('正在获取依赖源码:' + cleaned + '…', 0)"))
257
+ assert.ok(source.includes("statusNote('正在启动 ' + program.name + '…', 0)"))
258
+ assert.ok(!source.includes("note('正在获取依赖源码:"))
259
+ assert.ok(source.includes("'data-ide-status-text': statusText === '' ? '0' : '1'"))
245
260
  })
246
261
 
247
262
  test('the tab dropdown lists open files then recent history, capped at 30', () => {
@@ -317,19 +332,6 @@ test('bulk close separates victims from the dirty ones it must ask about', () =>
317
332
  assert.deepEqual(T.bulkClosePlan([], undefined, dirty, false), { victims: [], dirty: [] })
318
333
  })
319
334
 
320
- test('the editor surfaces the batch-close prompt and the tab dropdown', async () => {
321
- const { readFile } = await import('node:fs/promises')
322
- const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
323
- for (const action of ['bulk-save-close', 'bulk-discard-close', 'bulk-cancel-close', 'tabs-menu']) {
324
- assert.ok(source.includes(`'data-action': '${action}'`), `${action} is wired`)
325
- }
326
- assert.match(source, /'data-bulk-prompt': '1'/)
327
- assert.match(source, /'data-tabs-menu': '1'/)
328
- assert.match(source, /recent: recentFiles/, 'the history survives a reload')
329
- assert.match(source, /'data-search-history': '1'/, 'the empty search box shows the history')
330
- assert.match(source, /'data-search-history-row': row.path/)
331
- })
332
-
333
335
  test('the bundle registers under the package name and exports a cordis plugin', () => {
334
336
  assert.equal(registration.id, 'dsh-ris-ide')
335
337
  assert.equal(client.name, 'dsh-ris-ide')
@@ -385,24 +387,22 @@ test('the compact panel is console rows plus a resizable 240px log pane', () =>
385
387
  }
386
388
  })
387
389
 
388
- test('the compact panel remembers which section is maximized', () => {
389
- assert.equal(T.readCompactMax(), '', 'nothing saved yet: the split view')
390
- const storage = {
391
- getItem: (key) => (key === T.COMPACT_MAX_KEY ? 'log' : null),
392
- setItem: () => {},
393
- }
394
- const previous = globalThis.window.localStorage
395
- globalThis.window.localStorage = storage
390
+ test('the compact panel does NOT remember which section was maximized (m00584)', () => {
391
+ // A persisted ⤢ used to hide the other section on every reopen, with nothing on
392
+ // screen explaining where it went, so the maximize mode became view state only.
393
+ assert.equal(T.readCompactMax, undefined, 'the stored mode is no longer read at all')
394
+ assert.equal(T.COMPACT_MAX_KEY, undefined, 'and the machine-wide key is gone')
395
+ if (!reactIsReal) return
396
+ const previous = Object.prototype.hasOwnProperty.call(globalThis, 'localStorage') ? globalThis.localStorage : undefined
397
+ globalThis.localStorage = { getItem: () => 'log', setItem: () => {} }
396
398
  try {
397
- assert.equal(T.readCompactMax(), 'log', 'the maximized log is remembered')
398
- storage.getItem = () => 'console'
399
- assert.equal(T.readCompactMax(), 'console')
400
- storage.getItem = () => 'editor'
401
- assert.equal(T.readCompactMax(), '', 'an unknown section degrades to the split view')
402
- storage.getItem = () => 'not-json'
403
- assert.equal(T.readCompactMax(), '')
399
+ const { renderToStaticMarkup } = require(`${REACT_ROOT}/react-dom/server`)
400
+ const markup = renderToStaticMarkup(React.createElement(T.ProgramsPanel, { sessionId: 's1', cwd: '/w', visible: true, compact: true }))
401
+ assert.match(markup, /data-action="compact-max-console"/, 'a stored "log" still leaves both sections on screen')
402
+ assert.match(markup, /data-action="compact-max-log"/)
404
403
  } finally {
405
- globalThis.window.localStorage = previous
404
+ if (previous === undefined) delete globalThis.localStorage
405
+ else globalThis.localStorage = previous
406
406
  }
407
407
  })
408
408
 
@@ -1891,7 +1891,7 @@ test('destructive file operations offer an inline undo and never strand focus',
1891
1891
  assert.match(source, /'data-tree-confirm-cancel': '1'/)
1892
1892
  })
1893
1893
 
1894
- test('the recent-file dropdown is walkable like the result list', async () => {
1894
+ test('the recent-file dropdown is walkable like the result list, and the tab/batch menus are wired', async () => {
1895
1895
  const { readFile } = await import('node:fs/promises')
1896
1896
  const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
1897
1897
  // One highlighted index drives both dropdowns.
@@ -1905,6 +1905,16 @@ test('the recent-file dropdown is walkable like the result list', async () => {
1905
1905
  assert.match(source, /'data-search-history-active': on \? '1' : '0'/)
1906
1906
  assert.match(source, /onMouseEnter: function \(\) \{ setSearchActive\(index\) \}/)
1907
1907
  assert.match(source, /最近打开 · ' \+ searchHistoryRows\.length \+ ' 个(↑↓ 选择,Enter 打开)/)
1908
+ // The same menu machinery drives the tab dropdown and the batch-close prompt
1909
+ // (the batch bar's buttons are only reachable from that menu).
1910
+ for (const action of ['bulk-save-close', 'bulk-discard-close', 'bulk-cancel-close', 'tabs-menu']) {
1911
+ assert.ok(source.includes(`'data-action': '${action}'`), `${action} is wired`)
1912
+ }
1913
+ assert.match(source, /'data-bulk-prompt': '1'/)
1914
+ assert.match(source, /'data-tabs-menu': '1'/)
1915
+ assert.match(source, /'data-search-history': '1'/, 'the empty search box shows the history')
1916
+ assert.match(source, /'data-search-history-row': row.path/)
1917
+ assert.match(source, /recent: recentFiles/, 'the history survives a reload')
1908
1918
  })
1909
1919
 
1910
1920
  test('renaming a file or folder keeps tabs, drafts and history pointing at it', async () => {
@@ -2113,6 +2123,77 @@ test('the tree mutations post JSON to the fs op routes', async () => {
2113
2123
  }
2114
2124
  })
2115
2125
 
2126
+ test('an outside-workspace refusal re-reads the live session and retries once (m00220)', async () => {
2127
+ const posts = []
2128
+ const original = globalThis.fetch
2129
+ globalThis.fetch = async (url, init) => {
2130
+ const href = String(url)
2131
+ // The window that kept the Session it booted on asks the host which Session
2132
+ // owns the workspace it shows.
2133
+ if (href.includes('/dsh-ris-ide/windows')) {
2134
+ return { ok: true, status: 200, json: async () => ({ ok: true, windows: [], session: { id: 's-live' } }) }
2135
+ }
2136
+ posts.push({ url: href, body: JSON.parse(init.body) })
2137
+ if (posts.length === 1) {
2138
+ return { ok: false, status: 403, json: async () => ({ ok: false, code: 'outside-workspace', message: '不能对工作区之外的路径执行新建文件夹' }) }
2139
+ }
2140
+ return { ok: true, status: 200, json: async () => ({ ok: true, path: '/w/newdir' }) }
2141
+ }
2142
+ try {
2143
+ const created = await T.fsMkdir({ sessionId: 's-stale', cwd: '/w' }, '/w/newdir')
2144
+ assert.equal(created.ok, true, 'the mutation succeeds instead of hitting the global error banner')
2145
+ assert.equal(posts.length, 2, 'exactly one retry')
2146
+ assert.equal(posts[0].body.sessionId, 's-stale')
2147
+ assert.equal(posts[1].body.sessionId, 's-live', 'the retry carries the host-live Session')
2148
+ assert.equal(posts[1].body.cwd, '/w', 'and the workspace the tree showed')
2149
+ } finally {
2150
+ globalThis.fetch = original
2151
+ }
2152
+ })
2153
+
2154
+ test('a refusal with nothing to heal surfaces with the host code, without a retry loop', async () => {
2155
+ const posts = []
2156
+ const original = globalThis.fetch
2157
+ globalThis.fetch = async (url, init) => {
2158
+ const href = String(url)
2159
+ if (href.includes('/dsh-ris-ide/windows')) {
2160
+ return { ok: true, status: 200, json: async () => ({ ok: true, windows: [], session: { id: 's1' } }) }
2161
+ }
2162
+ posts.push(href)
2163
+ return { ok: false, status: 403, json: async () => ({ ok: false, code: 'outside-workspace', message: '不能对工作区之外的路径执行删除' }) }
2164
+ }
2165
+ try {
2166
+ await assert.rejects(
2167
+ () => T.fsRemoveEntry({ sessionId: 's1', cwd: '/w' }, '/w/x', true),
2168
+ (error) => error.code === 'outside-workspace' && /不能对工作区之外的路径执行删除/.test(error.message),
2169
+ )
2170
+ assert.equal(posts.length, 1, 'the same Session is not asked twice')
2171
+ } finally {
2172
+ globalThis.fetch = original
2173
+ }
2174
+ })
2175
+
2176
+ test('the panel publishes its freshest scope for the retry', async () => {
2177
+ const { readFile } = await import('node:fs/promises')
2178
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
2179
+ assert.match(source, /function setLiveScopeResolver\(resolver\)/, 'the page can register a live-scope reader')
2180
+ assert.match(source, /return function \(\) \{ setLiveScopeResolver\(null\) \}/, 'and clears it when the panel unmounts')
2181
+ assert.match(source, /var live = liveSidebarSessionId\(\)/, 'the reader asks the sidebar which Session is live')
2182
+ assert.match(source, /await liveSessionOfScope\(scope\)/, 'the retry can also ask the host')
2183
+ })
2184
+
2185
+ test('context-menu rows show the same faint hover background as the tree rows (m00220)', async () => {
2186
+ const { readFile } = await import('node:fs/promises')
2187
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
2188
+ // `S.tabMenuItem` pins `background: transparent` inline, so the stylesheet needs
2189
+ // `!important` or every menu row keeps its flat look on hover.
2190
+ assert.match(source, /var MENU_HOVER_CSS = '\[data-workbench="ris-ide"\] \[data-ris-ide-menu\] button:hover:not\(:disabled\)'/)
2191
+ assert.match(source, /background:rgba\(0,0,0,0\.05\) !important/)
2192
+ assert.match(source, /\+ TREE_HOVER_CSS \+ MENU_HOVER_CSS\)/, 'the panel style sheet carries the rule')
2193
+ const marked = (source.match(/'data-ris-ide-menu': '1'/g) ?? []).length
2194
+ assert.ok(marked >= 5, `every menu container is marked (tree, flyout, tabs, tab, editor): ${marked}`)
2195
+ })
2196
+
2116
2197
  test('absolutePath resolves cwd-relative paths and keeps absolute ones', () => {
2117
2198
  assert.equal(T.absolutePath('/w', 'ris/a.java'), '/w/ris/a.java')
2118
2199
  assert.equal(T.absolutePath('/w/', 'ris/a.java'), '/w/ris/a.java')
@@ -2378,19 +2459,7 @@ test('a whole workbench console row picks the program, name and blank alike', as
2378
2459
  assert.match(source, /button\(ideBadgeIcon\('bug', 'play', 13\), function \(event\) \{ event\.stopPropagation\(\); void consoleDebug\(program\) \}/)
2379
2460
  })
2380
2461
 
2381
- test('sidebar start/stop/restart stay silent, and ⟳ is green like ▶', async () => {
2382
- const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
2383
- // The sidebar row itself shows the settled state (dot + ▶/■ swap): successes
2384
- // must not push the list down with a "已启动" strip. Failures still do.
2385
- assert.doesNotMatch(source, /program\.name \+ ' 已(启动|重启|停止)'/, 'no success note in the sidebar console')
2386
- assert.doesNotMatch(source, /program\.name \+ ' 已在运行'/, 'already-running stays silent too')
2387
- assert.match(source, /'启动失败:' : kind === 'restart' \? '重启失败:' : '停止失败:'/, 'failures still surface')
2388
- // ⟳ (re)starts, so it shares ▶'s green in BOTH consoles; ■ keeps red.
2389
- assert.match(source, /S\.startIcon, disabled: busy, 'data-action': 'restart'/, 'sidebar ⟳ is green')
2390
- assert.match(source, /width: 25, start: true, action: 'console-restart'/, 'workbench ⟳ is green')
2391
- })
2392
-
2393
- test('the stop mark is a drawn square, and the sidebar batch bar keeps the row tones', async () => {
2462
+ test('the stop mark is a drawn square, ⟳ is green like ▶, and the sidebar batch bar keeps the row tones', async () => {
2394
2463
  const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
2395
2464
  // The ■ character's ink is about half its advance width: inside a 20px sidebar
2396
2465
  // button (or a 25px workbench one) it read as a dot. Every stop control draws a
@@ -2409,6 +2478,9 @@ test('the stop mark is a drawn square, and the sidebar batch bar keeps the row t
2409
2478
  assert.match(source, /width: 25, stop: true, action: 'batch-stop'/, 'workbench batch ■ keeps its red tone')
2410
2479
  const glyphUses = source.match(/stopGlyph\(/g) || []
2411
2480
  assert.ok(glyphUses.length >= 4, 'both consoles (row + batch) draw the square')
2481
+ // ⟳ (re)starts, so it shares ▶'s green in BOTH consoles; ■ keeps red.
2482
+ assert.match(source, /S\.startIcon, disabled: busy, 'data-action': 'restart'/, 'sidebar ⟳ is green')
2483
+ assert.match(source, /width: 25, start: true, action: 'console-restart'/, 'workbench ⟳ is green')
2412
2484
  })
2413
2485
 
2414
2486
  test('copying in the tree also publishes the files to the OS clipboard', async () => {
@@ -2695,7 +2767,7 @@ test('fsTree fails loudly on a host without the tree route (no sidebar fallback)
2695
2767
  }
2696
2768
  })
2697
2769
 
2698
- test('the saved layout (maximised + theme + font + sizes) restores on init, even from a legacy key', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
2770
+ test('the saved layout (theme + font + sizes) restores on init, even from a legacy key — but maximised mode does not (m00584)', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
2699
2771
  const hadLocalStorage = Object.prototype.hasOwnProperty.call(globalThis, 'localStorage')
2700
2772
  const previousLocalStorage = globalThis.localStorage
2701
2773
  try {
@@ -2720,8 +2792,9 @@ test('the saved layout (maximised + theme + font + sizes) restores on init, even
2720
2792
  const root = workbenchRootTagOf(markup)
2721
2793
  assert.match(root, /font-size:15px/, 'the persisted font size is applied at init')
2722
2794
  assert.match(root, /data-theme="page"/, 'the IDE itself no longer stores a colour scheme')
2723
- assert.doesNotMatch(markup, /data-ide-pane="tree"/, 'the persisted maximised pane is applied at init')
2795
+ assert.match(markup, /data-ide-pane="tree"/, 'a persisted "editor" maximise mode is IGNORED: the grid comes back')
2724
2796
  assert.match(markup, /data-ide-pane="editor"/)
2797
+ assert.match(markup, /data-splitter="left"/, 'and so do the splitters')
2725
2798
  } finally {
2726
2799
  if (hadLocalStorage) globalThis.localStorage = previousLocalStorage
2727
2800
  else globalThis.localStorage = undefined
@@ -2862,7 +2935,7 @@ test('the tree highlight follows the editor, not the last locate', async () => {
2862
2935
  assert.match(tree, /if \(selectedPath === active\) return\n\s*selectOne\(active\)/)
2863
2936
  })
2864
2937
 
2865
- test('the locate walk against a real single-child package chain reaches the file parent', async () => {
2938
+ test('the locate walk against a real single-child package chain reaches the file parent', { skip: skipWithout(HAS_GIT, 'git') }, async () => {
2866
2939
  const { mkdtemp, mkdir, writeFile, rm } = await import('node:fs/promises')
2867
2940
  const { execFile } = await import('node:child_process')
2868
2941
  const { promisify } = await import('node:util')
@@ -3152,7 +3225,7 @@ test('streamed search answers are read page by page, not after the whole body',
3152
3225
  await assert.rejects(() => T.readSearchStream({}, () => {}), /不支持流式读取/)
3153
3226
  })
3154
3227
 
3155
- test('fsSearchStream paints page by page from the REAL streamed host route', async () => {
3228
+ test('fsSearchStream paints page by page from the REAL streamed host route', { skip: skipWithout(HAS_GIT, 'git') }, async () => {
3156
3229
  // End-to-end through the host half's own handler and a real listener: the
3157
3230
  // NDJSON is chunked over HTTP, so this proves the client parser and the host
3158
3231
  // framing agree — a unit fixture with a hand-made Response cannot.
@@ -3374,6 +3447,58 @@ test('every advisory strip carries a ✕ to close it', { skip: !reactIsReal ? 'R
3374
3447
  assert.match(workbench, /data-notice-close="config-note"/, 'the config note is closable')
3375
3448
  })
3376
3449
 
3450
+ test('the tab strip shows ⟳ while the buffer is clean and ± once it is dirty (m00388/m00808)', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
3451
+ const markup = renderWorkbenchWithFile('/w/README.md')
3452
+ const tag = (markup.match(/<button[^>]*data-action="reload-file"[^>]*>/) || [''])[0]
3453
+ assert.ok(tag !== '', 'the ⟳ button is in the source pane toolbar')
3454
+ assert.doesNotMatch(tag, /disabled/, 'it is enabled while a file is open')
3455
+ assert.match(tag, /重新加载 README\.md/, 'the tooltip names the file')
3456
+ assert.doesNotMatch(markup, /data-action="diff"/, 'a clean buffer has no comparison to offer, so ± is gone')
3457
+ const empty = renderWorkbench({})
3458
+ const emptyTag = (empty.match(/<button[^>]*data-action="reload-file"[^>]*>/) || [''])[0]
3459
+ assert.match(emptyTag, /disabled/, 'nothing to reload without an open file')
3460
+ })
3461
+
3462
+ test('closing a notice sticks for EVERY mounted copy of the panel (m00388)', () => {
3463
+ // The DSH sidebar can mount the same pane twice (a hidden keepMounted copy next
3464
+ // to the visible one); a per-instance useState made the ✕ look dead because the
3465
+ // other copy kept rendering the same notice.
3466
+ T.__resetNoticeDismissals()
3467
+ assert.equal(T.noticeIsOpen('config-updated', 'updated'), true, 'starts open')
3468
+ T.dismissNotice('config-updated', 'updated')
3469
+ assert.equal(T.noticeIsOpen('config-updated', 'updated'), false, 'closed for the shared table')
3470
+ assert.equal(T.noticeIsOpen('config-updated', 'updated-2'), true, 'a NEW signature reopens it')
3471
+ assert.equal(T.noticeIsOpen('config-generated', 'generated:cfg'), true, 'other kinds are untouched')
3472
+ T.dismissNotice('config-updated', 'updated')
3473
+ T.dismissNotice('config-updated', 'updated-2')
3474
+ assert.equal(T.noticeIsOpen('config-updated', 'updated'), true, 'a newer signature supersedes the old dismissal')
3475
+ T.__resetNoticeDismissals()
3476
+ assert.equal(T.noticeIsOpen('config-updated', 'updated'), true, 'reset restores the initial state')
3477
+ })
3478
+
3479
+ test('the source tab strip offers 重新加载, and a dirty tab asks before dropping it (m00388)', async () => {
3480
+ const { readFile } = await import('node:fs/promises')
3481
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
3482
+ assert.match(source, /'data-action': 'reload-file'/, 'the ⟳ button lives in the tab strip')
3483
+ assert.match(source, /function reloadPath\(path\)/, 'reload drops the draft, then rereads')
3484
+ assert.match(source, /ensureDoc\(path, true\)/, 'and forces a real read of an already-open path')
3485
+ for (const action of ['save-reload', 'discard-reload', 'cancel-reload']) {
3486
+ assert.match(source, new RegExp(`'data-action': '${action}'`), `missing the ${action} choice`)
3487
+ }
3488
+ assert.match(source, /'data-reload-prompt': '1'/, 'the (race-only) dirty-tab question is its own strip')
3489
+ // Reload must never merge: the draft is forgotten BEFORE the read.
3490
+ const reloadBody = source.slice(source.indexOf('function reloadPath(path)'))
3491
+ assert.ok(reloadBody.indexOf('forgetDoc(path)') < reloadBody.indexOf('ensureDoc(path, true)'), 'forget first, then read')
3492
+ // ± and ⟳ are mutually exclusive, sharing one slot (m00808): dirty -> diff,
3493
+ // clean -> reload. Both rendered unconditionally used to leave a dead ±.
3494
+ const diffAt = source.indexOf("'data-action': 'diff'")
3495
+ const reloadAt = source.indexOf("'data-action': 'reload-file'")
3496
+ const slot = source.slice(diffAt - 700, reloadAt)
3497
+ assert.ok(diffAt !== -1 && reloadAt > diffAt, 'both controls still exist, in that order')
3498
+ assert.match(slot, /isDirty\(openFile\) === true\s*\?\s*h\('button'/, 'the dirty case picks ±')
3499
+ assert.match(source.slice(diffAt, reloadAt), /:\s*h\('button'/, 'the clean case picks ⟳')
3500
+ })
3501
+
3377
3502
  test('driftSignature is stable per drift payload', () => {
3378
3503
  const a = { added: ['x'], missing: ['y'], changed: [] }
3379
3504
  assert.equal(T.driftSignature(a), T.driftSignature({ added: ['x'], missing: ['y'], changed: [] }))
@@ -3513,24 +3638,24 @@ function logHeadOf(markup) {
3513
3638
  return markup.slice(start, end === -1 ? undefined : end)
3514
3639
  }
3515
3640
 
3516
- test('a first ever open starts with the source pane maximised, and that state is saved', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
3641
+ test('every open starts on the plain 2x2 grid: a maximised pane is never persisted nor restored (m00584)', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
3517
3642
  const hadLocalStorage = Object.prototype.hasOwnProperty.call(globalThis, 'localStorage')
3518
3643
  const previousLocalStorage = globalThis.localStorage
3519
- const writes = []
3520
3644
  try {
3521
- // No saved layout at all: the workbench should collapse to the source pane.
3522
- globalThis.localStorage = { getItem: () => null, setItem: (key, value) => { writes.push({ key, value: JSON.parse(value) }) } }
3645
+ // No saved layout at all: the four panes are all on screen (no auto-maximize).
3646
+ globalThis.localStorage = { getItem: () => null, setItem: () => {} }
3523
3647
  const first = renderWorkbench({})
3524
- assert.match(first, /data-ide-pane="editor"/, 'the first open shows the source pane')
3525
- assert.doesNotMatch(first, /data-ide-pane="tree"/, 'the other panes are maximised away')
3526
- // Persistence round-trip: the same `ui.maximized` the effect writes is what a
3527
- // later open reads back (effects do not run under SSR, so emulate the write).
3648
+ assert.match(first, /data-ide-pane="tree"/, 'the first open shows every pane, not only the editor')
3649
+ assert.match(first, /data-ide-pane="editor"/)
3650
+ assert.match(first, /data-splitter="left"/)
3651
+
3652
+ // A blob from the old build still carrying `ui.maximized` is ignored.
3528
3653
  globalThis.localStorage = { getItem: () => JSON.stringify({ ui: { maximized: 'editor' }, files: [], sizes: {} }), setItem() {} }
3529
3654
  const again = renderWorkbench({})
3530
- assert.match(again, /data-ide-pane="editor"/, 'the saved maximised state restores')
3531
- assert.doesNotMatch(again, /data-ide-pane="tree"/)
3655
+ assert.match(again, /data-ide-pane="tree"/, 'the persisted maximised pane does not come back')
3656
+ assert.match(again, /data-ide-pane="editor"/)
3532
3657
 
3533
- // A stored layout (even "not maximised") always wins over the default.
3658
+ // The rest of the layout still restores.
3534
3659
  globalThis.localStorage = { getItem: () => JSON.stringify({ ui: { maximized: null }, files: [], sizes: {} }), setItem() {} }
3535
3660
  const restored = renderWorkbench({})
3536
3661
  assert.match(restored, /data-ide-pane="tree"/, 'a saved non-maximised layout restores the grid')
@@ -3570,7 +3695,7 @@ test('the IDE top bar hosts the workspace search and only shows config buttons w
3570
3695
  for (const bar of [head, bare]) {
3571
3696
  assert.match(bar, /data-action="layout-reset"/, 'the restore-layout button sits at the top bar right end')
3572
3697
  assert.match(bar, /title="还原布局尺寸/)
3573
- assert.match(bar, /data-action="layout-reset"[^>]*>⟲</, 'the button is labelled ⟲')
3698
+ assert.match(bar, /data-action="layout-reset"[^>]*>▦</, 'the button is labelled ▦ (no longer the ⟲ that read as reload)')
3574
3699
  const resetTag = bar.match(/<button[^>]*data-action="layout-reset"[^>]*>/)
3575
3700
  assert.ok(resetTag !== null)
3576
3701
  assert.match(resetTag[0], /width:22px/, 'the restore-layout control is an icon button')
@@ -4379,23 +4504,15 @@ test('the IDE console masks a program row while it starts, stops or debugs, and
4379
4504
  assert.match(source, /PROGRAM_LOADING_CSS/)
4380
4505
  // A transient top-bar note clears itself after 5 seconds.
4381
4506
  assert.match(source, /\}, 5000\)\n\s*return function \(\) \{ clearTimeout\(timer\) \}/)
4382
- })
4383
-
4384
- test('the console row masks itself while a start/stop is in flight', async () => {
4385
- const { readFile } = await import('node:fs/promises')
4386
- const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
4387
- assert.match(source, /'data-program-loading': program\.id/)
4507
+ // The mask layer: its own class, spinner, and the ACTION (not `alive`) wording.
4388
4508
  assert.match(source, /className: 'dsh-ris-ide-loading'/)
4389
4509
  assert.match(source, /dshRisIdeSpin/)
4390
- // The label follows the ACTION, not `alive`: debugging a running program used
4391
- // to flash 停止中 because the host restarts it in place.
4392
4510
  assert.match(source, /function busyMaskText\(alive, kind\) \{/)
4393
4511
  assert.match(source, /'data-program-loading-kind': busyKind/)
4394
4512
  assert.match(source, /'data-program-loading-kind': consoleBusyKind/)
4395
4513
  assert.doesNotMatch(source, /alive \? '停止中…' : '启动中…'/)
4396
- // The mask swallows the click, and the row is the containing block for it.
4514
+ // The mask swallows the click.
4397
4515
  assert.match(source, /onClick: function \(event\) \{ event\.stopPropagation\(\); event\.preventDefault\(\) \}/)
4398
- assert.match(source, /position: 'relative', overflow: 'hidden'/)
4399
4516
  // Rows keep their own height so the list scrolls; a shrinkable row used to
4400
4517
  // squash the whole project list into the panel (no scrollbar at all).
4401
4518
  assert.match(source, /flex: '0 0 auto', minWidth: 0, cursor: 'pointer', position: 'relative', overflow: 'hidden'/)
@@ -4538,20 +4655,6 @@ test('every change of the suspended top frame moves the editor there', async ()
4538
4655
  assert.ok(source.includes('void followDebugLocation(top)'))
4539
4656
  })
4540
4657
 
4541
- test('progress goes to the status bar; toasts stay for things the user must know', async () => {
4542
- const { readFile } = await import('node:fs/promises')
4543
- const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
4544
- // The static bottom help text moved into the ? panel.
4545
- assert.ok(!source.includes('Ctrl+S 保存 · Ctrl+W 关页签 · 拖分隔条调大小 · 双击标题最大化'))
4546
- assert.ok(!source.includes("' · F5 步入 · F6 单步 · F7 步出 · F8 继续'"))
4547
- // A status channel exists and the dependency-source progress uses it (no toast).
4548
- assert.ok(source.includes("var [statusText, setStatusText] = useState('')"))
4549
- assert.ok(source.includes("statusNote('正在获取依赖源码:' + cleaned + '…', 0)"))
4550
- assert.ok(source.includes("statusNote('正在启动 ' + program.name + '…', 0)"))
4551
- assert.ok(!source.includes("note('正在获取依赖源码:"))
4552
- assert.ok(source.includes("'data-ide-status-text': statusText === '' ? '0' : '1'"))
4553
- })
4554
-
4555
4658
  test('while a debug session is attached, F5 cannot reload the window', async () => {
4556
4659
  const { readFile } = await import('node:fs/promises')
4557
4660
  const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
@@ -5131,16 +5234,6 @@ test('the console keeps its log pane empty until a row is chosen (m07431)', asyn
5131
5234
  assert.equal(source.includes('First load with no explicit target'), false)
5132
5235
  })
5133
5236
 
5134
- test('no ProxyDialog component is shipped any more (m07355 / D4)', async () => {
5135
- const { readFile } = await import('node:fs/promises')
5136
- const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
5137
- assert.equal(source.includes('function ProxyDialog('), false, 'the old panel component is deleted')
5138
- assert.equal(source.includes('ProxyDialog: ProxyDialog'), false, 'it is no longer exported')
5139
- assert.equal(source.includes("'data-proxy-dialog'"), false, 'no markup keeps the old dialog addressable')
5140
- // The page itself is served by the daemon: /ui owns the rule editor now.
5141
- assert.ok(source.includes("routeUrl('dsh-ris-ide/proxy')"), 'the entry still asks the host where the page is')
5142
- })
5143
-
5144
5237
  test('the workbench reads its saved blob once per mount and remounts per workspace', async () => {
5145
5238
  const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
5146
5239
  // One read per mount, from a lazy useState initialiser: readSavedUi also runs