dsh-ris-ide 1.8.0 → 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 (52) hide show
  1. package/README.md +5 -3
  2. package/bin/risd.mjs +14 -17
  3. package/lib/client.js +400 -93
  4. package/lib/debug/vendor/README.md +14 -0
  5. package/lib/debug/vendor/jdwp/client.js +9 -4
  6. package/lib/debug/vendor/src/jdwp/client.ts +12 -5
  7. package/lib/index.js +794 -48
  8. package/lib/proxybridge-bundle.js +1 -1
  9. package/lib/proxybridge-health.js +206 -0
  10. package/lib/redirector.js +1181 -90
  11. package/lib/risd/lifecycle.js +9 -3
  12. package/lib/risd/server.js +762 -26
  13. package/lib/risd/ui.js +419 -98
  14. package/lib/risd-client.js +4 -1
  15. package/lib/startup.js +27 -7
  16. package/package.json +2 -2
  17. package/test/client-viewer.test.mjs +299 -120
  18. package/test/clipboard.test.mjs +259 -0
  19. package/test/debug-engine.test.mjs +3 -1
  20. package/test/dsh-origin.test.mjs +4 -11
  21. package/test/dsh-window-refresh.test.mjs +166 -1
  22. package/test/harness.test.mjs +1 -1
  23. package/test/helpers/cmd.mjs +29 -0
  24. package/test/helpers/tgz.mjs +71 -0
  25. package/test/host-search.test.mjs +18 -11
  26. package/test/host-tail.test.mjs +119 -24
  27. package/test/proxy-route.test.mjs +61 -0
  28. package/test/proxy-window.test.mjs +5 -0
  29. package/test/proxy.test.mjs +13 -1
  30. package/test/proxybridge-bundle.test.mjs +1 -59
  31. package/test/proxybridge-health.test.mjs +116 -0
  32. package/test/redirector-bundle.test.mjs +21 -67
  33. package/test/redirector.test.mjs +395 -5
  34. package/test/risd-api.test.mjs +114 -17
  35. package/test/risd-bridge-degrade.test.mjs +3 -29
  36. package/test/risd-engine.test.mjs +13 -50
  37. package/test/risd-entry.test.mjs +0 -37
  38. package/test/risd-follow-start.test.mjs +101 -0
  39. package/test/risd-git.test.mjs +7 -5
  40. package/test/risd-handoff.test.mjs +6 -50
  41. package/test/risd-helpers.mjs +150 -3
  42. package/test/risd-host-p2.test.mjs +2 -30
  43. package/test/risd-lifecycle.test.mjs +25 -0
  44. package/test/risd-programs.test.mjs +4 -34
  45. package/test/risd-restart.test.mjs +104 -0
  46. package/test/risd-review-p2.test.mjs +0 -13
  47. package/test/risd-shutdown.test.mjs +5 -38
  48. package/test/risd-teardown.test.mjs +8 -27
  49. package/test/risd-ui.test.mjs +322 -4
  50. package/test/risd-write.test.mjs +2 -1
  51. package/test/startup-reconcile.test.mjs +44 -8
  52. package/test/proxy-restart.test.mjs +0 -37
@@ -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,11 +2767,12 @@ 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 {
2702
- // A legacy per-program blob: the panel used to key the layout by program id.
2774
+ // A pre-m13444 blob for THIS tab: the panel used to key the layout without a
2775
+ // workspace suffix, and the first workspace to open the tab migrates it once.
2703
2776
  const legacy = JSON.stringify({
2704
2777
  ui: { maximized: 'editor', section: 'threads' },
2705
2778
  theme: 'light',
@@ -2708,7 +2781,7 @@ test('the saved layout (maximised + theme + font + sizes) restores on init, even
2708
2781
  files: [],
2709
2782
  file: undefined,
2710
2783
  })
2711
- const store = new Map([['dsh-ris-ide:ui:spring:ris/ris-model#a.B', legacy]])
2784
+ const store = new Map([['dsh-ris-ide:ui:workspace', legacy]])
2712
2785
  globalThis.localStorage = {
2713
2786
  get length() { return store.size },
2714
2787
  key: (index) => Array.from(store.keys())[index],
@@ -2719,41 +2792,58 @@ test('the saved layout (maximised + theme + font + sizes) restores on init, even
2719
2792
  const root = workbenchRootTagOf(markup)
2720
2793
  assert.match(root, /font-size:15px/, 'the persisted font size is applied at init')
2721
2794
  assert.match(root, /data-theme="page"/, 'the IDE itself no longer stores a colour scheme')
2722
- 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')
2723
2796
  assert.match(markup, /data-ide-pane="editor"/)
2797
+ assert.match(markup, /data-splitter="left"/, 'and so do the splitters')
2724
2798
  } finally {
2725
2799
  if (hadLocalStorage) globalThis.localStorage = previousLocalStorage
2726
2800
  else globalThis.localStorage = undefined
2727
2801
  }
2728
2802
  })
2729
2803
 
2730
- test('readSavedUi prefers the exact key, falls back to a legacy one, and survives junk', () => {
2804
+ test('readSavedUi prefers the exact key, migrates the legacy one ONCE, and survives junk', () => {
2731
2805
  const hadLocalStorage = Object.prototype.hasOwnProperty.call(globalThis, 'localStorage')
2732
2806
  const previousLocalStorage = globalThis.localStorage
2733
2807
  try {
2734
2808
  const store = new Map([
2735
- ['dsh-ris-ide:ui:workspace', JSON.stringify({ ui: { maximized: null }, font: 13 })],
2736
- ['dsh-ris-ide:ui:spring:x#y', JSON.stringify({ ui: { maximized: 'tree' }, font: 18 })],
2809
+ ['dsh-ris-ide:ui:workspace@/w/a', JSON.stringify({ ui: { maximized: null }, font: 13 })],
2810
+ ['dsh-ris-ide:ui:workspace', JSON.stringify({ ui: { maximized: 'tree' }, font: 18 })],
2737
2811
  ])
2738
2812
  globalThis.localStorage = {
2739
2813
  get length() { return store.size },
2740
2814
  key: (index) => Array.from(store.keys())[index],
2741
2815
  getItem: (key) => (store.has(key) ? store.get(key) : null),
2816
+ setItem: (key, value) => { store.set(key, value) },
2817
+ removeItem: (key) => { store.delete(key) },
2818
+ }
2819
+ assert.equal(T.readSavedUi('dsh-ris-ide:ui:workspace@/w/a', '/w/a').font, 13, 'the exact key wins')
2820
+ // The pre-m13444 global key is adopted once by the FIRST workspace and deleted,
2821
+ // so a second workspace does not inherit the same tabs again (C review P1-2).
2822
+ assert.equal(T.readSavedUi('dsh-ris-ide:ui:workspace@/w/b', '/w/b').font, 18, 'the legacy key is adopted')
2823
+ assert.equal(store.has('dsh-ris-ide:ui:workspace'), false, 'and removed after adoption')
2824
+ assert.equal(T.readSavedUi('dsh-ris-ide:ui:workspace@/w/c', '/w/c'), null, 'a second workspace gets nothing')
2825
+
2826
+ // Non-blob preferences share the `…:ui:` prefix; they must not abort the scan.
2827
+ const noisy = new Map([['dsh-ris-ide:ui:compact-max', 'log']])
2828
+ globalThis.localStorage = {
2829
+ get length() { return noisy.size },
2830
+ key: (index) => Array.from(noisy.keys())[index],
2831
+ getItem: (key) => (noisy.has(key) ? noisy.get(key) : null),
2742
2832
  setItem: () => {},
2833
+ removeItem: () => {},
2743
2834
  }
2744
- assert.equal(T.readSavedUi('dsh-ris-ide:ui:workspace').font, 13, 'the exact key wins')
2835
+ assert.equal(T.readSavedUi('dsh-ris-ide:ui:nothing', 'nothing'), null, 'junk does not throw')
2745
2836
 
2746
- const withoutExact = new Map(Array.from(store.entries()).filter(([key]) => key !== 'dsh-ris-ide:ui:workspace'))
2837
+ // Another workspace's tab is never adopted; a cwd containing `@` cannot spoof it.
2838
+ const other = new Map([['dsh-ris-ide:ui:workspace@/ws/x@/w/a', JSON.stringify({ font: 19 })]])
2747
2839
  globalThis.localStorage = {
2748
- get length() { return withoutExact.size },
2749
- key: (index) => Array.from(withoutExact.keys())[index],
2750
- getItem: (key) => (withoutExact.has(key) ? withoutExact.get(key) : null),
2840
+ get length() { return other.size },
2841
+ key: (index) => Array.from(other.keys())[index],
2842
+ getItem: (key) => (other.has(key) ? other.get(key) : null),
2751
2843
  setItem: () => {},
2844
+ removeItem: () => {},
2752
2845
  }
2753
- assert.equal(T.readSavedUi('dsh-ris-ide:ui:workspace').font, 18, 'a legacy per-program key is adopted')
2754
-
2755
- withoutExact.set('dsh-ris-ide:ui:broken', '{not json')
2756
- assert.ok(T.readSavedUi('dsh-ris-ide:ui:nothing') !== null, 'junk does not throw')
2846
+ assert.equal(T.readSavedUi('dsh-ris-ide:ui:workspace@/w/b', '/w/b'), null, 'cross-workspace adoption is refused')
2757
2847
  } finally {
2758
2848
  if (hadLocalStorage) globalThis.localStorage = previousLocalStorage
2759
2849
  else globalThis.localStorage = undefined
@@ -2845,7 +2935,7 @@ test('the tree highlight follows the editor, not the last locate', async () => {
2845
2935
  assert.match(tree, /if \(selectedPath === active\) return\n\s*selectOne\(active\)/)
2846
2936
  })
2847
2937
 
2848
- 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 () => {
2849
2939
  const { mkdtemp, mkdir, writeFile, rm } = await import('node:fs/promises')
2850
2940
  const { execFile } = await import('node:child_process')
2851
2941
  const { promisify } = await import('node:util')
@@ -3135,7 +3225,7 @@ test('streamed search answers are read page by page, not after the whole body',
3135
3225
  await assert.rejects(() => T.readSearchStream({}, () => {}), /不支持流式读取/)
3136
3226
  })
3137
3227
 
3138
- 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 () => {
3139
3229
  // End-to-end through the host half's own handler and a real listener: the
3140
3230
  // NDJSON is chunked over HTTP, so this proves the client parser and the host
3141
3231
  // framing agree — a unit fixture with a hand-made Response cannot.
@@ -3357,6 +3447,58 @@ test('every advisory strip carries a ✕ to close it', { skip: !reactIsReal ? 'R
3357
3447
  assert.match(workbench, /data-notice-close="config-note"/, 'the config note is closable')
3358
3448
  })
3359
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
+
3360
3502
  test('driftSignature is stable per drift payload', () => {
3361
3503
  const a = { added: ['x'], missing: ['y'], changed: [] }
3362
3504
  assert.equal(T.driftSignature(a), T.driftSignature({ added: ['x'], missing: ['y'], changed: [] }))
@@ -3496,24 +3638,24 @@ function logHeadOf(markup) {
3496
3638
  return markup.slice(start, end === -1 ? undefined : end)
3497
3639
  }
3498
3640
 
3499
- 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 }, () => {
3500
3642
  const hadLocalStorage = Object.prototype.hasOwnProperty.call(globalThis, 'localStorage')
3501
3643
  const previousLocalStorage = globalThis.localStorage
3502
- const writes = []
3503
3644
  try {
3504
- // No saved layout at all: the workbench should collapse to the source pane.
3505
- 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: () => {} }
3506
3647
  const first = renderWorkbench({})
3507
- assert.match(first, /data-ide-pane="editor"/, 'the first open shows the source pane')
3508
- assert.doesNotMatch(first, /data-ide-pane="tree"/, 'the other panes are maximised away')
3509
- // Persistence round-trip: the same `ui.maximized` the effect writes is what a
3510
- // 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.
3511
3653
  globalThis.localStorage = { getItem: () => JSON.stringify({ ui: { maximized: 'editor' }, files: [], sizes: {} }), setItem() {} }
3512
3654
  const again = renderWorkbench({})
3513
- assert.match(again, /data-ide-pane="editor"/, 'the saved maximised state restores')
3514
- 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"/)
3515
3657
 
3516
- // A stored layout (even "not maximised") always wins over the default.
3658
+ // The rest of the layout still restores.
3517
3659
  globalThis.localStorage = { getItem: () => JSON.stringify({ ui: { maximized: null }, files: [], sizes: {} }), setItem() {} }
3518
3660
  const restored = renderWorkbench({})
3519
3661
  assert.match(restored, /data-ide-pane="tree"/, 'a saved non-maximised layout restores the grid')
@@ -3553,7 +3695,7 @@ test('the IDE top bar hosts the workspace search and only shows config buttons w
3553
3695
  for (const bar of [head, bare]) {
3554
3696
  assert.match(bar, /data-action="layout-reset"/, 'the restore-layout button sits at the top bar right end')
3555
3697
  assert.match(bar, /title="还原布局尺寸/)
3556
- 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)')
3557
3699
  const resetTag = bar.match(/<button[^>]*data-action="layout-reset"[^>]*>/)
3558
3700
  assert.ok(resetTag !== null)
3559
3701
  assert.match(resetTag[0], /width:22px/, 'the restore-layout control is an icon button')
@@ -3653,6 +3795,58 @@ test('capOpenFiles appends under the cap and evicts only the oldest clean tab',
3653
3795
 
3654
3796
 
3655
3797
 
3798
+ test('tabs, recent history and search cache are scoped to one workspace (m13444)', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
3799
+ const hadLocalStorage = Object.prototype.hasOwnProperty.call(globalThis, 'localStorage')
3800
+ const previousLocalStorage = globalThis.localStorage
3801
+ try {
3802
+ const keys = []
3803
+ globalThis.localStorage = {
3804
+ getItem: (key) => { keys.push(String(key)); return null },
3805
+ setItem: () => {},
3806
+ }
3807
+ renderWorkbench({ scope: { sessionId: 's1', cwd: '/w/a' }, tab: { id: T.PROGRAM_TAB_ID, type: T.PROGRAM_TAB_ID, title: 'workspace' } })
3808
+ renderWorkbench({ scope: { sessionId: 's1', cwd: '/w/b' }, tab: { id: T.PROGRAM_TAB_ID, type: T.PROGRAM_TAB_ID, title: 'workspace' } })
3809
+ assert.ok(keys.includes('dsh-ris-ide:ui:workspace@/w/a'), `workspace A key missing: ${keys.join(', ')}`)
3810
+ assert.ok(keys.includes('dsh-ris-ide:ui:workspace@/w/b'), `workspace B key missing: ${keys.join(', ')}`)
3811
+
3812
+ // Adopting a legacy blob must stay inside the current workspace.
3813
+ const store = new Map([
3814
+ ['dsh-ris-ide:ui:workspace@/w/a', JSON.stringify({ files: ['/w/a/x.java'], file: '/w/a/x.java' })],
3815
+ ])
3816
+ globalThis.localStorage = {
3817
+ getItem: (key) => store.get(key) ?? null,
3818
+ setItem: () => {},
3819
+ get length() { return store.size },
3820
+ key: (index) => [...store.keys()][index] ?? null,
3821
+ }
3822
+ assert.equal(T.readSavedUi('dsh-ris-ide:ui:workspace@/w/b', '/w/b'), null, "another workspace's tabs are not adopted")
3823
+ assert.deepEqual(T.readSavedUi('dsh-ris-ide:ui:workspace@/w/a', '/w/a').files, ['/w/a/x.java'])
3824
+ // A migrated legacy blob is consumed once: another FILE tab of the same
3825
+ // workspace must not inherit the pre-m13444 tabs again (20261109-2326 review).
3826
+ const legacyStore = new Map([['dsh-ris-ide:ui:workspace', JSON.stringify({ files: ['/w/a/x.java'] })]]);
3827
+ const removedKeys = []
3828
+ globalThis.localStorage = {
3829
+ getItem: (key) => (legacyStore.has(key) ? legacyStore.get(key) : null),
3830
+ setItem: (key, value) => { legacyStore.set(key, String(value)) },
3831
+ removeItem: (key) => { removedKeys.push(key); legacyStore.delete(key) },
3832
+ get length() { return legacyStore.size },
3833
+ key: (index) => [...legacyStore.keys()][index] ?? null,
3834
+ }
3835
+ assert.deepEqual(T.readSavedUi('dsh-ris-ide:ui:workspace@/w/a', '/w/a').files, ['/w/a/x.java'], 'the first opener migrates the legacy blob')
3836
+ assert.deepEqual(removedKeys, ['dsh-ris-ide:ui:workspace'], 'the legacy key is consumed exactly once')
3837
+ assert.equal(T.readSavedUi('dsh-ris-ide:ui:demo@/w/a', '/w/a'), null, 'switching to another file tab does not re-migrate')
3838
+ } finally {
3839
+ if (hadLocalStorage) globalThis.localStorage = previousLocalStorage
3840
+ else globalThis.localStorage = undefined
3841
+ }
3842
+ })
3843
+
3844
+ test('the elevation terminal never opens during a test run (m13621)', async () => {
3845
+ const source = await readFile(new URL('../lib/redirector.js', import.meta.url), 'utf8')
3846
+ assert.match(source, /NODE_TEST_CONTEXT !== undefined && process\.env\.DSH_RIS_IDE_ALLOW_TERMINAL !== '1'/)
3847
+ assert.match(source, /if \(process\.env\.NODE_TEST_CONTEXT !== undefined && process\.env\.DSH_RIS_IDE_ALLOW_TERMINAL !== '1'\) return false/)
3848
+ })
3849
+
3656
3850
  test('the workbench restores open source tabs from localStorage and shows the workspace path', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
3657
3851
  const hadLocalStorage = Object.prototype.hasOwnProperty.call(globalThis, 'localStorage')
3658
3852
  const previousLocalStorage = globalThis.localStorage
@@ -3660,7 +3854,7 @@ test('the workbench restores open source tabs from localStorage and shows the wo
3660
3854
  globalThis.localStorage = {
3661
3855
  getItem: (key) => {
3662
3856
  keys.push(key)
3663
- return key === 'dsh-ris-ide:ui:workspace'
3857
+ return String(key).startsWith('dsh-ris-ide:ui:workspace@')
3664
3858
  ? JSON.stringify({ ui: {}, files: ['/w/a.java', '/w/b.java'], file: '/w/a.java', sizes: {} })
3665
3859
  : null
3666
3860
  },
@@ -3672,7 +3866,7 @@ test('the workbench restores open source tabs from localStorage and shows the wo
3672
3866
  // No program meta → the WORKSPACE storage key, the one this test restores.
3673
3867
  tab: { id: T.PROGRAM_TAB_ID, type: T.PROGRAM_TAB_ID, title: 'workspace' },
3674
3868
  })
3675
- assert.ok(keys.includes('dsh-ris-ide:ui:workspace'), `unexpected storage key ${keys.join(', ')}`)
3869
+ assert.ok(keys.some((key) => key.startsWith('dsh-ris-ide:ui:workspace@')), `unexpected storage key ${keys.join(', ')}`)
3676
3870
  assert.match(markup, /data-workbench-path="1">\/w\/work</, 'the top bar shows the workspace path')
3677
3871
  assert.equal((markup.match(/data-tab-close="source"/g) || []).length, 2, 'both restored files get a tab')
3678
3872
  assert.match(markup, /a\.java/)
@@ -3792,7 +3986,7 @@ test('a stored font size scales the IDE blocks through the style proxy', { skip:
3792
3986
  globalThis.localStorage = {
3793
3987
  getItem: (key) => {
3794
3988
  keys.push(key)
3795
- return key === 'dsh-ris-ide:ui:workspace'
3989
+ return String(key).startsWith('dsh-ris-ide:ui:workspace@')
3796
3990
  ? JSON.stringify({ font: 15, files: [], ui: {}, sizes: {} })
3797
3991
  : null
3798
3992
  },
@@ -3801,7 +3995,7 @@ test('a stored font size scales the IDE blocks through the style proxy', { skip:
3801
3995
  try {
3802
3996
  // Meta-less tab → the workspace key (a program meta would use its own key).
3803
3997
  const markup = renderWorkbench({ tab: { id: T.PROGRAM_TAB_ID, type: T.PROGRAM_TAB_ID, title: 'workspace' } })
3804
- assert.ok(keys.includes('dsh-ris-ide:ui:workspace'), `unexpected storage keys ${keys.join(', ')}`)
3998
+ assert.ok(keys.some((key) => key.startsWith('dsh-ris-ide:ui:workspace@')), `unexpected storage keys ${keys.join(', ')}`)
3805
3999
  assert.match(workbenchRootTagOf(markup), /font-size:15px/, 'the stored size reaches the workbench root')
3806
4000
  assert.match(styleChildOf(markup), /\.cm-editor\{font-size:15px !important\}/, 'the stored size reaches CodeMirror')
3807
4001
  // 12px authored × (15 / 12.5) = 14.4 → nearest 0.5px = 14.5
@@ -3863,7 +4057,7 @@ function stubWorkspaceUi(patch, keys) {
3863
4057
  globalThis.localStorage = {
3864
4058
  getItem: (key) => {
3865
4059
  if (keys !== undefined) keys.push(key)
3866
- return key === 'dsh-ris-ide:ui:workspace'
4060
+ return String(key).startsWith('dsh-ris-ide:ui:workspace@')
3867
4061
  ? JSON.stringify(Object.assign({ files: [], ui: {}, sizes: {} }, patch))
3868
4062
  : null
3869
4063
  },
@@ -4310,23 +4504,15 @@ test('the IDE console masks a program row while it starts, stops or debugs, and
4310
4504
  assert.match(source, /PROGRAM_LOADING_CSS/)
4311
4505
  // A transient top-bar note clears itself after 5 seconds.
4312
4506
  assert.match(source, /\}, 5000\)\n\s*return function \(\) \{ clearTimeout\(timer\) \}/)
4313
- })
4314
-
4315
- test('the console row masks itself while a start/stop is in flight', async () => {
4316
- const { readFile } = await import('node:fs/promises')
4317
- const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
4318
- assert.match(source, /'data-program-loading': program\.id/)
4507
+ // The mask layer: its own class, spinner, and the ACTION (not `alive`) wording.
4319
4508
  assert.match(source, /className: 'dsh-ris-ide-loading'/)
4320
4509
  assert.match(source, /dshRisIdeSpin/)
4321
- // The label follows the ACTION, not `alive`: debugging a running program used
4322
- // to flash 停止中 because the host restarts it in place.
4323
4510
  assert.match(source, /function busyMaskText\(alive, kind\) \{/)
4324
4511
  assert.match(source, /'data-program-loading-kind': busyKind/)
4325
4512
  assert.match(source, /'data-program-loading-kind': consoleBusyKind/)
4326
4513
  assert.doesNotMatch(source, /alive \? '停止中…' : '启动中…'/)
4327
- // The mask swallows the click, and the row is the containing block for it.
4514
+ // The mask swallows the click.
4328
4515
  assert.match(source, /onClick: function \(event\) \{ event\.stopPropagation\(\); event\.preventDefault\(\) \}/)
4329
- assert.match(source, /position: 'relative', overflow: 'hidden'/)
4330
4516
  // Rows keep their own height so the list scrolls; a shrinkable row used to
4331
4517
  // squash the whole project list into the panel (no scrollbar at all).
4332
4518
  assert.match(source, /flex: '0 0 auto', minWidth: 0, cursor: 'pointer', position: 'relative', overflow: 'hidden'/)
@@ -4469,20 +4655,6 @@ test('every change of the suspended top frame moves the editor there', async ()
4469
4655
  assert.ok(source.includes('void followDebugLocation(top)'))
4470
4656
  })
4471
4657
 
4472
- test('progress goes to the status bar; toasts stay for things the user must know', async () => {
4473
- const { readFile } = await import('node:fs/promises')
4474
- const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
4475
- // The static bottom help text moved into the ? panel.
4476
- assert.ok(!source.includes('Ctrl+S 保存 · Ctrl+W 关页签 · 拖分隔条调大小 · 双击标题最大化'))
4477
- assert.ok(!source.includes("' · F5 步入 · F6 单步 · F7 步出 · F8 继续'"))
4478
- // A status channel exists and the dependency-source progress uses it (no toast).
4479
- assert.ok(source.includes("var [statusText, setStatusText] = useState('')"))
4480
- assert.ok(source.includes("statusNote('正在获取依赖源码:' + cleaned + '…', 0)"))
4481
- assert.ok(source.includes("statusNote('正在启动 ' + program.name + '…', 0)"))
4482
- assert.ok(!source.includes("note('正在获取依赖源码:"))
4483
- assert.ok(source.includes("'data-ide-status-text': statusText === '' ? '0' : '1'"))
4484
- })
4485
-
4486
4658
  test('while a debug session is attached, F5 cannot reload the window', async () => {
4487
4659
  const { readFile } = await import('node:fs/promises')
4488
4660
  const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
@@ -4620,15 +4792,17 @@ test('the find box accepts more than one character while it has matches', async
4620
4792
  test('Ctrl+R re-reads the workspace instead of replaying the search cache', async () => {
4621
4793
  const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
4622
4794
 
4623
- // The cache is keyed by the query TEXT only, so an explicit re-search must drop
4624
- // the entries and make both streaming effects run again.
4795
+ // The cache is keyed by kind + WORKSPACE + query (m13444), so an explicit
4796
+ // re-search must drop this workspace's entries and re-run both effects.
4625
4797
  assert.match(source, /var \[searchReload, setSearchReload\] = useState\(0\)/)
4798
+ assert.match(source, /function searchKey\(kind, text\) \{/)
4799
+ assert.match(source, /return kind \+ ':' \+ workspaceKey \+ '\\u0000' \+ text/)
4626
4800
  assert.match(source, /function reloadWorkspaceSearch\(text\) \{/)
4627
- assert.match(source, /searchCacheRef\.current\.delete\('content:' \+ query\)/)
4628
- assert.match(source, /searchCacheRef\.current\.delete\('name:' \+ query\)/)
4629
- const effects = source.split("var cached = searchCacheRef.current.get('name:' + text)")
4801
+ assert.match(source, /searchCacheRef\.current\.delete\(searchKey\('content', query\)\)/)
4802
+ assert.match(source, /searchCacheRef\.current\.delete\(searchKey\('name', query\)\)/)
4803
+ const effects = source.split("var cached = searchCacheRef.current.get(searchKey('name', text))")
4630
4804
  assert.equal(effects.length, 2)
4631
- const contentStart = effects[1].indexOf("var cached = searchCacheRef.current.get('content:' + text)")
4805
+ const contentStart = effects[1].indexOf("var cached = searchCacheRef.current.get(searchKey('content', text))")
4632
4806
  assert.ok(contentStart !== -1)
4633
4807
  assert.match(effects[1].slice(contentStart, contentStart + 5000), /\}, \[treeQuery, cwd, searchReload\]\)/)
4634
4808
 
@@ -4888,9 +5062,9 @@ test('search hits survive a pick and the shortcut selects the query', async () =
4888
5062
  assert.doesNotMatch(pick, /setSearchHits\(null\)/, 'the result set stays after a pick')
4889
5063
  const contentPick = source.slice(source.indexOf('function openContentHit('), source.indexOf('// No auto-pick on first load'))
4890
5064
  assert.doesNotMatch(contentPick, /setTreeQuery\(''\)/, 'a content pick keeps the query too')
4891
- // Both searches cache their payloads keyed by the query text.
4892
- assert.match(source, /searchCacheRef\.current\.get\('name:' \+ text\)/)
4893
- assert.match(source, /rememberSearchEntry\(searchCacheRef\.current, 'content:' \+ text/)
5065
+ // Both searches cache their payloads keyed by kind + workspace + query.
5066
+ assert.match(source, /searchCacheRef\.current\.get\(searchKey\('name', text\)\)/)
5067
+ assert.match(source, /rememberSearchEntry\(searchCacheRef\.current, searchKey\('content', text\)/)
4894
5068
  // The shortcut focuses THROUGH an effect so select() survives the repaint.
4895
5069
  assert.match(source, /searchFocusPendingRef\.current = true/)
4896
5070
  // The dropdown is focus-owned: a pick blurs the box, so re-clicking it fires
@@ -5060,12 +5234,17 @@ test('the console keeps its log pane empty until a row is chosen (m07431)', asyn
5060
5234
  assert.equal(source.includes('First load with no explicit target'), false)
5061
5235
  })
5062
5236
 
5063
- test('no ProxyDialog component is shipped any more (m07355 / D4)', async () => {
5064
- const { readFile } = await import('node:fs/promises')
5237
+ test('the workbench reads its saved blob once per mount and remounts per workspace', async () => {
5065
5238
  const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
5066
- assert.equal(source.includes('function ProxyDialog('), false, 'the old panel component is deleted')
5067
- assert.equal(source.includes('ProxyDialog: ProxyDialog'), false, 'it is no longer exported')
5068
- assert.equal(source.includes("'data-proxy-dialog'"), false, 'no markup keeps the old dialog addressable')
5069
- // The page itself is served by the daemon: /ui owns the rule editor now.
5070
- assert.ok(source.includes("routeUrl('dsh-ris-ide/proxy')"), 'the entry still asks the host where the page is')
5239
+ // One read per mount, from a lazy useState initialiser: readSavedUi also runs
5240
+ // the one-shot legacy migration (it removes the adopted key), so calling it on
5241
+ // every render re-probed localStorage per keystroke.
5242
+ assert.match(source, /var \[savedUi\] = useState\(function \(\) \{ return readSavedUi\(storageKey, workspaceKey\) \}\)/)
5243
+ assert.doesNotMatch(source, /var savedUi = readSavedUi\(storageKey, workspaceKey\)/)
5244
+ // Tabs/recent/layout are seeded from that blob at mount, so a workspace switch
5245
+ // must remount the workbench instead of keeping the previous workspace's state.
5246
+ const mount = source.slice(source.indexOf('return h(ProgramWorkbench, {'), source.indexOf('return h(ProgramWorkbench, {') + 600)
5247
+ assert.match(mount, /key: typeof cwd === 'string' && cwd !== '' \? cwd : 'default'/)
5248
+ // The compact panel layout is a machine-wide preference on purpose.
5249
+ assert.match(source, /Deliberately NOT workspace-scoped/)
5071
5250
  })