@moonsand/dsh-ui-optimize 0.12.4 → 0.12.5

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
@@ -140,6 +140,8 @@ window.__ModuleLoader__.load({
140
140
  'updates.pendingUnsupported':
141
141
  'This host is not Linux ({platform}), so DSH cannot be stopped from here. While DSH is stopped, run: {command}',
142
142
  'updates.applyStarted': '{n} loaded plugin(s) are queued: DSH stops once, installs the whole batch, then starts once — not one restart per plugin. The page reconnects on its own.',
143
+ 'updates.logTitle': 'Install log — the batch runs in the background, this is its own output',
144
+ 'updates.logWaiting': 'Waiting for the installer to write its first line…',
143
145
  'updates.applyFailed': 'Could not start the background install. Try again in a moment.',
144
146
  'updates.waitingRestart': 'waiting for restart',
145
147
  'updates.compatTagUnknown': 'Not loadable on this DSH',
@@ -259,6 +261,8 @@ window.__ModuleLoader__.load({
259
261
  'updates.pendingUnsupported':
260
262
  '这个宿主不是 Linux({platform}),没法从这里停机安装。请在 DSH 停止时手动执行:{command}',
261
263
  'updates.applyStarted': '{n} 个插件正在运行的,会一起停机安装:DSH 先退出、这批一次装完、再启动一次(不是每个插件重启一遍)。装完页面会自动重连。',
264
+ 'updates.logTitle': '安装日志——这批在后台跑,下面是它自己的输出',
265
+ 'updates.logWaiting': '等安装脚本写出第一行……',
262
266
  'updates.applyFailed': '后台安装没能启动,稍后再试一次。',
263
267
  'updates.waitingRestart': '等待重启',
264
268
  'updates.compatTagUnknown': '与当前 DSH 不兼容',
@@ -2816,6 +2820,35 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
2816
2820
  }
2817
2821
  }
2818
2822
 
2823
+ /* The restart batch runs pnpm inside a detached child, so the only progress it
2824
+ * can honestly report is its own log. Same URL discipline as every other route:
2825
+ * try the base-URI-relative form first (reverse proxies rewrite the root), and
2826
+ * require real JSON — the fnOS gateway answers unknown paths with 200 + text. */
2827
+ async function readApplyLog() {
2828
+ const candidates = []
2829
+ try {
2830
+ candidates.push(new URL('ui-optimize/desktop/apply/log', document.baseURI).toString())
2831
+ } catch {
2832
+ /* baseURI can be opaque in tests; the absolute path below still works */
2833
+ }
2834
+ candidates.push('/ui-optimize/desktop/apply/log')
2835
+ for (const url of candidates) {
2836
+ try {
2837
+ const response = await fetch(url, {
2838
+ credentials: 'same-origin',
2839
+ headers: { 'x-ui-optimize-apply': '1' },
2840
+ })
2841
+ if (!response.ok) continue
2842
+ const text = await response.text()
2843
+ const data = JSON.parse(text)
2844
+ if (data && typeof data === 'object' && Array.isArray(data.lines)) return data
2845
+ } catch {
2846
+ /* try the next candidate */
2847
+ }
2848
+ }
2849
+ return null
2850
+ }
2851
+
2819
2852
  function UpdatesTab() {
2820
2853
  const [phase, setPhase] = React.useState(updateRun.busy ? 'ready' : 'loading')
2821
2854
  /* Mirror of `phase` for timers: reading a ref avoids calling one
@@ -2836,6 +2869,35 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
2836
2869
  function setChecked(next) { updateRun.set({ checked: next }) }
2837
2870
  function setBusy(next) { updateRun.set({ busy: next }) }
2838
2871
  const [message, setMessage] = React.useState('')
2872
+ const [pendingNote, setPendingNote] = React.useState('')
2873
+ const [applyLog, setApplyLog] = React.useState([])
2874
+ const [applyRunning, setApplyRunning] = React.useState(false)
2875
+ /* A queued batch is "applied" until DSH restarts and the page reloads, which is
2876
+ * a ~40 second silence. Poll its log so the click shows movement instead of a
2877
+ * frozen list. */
2878
+ const batchQueued = rows.some(function (row) { return row.state === 'applied' })
2879
+ React.useEffect(function () {
2880
+ if (!batchQueued) {
2881
+ setApplyLog([])
2882
+ setApplyRunning(false)
2883
+ return undefined
2884
+ }
2885
+ let stopped = false
2886
+ function tick() {
2887
+ readApplyLog().then(function (data) {
2888
+ if (!stopped && data) {
2889
+ setApplyLog(data.lines.slice(-8))
2890
+ setApplyRunning(data.running === true)
2891
+ }
2892
+ })
2893
+ }
2894
+ tick()
2895
+ const timer = setInterval(tick, 1500)
2896
+ return function () {
2897
+ stopped = true
2898
+ clearInterval(timer)
2899
+ }
2900
+ }, [batchQueued])
2839
2901
  const [open, setOpen] = React.useState({})
2840
2902
  const [notes, setNotes] = React.useState({})
2841
2903
  const [settings, setSettings] = React.useState(store.state)
@@ -3125,6 +3187,7 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
3125
3187
  if (targets.length === 0 && pendingRows.length === 0) return
3126
3188
  setBusy(true)
3127
3189
  setMessage('')
3190
+ setPendingNote('')
3128
3191
  let restarts = 0
3129
3192
  let refreshes = 0
3130
3193
  for (let index = 0; index < targets.length; index += 1) {
@@ -3223,7 +3286,7 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
3223
3286
  if (applyFailed) {
3224
3287
  setMessage(translate('updates.applyFailed') + (applyError ? '(' + applyError + ')' : ''))
3225
3288
  } else if (appliedPending > 0) {
3226
- setMessage(translate('updates.applyStarted').replace('{n}', String(appliedPending)))
3289
+ setPendingNote(translate('updates.applyStarted').replace('{n}', String(appliedPending)))
3227
3290
  } else {
3228
3291
  setMessage(
3229
3292
  restarts > 0
@@ -3353,6 +3416,11 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
3353
3416
  * `!row.state` was therefore never true and every row looked "busy",
3354
3417
  * which is what pushed the wait label back onto finished rows. */
3355
3418
  const idle = !row.state || row.state === 'idle'
3419
+ /* A queued restart-install keeps state 'applied' until the host comes back.
3420
+ * While the batch is still running it wears the same yellow + moving bar as
3421
+ * a live install; once the log says it is done it turns green like any other
3422
+ * finished row, so the pending area reads the same way as the ready one. */
3423
+ const shownState = row.state === 'applied' ? (applyRunning ? 'running' : 'succeeded') : row.state
3356
3424
  const usingFallback = !!target && target.fallback
3357
3425
  const fallbackShown = usingFallback ? target.version : ''
3358
3426
  /* A running or finished row speaks with its state, not with the plan:
@@ -3361,7 +3429,10 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
3361
3429
  /* A row the host cannot load is not a failed update to retry: it reads
3362
3430
  * as one fact ("this DSH cannot load it"), with the raw failure code
3363
3431
  * left in the log rather than on the card. */
3364
- const label = row.compat ? '' : (idle ? (quiet || usingFallback ? '' : updateLabel(row)) : updateLabel(row))
3432
+ const stateLabel = row.state === 'applied' && !applyRunning
3433
+ ? translate('updates.succeeded')
3434
+ : updateLabel(row)
3435
+ const label = row.compat ? '' : (idle ? (quiet || usingFallback ? '' : updateLabel(row)) : stateLabel)
3365
3436
  /* Nothing to install yet: say how far the nearest candidate is, so a
3366
3437
  * row that is "waiting" does not look like the plugin forgot it.
3367
3438
  * Only idle rows: a finished row must not read "已更新 · 剩余 5.1 小时". */
@@ -3377,9 +3448,9 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
3377
3448
  'div',
3378
3449
  {
3379
3450
  className: 'dsuik-up-row'
3380
- + (row.state === 'running' ? ' is-running' : '')
3381
- + (row.state === 'succeeded' ? ' is-ok' : '')
3382
- + (row.state === 'failed' && !row.compat ? ' is-fail' : '')
3451
+ + (shownState === 'running' ? ' is-running' : '')
3452
+ + (shownState === 'succeeded' ? ' is-ok' : '')
3453
+ + (shownState === 'failed' && !row.compat ? ' is-fail' : '')
3383
3454
  + (isOpen ? ' is-open' : ''),
3384
3455
  style: { animationDelay: String(Math.min(index, 12) * 18) + 'ms' },
3385
3456
  },
@@ -3426,7 +3497,7 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
3426
3497
  ),
3427
3498
  h('span', { className: 'dsuik-up-chev', 'aria-hidden': 'true' }, isOpen ? '▾' : '▸'),
3428
3499
  ),
3429
- row.state === 'running'
3500
+ shownState === 'running'
3430
3501
  ? (row.percent === null
3431
3502
  ? h('div', { className: 'dsuik-up-bar is-indef' }, h('i'))
3432
3503
  : h('div', { className: 'dsuik-up-bar' }, h('i', { style: { width: String(row.percent || 0) + '%' } })))
@@ -3526,11 +3597,24 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
3526
3597
  ? sectionArea(
3527
3598
  'updates.section.pending',
3528
3599
  groups.pending,
3529
- true,
3600
+ false,
3530
3601
  groups.pending.length > 0 ? 'updates.section.pendingHint' : 'updates.section.pendingEmpty',
3531
3602
  true,
3532
3603
  )
3533
3604
  : null,
3605
+ /* Both of these belong to the restart batch, so they sit under its own
3606
+ * heading instead of under the (often empty) ready list. */
3607
+ phase === 'ready' && pendingNote ? h('p', { className: 'dsuik-up-note is-after-pending' }, pendingNote) : null,
3608
+ phase === 'ready' && batchQueued
3609
+ ? h('div', { className: 'dsuik-up-log' },
3610
+ h('div', { className: 'dsuik-up-log-head' }, translate('updates.logTitle')),
3611
+ applyLog.length > 0
3612
+ ? applyLog.map(function (line, index) {
3613
+ return h('div', { className: 'dsuik-up-log-line', key: 'log' + index }, line)
3614
+ })
3615
+ : h('div', { className: 'dsuik-up-log-line is-empty' }, translate('updates.logWaiting')),
3616
+ )
3617
+ : null,
3534
3618
  phase === 'ready' ? sectionArea('updates.section.waiting', groups.waiting, true, 'updates.section.waitingHint', false) : null,
3535
3619
  phase === 'ready'
3536
3620
  ? sectionArea(
@@ -3572,6 +3656,11 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
3572
3656
  .dsuik-up-section-title{margin:0;font-size:12.5px;font-weight:600;letter-spacing:.01em;color:var(--dsw-alias-label-primary);}
3573
3657
  .dsuik-up-section.is-muted .dsuik-up-row{opacity:.7;background:transparent;}
3574
3658
  .dsuik-up-note.is-after-ready{margin-top:-4px;}
3659
+ .dsuik-up-note.is-after-pending{margin-top:-2px;}
3660
+ .dsuik-up-log{margin:-4px 0 2px;padding:8px 10px;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1);max-height:150px;overflow:auto;}
3661
+ .dsuik-up-log-head{font-size:11.5px;font-weight:600;color:var(--dsw-alias-label-secondary);margin-bottom:4px;}
3662
+ .dsuik-up-log-line{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11.5px;line-height:1.5;color:var(--dsw-alias-label-secondary);white-space:pre-wrap;word-break:break-all;}
3663
+ .dsuik-up-log-line.is-empty{font-style:italic;}
3575
3664
  .dsuik-up-note.is-empty{padding:10px 12px;border:1px dashed var(--dsw-alias-border-l1);border-radius:10px;}
3576
3665
  .dsuik-up-loading{display:flex;align-items:center;justify-content:center;gap:8px;padding:34px 0 30px;font-size:13px;color:var(--dsw-alias-label-secondary);animation:dsuik-up-in .2s ease-out both;}
3577
3666
  @media (prefers-reduced-motion: reduce){.dsuik-up-section,.dsuik-up-row,.dsuik-up-loading{animation:none;}}
@@ -56,6 +56,7 @@ const DIAGNOSE_PATH = `${PREFIX}/diagnose`
56
56
  * does the pnpm run *after* this reply flushes, then asks the fnOS gateway to
57
57
  * restart DSH so the new versions are what actually loads. */
58
58
  const APPLY_PATH = `${PREFIX}/apply`
59
+ const APPLY_LOG_PATH = `${PREFIX}/apply/log`
59
60
 
60
61
  /** Where the detached apply run keeps its log and backups. */
61
62
  const APPLY_DIR = join(process.env.DSH_HOME || tmpdir(), '.ui-optimize')
@@ -752,8 +753,12 @@ function writeApplyScript(specs) {
752
753
  ' cp -p pnpm-lock.yaml.bak-' + stamp + ' pnpm-lock.yaml 2>/dev/null || true',
753
754
  'else',
754
755
  ' echo "pnpm ok — asking the gateway to restart DSH"',
755
- ' curl -sS -m 20 --unix-socket ' + JSON.stringify(process.env.DSH_GATEWAY_SOCK || '/vol1/@appcenter/fn-deepseek-harness/app.sock') +
756
- ' -X POST -H "x-requested-with: fetch" -H "x-trim-isadmin: true" http://localhost/__fnos-gateway/control/web/restart >/dev/null 2>&1 || echo "restart request failed"',
756
+ /* Fire and forget: the gateway answers only after it has stopped this process, so
757
+ * waiting for the response here can only ever end in a timeout — and a timeout that
758
+ * leaves DSH running, which is exactly what happened on 2026-11-23 01:00. */
759
+ ' ( curl -sS -m 3 --unix-socket ' + JSON.stringify(process.env.DSH_GATEWAY_SOCK || '/vol1/@appcenter/fn-deepseek-harness/app.sock') +
760
+ ' -X POST -H "x-requested-with: fetch" -H "x-trim-isadmin: true" http://localhost/__fnos-gateway/control/web/restart >/dev/null 2>&1 & )',
761
+ ' echo "restart requested — not waiting, the gateway is about to stop this process"',
757
762
  'fi',
758
763
  'echo "== $(date -Is) apply done (rc=$rc) =="',
759
764
  ]
@@ -871,6 +876,38 @@ async function handleRequest(ctx, request, response) {
871
876
  logPath: HELPER_LOG_PATH,
872
877
  })
873
878
  }
879
+ if (pathname === APPLY_LOG_PATH) {
880
+ // Progress for the restart batch: the child does all its work in one pnpm run, so the
881
+ // only honest progress report is its own log. Reading it costs one small file read.
882
+ if (request.method !== 'GET') return reply(405, { ok: false, reason: 'method-not-allowed' })
883
+ const logPath = join(APPLY_DIR, 'apply.log')
884
+ if (!existsSync(logPath)) return reply(200, { ok: true, lines: [], running: false, mtime: null })
885
+ let text = ''
886
+ try {
887
+ text = readFileSync(logPath, 'utf8')
888
+ } catch {
889
+ text = ''
890
+ }
891
+ const all = text.split('\n').filter(function (line) { return line.trim().length > 0 })
892
+ let mtime = null
893
+ try {
894
+ mtime = statSync(logPath).mtime.toISOString()
895
+ } catch {
896
+ mtime = null
897
+ }
898
+ let lastStart = -1
899
+ for (let i = all.length - 1; i >= 0; i -= 1) {
900
+ if (all[i].indexOf('apply start') !== -1) {
901
+ lastStart = i
902
+ break
903
+ }
904
+ }
905
+ const running = lastStart >= 0 && !all.slice(lastStart).some(function (line) { return line.indexOf('apply done') !== -1 })
906
+ /* Only the current run: older runs are history, and showing them made a finished
907
+ * batch look like it was still installing. */
908
+ const current = lastStart >= 0 ? all.slice(lastStart) : []
909
+ return reply(200, { ok: true, lines: current.slice(-60), running, mtime })
910
+ }
874
911
  if (pathname === APPLY_PATH) {
875
912
  if (request.method !== 'POST') return reply(405, { ok: false, reason: 'method-not-allowed' })
876
913
  if (!sameOriginCaller(request)) return reply(403, { ok: false, reason: 'cross-origin' })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moonsand/dsh-ui-optimize",
3
- "version": "0.12.4",
3
+ "version": "0.12.5",
4
4
  "type": "module",
5
5
  "description": "Switches that tune how DeepSeek Harness looks and behaves across the whole interface, not just a few screens — each works on its own and more arrive as the shell grows: an eight-theme minimalist gallery, sidebar panel folding, and reload/restart buttons at the sidebar foot. · 调 DeepSeek Harness 整体观感与操作的开关集合,管的是整套界面而不只是某几块;每个开关独立生效,随宿主能力增长继续增加:8 套极简主题画廊、侧栏面板收纳,以及侧栏底部的刷新界面与重启应用按钮。",
6
6
  "license": "MIT",