dsh-ris-ide 1.7.2 → 1.8.0

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 (79) hide show
  1. package/README.md +43 -4
  2. package/bin/check-listing.mjs +247 -0
  3. package/bin/proxy-janitor.mjs +183 -0
  4. package/bin/risd.mjs +287 -0
  5. package/bin/run-with-log.ps1 +43 -5
  6. package/lib/client-codemirror.js +92 -66
  7. package/lib/client.js +774 -89
  8. package/lib/index.js +2256 -21
  9. package/lib/janitor.js +377 -0
  10. package/lib/proxy.js +1577 -0
  11. package/lib/proxybridge-bundle.js +798 -0
  12. package/lib/redirector.js +2558 -0
  13. package/lib/risd/build.js +91 -0
  14. package/lib/risd/debug.js +374 -0
  15. package/lib/risd/git.js +207 -0
  16. package/lib/risd/leases.js +124 -0
  17. package/lib/risd/lifecycle.js +148 -0
  18. package/lib/risd/log.js +59 -0
  19. package/lib/risd/ping.js +94 -0
  20. package/lib/risd/programs.js +348 -0
  21. package/lib/risd/server.js +1478 -0
  22. package/lib/risd/state.js +137 -0
  23. package/lib/risd/ui.js +1705 -0
  24. package/lib/risd/view.js +79 -0
  25. package/lib/risd-client.js +282 -0
  26. package/lib/standalone/window.html +14 -16
  27. package/lib/startup.js +114 -0
  28. package/package.json +7 -2
  29. package/skills/dsh-ris-ide-debug/SKILL.md +37 -2
  30. package/test/client-build.test.mjs +113 -0
  31. package/test/client-viewer.test.mjs +314 -20
  32. package/test/companion.test.mjs +65 -0
  33. package/test/dsh-origin.test.mjs +140 -0
  34. package/test/dsh-window-refresh.test.mjs +100 -0
  35. package/test/harness.test.mjs +9 -0
  36. package/test/host-noloop.test.mjs +74 -0
  37. package/test/host-tail.test.mjs +54 -5
  38. package/test/host-window.test.mjs +4 -4
  39. package/test/inherit-engine.test.mjs +175 -0
  40. package/test/install-phase.test.mjs +36 -0
  41. package/test/janitor.test.mjs +172 -0
  42. package/test/lifecycle.test.mjs +109 -0
  43. package/test/merge-owners.test.mjs +155 -0
  44. package/test/proxy-restart.test.mjs +37 -0
  45. package/test/proxy-route.test.mjs +599 -0
  46. package/test/proxy-window.test.mjs +45 -0
  47. package/test/proxy.test.mjs +914 -0
  48. package/test/proxybridge-bundle.test.mjs +687 -0
  49. package/test/redirector-bundle.test.mjs +391 -0
  50. package/test/redirector.test.mjs +571 -0
  51. package/test/risd-api.test.mjs +470 -0
  52. package/test/risd-bridge-degrade.test.mjs +101 -0
  53. package/test/risd-build.test.mjs +20 -0
  54. package/test/risd-cli-home.test.mjs +50 -0
  55. package/test/risd-client.test.mjs +130 -0
  56. package/test/risd-debug.test.mjs +261 -0
  57. package/test/risd-election.test.mjs +104 -0
  58. package/test/risd-engine.test.mjs +132 -0
  59. package/test/risd-entry.test.mjs +118 -0
  60. package/test/risd-git.test.mjs +109 -0
  61. package/test/risd-handoff.test.mjs +116 -0
  62. package/test/risd-heal.test.mjs +50 -0
  63. package/test/risd-helpers.mjs +108 -0
  64. package/test/risd-host-p2.test.mjs +147 -0
  65. package/test/risd-janitor-guard.test.mjs +46 -0
  66. package/test/risd-lease.test.mjs +83 -0
  67. package/test/risd-lifecycle.test.mjs +210 -0
  68. package/test/risd-log-follow.test.mjs +227 -0
  69. package/test/risd-mode.test.mjs +161 -0
  70. package/test/risd-ping.test.mjs +99 -0
  71. package/test/risd-programs.test.mjs +169 -0
  72. package/test/risd-review-p2.test.mjs +217 -0
  73. package/test/risd-shutdown.test.mjs +97 -0
  74. package/test/risd-teardown.test.mjs +87 -0
  75. package/test/risd-tools.test.mjs +211 -0
  76. package/test/risd-ui.test.mjs +445 -0
  77. package/test/risd-write.test.mjs +170 -0
  78. package/test/startup-reconcile.test.mjs +100 -0
  79. package/test/windows.test.mjs +37 -2
@@ -0,0 +1,113 @@
1
+ // Stale-UI handshake (m09693): the plugin tells an open page which client bundle
2
+ // the host serves now, so a page that booted an older one can reload itself instead
3
+ // of relying on the user pressing Ctrl+Shift+R.
4
+ //
5
+ // The daemon half (its own module graph) lives in test/risd-api.test.mjs and
6
+ // test/risd-ui.test.mjs; this file covers the host route plus the client hook.
7
+ import assert from 'node:assert/strict'
8
+ import { createServer, request } from 'node:http'
9
+ import { mkdtempSync, readFileSync, rmSync } from 'node:fs'
10
+ import { tmpdir } from 'node:os'
11
+ import { join } from 'node:path'
12
+ import { after, before, test } from 'node:test'
13
+ import { handleRequest } from '../lib/index.js'
14
+
15
+ let home
16
+ let workspace
17
+ let server
18
+ let port
19
+
20
+ before(async () => {
21
+ home = mkdtempSync(join(tmpdir(), 'dsh-build-home-'))
22
+ workspace = mkdtempSync(join(tmpdir(), 'dsh-build-ws-'))
23
+ process.env.DSH_RIS_IDE_PROXY_HOME = home
24
+ server = createServer((req, res) => {
25
+ handleRequest({ sessions: { get: () => ({ header: { cwd: workspace } }) } }, req, res, { maxBytes: 1024, restrictToCwd: false })
26
+ })
27
+ await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve))
28
+ port = server.address().port
29
+ })
30
+
31
+ after(async () => {
32
+ await new Promise((resolve) => server.close(resolve))
33
+ delete process.env.DSH_RIS_IDE_PROXY_HOME
34
+ rmSync(home, { recursive: true, force: true })
35
+ rmSync(workspace, { recursive: true, force: true })
36
+ })
37
+
38
+ function getJson(path, host) {
39
+ return new Promise((resolve) => {
40
+ const call = request({ host: '127.0.0.1', port, path, method: 'GET', headers: { host: host ?? `127.0.0.1:${port}` } }, (res) => {
41
+ let text = ''
42
+ res.setEncoding('utf8')
43
+ res.on('data', (chunk) => { text += chunk })
44
+ res.on('end', () => {
45
+ let body = null
46
+ try { body = JSON.parse(text) } catch { body = null }
47
+ resolve({ status: res.statusCode, body })
48
+ })
49
+ })
50
+ call.on('error', () => resolve({ status: 0, body: null }))
51
+ call.end()
52
+ })
53
+ }
54
+
55
+ test('GET /dsh-ris-ide/build names the client bundle being served', async () => {
56
+ const { status, body } = await getJson('/dsh-ris-ide/build')
57
+ assert.equal(status, 200)
58
+ assert.equal(body.ok, true)
59
+ assert.match(body.build, /^[0-9a-f]{12}$/, 'a stable 12-hex stamp, not a raw mtime')
60
+ })
61
+
62
+ test('the stamp is stable while the bundle does not change', async () => {
63
+ // A page takes its FIRST answer as the baseline; a stamp that wobbled between two
64
+ // requests would make every page reload itself in a loop.
65
+ const first = await getJson('/dsh-ris-ide/build')
66
+ const second = await getJson('/dsh-ris-ide/build')
67
+ assert.equal(first.body.build, second.body.build)
68
+ })
69
+
70
+ test('a non-loopback Host cannot read the build stamp', async () => {
71
+ const { status } = await getJson('/dsh-ris-ide/build', 'evil.example')
72
+ assert.equal(status, 403)
73
+ })
74
+
75
+ test('the build route is read-only', async () => {
76
+ const status = await new Promise((resolve) => {
77
+ const call = request({ host: '127.0.0.1', port, path: '/dsh-ris-ide/build', method: 'POST', headers: { host: `127.0.0.1:${port}` } }, (res) => {
78
+ res.resume()
79
+ res.on('end', () => resolve(res.statusCode))
80
+ })
81
+ call.on('error', () => resolve(0))
82
+ call.end()
83
+ })
84
+ assert.equal(status, 405)
85
+ })
86
+
87
+ test('a stale page offers a refresh and never reloads itself', () => {
88
+ // Source-level assertions: both lives of this watcher (stream hello and the
89
+ // slow poll) must compare against the SAME baseline, otherwise a page could
90
+ // "notice" its own seed and raise a hint for nothing. Reloading is a user
91
+ // action — an automatic reload would throw away the IDE window's unsaved
92
+ // buffers (review C3-P1-2), so the watcher must not navigate by itself.
93
+ const source = readFileSync(new URL('../lib/client.js', import.meta.url), 'utf8')
94
+ const watcher = source.slice(source.indexOf('function watchClientBuild()'), source.indexOf('function selectProgram'))
95
+ assert.match(watcher, /function watchClientBuild\(\)/)
96
+ assert.match(watcher, /pageBuildId === null/)
97
+ assert.match(watcher, /note\(payload\.build\)/, 'the stream hello carries the stamp')
98
+ assert.match(watcher, /routeUrl\('dsh-ris-ide\/build'\)/, 'the baseline is seeded before the hello arrives')
99
+ assert.doesNotMatch(watcher, /location\.reload\(\)/, 'no self-reload: it would drop unsaved editor buffers')
100
+ assert.match(watcher, /showStaleBuildNotice\(build\)/, 'the bar names the build it warns about')
101
+ assert.match(watcher, /BUILD_POLL_MS/, 'a foreground page re-asks on a slow timer')
102
+ assert.match(watcher, /setInterval\(pollBuild, BUILD_POLL_MS\)/)
103
+ assert.match(watcher, /addEventListener\('focus', pollBuild\)/, 'coming back to the tab also re-checks')
104
+ assert.match(watcher, /staleNoticeDismissedFor/, 'a dismissed hint stays closed for that build')
105
+ })
106
+
107
+ test('the stale-build bar carries a refresh button', () => {
108
+ const source = readFileSync(new URL('../lib/client.js', import.meta.url), 'utf8')
109
+ const notice = source.slice(source.indexOf('function showStaleBuildNotice'), source.indexOf('function watchClientBuild'))
110
+ assert.match(notice, /textContent = '刷新'/)
111
+ assert.match(notice, /location\.reload\(\)/, 'the reload happens only when the user clicks it')
112
+ assert.match(notice, /staleNoticeDismissedFor = staleNoticeBuild/)
113
+ })
@@ -14,6 +14,7 @@ import { createServer } from 'node:http'
14
14
  import { createRequire } from 'node:module'
15
15
  import { execFileSync } from 'node:child_process'
16
16
  import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'
17
+ import { readFileSync as readSync } from 'node:fs'
17
18
  import { tmpdir } from 'node:os'
18
19
  import { join } from 'node:path'
19
20
  import { fileURLToPath } from 'node:url'
@@ -183,6 +184,40 @@ test('double-clicking a title-bar control does not maximise the pane', () => {
183
184
  assert.equal(T.headerDoubleClickIsTitle(input), false)
184
185
  })
185
186
 
187
+ test('one proxy control governs engine, interception and git together', async () => {
188
+ const { readFile } = await import('node:fs/promises')
189
+ const host = await readFile(new URL('../lib/index.js', import.meta.url), 'utf8')
190
+ // Start/stop drive all three layers, and so does the host exit hook. The UI that
191
+ // 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('syncGitProxy({ cwd, host: gitHost, enabled: true })'), 'start writes the git entry')
194
+ assert.ok(host.includes('syncGitProxy({ cwd, host: gitHost, enabled: false })'), 'stop clears the git entry')
195
+ assert.ok(host.includes('const redirector = await stopRedirector()'), 'stop brings the interception down')
196
+ assert.ok(host.includes('clearGitProxySync()'), 'the exit hook undoes the git entry too')
197
+ })
198
+
199
+ test('the console follows the live sidebar session, not the one it opened in', async () => {
200
+ const { readFile } = await import('node:fs/promises')
201
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
202
+ // `keepMounted` keeps the body alive across Session switches, so the session id
203
+ // it was opened with goes stale — the panel has to read the sidebar's live one.
204
+ assert.ok(source.includes('data-sidebar-right-session'), 'the live marker must be read')
205
+ assert.ok(source.includes("attributeFilter: ['data-sidebar-right-session', 'data-sidebar-right-panel', 'hidden']"),
206
+ 'switch must be observed, including retained wrappers being shown')
207
+ assert.ok(source.includes('data-sidebar-right-panel'), 'the panel element outranks a retained SessionView wrapper')
208
+ assert.ok(source.includes("node.closest('[hidden]') !== null"), 'a wrapper inside a hidden tree must not win')
209
+ assert.ok(source.includes('getClientRects().length === 0'), 'an unrendered wrapper must not win')
210
+ assert.ok(source.includes('if (nearestId !== undefined && shown(nearest)) return nearestId'),
211
+ 'the nearest marker only wins while it is on screen')
212
+ assert.ok(source.includes('setInterval(sync, 1500)'), 'a repaint-only switch still needs a fallback')
213
+ assert.ok(source.includes("window.addEventListener('focus', sync)"), 'returning to the window re-checks the session')
214
+ assert.ok(source.includes("if (typeof liveSessionId === 'string' && liveSessionId !== '') sessionId = liveSessionId"),
215
+ 'the live id must win over the injected one')
216
+ assert.ok(source.includes('}, [sessionIdentity])'), 'another workspace must drop the followed program')
217
+ assert.ok(source.includes("'Microsoft YaHei', sans-serif)"),
218
+ 'the chrome stack must match what the IDE theme resolves to, not a mono list')
219
+ })
220
+
186
221
  test('only invisible outcomes and failures raise a toast', async () => {
187
222
  const { readFile } = await import('node:fs/promises')
188
223
  const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
@@ -444,10 +479,139 @@ test('apply adds a Session-header button immediately right of DSH\'s open-in-app
444
479
  const markup = renderToStaticMarkup(React.createElement(header.component, { sessionId: 's1' }))
445
480
  assert.match(markup, /data-action="ris-ide-window"/)
446
481
  assert.match(markup, /RIS-IDE/)
447
- assert.match(markup, /title="在独立窗口中打开RIS-IDE"/, 'the tooltip is the short wording')
482
+ assert.match(markup, /title="打开 risd 维护页(概览 \/ 代理 \/ IDE):IDE 内嵌其中,可按工作区切换"/, 'the tooltip names the maintenance page')
483
+ assert.match(markup, /aria-busy="false"/, 'idle: the button says it is not opening anything')
484
+ }
485
+ })
486
+
487
+ test('the header button opens THIS session\'s workspace, not the remembered one', async () => {
488
+ // The slot hands every entry the session store (`useSessions`) and the
489
+ // session id, so the window's cwd comes from the session itself. Passing only
490
+ // the id let the window fall back to `dsh-ris-ide:last-cwd` — the workspace of
491
+ // the previous session, which is what the button then reopened.
492
+ assert.equal(T.sessionWorkspaceCwd(undefined, 's1'), undefined, 'no store hook: the caller keeps its own fallback')
493
+ assert.equal(T.sessionWorkspaceCwd(() => undefined, ''), undefined, 'no session id: nothing to look up')
494
+ const store = (state) => (selector) => selector(state)
495
+ assert.equal(T.sessionWorkspaceCwd(store({ byId: { s1: { cwd: '/w/current' } } }), 's1'), '/w/current')
496
+ assert.equal(T.sessionWorkspaceCwd(store({ byId: { s1: {} } }), 's1'), undefined, 'a session row without a cwd')
497
+ assert.equal(T.sessionWorkspaceCwd(store({ byId: { s1: { cwd: '' } } }), 's1'), undefined, 'an empty cwd is not a workspace')
498
+ assert.equal(T.sessionWorkspaceCwd(store({}), 's1'), undefined, 'a store that has not listed the session yet')
499
+ assert.equal(T.sessionWorkspaceCwd(store(undefined), 's1'), undefined, 'a missing store snapshot')
500
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
501
+ assert.match(
502
+ source,
503
+ /var sessionCwd = sessionWorkspaceCwd\(props !== null && props !== undefined \? props\.useSessions : undefined, sessionId\)/,
504
+ 'the button reads the session store',
505
+ )
506
+ assert.match(
507
+ source,
508
+ /openStandaloneWindow\(\{ sessionId: sessionId, cwd: sessionCwd, windowCwd: sessionCwd \}\)/,
509
+ 'both the panel cwd and the single-window name follow the session workspace',
510
+ )
511
+ })
512
+
513
+ test('⧉ reuses the prefetched daemon address, so a warm click adds no round trip', async () => {
514
+ // The visible delay was the on-demand spawn, but the host-view read sat in front
515
+ // of EVERY click. The header button and the console prefetch it on mount with a
516
+ // 20 s TTL; a click inside that window only has to call `window.open`.
517
+ const previous = { window: globalThis.window, document: globalThis.document, fetch: globalThis.fetch }
518
+ const opened = []
519
+ const requested = []
520
+ globalThis.document = { baseURI: 'http://127.0.0.1:3080/' }
521
+ globalThis.window = { open: (url, name) => { opened.push([url, name]); return { focus() {} } } }
522
+ globalThis.fetch = async (href) => {
523
+ requested.push(String(href))
524
+ return { ok: true, status: 200, json: async () => ({ ok: true, risd: { available: true, url: 'http://127.0.0.1:4567' } }) }
525
+ }
526
+ let fallbacks = 0
527
+ try {
528
+ T.resetRisdPrefetch()
529
+ const warm = await T.prefetchRisd({ sessionId: 's1', cwd: '/w/project' })
530
+ assert.equal(warm.url, 'http://127.0.0.1:4567', 'the prefetch keeps the daemon address')
531
+ assert.equal(requested.length, 1, 'the prefetch asks the host once')
532
+ assert.deepEqual(T.risdCachedAddress(), warm, 'the address is cached for the click')
533
+
534
+ const entry = await T.openRisdPage({ sessionId: 's1', cwd: '/w/project' }, async () => { fallbacks += 1 })
535
+ assert.equal(entry, 'risd')
536
+ assert.equal(requested.length, 1, 'the click adds no request: the cache answered')
537
+ assert.equal(opened.length, 1, 'exactly one tab')
538
+ assert.equal(opened[0][1], 'dsh-risd-ui', 'the maintenance tab keeps its name')
539
+ assert.match(opened[0][0], /^http:\/\/127\.0\.0\.1:4567\/ui\?cwd=%2Fw%2Fproject$/, 'preselects the workspace without switching the tab (m11345)')
540
+ assert.equal(fallbacks, 0, 'no standalone fallback when the daemon address is known')
541
+ } finally {
542
+ globalThis.window = previous.window
543
+ globalThis.document = previous.document
544
+ globalThis.fetch = previous.fetch
545
+ T.resetRisdPrefetch()
546
+ }
547
+ })
548
+
549
+ test('a cold ⧉ falls back to ensure and a double click still opens ONE tab', async () => {
550
+ const previous = { window: globalThis.window, document: globalThis.document, fetch: globalThis.fetch }
551
+ const opened = []
552
+ const requested = []
553
+ let releaseProxy = null
554
+ globalThis.document = { baseURI: 'http://127.0.0.1:3080/' }
555
+ globalThis.window = { open: (url, name) => { opened.push([url, name]); return { focus() {} } } }
556
+ globalThis.fetch = async (href) => {
557
+ const url = String(href)
558
+ requested.push(url)
559
+ if (url.includes('/risd/ensure')) {
560
+ return { ok: true, status: 200, json: async () => ({ ok: true, spawned: true, risd: { available: true, url: 'http://127.0.0.1:4567' } }) }
561
+ }
562
+ // Hold the host view open so the second click lands while the first is in flight.
563
+ return await new Promise((resolve) => {
564
+ releaseProxy = () => resolve({ ok: true, status: 200, json: async () => ({ ok: true, risd: { available: false } }) })
565
+ })
566
+ }
567
+ try {
568
+ T.resetRisdPrefetch()
569
+ const fallback = async () => { throw new Error('a spawnable daemon must not fall back') }
570
+ const first = T.openRisdPage({ sessionId: 's1', cwd: '/w/project' }, fallback)
571
+ const second = T.openRisdPage({ sessionId: 's1', cwd: '/w/project' }, fallback)
572
+ assert.equal(typeof releaseProxy, 'function', 'the host view read is in flight')
573
+ releaseProxy()
574
+ assert.equal(await first, 'risd')
575
+ assert.equal(await second, 'risd')
576
+ assert.equal(opened.length, 1, 'the in-flight open is shared, not duplicated')
577
+ assert.deepEqual(requested.map((href) => new URL(href).pathname), ['/dsh-ris-ide/proxy', '/dsh-ris-ide/risd/ensure'])
578
+ assert.equal(new URL(opened[0][0]).searchParams.get('cwd'), '/w/project', 'preselects the workspace')
579
+ assert.equal(new URL(opened[0][0]).searchParams.get('tab'), null, 'does not switch the tab (m11345)')
580
+ assert.equal(T.risdCachedAddress().url, 'http://127.0.0.1:4567', 'the ensured address warms the cache')
581
+ } finally {
582
+ globalThis.window = previous.window
583
+ globalThis.document = previous.document
584
+ globalThis.fetch = previous.fetch
585
+ T.resetRisdPrefetch()
448
586
  }
449
587
  })
450
588
 
589
+ test('both ⧉ buttons show progress and never run two opens at once', async () => {
590
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
591
+ // Session-header button: disabled + aria-busy, the ⧉ becomes an ellipsis and the
592
+ // label says 「打开中」; `finally` puts it back even when the popup was blocked.
593
+ assert.match(source, /'aria-busy': opening === true \? 'true' : 'false'/, 'the header button announces its busy state')
594
+ assert.match(source, /disabled: opening === true,/, 'and cannot be clicked twice')
595
+ assert.match(source, /opening === true \? '…' : '⧉'/, 'the icon becomes a progress ellipsis')
596
+ assert.match(source, /opening === true \? '打开中' : 'RIS-IDE'/, 'the label says it is opening')
597
+ assert.match(source, /setOpening\(false\)/, 'finally restores the button')
598
+ // The icon-only console ⧉ mirrors it (title / aria-label carry the wording).
599
+ assert.match(source, /'aria-busy': openingIde === true \? 'true' : 'false'/)
600
+ assert.match(source, /disabled: openingIde === true,/)
601
+ assert.match(source, /openingIde === true \? '…' : '⧉'/)
602
+ assert.match(source, /正在打开 risd 维护页/)
603
+ assert.match(source, /setOpeningIde\(false\)/, 'its finally restores the button too')
604
+ // Warm cache + single flight.
605
+ assert.match(source, /var risdPrefetch = \{ at: 0, risd: null, pending: null \}/)
606
+ assert.match(source, /var RISD_PREFETCH_TTL_MS = 20000/)
607
+ assert.match(source, /function prefetchRisd\(scope\)/)
608
+ assert.match(source, /if \(risdOpenPending !== null\) return risdOpenPending/)
609
+ assert.match(source, /onPointerEnter: warmRisdAddress/, 'hovering the header button warms the address')
610
+ assert.match(source, /onPointerEnter: warmCompactRisd/, 'the console icon warms it the same way')
611
+ assert.match(source, /void prefetchRisd\(\{ sessionId: sessionId, cwd: sessionCwd \}\)/, 'the header button warms the cache on mount')
612
+ assert.match(source, /void prefetchRisd\(\{ sessionId: sessionId, cwd: cwd \}\)/, 'the console warms it too')
613
+ })
614
+
451
615
  test('openStandaloneWindow hands the scope to the plugin\'s own page', async () => {
452
616
  const previousWindow = globalThis.window
453
617
  const previousDocument = globalThis.document
@@ -462,7 +626,8 @@ test('openStandaloneWindow hands the scope to the plugin\'s own page', async ()
462
626
  try {
463
627
  const handle = await T.openStandaloneWindow({ sessionId: 's1', cwd: '/w/project', programId: 'p1' })
464
628
  assert.equal(opened.length, 1)
465
- const [openedUrl, name, features] = opened[0]
629
+ const [openedUrl, name] = opened[0]
630
+ assert.equal(opened[0].length, 2, 'a plain window.open(url, name): no feature string')
466
631
  const parsed = new URL(openedUrl)
467
632
  // Same origin as the DSH page: no new port, cookie auth comes along.
468
633
  assert.equal(parsed.origin, 'http://127.0.0.1:3080')
@@ -485,7 +650,6 @@ test('openStandaloneWindow hands the scope to the plugin\'s own page', async ()
485
650
  const scoped = new URL(opened[opened.length - 1][0])
486
651
  assert.equal(scoped.searchParams.get('cwd'), '/w/project/sub', 'the panel keeps its rooted cwd')
487
652
  assert.equal(opened[opened.length - 1][1], T.standaloneWindowName('/w/project'), 'the window name stays workspace-keyed')
488
- assert.match(features, /popup=yes/)
489
653
  // The compact panel's 🐞 button: same window, plus "start the JDWP session".
490
654
  await T.openStandaloneWindow({ sessionId: 's1', cwd: '/w/project', programId: 'p1', debug: true })
491
655
  assert.equal(new URL(opened[opened.length - 1][0]).searchParams.get('debug'), '1')
@@ -606,7 +770,7 @@ test('a closed window never blocks the next open (dead registrations do not wait
606
770
  }
607
771
  })
608
772
 
609
- test('openStandaloneWindow asks for the whole screen work area (maximized)', async () => {
773
+ test('openStandaloneWindow opens a normal browser window, not a sized popup', async () => {
610
774
  const previousWindow = globalThis.window
611
775
  const previousDocument = globalThis.document
612
776
  const previousFetch = globalThis.fetch
@@ -619,16 +783,13 @@ test('openStandaloneWindow asks for the whole screen work area (maximized)', asy
619
783
  globalThis.fetch = async () => ({ ok: false, status: 404, json: async () => ({}) })
620
784
  try {
621
785
  await T.openStandaloneWindow({ sessionId: 's1' })
622
- const features = opened[0][2]
623
- assert.match(features, /width=1920/, 'the work area width, not a fixed width')
624
- assert.match(features, /height=1040/, 'the work area height, not a fixed height')
625
- assert.match(features, /left=0/, 'pinned to the left edge')
626
- assert.match(features, /top=0/, 'pinned to the top edge')
627
- assert.match(features, /popup=yes/)
628
- // No screen information (odd hosts): keep the old fallback instead of NaN.
786
+ assert.equal(opened[0].length, 2, 'no features argument: the browser decides the frame')
787
+ assert.match(opened[0][1], /^dsh-ris-ide-window-/, 'the workspace-keyed name is what makes it single-instance')
788
+ // A host without screen information must not change the call shape either.
629
789
  globalThis.window = { open: (...args) => { opened.push(args); return { focus() {} } } }
790
+ globalThis.window.localStorage = { getItem: () => '/w/project' }
630
791
  await T.openStandaloneWindow({ sessionId: 's1' })
631
- assert.match(opened[1][2], /width=1500/)
792
+ assert.equal(opened[1].length, 2)
632
793
  } finally {
633
794
  globalThis.window = previousWindow
634
795
  globalThis.document = previousDocument
@@ -2095,7 +2256,9 @@ test('the title-bar controls share one 20px row height', { skip: !reactIsReal ?
2095
2256
  const sourceTags = buttonsOf(sourceHead)
2096
2257
  const consoleTags = buttonsOf(consoleHead)
2097
2258
  assert.ok(sourceTags.length >= 3, 'the source toolbar carries the font scale, the theme switch and reset')
2098
- assert.equal(consoleTags.length, 2, 'the console title bar carries 📄 open-config and ⚙ config-generate')
2259
+ const consoleActions = consoleTags.map((tag) => /data-action="([^"]+)"/.exec(tag)[1])
2260
+ assert.deepEqual(consoleActions, ['config-open', 'config-generate'],
2261
+ 'the console title bar carries 📄 open-config and ⚙ config-generate only (proxy moved out)')
2099
2262
  for (const tag of sourceTags.concat(consoleTags)) {
2100
2263
  const action = /data-action="([^"]+)"/.exec(tag)[1]
2101
2264
  assert.match(tag, /height:20px/, `${action} must sit on the shared 20px row`)
@@ -3950,8 +4113,9 @@ test('one IDE window per workspace: the window name is keyed by the workspace cw
3950
4113
  assert.doesNotMatch(source, /focusStandaloneWindow/, 'raising a foreign window is not attempted any more')
3951
4114
  assert.match(source, /await requestStandaloneWindowClose\(windowName\)/, 'present: ask the old window to close, then open one')
3952
4115
  assert.doesNotMatch(source, /focus-ack/, 'no focus handshake: the browser forbids it')
3953
- assert.match(source, /window\.open\(url\.href, windowName, features\)/, 'absent: create it straight on the IDE url')
3954
- assert.doesNotMatch(source, /window\.open\('', windowName, features\)/, 'never a blank window to close again')
4116
+ assert.match(source, /window\.open\(url\.href, windowName\)/, 'absent: create it straight on the IDE url, as a normal window')
4117
+ assert.doesNotMatch(source, /window\.open\(url\.href, windowName, features\)/, 'no popup feature string any more')
4118
+ assert.doesNotMatch(source, /window\.open\('', windowName/, 'never a blank window to close again')
3955
4119
  assert.doesNotMatch(source, /settleStandaloneWindow/)
3956
4120
  })
3957
4121
 
@@ -3981,7 +4145,11 @@ test('the standalone window claims a single-instance lock before booting the IDE
3981
4145
  // offers an explicit "close this window" action instead — and only that button
3982
4146
  // may close it (never an automatic close at boot).
3983
4147
  assert.match(claim, /关闭这个窗口/, 'the duplicate window can be closed on demand')
3984
- assert.equal((claim.match(/window\.close\(\)/g) || []).length, 2, 'closing happens only from the two explicit user actions')
4148
+ // One explicit close action remains; inside the maintenance page's iframe that
4149
+ // offer is dropped (window.close() is refused there — review D3).
4150
+ assert.equal((claim.match(/window\.close\(\)/g) || []).length, 2, 'closing happens only from the explicit user actions')
4151
+ assert.match(claim, /window\.self !== window\.top/, 'the embedded case is detected')
4152
+ assert.match(claim, /if \(!embedded\)/, 'the dead close button is not rendered inside an iframe')
3985
4153
  // Booting waits for the claim, so the notice cannot be raced by a mounted panel.
3986
4154
  assert.match(html, /window\.__risIdeClaimReady/)
3987
4155
  assert.match(html, /window\.__risIdeBootPanel = bootPanel/)
@@ -4371,7 +4539,7 @@ test('Ctrl+F searches what the editor, log or fallback editor has highlighted',
4371
4539
  // next one after a caret parked deep in the document.
4372
4540
  assert.match(chunkSource, /function findFirstFromStart\(view\) \{\n\s*view\.dispatch\(\{ selection: \{ anchor: 0 \} \}\)\n\s*findNext\(view\)/)
4373
4541
  assert.match(chunkSource, /if \(jump\) findFirstFromStart\(view\)/)
4374
- assert.match(chunkSource, /const seeded = searchSelectedText\(instance\); openSearchPanel\(instance\); if \(seeded\) findFirstFromStart\(instance\)/)
4542
+ assert.match(chunkSource, /const seeded = searchSelectedText\(instance\); openSearchPanel\(instance\); if \(seeded\) findFirstFromStart\(instance\); caretToEndOfFindField\(instance\)/)
4375
4543
  assert.match(chunk, /function findFirstFromStart\(view\)/)
4376
4544
  assert.match(chunk, /if \(jump\) findFirstFromStart\(view\)/)
4377
4545
  // A handed-over hit still starts at ITS line (that is the point of clicking it).
@@ -4418,13 +4586,66 @@ test('Ctrl+F with the search panel ALREADY open puts the caret back in the find
4418
4586
  // reach CodeMirror's keymap, so the browser's own find bar opened instead. The
4419
4587
  // workbench claims the chord in the standalone window and hands it to the open
4420
4588
  // file's editor handle, which opens/focuses the panel.
4421
- assert.match(chunkSource, /find\(\) \{\n\s*openSearchPanel\(view\)\n\s*\},/)
4422
- assert.match(chunk, /find\(\) \{\s*openSearchPanel\(view\);\s*\}/)
4589
+ assert.match(chunkSource, /find\(\) \{\n\s*openSearchPanel\(view\)[\s\S]{0,400}?caretToEndOfFindField\(view\)\n\s*\},/)
4590
+ assert.match(chunk, /find\(\) \{\s*openSearchPanel\(view\);[\s\S]{0,400}?caretToEndOfFindField\(view\);\s*\}/)
4423
4591
  assert.match(source, /function onFindKey\(event\) \{\n\s*if \(event\.defaultPrevented === true\) return/)
4424
4592
  assert.match(source, /if \(!ownsKeyTarget\(event\.target\)\) return[\s\S]{0,900}?typeof controls\.find === 'function'/)
4425
4593
  assert.match(source, /window\.addEventListener\('keydown', onFindKey\)/)
4426
4594
  })
4427
4595
 
4596
+ test('the find box accepts more than one character while it has matches', async () => {
4597
+ const chunkSource = await readFile(new URL('../src/chunks/codemirror.js', import.meta.url), 'utf8')
4598
+ const chunk = await readFile(new URL('../lib/client-codemirror.js', import.meta.url), 'utf8')
4599
+
4600
+ // Root cause: @codemirror/search's `selectSearchInput` selects the whole query
4601
+ // when the panel's [main-field] has focus, so the second keystroke replaced the
4602
+ // first and a term could never exceed one character (only once there was a hit:
4603
+ // with no match `findNext` returns before selecting).
4604
+ assert.match(chunkSource, /const end = searchInput\.value\.length\n\s*searchInput\.setSelectionRange\(end, end\)/)
4605
+ assert.ok(!chunkSource.includes('searchInput.select()'), 'focusing the field must never select the query')
4606
+ // Every path that runs findNext/findPrevious from the box restores the caret.
4607
+ assert.match(chunkSource, /const restoreSearchCaret = \(range\) => \{[\s\S]{0,600}?searchInput\.setSelectionRange\(start, stop\)/)
4608
+ assert.match(chunkSource, /const caret = \{ start: searchInput\.selectionStart, end: searchInput\.selectionEnd \}\n\s*apply\(\{ search: searchInput\.value \}, true\)\n\s*restoreSearchCaret\(caret\)/)
4609
+ assert.match(chunkSource, /restoreSearchCaret\(caret\)\n\s*sync\(\)/)
4610
+ // Programmatic opens (Ctrl+F keymap, editor handle, content-search hand-off) too.
4611
+ assert.match(chunkSource, /function caretToEndOfFindField\(view\) \{/)
4612
+ assert.match(chunkSource, /caretToEndOfFindField\(view\)\n\s*return true/)
4613
+ assert.match(chunkSource, /findNext\(view\)\n\s*caretToEndOfFindField\(view\)/)
4614
+ // The built chunk carries all of it (the runtime loads this file, not the source).
4615
+ assert.match(chunk, /function caretToEndOfFindField\(view\)/)
4616
+ assert.match(chunk, /restoreSearchCaret = \(range\) => \{/)
4617
+ assert.match(chunk, /setSelectionRange\(end, end\)/)
4618
+ })
4619
+
4620
+ test('Ctrl+R re-reads the workspace instead of replaying the search cache', async () => {
4621
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
4622
+
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.
4625
+ assert.match(source, /var \[searchReload, setSearchReload\] = useState\(0\)/)
4626
+ 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)")
4630
+ assert.equal(effects.length, 2)
4631
+ const contentStart = effects[1].indexOf("var cached = searchCacheRef.current.get('content:' + text)")
4632
+ assert.ok(contentStart !== -1)
4633
+ assert.match(effects[1].slice(contentStart, contentStart + 5000), /\}, \[treeQuery, cwd, searchReload\]\)/)
4634
+
4635
+ // Ctrl+R (Ctrl+Shift+R / F3) in the standalone window focuses the box through the
4636
+ // nonce effect; that same effect is where the stale cache is thrown away.
4637
+ const nonceGuard = "if (searchFocusPendingRef.current !== true) return"
4638
+ const nonceStart = source.indexOf(nonceGuard)
4639
+ assert.ok(nonceStart !== -1)
4640
+ const nonceEffect = source.slice(nonceStart, nonceStart + 1200)
4641
+ assert.match(nonceEffect, /input\.select\(\)\n\s*reloadWorkspaceSearch\(treeQuery\)/)
4642
+
4643
+ // Saving a file changes what `git grep` would return, so it invalidates too.
4644
+ const writeStart = source.indexOf('return fsWrite(scopeRef.current, path, docTextForDisk(doc)).then(function () {')
4645
+ assert.ok(writeStart !== -1)
4646
+ assert.match(source.slice(writeStart, writeStart + 500), /reloadWorkspaceSearch\(treeQuery\)/)
4647
+ })
4648
+
4428
4649
  test('an oversized text file opens a read-only windowed preview', async () => {
4429
4650
  const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
4430
4651
  assert.match(source, /function fsWindowRead\(scope, path, offset, length\)/)
@@ -4488,6 +4709,34 @@ test('trimLargeTextFront frees whole lines and keeps the line count aligned', ()
4488
4709
  assert.deepEqual(T.trimLargeTextFront('', 100), { text: '', droppedLines: 0, droppedChars: 0 })
4489
4710
  })
4490
4711
 
4712
+ test('hovering a tree row paints a faint background that stays below the selection', async () => {
4713
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
4714
+ // m09634: the row, not just its label, gets a light grey wash. A background
4715
+ // changes no metrics, so nothing moves; and since selected rows paint their tint
4716
+ // INLINE (S.treeRowOn / treeRowMulti), the stylesheet hover can never outrank them.
4717
+ const css = source.slice(source.indexOf('var TREE_HOVER_CSS'), source.indexOf('var SEARCH_PANEL_CSS'))
4718
+ assert.match(css, /\[data-tree-path\]:hover/)
4719
+ assert.match(css, /background:color-mix\(in srgb, currentColor 7%, transparent\)/, 'a faint grey wash')
4720
+ assert.doesNotMatch(css, /padding|margin|line-height|min-height|font-size|height:/, 'no metric changes: the tree must not jump')
4721
+ assert.match(source, /treeRowOn: \{[^}]*background: 'color-mix\(in srgb, currentColor 12%, transparent\)'/, 'the selected tint is an inline style (wins over hover)')
4722
+ assert.match(source, /treeRowMulti: \{[^}]*background:/, 'multi-selection tint too')
4723
+ assert.match(source, /PROGRAM_LOADING_CSS \+ TREE_HOVER_CSS/, 'injected with the panel styles')
4724
+ })
4725
+
4726
+ test('the embedded editor answers the maintenance page about unsaved buffers (m10900)', async () => {
4727
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
4728
+ // The daemon's maintenance page embeds this window cross-origin and reloads
4729
+ // itself on updates; it cannot read `docs`. It asks over postMessage, and only
4730
+ // the immediate parent plus the two named shapes are served.
4731
+ assert.match(source, /event\.source !== window\.parent/, 'only the embedding parent is served')
4732
+ assert.match(source, /'dsh-ris-ide:probe-dirty'/, 'it answers the dirty probe')
4733
+ assert.match(source, /'dsh-ris-ide:dirty-report'/, 'with a named report')
4734
+ assert.match(source, /'dsh-ris-ide:save-all'/, 'it can save every dirty buffer on request')
4735
+ assert.match(source, /'dsh-ris-ide:save-all-done'/, 'and reports whether the save succeeded')
4736
+ assert.match(source, /window\.parent\.postMessage\(payload, '\*'\)/, 'the reply goes to the parent')
4737
+ assert.match(source, /saveBulk\(pending\)/, 'the save-all reuses the bulk save path')
4738
+ })
4739
+
4491
4740
  test('the editor scrollbars are visible and a start re-reads its log', async () => {
4492
4741
  const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
4493
4742
  // BUG3: the host theme paints a 5px near-invisible scrollbar; the panel gives
@@ -4576,6 +4825,19 @@ test('the sidebar console opens the config as a sidebar file resource', async ()
4576
4825
  assert.match(source, /已在右侧栏打开 /, 'the console reports where the config went')
4577
4826
  })
4578
4827
 
4828
+ test('the config note names the file without a helper nested in another component', async () => {
4829
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
4830
+ // `shortName` used to be declared INSIDE ProgramWorkbench. The SIDEBAR
4831
+ // ProgramsPanel is a sibling component, so its openConfig threw
4832
+ // "shortName is not defined" right after the config file had already opened:
4833
+ // the file appeared, but the note showed 打开配置失败 instead. The basename
4834
+ // helper is module scope (like the stop square), so both halves share it.
4835
+ assert.doesNotMatch(source, /function shortName\(/, 'no basename helper nested in one component')
4836
+ assert.match(source, /^ {4}function fileBaseName\(path\) \{/m, 'the basename helper is declared at module scope')
4837
+ assert.match(source, /'已在右侧栏打开 ' \+ fileBaseName\(path\)/, 'the sidebar config note names the file through it')
4838
+ assert.match(source, /pendingBulk\.dirty\.slice\(0, 2\)\.map\(fileBaseName\)/, 'the workbench prompt uses the same helper')
4839
+ })
4840
+
4579
4841
  test('the mask names the action and a window opened on a program auto-debugs it', async () => {
4580
4842
  const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
4581
4843
 
@@ -4624,7 +4886,7 @@ test('search hits survive a pick and the shortcut selects the query', async () =
4624
4886
  const pick = source.slice(source.indexOf('function pickSearchHit('), source.indexOf('function openContentHit('))
4625
4887
  assert.doesNotMatch(pick, /setTreeQuery\(''\)/, 'the query stays after a pick')
4626
4888
  assert.doesNotMatch(pick, /setSearchHits\(null\)/, 'the result set stays after a pick')
4627
- const contentPick = source.slice(source.indexOf('function openContentHit('), source.indexOf('var runningSignature'))
4889
+ const contentPick = source.slice(source.indexOf('function openContentHit('), source.indexOf('// No auto-pick on first load'))
4628
4890
  assert.doesNotMatch(contentPick, /setTreeQuery\(''\)/, 'a content pick keeps the query too')
4629
4891
  // Both searches cache their payloads keyed by the query text.
4630
4892
  assert.match(source, /searchCacheRef\.current\.get\('name:' \+ text\)/)
@@ -4743,6 +5005,19 @@ test('content hits render in the same dropdown, with line numbers and the conten
4743
5005
  assert.match(markup, /data-search-hit-icon="content"/, 'content rows have their own icon')
4744
5006
  })
4745
5007
 
5008
+ test('editing the query ends the dropdown state Escape left behind', async () => {
5009
+ const { readFile } = await import('node:fs/promises')
5010
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
5011
+ const box = source.slice(source.indexOf("'data-action': 'tree-search'"), source.indexOf('// The dropdown belongs to FOCUS'))
5012
+ assert.match(box, /onChange: function \(event\) \{\n\s*var value = event\.target\.value\n\s*setTreeQuery\(value\)/, 'the edit is still applied verbatim')
5013
+ assert.match(box, /if \(value\.trim\(\) !== ''\) setSearchFocused\(true\)/, 'a non-empty edit re-opens the dropdown')
5014
+ // Escape is "leave the box", not "throw my query away": it blurs, and the focus
5015
+ // handler hides the dropdown while the query (and its cached hits) stay.
5016
+ const escape = box.slice(box.indexOf("if (event.key === 'Escape')"), box.indexOf('// Whichever dropdown is open'))
5017
+ assert.match(escape, /searchInputRef\.current\.blur\(\)/, 'Escape gives the caret back')
5018
+ assert.doesNotMatch(escape, /setTreeQuery\(''\)/, 'Escape no longer clears the query')
5019
+ })
5020
+
4746
5021
  test('a dialog keeps the anchor it opened at when the pointer moves or clicks again', async () => {
4747
5022
  const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
4748
5023
  // The point is frozen on open, not read live on every render: a second
@@ -4775,3 +5050,22 @@ test('a folder row only expands; the context menu\'s 进入 re-roots with an 上
4775
5050
  assert.match(region, /if \(locateRequest\.kind === 'dir'\) openDirRoot\(locateRequest\.path\)/, 'picking a folder search hit re-roots too')
4776
5051
  assert.match(region, /walk\(activeRoot, 0, \{\}\)/, 'Ctrl+A walks the active root')
4777
5052
  })
5053
+
5054
+ // ── the old in-panel proxy dialog is gone; the risd page owns the rules ──
5055
+ test('the console keeps its log pane empty until a row is chosen (m07431)', async () => {
5056
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
5057
+ // First load used to pick the first running service and load its log, which
5058
+ // located/opened a file nobody asked for. A click on a row is the only way in.
5059
+ assert.match(source, /\/\/ No auto-pick on first load \(m07431\)/)
5060
+ assert.equal(source.includes('First load with no explicit target'), false)
5061
+ })
5062
+
5063
+ test('no ProxyDialog component is shipped any more (m07355 / D4)', async () => {
5064
+ const { readFile } = await import('node:fs/promises')
5065
+ 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')
5071
+ })
@@ -0,0 +1,65 @@
1
+ // The two plugins must stay usable standalone, so the companion hint is a
2
+ // RECOMMENDATION that only appears when the workspace really looks like a
3
+ // YonBIP/YMS project — never on an ordinary Java/Vue repo.
4
+ import assert from 'node:assert/strict'
5
+ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
6
+ import { tmpdir } from 'node:os'
7
+ import { join } from 'node:path'
8
+ import test from 'node:test'
9
+
10
+ import { __test } from '../lib/index.js'
11
+
12
+ const { detectCompanionPlugin, renderProgramList } = __test
13
+
14
+ function workspace() {
15
+ return mkdtempSync(join(tmpdir(), 'ris-companion-'))
16
+ }
17
+
18
+ test('a plain workspace gets no companion hint', () => {
19
+ const dir = workspace()
20
+ try {
21
+ writeFileSync(join(dir, 'pom.xml'), '<project/>')
22
+ assert.equal(detectCompanionPlugin(dir), null)
23
+ assert.doesNotMatch(renderProgramList({ root: dir, dir, programs: [] }), /dsh-ris-yds/)
24
+ } finally {
25
+ rmSync(dir, { recursive: true, force: true })
26
+ }
27
+ })
28
+
29
+ test('yms-home marks the workspace as YonBIP/YMS', () => {
30
+ const dir = workspace()
31
+ try {
32
+ mkdirSync(join(dir, 'yms-home'))
33
+ const found = detectCompanionPlugin(dir)
34
+ assert.equal(found.plugin, 'dsh-ris-yds')
35
+ assert.match(found.detected, /yms-home/)
36
+ assert.match(found.hint, /YMS/)
37
+ } finally {
38
+ rmSync(dir, { recursive: true, force: true })
39
+ }
40
+ })
41
+
42
+ test('.vscode/settings.json with yds.* marks it too', () => {
43
+ const dir = workspace()
44
+ try {
45
+ mkdirSync(join(dir, '.vscode'))
46
+ writeFileSync(join(dir, '.vscode', 'settings.json'), JSON.stringify({ 'yds.module': 'c-ass-kk-hans' }))
47
+ assert.equal(detectCompanionPlugin(dir).plugin, 'dsh-ris-yds')
48
+ } finally {
49
+ rmSync(dir, { recursive: true, force: true })
50
+ }
51
+ })
52
+
53
+ test('the program list renders the hint as an optional extra line', () => {
54
+ const dir = workspace()
55
+ try {
56
+ mkdirSync(join(dir, 'yms-home'))
57
+ const text = renderProgramList({ root: dir, dir: join(dir, 'logs'), programs: [], companion: detectCompanionPlugin(dir) })
58
+ assert.match(text, /No runnable programs/)
59
+ assert.match(text, /Optional companion plugin: dsh-ris-yds/)
60
+ // Null companion keeps the rendered list exactly as before.
61
+ assert.doesNotMatch(renderProgramList({ root: dir, dir, programs: [], companion: null }), /Optional companion plugin/)
62
+ } finally {
63
+ rmSync(dir, { recursive: true, force: true })
64
+ }
65
+ })