dsh-ris-ide 1.7.0 → 1.7.1

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.
@@ -447,19 +447,22 @@ test('apply adds a Session-header button immediately right of DSH\'s open-in-app
447
447
  }
448
448
  })
449
449
 
450
- test('openStandaloneWindow hands the scope to the plugin\'s own page', () => {
450
+ test('openStandaloneWindow hands the scope to the plugin\'s own page', async () => {
451
451
  const previousWindow = globalThis.window
452
452
  const previousDocument = globalThis.document
453
+ const previousFetch = globalThis.fetch
453
454
  const opened = []
454
455
  globalThis.window = {
455
456
  open: (...args) => { opened.push(args); return { focus() {} } },
456
457
  }
457
458
  globalThis.document = { baseURI: 'http://127.0.0.1:3080/' }
459
+ // No window registered for this workspace yet: the opener creates it.
460
+ globalThis.fetch = async () => ({ ok: false, status: 404, json: async () => ({}) })
458
461
  try {
459
- T.openStandaloneWindow({ sessionId: 's1', cwd: '/w/project', programId: 'p1' })
462
+ const handle = await T.openStandaloneWindow({ sessionId: 's1', cwd: '/w/project', programId: 'p1' })
460
463
  assert.equal(opened.length, 1)
461
- const [url, name, features] = opened[0]
462
- const parsed = new URL(url)
464
+ const [openedUrl, name, features] = opened[0]
465
+ const parsed = new URL(openedUrl)
463
466
  // Same origin as the DSH page: no new port, cookie auth comes along.
464
467
  assert.equal(parsed.origin, 'http://127.0.0.1:3080')
465
468
  assert.equal(parsed.pathname, '/dsh-ris-ide/window')
@@ -467,6 +470,7 @@ test('openStandaloneWindow hands the scope to the plugin\'s own page', () => {
467
470
  assert.equal(parsed.searchParams.get('cwd'), '/w/project')
468
471
  assert.equal(parsed.searchParams.get('programId'), 'p1')
469
472
  assert.equal(parsed.searchParams.get('debug'), null, 'plain open: no auto-debug')
473
+ assert.notEqual(handle, null, 'the created window is handed back')
470
474
  // One IDE window per workspace: the name is derived from the cwd, so a
471
475
  // second click on the same workspace reuses this window, while another
472
476
  // workspace keeps its own window.
@@ -476,31 +480,144 @@ test('openStandaloneWindow hands the scope to the plugin\'s own page', () => {
476
480
  // A program-subdirectory cwd roots the panel there, but the WINDOW still
477
481
  // follows the workspace (`windowCwd`), so it never opens a second window.
478
482
  globalThis.window.localStorage = { getItem: () => '/w/project' }
479
- T.openStandaloneWindow({ sessionId: 's1', cwd: '/w/project/sub', programId: 'p1' })
483
+ await T.openStandaloneWindow({ sessionId: 's1', cwd: '/w/project/sub', programId: 'p1' })
480
484
  const scoped = new URL(opened[opened.length - 1][0])
481
485
  assert.equal(scoped.searchParams.get('cwd'), '/w/project/sub', 'the panel keeps its rooted cwd')
482
486
  assert.equal(opened[opened.length - 1][1], T.standaloneWindowName('/w/project'), 'the window name stays workspace-keyed')
483
487
  assert.match(features, /popup=yes/)
484
488
  // The compact panel's 🐞 button: same window, plus "start the JDWP session".
485
- T.openStandaloneWindow({ sessionId: 's1', cwd: '/w/project', programId: 'p1', debug: true })
489
+ await T.openStandaloneWindow({ sessionId: 's1', cwd: '/w/project', programId: 'p1', debug: true })
486
490
  assert.equal(new URL(opened[opened.length - 1][0]).searchParams.get('debug'), '1')
487
491
  } finally {
488
492
  globalThis.window = previousWindow
489
493
  globalThis.document = previousDocument
494
+ globalThis.fetch = previousFetch
490
495
  }
491
496
  })
492
497
 
493
- test('openStandaloneWindow asks for the whole screen work area (maximized)', () => {
498
+ test('an already-open window is asked to close before a fresh one is opened', async () => {
494
499
  const previousWindow = globalThis.window
495
500
  const previousDocument = globalThis.document
501
+ const previousFetch = globalThis.fetch
502
+ const previousChannel = globalThis.BroadcastChannel
503
+ const opened = []
504
+ const messages = []
505
+ const windowName = T.standaloneWindowName('/w/project')
506
+ let alive = true
507
+ globalThis.window = { open: (...args) => { opened.push(args); return { focus() {} } } }
508
+ globalThis.document = { baseURI: 'http://127.0.0.1:3080/' }
509
+ globalThis.fetch = async () => ({
510
+ ok: true,
511
+ status: 200,
512
+ json: async () => ({ ok: true, windows: [{ name: windowName, cwd: '/w/project', alive, idleMs: 12 }], session: null }),
513
+ })
514
+ globalThis.BroadcastChannel = class {
515
+ constructor(name) { this.name = name; this.onmessage = null }
516
+ postMessage(message) {
517
+ messages.push({ name: this.name, message })
518
+ // The old window obeys: it closes itself, so its stream disappears.
519
+ if (message !== null && message.type === 'close') alive = false
520
+ }
521
+ close() {}
522
+ }
523
+ try {
524
+ const handle = await T.openStandaloneWindow({ sessionId: 's1', cwd: '/w/project' })
525
+ assert.notEqual(handle, null, 'the click always ends with a window')
526
+ assert.equal(opened.length, 1, 'exactly one window is opened — after the old one is gone, no twin')
527
+ assert.equal(new URL(opened[0][0]).pathname, '/dsh-ris-ide/window')
528
+ assert.equal(opened[0][1], windowName, 'the window name is workspace-keyed')
529
+ assert.deepEqual(messages, [{ name: windowName, message: { type: 'close' } }], 'the old window is asked to close, not raised')
530
+ } finally {
531
+ globalThis.window = previousWindow
532
+ globalThis.document = previousDocument
533
+ globalThis.fetch = previousFetch
534
+ globalThis.BroadcastChannel = previousChannel
535
+ }
536
+ })
537
+
538
+ test('a window that refuses to close does not block the new one', async () => {
539
+ const previousWindow = globalThis.window
540
+ const previousDocument = globalThis.document
541
+ const previousFetch = globalThis.fetch
542
+ const previousChannel = globalThis.BroadcastChannel
543
+ const opened = []
544
+ const messages = []
545
+ const windowName = T.standaloneWindowName('/w/project')
546
+ globalThis.window = { open: (...args) => { opened.push(args); return { focus() {} } } }
547
+ globalThis.document = { baseURI: 'http://127.0.0.1:3080/' }
548
+ // It stays alive: the old window ignored the close ping (a frozen tab, say).
549
+ globalThis.fetch = async () => ({
550
+ ok: true,
551
+ status: 200,
552
+ json: async () => ({ ok: true, windows: [{ name: windowName, cwd: '/w/project', alive: true, idleMs: 8 }], session: null }),
553
+ })
554
+ globalThis.BroadcastChannel = class {
555
+ constructor(name) { this.name = name; this.onmessage = null }
556
+ postMessage(message) { messages.push({ name: this.name, message }) }
557
+ close() {}
558
+ }
559
+ try {
560
+ const started = Date.now()
561
+ const handle = await T.openStandaloneWindow({ sessionId: 's1', cwd: '/w/project' })
562
+ assert.notEqual(handle, null, 'the click still ends with a window')
563
+ assert.equal(opened.length, 1)
564
+ assert.deepEqual(messages.map((entry) => entry.message.type), ['close'], 'the close ping is the only message')
565
+ assert.ok(Date.now() - started >= 1400, 'it waited for the closing handshake before giving up')
566
+ } finally {
567
+ globalThis.window = previousWindow
568
+ globalThis.document = previousDocument
569
+ globalThis.fetch = previousFetch
570
+ globalThis.BroadcastChannel = previousChannel
571
+ }
572
+ })
573
+
574
+ test('a closed window never blocks the next open (dead registrations do not wait)', async () => {
575
+ const previousWindow = globalThis.window
576
+ const previousDocument = globalThis.document
577
+ const previousFetch = globalThis.fetch
578
+ const previousChannel = globalThis.BroadcastChannel
579
+ const opened = []
580
+ const messages = []
581
+ globalThis.window = { open: (...args) => { opened.push(args); return { focus() {} } } }
582
+ globalThis.document = { baseURI: 'http://127.0.0.1:3080/' }
583
+ globalThis.fetch = async () => ({
584
+ ok: true,
585
+ status: 200,
586
+ json: async () => ({ ok: true, windows: [{ name: T.standaloneWindowName('/w/project'), cwd: '/w/project', alive: false, idleMs: 5000 }], session: null }),
587
+ })
588
+ globalThis.BroadcastChannel = class {
589
+ constructor(name) { this.name = name; this.onmessage = null }
590
+ postMessage(message) { messages.push({ name: this.name, message }) }
591
+ close() {}
592
+ }
593
+ try {
594
+ const started = Date.now()
595
+ const handle = await T.openStandaloneWindow({ sessionId: 's1', cwd: '/w/project' })
596
+ assert.notEqual(handle, null, 'a registration whose stream is gone must not block opening')
597
+ assert.equal(opened.length, 1)
598
+ assert.deepEqual(messages, [], 'no close ping: there is nobody to close')
599
+ assert.ok(Date.now() - started < 850, 'no pointless wait for a window that is already gone')
600
+ } finally {
601
+ globalThis.window = previousWindow
602
+ globalThis.document = previousDocument
603
+ globalThis.fetch = previousFetch
604
+ globalThis.BroadcastChannel = previousChannel
605
+ }
606
+ })
607
+
608
+ test('openStandaloneWindow asks for the whole screen work area (maximized)', async () => {
609
+ const previousWindow = globalThis.window
610
+ const previousDocument = globalThis.document
611
+ const previousFetch = globalThis.fetch
496
612
  const opened = []
497
613
  globalThis.window = {
498
614
  screen: { availWidth: 1920, availHeight: 1040 },
499
615
  open: (...args) => { opened.push(args); return { focus() {} } },
500
616
  }
501
617
  globalThis.document = { baseURI: 'http://127.0.0.1:3080/' }
618
+ globalThis.fetch = async () => ({ ok: false, status: 404, json: async () => ({}) })
502
619
  try {
503
- T.openStandaloneWindow({ sessionId: 's1' })
620
+ await T.openStandaloneWindow({ sessionId: 's1' })
504
621
  const features = opened[0][2]
505
622
  assert.match(features, /width=1920/, 'the work area width, not a fixed width')
506
623
  assert.match(features, /height=1040/, 'the work area height, not a fixed height')
@@ -509,24 +626,28 @@ test('openStandaloneWindow asks for the whole screen work area (maximized)', ()
509
626
  assert.match(features, /popup=yes/)
510
627
  // No screen information (odd hosts): keep the old fallback instead of NaN.
511
628
  globalThis.window = { open: (...args) => { opened.push(args); return { focus() {} } } }
512
- T.openStandaloneWindow({ sessionId: 's1' })
629
+ await T.openStandaloneWindow({ sessionId: 's1' })
513
630
  assert.match(opened[1][2], /width=1500/)
514
631
  } finally {
515
632
  globalThis.window = previousWindow
516
633
  globalThis.document = previousDocument
634
+ globalThis.fetch = previousFetch
517
635
  }
518
636
  })
519
637
 
520
- test('openStandaloneWindow reports a blocked popup instead of failing silently', () => {
638
+ test('openStandaloneWindow reports a blocked popup instead of failing silently', async () => {
521
639
  const previousWindow = globalThis.window
522
640
  const previousDocument = globalThis.document
641
+ const previousFetch = globalThis.fetch
523
642
  globalThis.window = { open: () => null }
524
643
  globalThis.document = { baseURI: 'http://127.0.0.1:3080/' }
644
+ globalThis.fetch = async () => ({ ok: false, status: 404, json: async () => ({}) })
525
645
  try {
526
- assert.throws(() => T.openStandaloneWindow({ sessionId: 's1' }), /被拦截/)
646
+ await assert.rejects(T.openStandaloneWindow({ sessionId: 's1' }), /被拦截/)
527
647
  } finally {
528
648
  globalThis.window = previousWindow
529
649
  globalThis.document = previousDocument
650
+ globalThis.fetch = previousFetch
530
651
  }
531
652
  })
532
653
 
@@ -545,11 +666,10 @@ test('mountStandalone renders the IDE panel with no DSH context at all', async (
545
666
  // The panel sits under the error boundary, so one render error cannot blank
546
667
  // the window; the boundary itself is the outermost component.
547
668
  assert.equal(element.type, T.IdeErrorBoundary, 'the panel is wrapped in the error boundary')
548
- const panel = element.props.children
549
- assert.equal(typeof panel.type, 'function', 'the panel component, not a wrapper')
550
- assert.equal(panel.props.sessionId, 's1')
551
- assert.equal(panel.props.cwd, '/w/project')
552
- assert.equal(panel.props.visible, true)
669
+ const windowRoot = element.props.children
670
+ assert.equal(windowRoot.type, T.StandaloneWindow, 'the window root owns the scope it can change')
671
+ assert.equal(windowRoot.props.sessionId, 's1')
672
+ assert.equal(windowRoot.props.cwd, '/w/project')
553
673
  } finally {
554
674
  globalThis.window = previousWindow
555
675
  globalThis.document = previousDocument
@@ -643,7 +763,7 @@ async function withLogServer(run) {
643
763
  res.writeHead(state.disableConfig ? 409 : 200, { 'content-type': 'application/json' })
644
764
  res.end(JSON.stringify(state.disableConfig
645
765
  ? { ok: false, code: 'config-exists', message: 'exists' }
646
- : { ok: true, path: '/w/.dsh-ris-ide.json', count: 3, mode: state.configBody.mode ?? 'generate' }))
766
+ : { ok: true, path: '/w/.dsh-ris-ide/config.json', count: 3, mode: state.configBody.mode ?? 'generate' }))
647
767
  })
648
768
  return
649
769
  }
@@ -919,7 +1039,7 @@ test('generateConfig asks the host to write or update the config', async () => {
919
1039
  const scope = { sessionId: 's1', cwd: '/w' }
920
1040
  const generated = await T.generateConfig(scope)
921
1041
  assert.equal(generated.ok, true)
922
- assert.equal(generated.path, '/w/.dsh-ris-ide.json')
1042
+ assert.equal(generated.path, '/w/.dsh-ris-ide/config.json')
923
1043
  assert.equal(generated.mode, 'generate')
924
1044
  assert.equal(state.configCalls, 1)
925
1045
  assert.deepEqual(state.configBody, { sessionId: 's1', cwd: '/w' })
@@ -1319,6 +1439,105 @@ test('a file row is a drop target for the directory it lives in', async () => {
1319
1439
  assert.doesNotMatch(source, /onDragOver: entry\.isDir === true \?/)
1320
1440
  })
1321
1441
 
1442
+ // 1.7.1: 从系统桌面复制多个文件到文件树、目标目录里已有同名文件时,1.7.0 的
1443
+ // importExternal 在第一个同名冲突处 `break`,后面的文件被静默丢弃(用户看到「只复制了
1444
+ // 一个」)。批量导入现在先落地其余文件,把同名的收集进同一张「覆盖 / 生成副本」卡片;
1445
+ // 只有单个文件时才保留「粘贴为」改名卡。files 与 text/uri-list 也必须一起读——有些
1446
+ // 桌面只投递文本,只读 files 会再次丢文件。
1447
+ test('pasting several OS files never stops at the first existing name', async () => {
1448
+ const { readFile } = await import('node:fs/promises')
1449
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
1450
+ // The batch loop no longer abandons the rest of the paste on a collision.
1451
+ assert.doesNotMatch(source, /if \(created === undefined\) break/,
1452
+ 'a 同名 collision must not drop every file after it')
1453
+ assert.match(source, /async function importOne\(source, dir, name, overwrite\)/)
1454
+ assert.match(source, /async function importOneWithCopyName\(source, dir\)/)
1455
+ assert.match(source, /var name = attempt === 0 \? source\.name : collisionCopyName\(source\.name, false, attempt\)/,
1456
+ '生成副本 reuses the batch suffix rule')
1457
+ // ONE file keeps the 粘贴为 card; MANY collect the collisions into the batch card.
1458
+ assert.match(source, /if \(sources\.length === 1\) \{\n\s+\/\/ A single pasted file: the collision is a choice, not a batch\.\n\s+parkPasteName\(source, trimmedDir, source\.name\)/)
1459
+ assert.match(source, /items: conflicts, created: created,\n\s+origins: \[\], touched: \[trimmedDir\], external: true,/,
1460
+ 'the external collisions park the same 覆盖 / 生成副本 card')
1461
+ assert.match(source, /if \(pending\.external === true\) \{/, 'the batch card knows how to place a pasted blob/path')
1462
+ assert.match(source, /created\.push\(await importOne\(item, pending\.dir, item\.name, true\)\)/, '覆盖 re-sends the pasted bytes')
1463
+ assert.match(source, /var placedExternal = await importOneWithCopyName\(item, pending\.dir\)/, '生成副本 re-sends under a suffixed name')
1464
+ // files AND the URI list are read together; a name delivered as both is imported once.
1465
+ assert.match(source, /if \(files\.length > 0 \|\| paths\.length > 0\) \{/,
1466
+ 'a payload with files or paths goes through the tree paste path')
1467
+ assert.match(source, /void pasteFromOsClipboard\(text\)/,
1468
+ 'an empty payload asks the Host what the OS clipboard holds')
1469
+ assert.match(source, /void importExternal\(pasteTargetDir\(\), files, paths\)/)
1470
+ assert.match(source, /if \(fileName === '' \|\| seen\[fileName\] === true\) continue/)
1471
+ assert.match(source, /if \(leaf === '' \|\| seen\[leaf\] === true\) continue/)
1472
+ })
1473
+
1474
+ // 1.7.1: 树里按 Ctrl+C(内部剪贴板非空)之后,在资源管理器复制别的文件、再回树里
1475
+ // Ctrl+V —— keydown 曾经直接 preventDefault + pasteInto(内部剪贴板),浏览器根本不发
1476
+ // paste 事件,粘出来的是「之前复制出去的那批文件」(源文件已删就报不存在)。现在 OS
1477
+ // 剪贴板优先:keydown 只兜底,paste 事件先到先按外部内容导入;只有同名同数量的那批
1478
+ // 才是回头的自家剪贴板,仍走树内语义(剪切 = 移动)。
1479
+ test('an OS clipboard paste wins over a stale tree clipboard', async () => {
1480
+ const { readFile } = await import('node:fs/promises')
1481
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
1482
+ // The keydown no longer claims the gesture when our own clipboard is non-empty…
1483
+ assert.match(source, /if \(clipboard === null\) return\n\s+\/\/ A text field owns Ctrl\+V/,
1484
+ 'the tree clipboard no longer swallows Ctrl+V outright')
1485
+ assert.match(source, /if \(isTextEntry\(event\.target\)\) return/, 'an editor keeps its native paste')
1486
+ // …it waits one beat, so an empty OS clipboard still pastes the tree clipboard.
1487
+ assert.match(source, /var askedAt = Date\.now\(\)/)
1488
+ assert.match(source, /if \(pasteAtRef\.current >= askedAt\) return/)
1489
+ // The paste handler decides: our own copy keeps the tree semantics, anything else imports.
1490
+ assert.match(source, /pasteAtRef\.current = Date\.now\(\)/, 'the paste event stands the fallback down')
1491
+ assert.match(source, /if \(clipboard !== null && isTreeClipboardCopy\(files, paths\)\) \{/,
1492
+ 'our own copy is confirmed against the Host before it takes the tree path')
1493
+ assert.match(source, /function isTreeClipboardCopy\(files, paths\) \{/)
1494
+ assert.match(source, /function isTextEntry\(node\) \{/)
1495
+ assert.match(source, /if \(own\.length === 0 \|\| seen\.length !== own\.length\) return false/,
1496
+ 'a different file set is external content, not the tree clipboard')
1497
+ })
1498
+
1499
+ // 谁新谁赢:`beginCopy` 会把同一批写进系统剪贴板,所以粘贴负载与树内那批不同 ⇒
1500
+ // 系统剪贴板是后来复制的东西,树里的旧剪贴板作废(丢弃),绝不复活旧条目。
1501
+ test('a newer OS clipboard discards the older tree clipboard', async () => {
1502
+ const { readFile } = await import('node:fs/promises')
1503
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
1504
+ assert.match(source, /\/\/ Different files than the tree copied[\s\S]{0,300}if \(clipboard !== null\) setClipboard\(null\)\n\s+void importExternal\(pasteTargetDir\(\), files, paths\)/)
1505
+ assert.match(source, /已清空文件树里的旧复制/)
1506
+ assert.match(source, /var newer = text\.trim\(\) !== '' \|\| \(host !== null && host\.text\.trim\(\) !== ''\)/)
1507
+ assert.match(source, /\/\/ No paste payload at all and nothing readable[\s\S]{0,200}void pasteInto\(pasteTargetDir\(\)\)/)
1508
+ })
1509
+
1510
+ // 桌面 → 文件树(WSL):Explorer 里的文件复制根本进不了 Chromium(WSLg 不桥接
1511
+ // Windows 的 CF_HDROP),paste 事件是空负载;此时由宿主读系统剪贴板,拿真实文件
1512
+ // 列表走 /fs/import。宿主的读数同时用来判断树里那份旧剪贴板是否还有效。
1513
+ test('a desktop copy reaches the tree through the Host clipboard', async () => {
1514
+ const { readFile } = await import('node:fs/promises')
1515
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
1516
+ assert.match(source, /void pasteFromOsClipboard\(text\)/, 'an empty payload asks the Host')
1517
+ assert.match(source, /async function fsClipboardState\(scope\) \{[\s\S]{0,400}'dsh-ris-ide\/clipboard\/read'/)
1518
+ assert.match(source, /var host = await readHostClipboard\(\)/)
1519
+ assert.match(source, /if \(clipboard !== null && samePathList\(host\.files, clipboardItems\(\)\)\) \{/,
1520
+ 'our own copy stays on the tree path')
1521
+ assert.match(source, /void importExternal\(pasteTargetDir\(\), \[\], host\.files\)/,
1522
+ 'files the page cannot see are imported from the Host list')
1523
+ assert.match(source, /function samePathList\(files, items\) \{/)
1524
+ assert.match(source, /function trimTrailingSeparator\(path\) \{/)
1525
+ })
1526
+
1527
+ // 系统剪贴板只投递 `text/uri-list`(没有 File blob)时走 `/fs/import`:宿主读的是
1528
+ // `from` = 源文件、`dir` = 目标目录。两个调用点曾把两者写反(from=目标目录、
1529
+ // dir=源文件),于是粘贴报「粘贴目标不是目录」,文件一个都落不下来。
1530
+ test('a path paste sends the source as `from` and the folder as `dir`', async () => {
1531
+ const { readFile } = await import('node:fs/promises')
1532
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
1533
+ assert.match(source, /async function fsImportPath\(scope, sourcePath, dir, name, overwrite\)/)
1534
+ assert.match(source, /\{ from: sourcePath, dir: dir, name: name, overwrite: overwrite === true \}/)
1535
+ assert.match(source, /await fsImportPath\(scope, source\.path, trimmedDir, name, overwrite === true\)/)
1536
+ assert.match(source, /await fsImportPath\(scope, source\.path, dir, name, replace\)/)
1537
+ assert.doesNotMatch(source, /fsImportPath\(scope, dir, source\.path/)
1538
+ assert.doesNotMatch(source, /fsImportPath\(scope, trimmedDir, source\.path/)
1539
+ })
1540
+
1322
1541
  test('a forced tree read asks the host for a fresh listing', async () => {
1323
1542
  const { readFile } = await import('node:fs/promises')
1324
1543
  const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
@@ -1524,9 +1743,9 @@ test('the tree watch only reloads loaded directories and keeps a short cache', (
1524
1743
  })
1525
1744
 
1526
1745
  test('deletes park in the undo trash under a unique, recognisable name', () => {
1527
- assert.equal(T.TREE_TRASH_DIR, '.dsh-ris-ide-trash')
1528
- assert.equal(T.trashDirFor('/w/ris'), '/w/ris/.dsh-ris-ide-trash')
1529
- assert.equal(T.trashDirFor('/w/ris/'), '/w/ris/.dsh-ris-ide-trash')
1746
+ assert.equal(T.TREE_TRASH_DIR, '.dsh-ris-ide/trash')
1747
+ assert.equal(T.trashDirFor('/w/ris'), '/w/ris/.dsh-ris-ide/trash')
1748
+ assert.equal(T.trashDirFor('/w/ris/'), '/w/ris/.dsh-ris-ide/trash')
1530
1749
  assert.equal(T.trashNameFor('/w/ris/src/ModelHelper.java', 1730), '1730-ModelHelper.java')
1531
1750
  assert.equal(T.trashNameFor('/w/ris/src', 1730), '1730-src')
1532
1751
  })
@@ -1923,7 +2142,7 @@ test('a whole workbench console row picks the program, name and blank alike', as
1923
2142
  // pressing ■ on another program does not also switch this pane's log.
1924
2143
  assert.match(source, /onClick: function \(\) \{ selectProgram\(program\) \}/, 'row picks the program')
1925
2144
  assert.match(source, /button\('▶', function \(event\) \{ event\.stopPropagation\(\); void consoleStart\(program\) \}/)
1926
- assert.match(source, /button\('■', function \(event\) \{ event\.stopPropagation\(\); void consoleStop\(program\) \}/)
2145
+ assert.match(source, /button\(stopGlyph\(11\), function \(event\) \{ event\.stopPropagation\(\); void consoleStop\(program\) \}/)
1927
2146
  assert.match(source, /button\('⟳', function \(event\) \{ event\.stopPropagation\(\); void consoleRestart\(program\) \}/)
1928
2147
  assert.match(source, /button\(ideBadgeIcon\('bug', 'play', 13\), function \(event\) \{ event\.stopPropagation\(\); void consoleDebug\(program\) \}/)
1929
2148
  })
@@ -1940,6 +2159,41 @@ test('sidebar start/stop/restart stay silent, and ⟳ is green like ▶', async
1940
2159
  assert.match(source, /width: 25, start: true, action: 'console-restart'/, 'workbench ⟳ is green')
1941
2160
  })
1942
2161
 
2162
+ test('the stop mark is a drawn square, and the sidebar batch bar keeps the row tones', async () => {
2163
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
2164
+ // The ■ character's ink is about half its advance width: inside a 20px sidebar
2165
+ // button (or a 25px workbench one) it read as a dot. Every stop control draws a
2166
+ // fixed square instead, so both consoles agree on the size.
2167
+ // Module scope, not inside ProgramWorkbench: the sidebar ProgramsPanel draws it too,
2168
+ // and a nested declaration makes the whole sidebar tab throw "stopGlyph is not defined".
2169
+ assert.match(source, /^ {4}function stopGlyph\(size\) \{/m, 'stopGlyph is declared at module scope')
2170
+ assert.match(source, /width: side, height: side, flex: '0 0 auto'/, 'the square has a real box')
2171
+ assert.match(
2172
+ source,
2173
+ /display: 'inline-block', verticalAlign: 'middle'/,
2174
+ 'the square keeps the text line box, so the border matches the neighbouring buttons',
2175
+ )
2176
+ assert.match(source, /S\.paneIconOff : S\.stopIcon, 'data-action': 'batch-stop'/, 'sidebar batch ■ is red like the row ■')
2177
+ assert.match(source, /S\.paneIconOff : S\.startIcon, 'data-action': 'batch-start'/, 'sidebar batch ▶ is green like the row ▶')
2178
+ assert.match(source, /width: 25, stop: true, action: 'batch-stop'/, 'workbench batch ■ keeps its red tone')
2179
+ const glyphUses = source.match(/stopGlyph\(/g) || []
2180
+ assert.ok(glyphUses.length >= 4, 'both consoles (row + batch) draw the square')
2181
+ })
2182
+
2183
+ test('copying in the tree also publishes the files to the OS clipboard', async () => {
2184
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
2185
+ // The internal clipboard alone only feeds the tree's own Ctrl+V. Putting the
2186
+ // SAME list on the system clipboard is what lets Explorer / a desktop paste it;
2187
+ // the page cannot do that itself, so the Host route does it — and when the Host
2188
+ // has no backend the paths still land as text instead of the copy failing.
2189
+ assert.match(source, /dsh-ris-ide\/clipboard\/files/, 'the copy asks the host clipboard route')
2190
+ assert.match(source, /await fsClipboardFiles\(scope, items, mode === 'cut'\)/, 'cut keeps its MOVE intent')
2191
+ assert.match(source, /function clipboardQuery\(scope\) \{/, 'the host needs the workspace to stage a copy')
2192
+ assert.match(source, /await fsClipboardFiles\(scope, items, mode === 'cut'\)[\s\S]{0,40}/)
2193
+ assert.match(source, /await navigator\.clipboard\.writeText\(items\.map/, 'without a backend the paths still land as text')
2194
+ assert.match(source, /void publishSystemClipboard\(items, mode\)/, 'beginCopy publishes right after it sets the internal clipboard')
2195
+ })
2196
+
1943
2197
  test('console program rows keep one horizontal inset when a row is picked', async () => {
1944
2198
  const S = T.stylesFor(1)
1945
2199
  assert.equal(S.consoleRow.padding, '1px 6px', 'unpicked rows have a left/right inset')
@@ -1987,7 +2241,7 @@ test('the help panel data covers tree, editor and debug shortcuts', () => {
1987
2241
  const logKeys = sections.find((section) => section.title === '日志').rows.map((row) => row.keys).join(' ')
1988
2242
  assert.match(logKeys, /Ctrl\+F/, 'log find is documented')
1989
2243
  const configKeys = sections.find((section) => section.title === '配置').rows.map((row) => row.keys).join(' ')
1990
- assert.match(configKeys, /\.dsh-ris-ide\.json/, 'the hidden config file is documented')
2244
+ assert.match(configKeys, /\.dsh-ris-ide\/config\.json/, 'the config file (inside the state folder) is documented')
1991
2245
  // The help panel must not promise an editor back/forward that does not exist.
1992
2246
  assert.doesNotMatch(generalKeys, /Alt\+\u2190/, 'no fake editor back/forward row')
1993
2247
  })
@@ -2901,7 +3155,7 @@ test('the IDE top bar hosts the workspace search and only shows config buttons w
2901
3155
  // the programs listed underneath (the sidebar console keeps 打开配置/更新配置
2902
3156
  // in the same place), so they no longer ride on the source pane toolbar.
2903
3157
  const consoleHead = consoleHeadOf(markup)
2904
- assert.match(consoleHead, /title="打开配置文件/, 'the console offers 📄 for .dsh-ris-ide.json')
3158
+ assert.match(consoleHead, /title="打开配置文件/, 'the console offers 📄 for .dsh-ris-ide/config.json')
2905
3159
  for (const action of ['config-open', 'config-generate']) {
2906
3160
  const tag = consoleHead.match(new RegExp(`<button[^>]*data-action="${action}"[^>]*>`))
2907
3161
  assert.ok(tag !== null, `missing ${action} in the console title bar`)
@@ -3443,7 +3697,17 @@ test('one IDE window per workspace: the window name is keyed by the workspace cw
3443
3697
  assert.match(source, /var windowCwd = typeof opts\.windowCwd === 'string'/)
3444
3698
  assert.match(source, /var windowName = standaloneWindowName\(windowCwd !== undefined \? windowCwd : cwd\)/)
3445
3699
  assert.match(source, /url\.searchParams\.set\('wname', windowName\)/)
3446
- assert.match(source, /window\.open\(url\.href, windowName, features\)/)
3700
+ // A workspace owns ONE window: ask the host registry first, and only create a
3701
+ // window when the registry says there is none (no blank popup that is closed
3702
+ // again, which both flashes and still fails to raise the window).
3703
+ assert.match(source, /async function openStandaloneWindow\(options\) \{/)
3704
+ assert.match(source, /if \(state\.exists === true && state\.alive === true\) \{/)
3705
+ assert.doesNotMatch(source, /focusStandaloneWindow/, 'raising a foreign window is not attempted any more')
3706
+ assert.match(source, /await requestStandaloneWindowClose\(windowName\)/, 'present: ask the old window to close, then open one')
3707
+ assert.doesNotMatch(source, /focus-ack/, 'no focus handshake: the browser forbids it')
3708
+ assert.match(source, /window\.open\(url\.href, windowName, features\)/, 'absent: create it straight on the IDE url')
3709
+ assert.doesNotMatch(source, /window\.open\('', windowName, features\)/, 'never a blank window to close again')
3710
+ assert.doesNotMatch(source, /settleStandaloneWindow/)
3447
3711
  })
3448
3712
 
3449
3713
  test('the standalone window claims a single-instance lock before booting the IDE', async () => {
@@ -3458,7 +3722,11 @@ test('the standalone window claims a single-instance lock before booting the IDE
3458
3722
  assert.match(claim, /BroadcastChannel/, 'fallback channel exists')
3459
3723
  assert.match(claim, /params\.get\('wname'\)/, 'the opener hands the workspace window name over')
3460
3724
  assert.match(claim, /var key = windowName/, 'the lock key IS the window name')
3461
- assert.match(claim, /type: 'focus'/, 'the surviving window is nudged forward')
3725
+ assert.match(claim, /data\.type === 'focus'/, 'the surviving window is nudged forward')
3726
+ assert.match(claim, /data\.type === 'close'/, 'the opener can ask the old window to close itself')
3727
+ assert.match(claim, /function closeForOpener\(\)/, 'closing is the window\'s own decision')
3728
+ assert.match(claim, /function takeover\(\)/, 'the blocked window can wait for the old lock and boot here')
3729
+ assert.match(claim, /关闭旧窗口,在这里打开/, 'the duplicate offers to replace the old window')
3462
3730
  // A reused window (same name, e.g. after a dsh restart) can still see the old
3463
3731
  // document's lock for a moment: retry before believing there is a real second
3464
3732
  // window, and NEVER close this one (that made it flash and vanish).
@@ -3468,7 +3736,7 @@ test('the standalone window claims a single-instance lock before booting the IDE
3468
3736
  // offers an explicit "close this window" action instead — and only that button
3469
3737
  // may close it (never an automatic close at boot).
3470
3738
  assert.match(claim, /关闭这个窗口/, 'the duplicate window can be closed on demand')
3471
- assert.equal((claim.match(/window\.close\(\)/g) || []).length, 1, 'closing happens only from the button')
3739
+ assert.equal((claim.match(/window\.close\(\)/g) || []).length, 2, 'closing happens only from the two explicit user actions')
3472
3740
  // Booting waits for the claim, so the notice cannot be raced by a mounted panel.
3473
3741
  assert.match(html, /window\.__risIdeClaimReady/)
3474
3742
  assert.match(html, /window\.__risIdeBootPanel = bootPanel/)
@@ -3585,7 +3853,7 @@ test('a render failure inside the panel shows a retry banner instead of taking d
3585
3853
 
3586
3854
  // BOTH mount points are wrapped (the dsh sidebar tab and the standalone window).
3587
3855
  assert.match(source, /function IdePanelBoundary\(props\) \{ return h\(IdeErrorBoundary, null, h\(ProgramsPanel, Object\.assign\(\{\}, props, \{ clientCtx: ctx \}\)\)\) \}/)
3588
- assert.match(source, /root\.render\(h\(IdeErrorBoundary, null, h\(ProgramsPanel, \{ sessionId: sessionId, cwd: cwd, visible: true, compact: false \}\)\)\)/)
3856
+ assert.match(source, /root\.render\(h\(IdeErrorBoundary, null, h\(StandaloneWindow, \{ sessionId: sessionId, cwd: cwd \}\)\)\)/)
3589
3857
  })
3590
3858
 
3591
3859
  test('a start switches to that program log before waiting for the spawn', async () => {
@@ -3613,7 +3881,7 @@ test('the debug pane has a visual settings dialog for dependency sources', { ski
3613
3881
  assert.match(source, /fsDependencySource\(scopeRef\.current, cleaned/, 'a missing workspace source asks the host for the jar source')
3614
3882
  assert.match(source, /dsh-ris-ide\/debug\/source/)
3615
3883
  assert.match(source, /-sources\.jar/)
3616
- assert.match(source, /\.dsh-ris-ide-cache/)
3884
+ assert.match(source, /\.dsh-ris-ide\/cache/)
3617
3885
  })
3618
3886
 
3619
3887
  test('the IDE console masks a program row while it starts, stops or debugs, and the compact note expires', async () => {