dsh-chat-embed 0.6.11 → 0.6.14

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/client.js CHANGED
@@ -115,7 +115,7 @@ window.__ModuleLoader__.load({
115
115
  let activeCtx = undefined
116
116
 
117
117
  /** Build identity, surfaced in the panel so a packaged app can be diagnosed. */
118
- const BUILD = '0.6.11'
118
+ const BUILD = '0.6.14'
119
119
 
120
120
  /** Where a re-applied instance finds the one it must take over from. */
121
121
  const INSTANCE_KEY = '__DSH_CHAT_EMBED_INSTANCE__'
@@ -210,6 +210,8 @@ let activeCtx = undefined
210
210
  /** The first `dom-ready` can beat the shell's lease registration. */
211
211
  const NAVIGATE_RETRY_MS = 350
212
212
  const NAVIGATE_MAX_ATTEMPTS = 5
213
+ /** How long a mount may wait for the site to commit before failing. */
214
+ const NAVIGATE_TIMEOUT_MS = 20000
213
215
 
214
216
  /**
215
217
  * How long to wait after an OAuth roundtrip lands back on the site before
@@ -274,24 +276,38 @@ let activeCtx = undefined
274
276
  persistHint: 'Needs the shell patch; a plugin cannot change how the shell names partitions.',
275
277
  persistRisk:
276
278
  'Experimental: the patch rewrites the app.asar of the desktop shell and needs write access to its install folder. A shell update replaces it, so the patch has to be applied again.',
277
- persistCheckHint: 'Opens a new session and drafts the check for you',
279
+ persistCheckHint: 'Click to apply the patch now; it asks you to quit DSH',
278
280
  persistConfirmTitle: 'Turn on “login across restarts”?',
279
- persistConfirmNote: 'Continuing opens a new session containing the task and the known facts; sending it lets the agent apply the patch and hand you the elevated command if permissions block it.',
280
- persistConfirmGo: 'Continue',
281
+ persistConfirmNote:
282
+ 'The switch runs this script by itself. This copyable command is the fallback for when it cannot: run it, quit DSH when it says so, and it swaps the file.',
283
+ persistConfirmGo: 'Copy command',
281
284
  persistConfirmCancel: 'Cancel',
282
285
  persistOffTitle: 'Turn off "logins survive restarts"?',
283
286
  persistOffBody: 'This removes the patch and puts the original app.asar back. Every restart will ask you to sign in again; flip the switch to undo.',
284
- restoreTask: 'Remove the DSH desktop shell patch that keeps embedded chat logins across restarts, restoring the original app.asar.',
285
- restoreStepsTitle: 'Restore steps (DSH must be fully quit first)',
286
- restoreWarning: 'After this, logins no longer survive a restart.',
287
-
288
- patchNoWorkspace: 'This composition has no Session service; the patch instructions were copied to the clipboard.',
289
- patchTask: 'Apply the DSH desktop shell patch that keeps embedded chat logins across restarts.',
290
- patchTaskDir: 'Install directory',
291
- patchTaskCommand: 'Command',
292
- patchTaskReadonly: 'The plugin reports this directory as not writable, which can be wrong: run it anyway and let the system answer. Only if the write is actually refused, hand me the command that needs administrator rights — do not work around it another way.',
293
- patchTaskNoSite: 'This shell version has no patch site, so the patch does not apply — explain why and change nothing else.',
294
- patchTaskVerify: 'When it is done, tell me how to verify (restart DSH, reopen the settings menu).',
287
+ patchPending: 'Patch ready',
288
+ patchPendingHint:
289
+ 'Quit DSH from the tray (right-click the tray icon → Quit). The archive is swapped and DSH reopens on its own. You do not have to quit immediately — the script waits up to 12 hours.',
290
+ patchNeedsAdmin: 'The install folder needs administrator rights, so it cannot run from here. Run the command below as administrator.',
291
+ patchNoInstall: 'No DSH desktop install was found, so there is no shell to patch. Open this panel in the desktop app.',
292
+ patchSame: 'Nothing to change: the shell archive is already in that state.',
293
+ patchNoRoute: 'This DSH build has no route for the switch yet; run the command below instead.',
294
+ patchStartFailed: 'The patch could not be started:',
295
+ patchScriptLabel: 'Script',
296
+ patchCommandLabel: 'Command',
297
+ patchScriptMissing: 'The patch script is not in this install (tools/shell-patch). The plugin may live elsewhere, or the package is incomplete.',
298
+ patchNoSite: 'This shell version has no patch site, so the script needs updating too; running it only reports that and changes nothing.',
299
+ patchRestartHint: 'Restart DSH afterwards for the change to take effect.',
300
+ cacheLabel: 'Cache',
301
+ cacheClear: 'Clear',
302
+ cacheClearing: 'Clearing…',
303
+ cacheKeepHint: 'Login across restarts is on: only disposable cache is removed. Sign-in data stays.',
304
+ cachePurgeHint: 'Login across restarts is off: this deletes the leftover sign-in data of these seven services.',
305
+ cachePurgeTitle: 'Delete leftover sign-in data?',
306
+ cachePurgeBody:
307
+ 'The patch is off. This removes the seven partitions that belong to this panel, including their saved sign-ins. It does not touch DSH’s own sign-in, or any other partition.',
308
+ cachePurgeGo: 'Delete',
309
+ cacheUnavailable: 'unavailable',
310
+ cacheFailed: 'Could not clear:',
295
311
  copyDiag: 'Copy diagnostics',
296
312
  copied: 'Copied',
297
313
  copyFailed: 'Copy failed',
@@ -368,23 +384,37 @@ let activeCtx = undefined
368
384
  persistUnknown: '尚未检测',
369
385
  persistHint: '需要桌面壳补丁;插件无法改变壳的分区命名。',
370
386
  persistRisk: '实验性功能:补丁会改写桌面壳的 app.asar,需要安装目录的写权限;桌面壳升级会覆盖补丁,需要重新打一次。',
371
- persistCheckHint: '打开新会话,把检查内容写好,点发送即可',
387
+ persistCheckHint: '点一下直接执行补丁,会请你退出 DSH',
372
388
  persistConfirmTitle: '开启「重启保持登录」?',
373
- persistConfirmNote: '点击「继续」会打开一个新会话,里面是给它的任务说明和已知事实;发送后由它完成补丁操作,遇到权限问题会给出需要提权的命令。',
374
- persistConfirmGo: '继续',
389
+ persistConfirmNote:
390
+ '开关会自己运行这个脚本;只有它跑不起来时才需要下面这条命令:运行它,按提示退出 DSH,脚本会替换好文件。',
391
+ persistConfirmGo: '复制命令',
375
392
  persistConfirmCancel: '取消',
376
393
  persistOffTitle: '关闭「重启保持登录」?',
377
394
  persistOffBody: '会撤掉补丁、恢复原版 app.asar。之后每次重启都要重新登录;想再开启,再点一次这个开关即可。',
378
- restoreTask: '把 DSH 桌面版的「重启保持登录」补丁撤掉,恢复原版 app.asar。',
379
- restoreStepsTitle: '还原步骤(必须在 DSH 完全退出后)',
380
- restoreWarning: '撤掉后登录态不再跨重启保留,每次重启都要重新登录。',
381
- patchNoWorkspace: '当前拼装没有会话服务,补丁说明已复制到剪贴板。',
382
- patchTask: '给 DSH 桌面版打上「跨重启保持登录」补丁。',
383
- patchTaskDir: '安装目录',
384
- patchTaskCommand: '命令',
385
- patchTaskReadonly: '插件探测显示安装目录不可写(可能误判):照常执行,让系统自己回答。如果确实被拒绝写入,再把需要管理员权限的命令给我,不要用别的办法绕过。',
386
- patchTaskNoSite: '当前桌面壳版本找不到补丁点,补丁不适用——说明原因即可,不要改别的。',
387
- patchTaskVerify: '打好后告诉我怎么验证(重启 DSH,回设置菜单看状态)。',
395
+ patchPending: '补丁已就绪',
396
+ patchPendingHint: '请从托盘退出 DSH(右键托盘图标 →「退出」),退出后自动替换并重新打开。不必马上退出,脚本最多等 12 小时。',
397
+ patchNeedsAdmin: '安装目录需要管理员权限,这里没法直接执行。请以管理员身份运行下面的命令。',
398
+ patchNoInstall: '没有找到 DSH 桌面版安装目录,没有可以打补丁的壳。请在桌面版里打开本面板。',
399
+ patchSame: '不用改:桌面壳档案已经是这个状态。',
400
+ patchNoRoute: '这个 DSH 版本还没有提供开关用的通道;请改运行下面的命令。',
401
+ patchStartFailed: '没能启动补丁:',
402
+ patchScriptLabel: '脚本',
403
+ patchCommandLabel: '命令',
404
+ patchScriptMissing: '这个安装里找不到补丁脚本(tools/shell-patch)。插件可能装在别处,或包不完整。',
405
+ patchNoSite: '当前桌面壳版本里找不到补丁点,脚本也需要更新;运行它只会报告这一点,不会改动文件。',
406
+ patchRestartHint: '运行后请重新打开 DSH 使其生效。',
407
+ cacheLabel: '缓存',
408
+ cacheClear: '清空',
409
+ cacheClearing: '正在清空…',
410
+ cacheKeepHint: '重启保持登录已开启:只删除缓存,登录保留。',
411
+ cachePurgeHint: '重启保持登录已关闭:将删除这 7 个服务留下的登录数据。',
412
+ cachePurgeTitle: '删除残留登录?',
413
+ cachePurgeBody:
414
+ '补丁已关闭。这会删除本面板自己的 7 个分区,包括其中的登录。不会动 DSH 自己的登录,也不会动其他分区。',
415
+ cachePurgeGo: '删除',
416
+ cacheUnavailable: '无法测量',
417
+ cacheFailed: '没能清空:',
388
418
  copyDiag: '复制诊断信息',
389
419
  copied: '已复制',
390
420
  copyFailed: '复制失败',
@@ -1167,7 +1197,11 @@ let activeCtx = undefined
1167
1197
  }
1168
1198
 
1169
1199
  /** @param {GuestRecord} record */
1170
- function dropGuest(record) {
1200
+ /**
1201
+ * @param {GuestRecord} record
1202
+ * @param {string} [reason] why this guest is being torn down
1203
+ */
1204
+ function dropGuest(record, reason) {
1171
1205
  const element = record.element
1172
1206
  const lease = record.lease
1173
1207
  const handlers = record.handlers
@@ -1187,6 +1221,12 @@ let activeCtx = undefined
1187
1221
  // `oauthBlocked` is deliberately kept: the explanation must survive the
1188
1222
  // recovery reload that replaces the stuck guest.
1189
1223
 
1224
+ if (element !== undefined && element !== null) {
1225
+ let owner = 'unknown'
1226
+ for (const [id, candidate] of guests) if (candidate === record) owner = id
1227
+ log('info', 'guest dropped', { provider: owner, reason: reason === undefined ? 'unspecified' : reason })
1228
+ }
1229
+
1190
1230
  if (record.reloadTimer !== undefined) {
1191
1231
  try {
1192
1232
  clearTimeout(record.reloadTimer)
@@ -1266,6 +1306,24 @@ let activeCtx = undefined
1266
1306
  }
1267
1307
  }
1268
1308
 
1309
+ /**
1310
+ * Whether the guest is still loading a document.
1311
+ *
1312
+ * `location.href` must not be reassigned while this is true: a second assign
1313
+ * cancels the navigation in flight and the page starts from zero.
1314
+ *
1315
+ * @param {any} element
1316
+ * @returns {boolean | undefined} undefined when the shell offers no answer
1317
+ */
1318
+ function guestLoading(element) {
1319
+ if (element === undefined || element === null || typeof element.isLoading !== 'function') return undefined
1320
+ try {
1321
+ return element.isLoading() === true
1322
+ } catch (error) {
1323
+ return undefined
1324
+ }
1325
+ }
1326
+
1269
1327
  /** @param {object} provider */
1270
1328
  function layerFor(provider) {
1271
1329
  const record = guestRecord(provider.id)
@@ -1383,6 +1441,9 @@ let activeCtx = undefined
1383
1441
  record.navigated = false
1384
1442
  record.handlers = handlers
1385
1443
  record.mounts += 1
1444
+ // A mount is a fresh document load. Printing the count makes "one page
1445
+ // in the tab" distinguishable from "the tab was rebuilt" in the ring.
1446
+ log('info', 'guest mounted', { provider: id, mount: record.mounts })
1386
1447
 
1387
1448
  try {
1388
1449
  layer.appendChild(element)
@@ -1423,22 +1484,34 @@ let activeCtx = undefined
1423
1484
  const provider = findProvider(id)
1424
1485
  if (provider === undefined) return
1425
1486
  const record = guestRecord(id)
1487
+ const target = startUrlFor(provider)
1488
+ const deadline = Date.now() + NAVIGATE_TIMEOUT_MS
1489
+ let issued = 0
1426
1490
 
1427
- for (let attempt = 0; attempt < NAVIGATE_MAX_ATTEMPTS; attempt += 1) {
1428
- if (element !== record.element) return
1429
- try {
1430
- await element.executeJavaScript('location.href = ' + JSON.stringify(startUrlFor(provider)) + ';')
1431
- } catch (error) {
1432
- // The guest document is not executing yet; keep trying.
1433
- }
1434
- await delay(NAVIGATE_RETRY_MS)
1491
+ while (Date.now() < deadline) {
1435
1492
  if (element !== record.element) return
1436
1493
  const landed = guestUrl(element)
1437
1494
  if (isLiveUrl(landed)) {
1438
- if (typeof landed === 'string' && landed !== '') lastUrls.set(id, landed)
1495
+ if (landed !== '') lastUrls.set(id, landed)
1439
1496
  setPhase(id, PHASE.READY, '')
1440
1497
  return
1441
1498
  }
1499
+ const loading = guestLoading(element)
1500
+ // Assigning location.href while a navigation is already running cancels
1501
+ // it and starts over: that is what made every mount load the page two or
1502
+ // three times. Wait for the one in flight instead of restarting it.
1503
+ if (loading === true) {
1504
+ await delay(NAVIGATE_RETRY_MS)
1505
+ continue
1506
+ }
1507
+ if (issued >= NAVIGATE_MAX_ATTEMPTS) break
1508
+ issued += 1
1509
+ try {
1510
+ await element.executeJavaScript('location.href = ' + JSON.stringify(target) + ';')
1511
+ } catch (error) {
1512
+ // The guest document is not executing yet; keep trying.
1513
+ }
1514
+ await delay(NAVIGATE_RETRY_MS)
1442
1515
  }
1443
1516
  if (element !== record.element) return
1444
1517
  setPhase(id, PHASE.FAILED, 'navigation-timeout')
@@ -1735,10 +1808,11 @@ let activeCtx = undefined
1735
1808
  await mountGuest(id)
1736
1809
  }
1737
1810
  /** Release every guest; used on plugin unload. */
1738
- function destroyGuests() {
1811
+ /** @param {string} [reason] */
1812
+ function destroyGuests(reason) {
1739
1813
  for (const [id, record] of guests) {
1740
1814
  record.generation += 1
1741
- dropGuest(record)
1815
+ dropGuest(record, reason)
1742
1816
  setPhase(id, PHASE.IDLE, '')
1743
1817
  if (record.layer !== undefined && record.layer !== null) {
1744
1818
  try {
@@ -1856,7 +1930,7 @@ let activeCtx = undefined
1856
1930
  const chosen = seat === undefined ? null : inlineHosts[seat]
1857
1931
  if (chosen !== state.surface.host) log('info', 'host resolved', { seat: seat === undefined ? 'none' : seat })
1858
1932
  setHost(chosen)
1859
- if (chosen === null) destroyGuests()
1933
+ if (chosen === null) destroyGuests('no viewport')
1860
1934
  else {
1861
1935
  dropGuestsOutside(chosen)
1862
1936
  void ensureActiveGuest()
@@ -2129,7 +2203,8 @@ let activeCtx = undefined
2129
2203
  const workspace = typeof ctx.get === 'function' ? ctx.get('uiWorkspace') : undefined
2130
2204
  out.uiWorkspace = workspace !== undefined && workspace !== null
2131
2205
  out.uiWorkspaceStartSession = out.uiWorkspace && typeof workspace.startSession === 'function'
2132
- out.patchCheckRunning = patchCheck.running
2206
+ out.patchRunning = patchAction.running
2207
+ out.patchPending = patchAction.pending
2133
2208
  out.activeCtx = activeCtx !== undefined && activeCtx !== null
2134
2209
  out.probeLoaded = patchProbe.loaded
2135
2210
  if (out.service) {
@@ -2471,6 +2546,21 @@ let activeCtx = undefined
2471
2546
  return t('persistUnknown')
2472
2547
  }
2473
2548
 
2549
+ /**
2550
+ * Compact size for the cache row. Unknown stays blank so the row can say
2551
+ * "unavailable" instead of pretending the cache is empty.
2552
+ *
2553
+ * @param {unknown} bytes
2554
+ * @returns {string}
2555
+ */
2556
+ function formatCacheBytes(bytes) {
2557
+ const value = typeof bytes === 'number' ? bytes : Number(bytes)
2558
+ if (!Number.isFinite(value) || value < 0) return ''
2559
+ if (value >= 1024 * 1024) return (value / (1024 * 1024)).toFixed(1) + ' MB'
2560
+ if (value >= 1024) return (value / 1024).toFixed(1) + ' KB'
2561
+ return String(Math.round(value)) + ' B'
2562
+ }
2563
+
2474
2564
  /**
2475
2565
  * The clipboard copy behind "copy the patch instructions": what to run,
2476
2566
  * where the tool is, and how to replace the archive safely.
@@ -2488,36 +2578,36 @@ let activeCtx = undefined
2488
2578
  * @param {any} [probe]
2489
2579
  * @returns {string}
2490
2580
  */
2491
- function patchInstructions(t, probe) {
2581
+ function patchInstructions(t, probe, mode) {
2492
2582
  const info = probe !== undefined && probe !== null ? probe : {}
2583
+ const action = mode === 'off' ? 'revert' : 'apply'
2493
2584
  const command =
2494
- typeof info.patchCommand === 'string' && info.patchCommand !== ''
2495
- ? info.patchCommand
2496
- : 'node tools/shell-patch/patch-asar.cjs build'
2497
- const lines = [t('persistLabel') + ':' + t('persistHint'), '']
2498
- lines.push('1) 执行下面这条命令(Desk 自带的 Node 运行时;无需另装 Node):')
2499
- lines.push(' ' + command)
2500
- lines.push(' 脚本会自动探测安装目录并逐字节校验,生成 app.asar.new。')
2585
+ typeof info[action + 'Command'] === 'string' && info[action + 'Command'] !== ''
2586
+ ? info[action + 'Command']
2587
+ : 'node tools/shell-patch/shell-patch.mjs ' + action
2588
+ const lines = []
2589
+ lines.push(t('persistLabel') + ':' + t('persistConfirmTitle'))
2501
2590
  lines.push('')
2502
- lines.push('2) 完全退出 DSH 后替换(任选其一):')
2503
- lines.push(' - 运行 tools/shell-patch/watchdog.ps1,退出瞬间自动替换;')
2504
- lines.push(' - 手动把 resources\\app.asar.new 改名为 app.asar。')
2505
- lines.push('')
2506
- lines.push('3) 重启 DSH,回到这里应显示「' + t('persistOn') + '」。')
2591
+ if (typeof info.launcher === 'string' && info.launcher !== '') {
2592
+ lines.push(t('patchScriptLabel') + ': ' + info.launcher)
2593
+ }
2594
+ lines.push(t('patchCommandLabel') + ':')
2595
+ lines.push(' ' + command)
2507
2596
  lines.push('')
2508
- lines.push('回滚:restore-shell-patch.cmd(把 app.asar.orig 换回去)。')
2509
- lines.push('Windows 之外的安装目录请用 --resources 指定。')
2597
+ lines.push(t('patchRestartHint'))
2510
2598
  return lines.join('\n')
2511
2599
  }
2512
2600
 
2513
2601
  /**
2514
- * Host-side probe state for the "check the patch setup" button. The Host
2515
- * half answers, so a renderer without Node access can still report where
2516
- * the shell lives and whether the archive is writable.
2602
+ * State behind the "login across restarts" switch.
2603
+ *
2604
+ * Clicking it starts the patch script through the Host. `pending` means a
2605
+ * script is running and waiting for DSH to exit, so the panel stops
2606
+ * pretending a restart is still needed.
2517
2607
  *
2518
- * @type {{ running: boolean, report: string }}
2608
+ * @type {{ running: boolean, pending: boolean, action: string }}
2519
2609
  */
2520
- const patchCheck = { running: false }
2610
+ const patchAction = { running: false, pending: false, action: 'on' }
2521
2611
 
2522
2612
  /** One-shot cache of the Host probe, so both actions read the same facts. */
2523
2613
  const patchProbe = { loaded: false, value: undefined }
@@ -2566,118 +2656,137 @@ let activeCtx = undefined
2566
2656
  }
2567
2657
 
2568
2658
  /**
2569
- * Hand the self-check to a Session instead of rendering it into the menu.
2659
+ * What to tell the user when the action did not start.
2660
+ *
2661
+ * @param {(key: string) => string} t
2662
+ * @param {any} body the Host's answer, when there was one
2663
+ * @returns {string}
2664
+ */
2665
+ function patchFallbackText(t, body) {
2666
+ const state = body !== undefined && body !== null && typeof body.state === 'string' ? body.state : ''
2667
+ const detail = body !== undefined && body !== null && typeof body.detail === 'string' ? body.detail : ''
2668
+ const lead =
2669
+ state === 'denied'
2670
+ ? t('patchNeedsAdmin')
2671
+ : state === 'noapp'
2672
+ ? t('patchNoInstall')
2673
+ : state === 'unsupported'
2674
+ ? t('patchNoSite')
2675
+ : state === 'same'
2676
+ ? t('patchSame')
2677
+ : t('patchNoRoute')
2678
+ return detail === '' ? lead : lead + ' ' + detail
2679
+ }
2680
+
2681
+ /**
2682
+ * Ask the Host to run the patch script — the switch's whole job.
2570
2683
  *
2571
- * A report inside the settings menu made the panel unusable: absolute paths
2572
- * and a full command line stretched it across the surface, and the result was
2573
- * a one-shot answer kept in panel state. A Session is the right place — the
2574
- * agent can call the patch-check tool, read the reply and explain it, and the
2575
- * user confirms by pressing send.
2684
+ * A click that can work does not open a dialog: the Host spawns the script,
2685
+ * the script waits for DSH to exit, swaps the archive, and starts DSH
2686
+ * again. The dialog is the fallback for the cases where nothing can be
2687
+ * started from here (an older Host without the route, an install folder
2688
+ * that needs administrator rights, a shell whose patch site moved, no
2689
+ * install at all), and it still carries the exact command, because a user
2690
+ * who cannot click their way out needs something to run.
2576
2691
  *
2577
2692
  * @param {(key: string) => string} t
2578
- * @returns {Promise<void>}
2693
+ * @param {string} mode 'on' or 'off'
2694
+ * @returns {Promise<{ lead: string, script: string | undefined }>} `lead` is
2695
+ * empty when the script started; otherwise it explains the dialog
2579
2696
  */
2580
- async function openPatchCheckSession(t, mode) {
2581
- const host = activeCtx
2582
- // Nothing in here may fail silently: a click that does nothing is
2583
- // indistinguishable from a broken build, so every step is logged and the
2584
- // reason comes back to the dialog.
2585
- let failure = ''
2697
+ async function startPatchAction(t, mode) {
2698
+ if (patchAction.running) return { lead: '', script: undefined }
2699
+ patchAction.running = true
2700
+ patchAction.action = mode
2701
+ notify()
2702
+ const action = mode === 'off' ? 'revert' : 'apply'
2703
+ let script
2586
2704
  try {
2587
- log('info', 'patch-check: entered')
2588
- const workspace = host !== undefined && typeof host.get === 'function' ? host.get('uiWorkspace') : undefined
2589
- log(
2590
- 'info',
2591
- 'patch-check: uiWorkspace ' +
2592
- (workspace === undefined || workspace === null ? 'missing' : 'startSession=' + typeof workspace.startSession),
2593
- )
2594
- if (workspace === undefined || workspace === null || typeof workspace.startSession !== 'function') {
2595
- void copyText(patchInstructions(t, patchProbe.value))
2596
- failure = t('patchNoWorkspace')
2597
- return failure
2705
+ log('info', 'patch-action: entered (' + action + ')')
2706
+ const probe = await fetchProbe()
2707
+ const info = probe !== undefined && probe !== null ? probe : {}
2708
+ if (probe !== undefined && probe !== null) {
2709
+ // The launcher is what a user double-clicks; a platform without one
2710
+ // still gets the script, which is the same thing with a command in
2711
+ // front of it.
2712
+ script =
2713
+ typeof info.launcher === 'string' && info.launcher !== ''
2714
+ ? info.launcher
2715
+ : typeof info.script === 'string' && info.script !== ''
2716
+ ? info.script
2717
+ : ''
2718
+ }
2719
+ const token = typeof info.token === 'string' ? info.token : ''
2720
+ if (token === '') {
2721
+ log('warn', 'patch-action: the Host has no action route yet')
2722
+ return { lead: t('patchNoRoute'), script }
2723
+ }
2724
+ // The carrier behind these routes answers GET/HEAD only, so the action
2725
+ // is a GET guarded by the token the probe just handed out.
2726
+ const controller = new AbortController()
2727
+ const timer = setTimeout(() => controller.abort(), 8000)
2728
+ let response
2729
+ try {
2730
+ response = await fetch('./dsh-chat-embed/patch?action=' + action + '&token=' + encodeURIComponent(token), {
2731
+ method: 'GET',
2732
+ headers: { accept: 'application/json' },
2733
+ cache: 'no-store',
2734
+ signal: controller.signal,
2735
+ })
2736
+ } finally {
2737
+ clearTimeout(timer)
2738
+ }
2739
+ let body
2740
+ try {
2741
+ body = await response.json()
2742
+ } catch (error) {
2743
+ log('warn', 'patch-action: the answer was not JSON: ' + messageOf(error))
2744
+ body = undefined
2598
2745
  }
2599
- patchCheck.running = true
2746
+ if (body !== undefined && body !== null && body.ok === true && body.state === 'started') {
2747
+ patchAction.pending = true
2748
+ log('info', 'patch-action: started ' + action)
2749
+ notify()
2750
+ return { lead: '', script }
2751
+ }
2752
+ log('warn', 'patch-action: not started (' + (body === undefined ? 'no body' : String(body.state)) + ')')
2753
+ return { lead: patchFallbackText(t, body), script }
2754
+ } catch (error) {
2755
+ log('error', 'patch-action: failed', messageOf(error))
2756
+ return { lead: t('patchStartFailed') + ' ' + messageOf(error), script }
2757
+ } finally {
2758
+ patchAction.running = false
2600
2759
  notify()
2760
+ }
2761
+ }
2762
+
2763
+ async function copyPatchCommand(t, mode) {
2764
+ // No session, no agent: the script does the whole job, so all this has to
2765
+ // do is put its exact path and command on the clipboard. Every step is
2766
+ // logged and the reason comes back to the dialog, because a click that
2767
+ // does nothing is indistinguishable from a broken build.
2768
+ let failure = ''
2769
+ patchAction.running = true
2770
+ notify()
2771
+ try {
2772
+ log('info', 'patch-command: entered')
2601
2773
  const probe = await fetchProbe()
2602
- log('info', 'patch-check: probe ' + (probe === undefined || probe === null ? 'absent' : 'ok'))
2603
- const prompt = mode === 'off' ? buildRestorePrompt(t, probe) : buildPatchPrompt(t, probe)
2604
- patchProbe.loaded = false
2605
- // A custom main panel stays selected when a Session opens, so the new
2606
- // Session lands behind this panel and the click looks like a no-op.
2607
- // Hand the main area back to the conversation first.
2608
- const layout = host !== undefined && typeof host.get === 'function' ? host.get('layout') : undefined
2609
- if (layout !== undefined && layout !== null && typeof layout.selectPanel === 'function') {
2610
- log('info', 'patch-check: releasing the main panel before opening the Session')
2611
- layout.selectPanel(null)
2612
- }
2613
- log('info', 'patch-check: opening a Session with a ' + prompt.length + '-char draft')
2614
- // 'replace', not 'append': the Workspace blank can already hold a draft
2615
- // from another flow (the plugin-creation template, for one), and appending
2616
- // would hand the agent two unrelated instructions at once.
2617
- workspace.startSession(undefined, { prompt, whenDraftExists: 'replace' })
2618
- log('info', 'patch-check: startSession returned')
2774
+ log('info', 'patch-command: probe ' + (probe === undefined || probe === null ? 'absent' : 'ok'))
2775
+ const text = patchInstructions(t, probe, mode)
2776
+ const copied = await copyText(text)
2777
+ log('info', 'patch-command: clipboard ' + (copied ? 'ok' : 'failed'))
2778
+ if (copied !== true) failure = t('copyFailed')
2619
2779
  } catch (error) {
2620
2780
  failure = messageOf(error)
2621
- log('error', 'patch-check: failed', failure)
2622
- void copyText(patchInstructions(t, patchProbe.value) + '\n' + t('copyFailed') + ': ' + failure)
2781
+ log('error', 'patch-command: failed', failure)
2623
2782
  } finally {
2624
- patchCheck.running = false
2783
+ patchAction.running = false
2625
2784
  notify()
2626
2785
  }
2627
2786
  return failure
2628
2787
  }
2629
2788
 
2630
- /**
2631
- * The draft for the other direction: put the original app.asar back.
2632
- *
2633
- * Turning the switch off is a real operation, not a dead end — the patch
2634
- * kept a copy, so undoing it is a rename away.
2635
- *
2636
- * @param {(key: string) => string} t
2637
- * @param {any} [probe]
2638
- * @returns {string}
2639
- */
2640
- function buildRestorePrompt(t, probe) {
2641
- const info = probe !== undefined && probe !== null ? probe : {}
2642
- const lines = [t('restoreTask')]
2643
- if (typeof info.resources === 'string' && info.resources !== '') {
2644
- lines.push('', t('patchTaskDir') + ': ' + info.resources)
2645
- }
2646
- if (typeof info.asar === 'string' && info.asar !== '') {
2647
- lines.push('', t('restoreStepsTitle') + ':')
2648
- lines.push(' 1. ' + info.asar + ' -> ' + info.asar + '.patched.bak')
2649
- lines.push(' 2. ' + info.asar + '.orig -> ' + info.asar)
2650
- }
2651
- if (info.writable === false) lines.push('', t('patchTaskReadonly'))
2652
- lines.push('', t('restoreWarning'))
2653
- lines.push('', t('patchTaskVerify'))
2654
- return lines.join('\n')
2655
- }
2656
2789
 
2657
- /**
2658
- * The text dropped into the new Session's draft: what is already known, so
2659
- * the agent starts from facts instead of asking the user to run something.
2660
- *
2661
- * @param {(key: string) => string} t
2662
- * @param {any} probe
2663
- * @returns {string}
2664
- */
2665
- function buildPatchPrompt(t, probe) {
2666
- const info = probe !== undefined && probe !== null ? probe : {}
2667
- // The plugin already knows the state; the draft only says what to do about
2668
- // it. Anything the patch script enforces itself (byte checks, quitting
2669
- // first) does not belong here — that is a manual, not an instruction.
2670
- const lines = [t('patchTask')]
2671
- const command = typeof info.patchCommand === 'string' && info.patchCommand !== '' ? info.patchCommand : ''
2672
- if (typeof info.resources === 'string' && info.resources !== '') {
2673
- lines.push('', t('patchTaskDir') + ': ' + info.resources)
2674
- }
2675
- if (command !== '') lines.push('', t('patchTaskCommand') + ':', ' ' + command)
2676
- if (info.writable === false) lines.push('', t('patchTaskReadonly'))
2677
- if (info.patchSite === false) lines.push('', t('patchTaskNoSite'))
2678
- lines.push('', t('patchTaskVerify'))
2679
- return lines.join('\n')
2680
- }
2681
2790
 
2682
2791
  /** @returns {{ state: string, detail: string, seats: any[] }} */
2683
2792
  function rightSidebarStatus() {
@@ -2871,6 +2980,10 @@ let activeCtx = undefined
2871
2980
  '.dce-icon-button:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}',
2872
2981
  '.dce-icon-button:focus-visible{outline:2px solid var(--dsw-alias-button-primary-fill,#4c6ef5);outline-offset:-2px}',
2873
2982
  '.dce-status-bar{position:absolute;top:0;left:0;right:0;z-index:2;display:flex;align-items:center;gap:8px;box-sizing:border-box;padding:4px 10px;border-bottom:1px solid var(--dsw-alias-border-l1,rgba(127,127,127,.18));background:var(--dsw-alias-bg-base,#fff);font-size:12px}',
2983
+ // A pending patch keeps the tab bar pinned open, and the tab bar sits on
2984
+ // the same top edge with a higher z-index — so the strip has to move below
2985
+ // it or it is hidden by the very state it is reporting.
2986
+ '.dce-status-bar[data-patch-pending="true"]{top:33px;z-index:5;}',
2874
2987
  '.dce-dot{flex:0 0 auto;width:8px;height:8px;border-radius:50%;background:var(--dsw-alias-label-tertiary,#9aa0a6)}',
2875
2988
  '.dce-dot[data-phase="ready"]{background:var(--dsw-alias-state-success-primary,#2ea043)}',
2876
2989
  '.dce-dot[data-phase="failed"]{background:var(--dsw-alias-state-error-primary,#d33)}',
@@ -2906,6 +3019,9 @@ let activeCtx = undefined
2906
3019
  '.dce-card[data-modal="true"]{z-index:8}',
2907
3020
  '.dce-menu-item{display:flex;align-items:center;justify-content:flex-start;gap:8px;width:100%;box-sizing:border-box;padding:6px 8px;border:0;border-radius:6px;background:transparent;color:inherit;font-size:13px;text-align:left;cursor:pointer}',
2908
3021
  '.dce-menu-item:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}',
3022
+ '.dce-menu-action{flex:0 0 auto;border:0;border-radius:6px;padding:3px 8px;background:transparent;color:inherit;font-size:12px;cursor:pointer}',
3023
+ '.dce-menu-action:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.18))}',
3024
+ '.dce-menu-action:disabled{opacity:.45;cursor:default}',
2909
3025
  '.dce-right-title{display:inline-flex;align-items:center;gap:6px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
2910
3026
  '.dce-right-dot{width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-state-success-primary,#19a15f);flex:0 0 auto}',
2911
3027
  '.dce-right-dot[data-phase="failed"]{background:var(--dsw-alias-state-error-primary,#d33)}',
@@ -3325,8 +3441,21 @@ let activeCtx = undefined
3325
3441
  const [barOpen, setBarOpen] = React.useState(false)
3326
3442
  const [menuOpen, setMenuOpen] = React.useState(false)
3327
3443
  const [confirmOpen, setConfirmOpen] = React.useState(false)
3444
+ const [cacheReport, setCacheReport] = React.useState(undefined)
3445
+ const [cacheBusy, setCacheBusy] = React.useState(false)
3446
+ const [cacheConfirm, setCacheConfirm] = React.useState(false)
3328
3447
  const [confirmError, setConfirmError] = React.useState('')
3329
3448
  const [confirmMode, setConfirmMode] = React.useState('on')
3449
+ // Why the dialog is open at all: the action could not start, and this
3450
+ // line says which reason applied. Empty on a dialog opened by a click
3451
+ // that never tried to start anything.
3452
+ const [confirmLead, setConfirmLead] = React.useState('')
3453
+ // The launcher path the dialog names. Three states, because "still
3454
+ // asking the Host" must not read as "this install has no script":
3455
+ // undefined the probe has not answered yet
3456
+ // '' it answered, and there is no launcher
3457
+ // '<path>' the file to double-click
3458
+ const [confirmScript, setConfirmScript] = React.useState(undefined)
3330
3459
 
3331
3460
  /**
3332
3461
  * Close the settings menu.
@@ -3337,6 +3466,68 @@ let activeCtx = undefined
3337
3466
  const closeMenu = () => {
3338
3467
  setMenuOpen(false)
3339
3468
  }
3469
+
3470
+ /**
3471
+ * Ask the Host how much of this panel's partitions the clear button would
3472
+ * remove. Opening the menu is the event; nothing polls.
3473
+ */
3474
+ const refreshCache = () => {
3475
+ const controller = new AbortController()
3476
+ const timer = setTimeout(() => controller.abort(), 4000)
3477
+ fetch('./dsh-chat-embed/cache', {
3478
+ method: 'GET',
3479
+ headers: { accept: 'application/json' },
3480
+ cache: 'no-store',
3481
+ signal: controller.signal,
3482
+ })
3483
+ .then((response) => (response.ok ? response.json() : undefined))
3484
+ .then((body) => {
3485
+ setCacheReport(body)
3486
+ })
3487
+ .catch((error) => {
3488
+ setCacheReport(undefined)
3489
+ log('warn', 'cache: size route did not answer: ' + messageOf(error))
3490
+ })
3491
+ .finally(() => {
3492
+ clearTimeout(timer)
3493
+ })
3494
+ }
3495
+
3496
+ /**
3497
+ * Start the script. The Host does not delete; the script re-reads the
3498
+ * archive and refuses to touch any partition that is not one of the seven.
3499
+ */
3500
+ const requestCacheClear = () => {
3501
+ const info = cacheReport !== undefined && cacheReport !== null ? cacheReport : {}
3502
+ const token = typeof info.token === 'string' ? info.token : ''
3503
+ if (token === '' || cacheBusy) return
3504
+ setCacheBusy(true)
3505
+ setCacheConfirm(false)
3506
+ const controller = new AbortController()
3507
+ const timer = setTimeout(() => controller.abort(), 60000)
3508
+ fetch('./dsh-chat-embed/cache-clear?token=' + encodeURIComponent(token), {
3509
+ method: 'GET',
3510
+ headers: { accept: 'application/json' },
3511
+ cache: 'no-store',
3512
+ signal: controller.signal,
3513
+ })
3514
+ .then((response) => (response.ok ? response.json() : undefined))
3515
+ .then((body) => {
3516
+ if (body === undefined || body === null) {
3517
+ setCacheReport({ ...info, detail: t('cacheFailed') })
3518
+ return
3519
+ }
3520
+ setCacheReport({ ...info, ...body, token })
3521
+ })
3522
+ .catch((error) => {
3523
+ setCacheReport({ ...info, ok: false, detail: messageOf(error) })
3524
+ log('warn', 'cache: clear did not finish: ' + messageOf(error))
3525
+ })
3526
+ .finally(() => {
3527
+ clearTimeout(timer)
3528
+ setCacheBusy(false)
3529
+ })
3530
+ }
3340
3531
  const [copyState, setCopyState] = React.useState('')
3341
3532
  const barTimerRef = React.useRef(0)
3342
3533
  const cancelBarTimer = () => {
@@ -3405,14 +3596,18 @@ let activeCtx = undefined
3405
3596
  const record = guestRecord(provider.id)
3406
3597
 
3407
3598
  // The status strip only earns its space while something is happening or
3408
- // wrong; a healthy tab shows nothing but its tabs.
3409
- const showStatus = snapshot.phase !== PHASE.READY && snapshot.phase !== PHASE.IDLE
3599
+ // wrong; a healthy tab shows nothing but its tabs. A pending patch is
3600
+ // "something is happening": the script is waiting for DSH to exit, and
3601
+ // the user has to quit it from the tray, so say so where they look.
3602
+ const patchPending = patchAction.pending
3603
+ const showStatus = patchPending || snapshot.phase !== PHASE.READY && snapshot.phase !== PHASE.IDLE
3410
3604
  // A problem keeps the bar reachable without hunting for it.
3411
3605
  const barVisible =
3412
3606
  barOpen ||
3413
3607
  menuOpen ||
3414
3608
  record.diagOpen ||
3415
3609
  record.oauthBlocked ||
3610
+ patchPending ||
3416
3611
  snapshot.phase === PHASE.FAILED
3417
3612
  const reloadTitle =
3418
3613
  t('reload') +
@@ -3524,7 +3719,10 @@ let activeCtx = undefined
3524
3719
  'aria-expanded': menuOpen ? 'true' : 'false',
3525
3720
  onClick: () => {
3526
3721
  if (menuOpen) closeMenu()
3527
- else setMenuOpen(true)
3722
+ else {
3723
+ setMenuOpen(true)
3724
+ refreshCache()
3725
+ }
3528
3726
  openBar()
3529
3727
  },
3530
3728
  },
@@ -3584,16 +3782,83 @@ let activeCtx = undefined
3584
3782
  'data-persist-open': 'true',
3585
3783
  'aria-label': t('persistLabel'),
3586
3784
  title: t('persistCheckHint'),
3587
- disabled: patchCheck.running,
3785
+ disabled: patchAction.running,
3588
3786
  onClick: () => {
3589
- log('info', 'dialog: opened by the restart-login switch')
3787
+ // The switch is the control, not a question: a click that
3788
+ // can work starts the script straight away. The dialog is
3789
+ // the fallback, so it only opens when nothing started.
3790
+ const target = persistenceState() === 'on' ? 'off' : 'on'
3791
+ log('info', 'patch: restart-login switch -> ' + target)
3590
3792
  closeMenu()
3591
- // The switch is a switch: on means the next click offers to undo it.
3592
- setConfirmMode(persistenceState() === 'on' ? 'off' : 'on')
3593
- setConfirmOpen(true)
3793
+ void startPatchAction(t, target).then(
3794
+ (outcome) => {
3795
+ if (outcome === undefined || outcome === null || outcome.lead === '') return
3796
+ setConfirmMode(target)
3797
+ setConfirmLead(outcome.lead)
3798
+ setConfirmScript(outcome.script)
3799
+ setConfirmOpen(true)
3800
+ notify()
3801
+ },
3802
+ (error) => {
3803
+ log('error', 'patch: startPatchAction rejected', messageOf(error))
3804
+ },
3805
+ )
3594
3806
  },
3595
3807
  }),
3596
3808
  ),
3809
+ h(
3810
+ 'div',
3811
+ { className: 'dce-menu-row', 'data-cache-row': 'true' },
3812
+ h(
3813
+ 'span',
3814
+ {
3815
+ className: 'dce-menu-label',
3816
+ title:
3817
+ cacheReport !== undefined && cacheReport !== null && cacheReport.mode === 'keep'
3818
+ ? t('cacheKeepHint')
3819
+ : cacheReport !== undefined && cacheReport !== null && cacheReport.mode === 'purge'
3820
+ ? t('cachePurgeHint')
3821
+ : t('cacheUnavailable'),
3822
+ },
3823
+ t('cacheLabel') +
3824
+ ' ' +
3825
+ (cacheReport === undefined || cacheReport === null || cacheReport.ok !== true
3826
+ ? t('cacheUnavailable')
3827
+ : formatCacheBytes(cacheReport.bytes)),
3828
+ ),
3829
+ h(
3830
+ 'button',
3831
+ {
3832
+ type: 'button',
3833
+ className: 'dce-menu-action',
3834
+ 'data-cache-clear': 'true',
3835
+ disabled:
3836
+ cacheBusy ||
3837
+ cacheReport === undefined ||
3838
+ cacheReport === null ||
3839
+ cacheReport.ok !== true ||
3840
+ cacheReport.bytes === 0,
3841
+ title:
3842
+ cacheReport !== undefined &&
3843
+ cacheReport !== null &&
3844
+ typeof cacheReport.detail === 'string' &&
3845
+ cacheReport.detail !== ''
3846
+ ? t('cacheFailed') + ' ' + cacheReport.detail
3847
+ : cacheReport !== undefined && cacheReport !== null && cacheReport.mode === 'purge'
3848
+ ? t('cachePurgeHint')
3849
+ : t('cacheKeepHint'),
3850
+ onClick: () => {
3851
+ if (cacheReport !== undefined && cacheReport !== null && cacheReport.mode === 'purge') {
3852
+ closeMenu()
3853
+ setCacheConfirm(true)
3854
+ return
3855
+ }
3856
+ requestCacheClear()
3857
+ },
3858
+ },
3859
+ cacheBusy ? t('cacheClearing') : t('cacheClear'),
3860
+ ),
3861
+ ),
3597
3862
  h(
3598
3863
  'button',
3599
3864
  {
@@ -3653,10 +3918,14 @@ let activeCtx = undefined
3653
3918
  { className: 'dce-card-title' },
3654
3919
  t(confirmMode === 'off' ? 'persistOffTitle' : 'persistConfirmTitle'),
3655
3920
  ),
3921
+ confirmLead === '' ? null : h('div', { className: 'dce-card-body', 'data-persist-lead': 'true' }, confirmLead),
3656
3922
  h('div', { className: 'dce-card-body' }, t(confirmMode === 'off' ? 'persistOffBody' : 'persistRisk')),
3657
- confirmMode === 'off'
3923
+ confirmMode === 'off' ? null : h('div', { className: 'dce-card-body' }, t('persistConfirmNote')),
3924
+ confirmScript === undefined
3658
3925
  ? null
3659
- : h('div', { className: 'dce-card-body' }, t('persistConfirmNote')),
3926
+ : confirmScript === ''
3927
+ ? h('div', { className: 'dce-card-body' }, t('patchScriptMissing'))
3928
+ : h('div', { className: 'dce-card-detail' }, confirmScript),
3660
3929
  confirmError === '' ? null : h('div', { className: 'dce-card-detail' }, confirmError),
3661
3930
  h(
3662
3931
  'div',
@@ -3672,18 +3941,18 @@ let activeCtx = undefined
3672
3941
  type: 'button',
3673
3942
  className: 'dce-button dce-button-primary',
3674
3943
  'data-persist-confirm': 'true',
3675
- disabled: patchCheck.running,
3944
+ disabled: patchAction.running,
3676
3945
  onClick: () => {
3677
3946
  log('info', 'dialog: the confirm button was clicked')
3678
3947
  setConfirmError('')
3679
- void openPatchCheckSession(t, confirmMode).then(
3948
+ void copyPatchCommand(t, confirmMode).then(
3680
3949
  (failure) => {
3681
3950
  if (typeof failure === 'string' && failure !== '') setConfirmError(failure)
3682
3951
  else setConfirmOpen(false)
3683
3952
  },
3684
3953
  (error) => {
3685
3954
  const reason = messageOf(error)
3686
- log('error', 'dialog: openPatchCheckSession rejected', reason)
3955
+ log('error', 'dialog: copyPatchCommand rejected', reason)
3687
3956
  setConfirmError(reason)
3688
3957
  },
3689
3958
  )
@@ -3694,13 +3963,73 @@ let activeCtx = undefined
3694
3963
  ),
3695
3964
  )
3696
3965
  : null,
3966
+ cacheConfirm
3967
+ ? h('div', {
3968
+ className: 'dce-confirm-scrim',
3969
+ onPointerDown: () => setCacheConfirm(false),
3970
+ })
3971
+ : null,
3972
+ cacheConfirm
3973
+ ? h(
3974
+ 'div',
3975
+ {
3976
+ className: 'dce-card',
3977
+ role: 'dialog',
3978
+ 'aria-modal': 'true',
3979
+ 'data-modal': 'true',
3980
+ 'data-cache-confirm': 'true',
3981
+ 'aria-label': t('cachePurgeTitle'),
3982
+ },
3983
+ h('div', { className: 'dce-card-title' }, t('cachePurgeTitle')),
3984
+ h('div', { className: 'dce-card-body' }, t('cachePurgeBody')),
3985
+ h(
3986
+ 'div',
3987
+ { className: 'dce-card-actions' },
3988
+ h(
3989
+ 'button',
3990
+ {
3991
+ type: 'button',
3992
+ className: 'dce-button',
3993
+ 'data-cache-cancel': 'true',
3994
+ onClick: () => setCacheConfirm(false),
3995
+ },
3996
+ t('persistConfirmCancel'),
3997
+ ),
3998
+ h(
3999
+ 'button',
4000
+ {
4001
+ type: 'button',
4002
+ className: 'dce-button dce-button-primary',
4003
+ 'data-cache-confirm-go': 'true',
4004
+ disabled: cacheBusy,
4005
+ onClick: () => {
4006
+ requestCacheClear()
4007
+ },
4008
+ },
4009
+ t('cachePurgeGo'),
4010
+ ),
4011
+ ),
4012
+ )
4013
+ : null,
3697
4014
  showStatus
3698
4015
  ? h(
3699
4016
  'div',
3700
- { className: 'dce-status-bar' },
3701
- h('span', { className: 'dce-dot', 'data-phase': snapshot.phase, 'aria-hidden': true }),
3702
- h('span', { className: 'dce-status' }, t(STATUS_KEY[snapshot.phase] || 'statusIdle')),
3703
- snapshot.detail === '' ? null : h('span', { className: 'dce-diag' }, snapshot.detail),
4017
+ { className: 'dce-status-bar', 'data-patch-pending': patchPending ? 'true' : 'false' },
4018
+ h('span', {
4019
+ className: 'dce-dot',
4020
+ 'data-phase': patchPending ? 'pending' : snapshot.phase,
4021
+ 'aria-hidden': true,
4022
+ }),
4023
+ h(
4024
+ 'span',
4025
+ { className: 'dce-status' },
4026
+ patchPending ? t('patchPending') : t(STATUS_KEY[snapshot.phase] || 'statusIdle'),
4027
+ ),
4028
+ patchPending
4029
+ ? h('span', { className: 'dce-diag' }, t('patchPendingHint'))
4030
+ : snapshot.detail === ''
4031
+ ? null
4032
+ : h('span', { className: 'dce-diag' }, snapshot.detail),
3704
4033
  )
3705
4034
  : null,
3706
4035
  h(
@@ -3931,16 +4260,17 @@ let activeCtx = undefined
3931
4260
  updateSurface,
3932
4261
  getLogging,
3933
4262
  persistenceState,
4263
+ formatCacheBytes,
3934
4264
  readPersistedSeen,
3935
4265
  storePersistenceSeen,
3936
4266
  livePartitionState,
3937
4267
  patchInstructions,
3938
4268
  fetchProbe,
3939
4269
  patchProbe,
3940
- patchCheck,
3941
- openPatchCheckSession,
3942
- buildPatchPrompt,
3943
- buildRestorePrompt,
4270
+ patchAction,
4271
+ startPatchAction,
4272
+ patchFallbackText,
4273
+ copyPatchCommand,
3944
4274
  setLogging,
3945
4275
  clearLog,
3946
4276
  readLogEntries,