dsh-aiterm 0.5.1 → 0.5.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRACTS.md +104 -22
- package/README.md +206 -26
- package/client/HistoryPanel.jsx +342 -29
- package/client/api.js +44 -3
- package/client/locale.js +40 -2
- package/cordis.patch.yml +1 -0
- package/lib/client.js +30 -30
- package/lib/host/autolog.js +107 -4
- package/lib/host/config.js +14 -0
- package/lib/host/disclosure.js +357 -0
- package/lib/host/exporter.js +447 -159
- package/lib/host/history-store.js +1735 -295
- package/lib/host/permission.js +13 -0
- package/lib/host/prompt.js +5 -2
- package/lib/host/registry.js +858 -76
- package/lib/host/routes.js +45 -2
- package/lib/host/tools.js +291 -22
- package/lib/index.js +4 -2
- package/package.json +2 -2
- package/scripts/smoke-client.mjs +193 -6
package/scripts/smoke-client.mjs
CHANGED
|
@@ -2445,13 +2445,62 @@ await closePanelViaBar()
|
|
|
2445
2445
|
}
|
|
2446
2446
|
|
|
2447
2447
|
// ── history panel: export (current / all) + auto-log switch ────────────
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2448
|
+
let raceResolve = null
|
|
2449
|
+
let raceReject = null
|
|
2450
|
+
let raceActive = false
|
|
2451
|
+
let legacyRaceResolve = null
|
|
2452
|
+
let legacyRaceActive = false
|
|
2453
|
+
let reloadResolve = null
|
|
2454
|
+
let reloadActive = false
|
|
2455
|
+
let legacyQueryResolve = null
|
|
2456
|
+
let legacyQueryActive = false
|
|
2457
|
+
let normalQueryResolve = null
|
|
2458
|
+
let normalQueryActive = false
|
|
2459
|
+
scene.handlers.set('history.sessions', async (params) => {
|
|
2460
|
+
if (reloadActive && (params.offset === undefined || params.offset === 0)) {
|
|
2461
|
+
return await new Promise((resolve) => { reloadResolve = resolve })
|
|
2462
|
+
}
|
|
2463
|
+
if (raceActive && params.offset === 1) {
|
|
2464
|
+
return await new Promise((resolve, reject) => { raceResolve = resolve; raceReject = reject })
|
|
2465
|
+
}
|
|
2466
|
+
if (params.offset === 1 && params.snapshot === 'snap-1') {
|
|
2467
|
+
return { sessions: [], total: 2, truncated: true, stale: true, snapshot: 'snap-2' }
|
|
2468
|
+
}
|
|
2469
|
+
return {
|
|
2470
|
+
sessions: [
|
|
2471
|
+
{ id: 'st-ssh', title: 'web-1', transport: 'ssh', host: '10.0.0.5', port: 22, username: 'root', createdAt: now - 60_000, bytes: 2048, lastTs: now },
|
|
2472
|
+
],
|
|
2473
|
+
total: 2,
|
|
2474
|
+
truncated: true,
|
|
2475
|
+
snapshot: 'snap-1',
|
|
2476
|
+
}
|
|
2477
|
+
})
|
|
2478
|
+
scene.handlers.set('history.query', async () => {
|
|
2479
|
+
if (normalQueryActive) return await new Promise((resolve) => { normalQueryResolve = resolve })
|
|
2480
|
+
return { matches: [], scannedBytes: 0 }
|
|
2481
|
+
})
|
|
2482
|
+
scene.handlers.set('history.legacy.sessions', async () => {
|
|
2483
|
+
if (legacyRaceActive) {
|
|
2484
|
+
return await new Promise((resolve) => { legacyRaceResolve = resolve })
|
|
2485
|
+
}
|
|
2486
|
+
return {
|
|
2487
|
+
sessions: [
|
|
2488
|
+
{ id: 'st-legacy', title: 'old-unowned', transport: 'ssh', host: 'old.example', port: 22, username: 'old', createdAt: now - 120_000, bytes: 100, lastTs: now - 100_000 },
|
|
2489
|
+
],
|
|
2490
|
+
total: 1,
|
|
2491
|
+
truncated: false,
|
|
2492
|
+
snapshot: 'legacy-snap-1',
|
|
2493
|
+
}
|
|
2494
|
+
})
|
|
2495
|
+
scene.handlers.set('history.legacy.query', async () => {
|
|
2496
|
+
if (legacyQueryActive) return await new Promise((resolve) => { legacyQueryResolve = resolve })
|
|
2497
|
+
return { matches: [{ at: now, line: 'LEGACY-OUT', before: [], after: [] }], scannedBytes: 50, truncated: false }
|
|
2498
|
+
})
|
|
2499
|
+
scene.handlers.set('history.legacy.export', async (params) => ({
|
|
2500
|
+
dir: '/home/u/.dsh/aiterm/exports',
|
|
2501
|
+
files: [{ sessionId: params.sessionId, path: '/home/u/.dsh/aiterm/exports/st-legacy-old-20261023.log', bytes: 64, lines: 2 }],
|
|
2452
2502
|
}))
|
|
2453
|
-
scene.handlers.set('
|
|
2454
|
-
scene.handlers.set('autolog.get', async () => ({ enabled: false, dir: '/home/u/.dsh/aiterm/logs' }))
|
|
2503
|
+
scene.handlers.set('autolog.get', async () => ({ enabled: false, dir: '/home/u/.dsh/aiterm/logs', needsReview: true }))
|
|
2455
2504
|
scene.handlers.set('autolog.set', async (params) => ({ enabled: params.enabled === true, dir: '/home/u/.dsh/aiterm/logs' }))
|
|
2456
2505
|
scene.handlers.set('history.export', async (params) => ({
|
|
2457
2506
|
dir: '/home/u/.dsh/aiterm/exports',
|
|
@@ -2486,6 +2535,7 @@ await closePanelViaBar()
|
|
|
2486
2535
|
assert.ok(call, 'exporting must call history.export')
|
|
2487
2536
|
assert.equal(call.params.all, undefined, 'exporting one session must not ask for all')
|
|
2488
2537
|
assert.ok(call.params.sessionId, 'exporting one session must name it')
|
|
2538
|
+
assert.equal(call.params.owner, 'session-smoke', 'history.export must be scoped to the DSH session')
|
|
2489
2539
|
const flat = textOf(lastTree)
|
|
2490
2540
|
assert.ok(flat.includes('-web-1-'), 'the exported file path must be rendered, got: ' + flat.slice(-200))
|
|
2491
2541
|
assert.ok(flat.includes(dict('historyExportLines').split('{')[0]), 'the exported line count must render')
|
|
@@ -2498,6 +2548,122 @@ await closePanelViaBar()
|
|
|
2498
2548
|
const call = scene.rpcCalls.slice(mark).find((entry) => entry.method === 'history.export')
|
|
2499
2549
|
assert.ok(call, 'export-all must call history.export')
|
|
2500
2550
|
assert.equal(call.params.all, true, 'export-all must pass all: true')
|
|
2551
|
+
assert.equal(call.params.owner, 'session-smoke', 'export-all must be scoped to the DSH session')
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
// Paging with a stale snapshot must reload rather than silently skip rows.
|
|
2555
|
+
{
|
|
2556
|
+
const mark = scene.rpcCalls.length
|
|
2557
|
+
await clickNode(findButtonByText(dict('historyLoadMore')), 'load more history')
|
|
2558
|
+
await settle('history stale page handled')
|
|
2559
|
+
const calls = scene.rpcCalls.slice(mark).filter((entry) => entry.method === 'history.sessions')
|
|
2560
|
+
assert.ok(calls.some((entry) => entry.params.offset === 1 && entry.params.snapshot === 'snap-1'), 'load more must send the snapshot and raw offset')
|
|
2561
|
+
assert.ok(calls.some((entry) => (entry.params.offset === undefined || entry.params.offset === 0)), 'a stale response must reload the first page')
|
|
2562
|
+
assert.ok(textOf(lastTree).includes(dict('historyStaleReload').slice(0, 8)), 'the stale reload must be explained')
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2565
|
+
// A normal loadMore that fails after switching to a slow legacy load must not
|
|
2566
|
+
// paint, error, or leave a clickable old Load more (real bundle async race).
|
|
2567
|
+
{
|
|
2568
|
+
raceActive = true
|
|
2569
|
+
legacyRaceActive = true
|
|
2570
|
+
await clickNode(findButtonByText(dict('historyLoadMore')), 'start racing normal page')
|
|
2571
|
+
await settle('normal page pending')
|
|
2572
|
+
await clickNode(findButtonByText(dict('historyLegacyEntry')), 'switch to legacy while normal page pending')
|
|
2573
|
+
await settle('legacy page pending')
|
|
2574
|
+
assert.ok(!findButtonByText(dict('historyLoadMore')), 'the old Load more must disappear on source switch')
|
|
2575
|
+
assert.ok(
|
|
2576
|
+
!collect(lastTree, (node) => node.props && node.props.role === 'option').some((node) => textOf(node).includes('web-1')),
|
|
2577
|
+
'the old normal list must be cleared on source switch',
|
|
2578
|
+
)
|
|
2579
|
+
assert.equal(typeof legacyRaceResolve, 'function')
|
|
2580
|
+
assert.equal(typeof raceReject, 'function')
|
|
2581
|
+
raceReject(new Error('late normal failure'))
|
|
2582
|
+
await settle('late normal failure ignored')
|
|
2583
|
+
assert.equal(textOf(lastTree).includes('late normal failure'), false, 'a late normal failure must not paint the legacy page')
|
|
2584
|
+
legacyRaceResolve({ sessions: [{ id: 'st-legacy', title: 'old-unowned', transport: 'ssh', host: 'old.example', port: 22, username: 'old', createdAt: now - 120_000, bytes: 100, lastTs: now - 100_000 }], total: 1, truncated: false, snapshot: 'legacy-snap-2' })
|
|
2585
|
+
await settle('slow legacy page resolved')
|
|
2586
|
+
assert.ok(textOf(lastTree).includes('old-unowned'), 'the legacy page must render after its slow response')
|
|
2587
|
+
raceActive = false
|
|
2588
|
+
legacyRaceActive = false
|
|
2589
|
+
await clickNode(findButtonByText(dict('historyLegacyBack')), 'return from race legacy')
|
|
2590
|
+
await settle('returned to normal history')
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2593
|
+
// A delayed query from the old source must not paint into the new source.
|
|
2594
|
+
{
|
|
2595
|
+
await clickNode(findButtonByText(dict('historyLegacyEntry')), 'legacy for delayed query')
|
|
2596
|
+
await settle('legacy query baseline')
|
|
2597
|
+
legacyQueryActive = true
|
|
2598
|
+
await clickNode(findButtonByText('old-unowned'), 'trigger delayed legacy query')
|
|
2599
|
+
await settle('legacy query pending')
|
|
2600
|
+
await clickNode(findButtonByText(dict('historyLegacyBack')), 'switch to normal while legacy query pending')
|
|
2601
|
+
await settle('normal after legacy query')
|
|
2602
|
+
assert.equal(typeof legacyQueryResolve, 'function')
|
|
2603
|
+
legacyQueryResolve({ matches: [{ at: now, line: 'STALE-LEGACY-QUERY', before: [], after: [] }], scannedBytes: 10, truncated: false })
|
|
2604
|
+
await settle('stale legacy query resolved')
|
|
2605
|
+
assert.equal(textOf(lastTree).includes('STALE-LEGACY-QUERY'), false, 'a stale legacy query must not paint into normal')
|
|
2606
|
+
|
|
2607
|
+
normalQueryActive = true
|
|
2608
|
+
const webOption = collect(lastTree, (node) => node.type === 'button' && node.props && node.props.role === 'option' && textOf(node).includes('web-1'))[0]
|
|
2609
|
+
assert.ok(webOption, 'the normal history option must be selectable')
|
|
2610
|
+
await clickNode(webOption, 'trigger delayed normal query')
|
|
2611
|
+
await settle('normal query pending')
|
|
2612
|
+
await clickNode(findButtonByText(dict('historyLegacyEntry')), 'switch to legacy while normal query pending')
|
|
2613
|
+
await settle('legacy after normal query')
|
|
2614
|
+
assert.equal(typeof normalQueryResolve, 'function')
|
|
2615
|
+
normalQueryResolve({ matches: [{ at: now, line: 'STALE-NORMAL-QUERY', before: [], after: [] }], scannedBytes: 10, truncated: false })
|
|
2616
|
+
await settle('stale normal query resolved')
|
|
2617
|
+
assert.equal(textOf(lastTree).includes('STALE-NORMAL-QUERY'), false, 'a stale normal query must not paint into legacy')
|
|
2618
|
+
legacyQueryActive = false
|
|
2619
|
+
normalQueryActive = false
|
|
2620
|
+
await clickNode(findButtonByText(dict('historyLegacyBack')), 'return after delayed query')
|
|
2621
|
+
await settle('returned after delayed query')
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
// Explicit human-only legacy view: owner-bound GUI still reaches it.
|
|
2625
|
+
{
|
|
2626
|
+
const mark = scene.rpcCalls.length
|
|
2627
|
+
await clickNode(findButtonByText(dict('historyLegacyEntry')), 'open legacy history')
|
|
2628
|
+
await settle('legacy history opened')
|
|
2629
|
+
const listCall = scene.rpcCalls.slice(mark).find((entry) => entry.method === 'history.legacy.sessions')
|
|
2630
|
+
assert.ok(listCall, 'the legacy button must call history.legacy.sessions')
|
|
2631
|
+
assert.equal(listCall.params.owner, undefined, 'the legacy view is an explicit human path, not an owner-scoped call')
|
|
2632
|
+
const queryCall = scene.rpcCalls.slice(mark).find((entry) => entry.method === 'history.legacy.query')
|
|
2633
|
+
assert.ok(queryCall, 'selecting legacy history must call history.legacy.query')
|
|
2634
|
+
assert.equal(queryCall.params.sessionId, 'st-legacy')
|
|
2635
|
+
assert.ok(textOf(lastTree).includes(dict('historyLegacyHint').slice(0, 8)), 'the legacy view must explain its boundary')
|
|
2636
|
+
|
|
2637
|
+
const exportMark = scene.rpcCalls.length
|
|
2638
|
+
await clickNode(findButtonByText(dict('historyExportOne')), 'export legacy session')
|
|
2639
|
+
const exportCall = scene.rpcCalls.slice(exportMark).find((entry) => entry.method === 'history.legacy.export')
|
|
2640
|
+
assert.ok(exportCall, 'exporting legacy history must use history.legacy.export')
|
|
2641
|
+
assert.equal(exportCall.params.sessionId, 'st-legacy')
|
|
2642
|
+
|
|
2643
|
+
const backMark = scene.rpcCalls.length
|
|
2644
|
+
await clickNode(findButtonByText(dict('historyLegacyBack')), 'leave legacy history')
|
|
2645
|
+
await settle('legacy history closed')
|
|
2646
|
+
assert.ok(
|
|
2647
|
+
scene.rpcCalls.slice(backMark).some((entry) => entry.method === 'history.sessions'),
|
|
2648
|
+
'leaving the legacy view must restore the normal owner-scoped list',
|
|
2649
|
+
)
|
|
2650
|
+
}
|
|
2651
|
+
|
|
2652
|
+
// A legacy enabled auto-log setting is paused pending an explicit human choice.
|
|
2653
|
+
{
|
|
2654
|
+
assert.ok(
|
|
2655
|
+
textOf(lastTree).includes(dict('historyAutoLogLegacyReview').slice(0, 10)),
|
|
2656
|
+
'the panel must explain the legacy auto-log review',
|
|
2657
|
+
)
|
|
2658
|
+
assert.ok(textOf(lastTree).includes('/home/u/.dsh/aiterm/logs'), 'the old autolog path must be shown before confirming')
|
|
2659
|
+
assert.ok(textOf(lastTree).includes(dict('historyAutoLogLegacyEnable').slice(0, 6)), 'an explicit confirm action must be present')
|
|
2660
|
+
const reviewBoxes = collect(lastTree, (node) => node.type === 'input' && node.props && node.props.type === 'checkbox')
|
|
2661
|
+
assert.equal(reviewBoxes[reviewBoxes.length - 1].props.disabled, true, 'the one-click switch must stay disabled during review')
|
|
2662
|
+
const mark = scene.rpcCalls.length
|
|
2663
|
+
await clickNode(findButtonByText(dict('historyAutoLogLegacyKeepOff')), 'keep legacy auto-log off')
|
|
2664
|
+
const call = scene.rpcCalls.slice(mark).find((entry) => entry.method === 'autolog.set')
|
|
2665
|
+
assert.ok(call, 'the keep-off confirmation must call autolog.set')
|
|
2666
|
+
assert.equal(call.params.enabled, false, 'keep-off must persist an explicit disabled state')
|
|
2501
2667
|
}
|
|
2502
2668
|
|
|
2503
2669
|
// Flip the auto-log switch on.
|
|
@@ -2512,6 +2678,27 @@ await closePanelViaBar()
|
|
|
2512
2678
|
assert.ok(textOf(lastTree).includes(dict('historyAutoLogWhere').split('{')[0]), 'the writing directory must be shown')
|
|
2513
2679
|
}
|
|
2514
2680
|
|
|
2681
|
+
// A delayed initial normal load that resolves after switching to legacy must
|
|
2682
|
+
// not overwrite the legacy page either (initial-load race, not just loadMore).
|
|
2683
|
+
await closePanelViaBar()
|
|
2684
|
+
reloadActive = true
|
|
2685
|
+
await openPanelViaBar('history')
|
|
2686
|
+
await settle('initial normal load pending')
|
|
2687
|
+
await clickNode(findButtonByText(dict('historyLegacyEntry')), 'enter legacy during initial load')
|
|
2688
|
+
await settle('legacy during initial load')
|
|
2689
|
+
assert.ok(textOf(lastTree).includes('old-unowned'), 'legacy must render before the initial normal response')
|
|
2690
|
+
assert.equal(typeof reloadResolve, 'function')
|
|
2691
|
+
reloadResolve({
|
|
2692
|
+
sessions: [{ id: 'st-ssh-initial', title: 'normal-initial', transport: 'ssh', host: '10.0.0.5', port: 22, username: 'root', createdAt: now - 20_000, bytes: 10, lastTs: now }],
|
|
2693
|
+
total: 1,
|
|
2694
|
+
truncated: false,
|
|
2695
|
+
snapshot: 'initial-snap',
|
|
2696
|
+
})
|
|
2697
|
+
await settle('late initial normal resolved')
|
|
2698
|
+
assert.equal(textOf(lastTree).includes('normal-initial'), false, 'a late initial normal response must not overwrite legacy')
|
|
2699
|
+
assert.ok(textOf(lastTree).includes('old-unowned'), 'legacy remains after the late initial response')
|
|
2700
|
+
reloadActive = false
|
|
2701
|
+
|
|
2515
2702
|
await closePanelViaBar()
|
|
2516
2703
|
await setSessions([sessionRecord()])
|
|
2517
2704
|
}
|