sideby 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +3 -1
  2. package/ai-tasks.json +90 -0
  3. package/dist/build.json +1 -1
  4. package/dist/src/cli/commands.d.ts +9 -1
  5. package/dist/src/cli/commands.js +349 -14
  6. package/dist/src/cli/json-schemas.js +157 -18
  7. package/dist/src/cli/main.js +56 -7
  8. package/dist/src/core/after-install.d.ts +54 -0
  9. package/dist/src/core/after-install.js +78 -0
  10. package/dist/src/core/ask.d.ts +73 -1
  11. package/dist/src/core/ask.js +106 -6
  12. package/dist/src/core/autostart.d.ts +38 -8
  13. package/dist/src/core/autostart.js +85 -39
  14. package/dist/src/core/brand-mark.d.ts +49 -11
  15. package/dist/src/core/brand-mark.js +116 -38
  16. package/dist/src/core/config.d.ts +5 -0
  17. package/dist/src/core/config.js +11 -1
  18. package/dist/src/core/desktop-app.d.ts +1 -1
  19. package/dist/src/core/desktop-app.js +2 -2
  20. package/dist/src/core/edit-settings.d.ts +24 -0
  21. package/dist/src/core/edit-settings.js +97 -0
  22. package/dist/src/core/handoff-brief.d.ts +4 -2
  23. package/dist/src/core/handoff-brief.js +6 -1
  24. package/dist/src/core/handoff-chain.d.ts +24 -0
  25. package/dist/src/core/handoff-chain.js +2 -0
  26. package/dist/src/core/handoff-run.d.ts +4 -3
  27. package/dist/src/core/handoff-run.js +14 -9
  28. package/dist/src/core/launch.d.ts +2 -0
  29. package/dist/src/core/launch.js +14 -10
  30. package/dist/src/core/local-build.d.ts +12 -5
  31. package/dist/src/core/local-build.js +49 -31
  32. package/dist/src/core/lock.d.ts +30 -0
  33. package/dist/src/core/lock.js +143 -0
  34. package/dist/src/core/quota-levels.d.ts +6 -1
  35. package/dist/src/core/quota-levels.js +16 -5
  36. package/dist/src/core/task-spec.d.ts +95 -0
  37. package/dist/src/core/task-spec.js +209 -0
  38. package/dist/src/core/terminal.js +6 -1
  39. package/dist/src/core/update.d.ts +27 -16
  40. package/dist/src/core/update.js +67 -93
  41. package/dist/src/desktop/icon.js +12 -15
  42. package/dist/src/families/claude/ai-task.d.ts +8 -0
  43. package/dist/src/families/claude/ai-task.js +38 -0
  44. package/dist/src/families/claude/handoff-hook.js +4 -4
  45. package/dist/src/families/claude/index.js +3 -0
  46. package/dist/src/families/codex/handoff-hook.js +4 -4
  47. package/dist/src/families/codex/index.js +9 -0
  48. package/dist/src/families/grok/handoff-hook.js +4 -4
  49. package/dist/src/families/grok/index.js +1 -0
  50. package/dist/src/families/pi/index.js +1 -0
  51. package/dist/src/handoff/hook.js +51 -30
  52. package/dist/src/handoff/levels.d.ts +24 -0
  53. package/dist/src/handoff/levels.js +70 -0
  54. package/dist/src/handoff/messages.d.ts +6 -3
  55. package/dist/src/handoff/messages.js +20 -7
  56. package/dist/src/handoff/reader.d.ts +6 -3
  57. package/dist/src/menubar/agent.d.ts +3 -0
  58. package/dist/src/menubar/agent.js +21 -0
  59. package/dist/src/menubar/script.d.ts +8 -0
  60. package/dist/src/menubar/script.js +457 -0
  61. package/dist/src/menubar/snapshot.d.ts +115 -0
  62. package/dist/src/menubar/snapshot.js +255 -0
  63. package/dist/src/menubar/strings.d.ts +87 -0
  64. package/dist/src/menubar/strings.js +88 -0
  65. package/dist/src/panel/background.js +12 -19
  66. package/dist/src/panel/handler.d.ts +12 -0
  67. package/dist/src/panel/handler.js +80 -80
  68. package/dist/src/panel/i18n.d.ts +33 -0
  69. package/dist/src/panel/i18n.js +66 -0
  70. package/dist/src/panel/page-logic.d.ts +105 -0
  71. package/dist/src/panel/page-logic.js +170 -15
  72. package/dist/src/panel/page-script.js +238 -109
  73. package/dist/src/panel/page-styles.js +42 -13
  74. package/dist/src/panel/page.d.ts +7 -0
  75. package/dist/src/panel/page.js +5 -0
  76. package/dist/src/runtime.d.ts +9 -1
  77. package/dist/src/runtime.js +11 -3
  78. package/dist/src/types.d.ts +14 -0
  79. package/package.json +4 -3
  80. package/schemas/ask-choices.json +168 -0
  81. package/schemas/ask-print.json +87 -0
  82. package/schemas/config.json +17 -1
  83. package/schemas/edit.json +119 -0
  84. package/schemas/error.json +4 -0
  85. package/schemas/families.json +4 -0
  86. package/schemas/list.json +4 -0
  87. package/schemas/local.json +1 -1
  88. package/schemas/menubar-snapshot.json +646 -0
  89. package/schemas/menubar-start.json +112 -0
  90. package/schemas/menubar.json +165 -0
  91. package/skills/sideby/SKILL.md +6 -2
  92. package/skills/sideby/references/ai-tasks.md +10 -0
  93. package/skills/sideby/references/handoff.md +3 -1
  94. package/skills/sideby/references/panel.md +6 -0
  95. package/skills/sideby/references/update.md +1 -1
@@ -1,8 +1,10 @@
1
1
  // The Panel page's inline script. Plain browser JavaScript in a string (no template literals inside, so String.raw
2
2
  // keeps it verbatim); the pure helpers from page-logic.ts are prepended so the tested code is the code that runs.
3
- import { aiTaskAccounts, aliasArgsOf, aliasIssue, askCopy, attentionReasons, attentionWhy, autostartNote, cacheHitRate, canLeaveLocal, fileSize, fixPrompt, formatDuration, handoffChangeOf, handoffHintAccount, handoffTaskFacts, inDisplayOrder, loginClusters, loginKey, maskEmail, matchesQuery, menuPlacement, mergeDaily, newAccountDir, nextReset, panelFixes, panelHint, panelLang, panelMigration, panelPrefs, passedWindow, pinnedIn, quotaAskable, quotaPressure, remoteControlSummary, remoteControlTodo, reorder, rowBadge, sortAccounts, stripSecrets, suggestAlias, suggestName, switchFailure, taskFindings, updatedAge, windowState, withPinned, } from './page-logic.js';
3
+ import { aiTaskAccounts, aliasArgsOf, aliasIssue, askBridge, askBridged, askCopy, attentionReasons, attentionWhy, autostartNote, cacheHitRate, canLeaveLocal, codeSwapOutcome, fileSize, fixPrompt, foldSkips, formatDuration, handoffChangeOf, handoffHintAccount, handoffTaskFacts, inDisplayOrder, loginClusters, loginKey, maskEmail, matchesQuery, menuPlacement, mergeDaily, newAccountDir, nextReset, panelFixes, panelHint, panelLang, panelMigration, panelPrefs, passedWindow, pinnedIn, quotaAskable, quotaPressure, remoteControlSummary, remoteControlTodo, reorder, rowBadge, runCodeSwap, sortAccounts, stripSecrets, suggestAlias, suggestName, switchFailure, taskFindings, updatedAge, widthFollower, widthTier, windowState, withPinned, } from './page-logic.js';
4
4
  const LOGIC = [
5
5
  aiTaskAccounts,
6
+ askBridge,
7
+ askBridged,
6
8
  askCopy,
7
9
  quotaAskable,
8
10
  stripSecrets,
@@ -15,6 +17,7 @@ const LOGIC = [
15
17
  cacheHitRate,
16
18
  fileSize,
17
19
  fixPrompt,
20
+ foldSkips,
18
21
  formatDuration,
19
22
  handoffChangeOf,
20
23
  handoffHintAccount,
@@ -29,6 +32,8 @@ const LOGIC = [
29
32
  newAccountDir,
30
33
  nextReset,
31
34
  canLeaveLocal,
35
+ codeSwapOutcome,
36
+ runCodeSwap,
32
37
  switchFailure,
33
38
  panelFixes,
34
39
  panelHint,
@@ -46,6 +51,8 @@ const LOGIC = [
46
51
  suggestName,
47
52
  updatedAge,
48
53
  pinnedIn,
54
+ widthFollower,
55
+ widthTier,
49
56
  windowState,
50
57
  withPinned,
51
58
  ]
@@ -68,6 +75,9 @@ const MAIN = String.raw `
68
75
  const AUTO_MS = 20000
69
76
  const FAST_MS = 5000
70
77
  const FAST_FOR_MS = 3 * 60000
78
+ // After the layout follows a width into another band, how long the width must hold still before a later crossing
79
+ // in the same gesture is applied (page-logic.ts, widthFollower).
80
+ const WIDTH_SETTLE_MS = 90
71
81
  const S = {
72
82
  state: null, loadError: null, loading: false, loadedAt: 0, history: null,
73
83
  report: null, checking: false, fixing: false, checkError: null, checkRetry: null, fixes: null,
@@ -94,6 +104,7 @@ const MAIN = String.raw `
94
104
  if (raw.hideEmail === true) p.hideEmail = true
95
105
  if (typeof raw.ahHintAt === 'number') p.ahHintAt = raw.ahHintAt
96
106
  if (raw.rcHide === true) p.rcHide = true
107
+ if (raw.mbHintDone === true) p.mbHintDone = true
97
108
  if (raw.cfgDone === true) p.cfgDone = true
98
109
  if (typeof raw.family === 'string') p.family = raw.family
99
110
  if (raw.collapsed && typeof raw.collapsed === 'object')
@@ -292,6 +303,7 @@ const MAIN = String.raw `
292
303
  terminal: 'M4 17l6-5-6-5M12 19h8',
293
304
  key: 'M15 9a3 3 0 1 0-.01 0M12.9 11.1L4 20M7 17l2 2M9.5 14.5l2 2',
294
305
  folder: 'M3 6h6l2 2h10v11H3z',
306
+ file: 'M14 3H6v18h12V7zM14 3v4h4M9 13h6M9 17h6',
295
307
  check: 'M9 12l2 2 4-4M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18z',
296
308
  userPlus: 'M15 19a6 6 0 0 0-12 0M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM19 8v6M16 11h6',
297
309
  x: 'M6 6l12 12M18 6L6 18',
@@ -708,6 +720,26 @@ const MAIN = String.raw `
708
720
  }
709
721
  document.addEventListener('pointerdown', (e) => { if (menu.el && !menu.el.contains(e.target) && !menu.anchor.contains(e.target)) closeMenu() })
710
722
  window.addEventListener('resize', () => closeMenu())
723
+ // Layout bands: the page's narrow-screen rules hang on the root's data-width (set before the first paint by the
724
+ // head script), not on media queries, so a width that slides across a breakpoint (a dragged window, a Portal's
725
+ // sidebar opening around this frame) changes the layout as it crosses, as one short cross-fade, not once per frame.
726
+ function applyWidthTier(tier) {
727
+ const root = document.documentElement
728
+ const set = () => { root.dataset.width = tier }
729
+ if (REDUCED || document.hidden || !document.startViewTransition) return set()
730
+ root.classList.add('vt-width')
731
+ document.startViewTransition(set).finished.finally(() => root.classList.remove('vt-width'))
732
+ }
733
+ let widthFollow = null
734
+ function followWidth(width) {
735
+ if (!widthFollow) {
736
+ const timers = { set: (fn, ms) => setTimeout(fn, ms), clear: (id) => clearTimeout(id) }
737
+ const shown = document.documentElement.dataset.width || widthTier(window.innerWidth)
738
+ widthFollow = widthFollower(shown, widthTier, applyWidthTier, WIDTH_SETTLE_MS, timers)
739
+ }
740
+ widthFollow(width)
741
+ }
742
+ window.addEventListener('resize', () => followWidth(window.innerWidth))
711
743
  // Capture also sees the scroll of an inner scroller (a dialog, a list); the menu's own scroll is left alone.
712
744
  window.addEventListener('scroll', (e) => { if (menu.el && !menu.el.contains(e.target)) placeFloat() }, { passive: true, capture: true })
713
745
 
@@ -728,9 +760,24 @@ const MAIN = String.raw `
728
760
  return [
729
761
  a.modelInfo && a.modelInfo.settable ? { icon: 'terminal', label: t('menu.model'), run: () => openModel(a) } : null,
730
762
  family(a.family).tuning ? { icon: 'check', label: t('menu.tune'), run: () => openTune(a) } : null,
763
+ settingsItem(a),
731
764
  { icon: 'check', label: t('menu.check'), disabled: S.checking || S.fixing || Boolean(ui.checkingRef), run: () => checkAccount(a.ref) },
732
765
  ]
733
766
  }
767
+ // The directory's own Host settings file, opened in the user's editor (spec §3.30); it starts a program, so a
768
+ // read-only Panel has no such item.
769
+ function settingsItem(a) {
770
+ const file = family(a.family).settingsFile
771
+ if (!file || !a.dir || BOOT.readOnly) return null
772
+ return { icon: 'file', label: t('menu.editSettings', { file }), hint: a.dir + '/' + file, run: () => editSettings(a, file) }
773
+ }
774
+ async function editSettings(a, file) {
775
+ try {
776
+ const r = await api('/api/account/edit-settings', { account: a.ref })
777
+ toast(t('edit.opened', { ref: a.ref, file }))
778
+ if (r.sharedWith && r.sharedWith.length) toast(t('edit.shared', { names: r.sharedWith.map(refName).join(', ') }), { kind: 'info', duration: 8000 })
779
+ } catch (e) { toast(t('edit.failed', { ref: a.ref, file, msg: e.message }), { kind: 'fail' }) }
780
+ }
734
781
  // What the login does, whichever directory: the browser, signing in, the email, a new account like it.
735
782
  function loginItems(a) {
736
783
  return [
@@ -963,7 +1010,7 @@ const MAIN = String.raw `
963
1010
  })
964
1011
  const display = h('button', { class: 'btn tb-display', type: 'button', 'aria-haspopup': 'dialog', 'aria-expanded': 'false', title: t('tb.display') }, icon('sliders'), h('span', null, t('tb.display')))
965
1012
  display.addEventListener('click', () => openPopover(display, 'display', t('tb.display'), displayPanel, 'end'))
966
- const create = BOOT.readOnly ? null : h('button', { class: 'btn btn-primary', type: 'button', 'aria-label': t('tb.new'), onclick: () => openCreate(null) }, icon('plus'), h('span', null, t('tb.new')))
1013
+ const create = BOOT.readOnly ? null : h('button', { class: 'btn btn-primary', type: 'button', 'aria-label': t('tb.new'), title: t('tb.new'), onclick: () => openCreate(null) }, icon('plus'), h('span', null, t('tb.new')))
967
1014
  setKids($('toolbar'), [
968
1015
  h('label', { class: 'search' }, icon('search', 'search-ic'), tb.search, h('kbd', { class: 'kbd', 'aria-hidden': 'true' }, '/')),
969
1016
  h('div', { class: 'tools' }, tb.family, tb.sort, display),
@@ -1081,7 +1128,9 @@ const MAIN = String.raw `
1081
1128
  const via = q.fetched ? t('quota.fetchedFrom', { host: famTitle(a), ago: ago(q.observedAt) }) : null
1082
1129
  const failed = q.fetchError ? t('quota.lastCheckFailed', { why: q.fetchError }) : null
1083
1130
  const title = [from || via || (stale ? null : t('quota.dataFrom', { ago: ago(q.observedAt) })), failed].filter(Boolean).join('\n') || null
1084
- return h('div', { class: 'quota' + (stale ? ' is-stale' : ''), title },
1131
+ // --qr: this row's own number of windows, so a narrow list can split the width between them alone (--qn is the
1132
+ // widest Family's, for the wide list's shared columns).
1133
+ return h('div', { class: 'quota' + (stale ? ' is-stale' : ''), title, css: wins.length ? { '--qr': String(cols.length) } : null },
1085
1134
  wins.length ? cols.map((c) => {
1086
1135
  const w = wins.find((x) => winKey(x) === c)
1087
1136
  return w ? meter(w, now, stale, q.observedAt) : noMeter(winTitle(c))
@@ -1104,9 +1153,14 @@ const MAIN = String.raw `
1104
1153
  h('div', { class: 'u-sub' }, rate === null ? tn('usage.sessions', u.sessions) : t('usage.cache', { n: Math.round(rate * 100) }))),
1105
1154
  u.totalTokens ? spark(u.daily) : null)
1106
1155
  }
1107
- function lastUsed(a) {
1156
+ function lastUsed(a, cls = 'last') {
1108
1157
  const at = a.usage && a.usage.status === 'ok' && a.usage.lastActivityAt
1109
- return h('div', { class: 'last', title: at ? t('last.title', { at: clock(at) }) : t('last.unknown') }, at ? ago(at) : h('span', { class: 'faint' }, '—'))
1158
+ return h('div', { class: cls, title: at ? t('last.title', { at: clock(at) }) : t('last.unknown') }, at ? ago(at) : h('span', { class: 'faint' }, '—'))
1159
+ }
1160
+ // The line under a row's name, with a copy of the last use at its end: the medium-width list shows that copy
1161
+ // instead of the column (the styles show one of the two), so the time stays next to the account it belongs to.
1162
+ function metaLine(line, a) {
1163
+ return h('div', { class: 'ident-meta' }, line, lastUsed(a, 'last-inline'))
1110
1164
  }
1111
1165
  function healthChip(a) {
1112
1166
  const hs = healthOf(a.ref)
@@ -1367,7 +1421,7 @@ const MAIN = String.raw `
1367
1421
  function foldClick(a) { return foldHit(() => toggleRow(a)) }
1368
1422
  function foldHit(run) {
1369
1423
  return (e) => {
1370
- if (e.target.closest('button, a, input, select, textarea, .tip')) return
1424
+ if (foldSkips(e.target)) return
1371
1425
  const dragged = downAt && Math.hypot(e.clientX - downAt.x, e.clientY - downAt.y) > 4
1372
1426
  if (dragged && window.getSelection && String(window.getSelection())) return
1373
1427
  run()
@@ -1479,7 +1533,7 @@ const MAIN = String.raw `
1479
1533
  const open = isOpen(a)
1480
1534
  const email = emailLine(a)
1481
1535
  return withMenu(h('div', { class: 'row fold-hit' + (open ? ' row-open' : '') + (a.error ? ' row-error' : ''), role: 'listitem', 'data-ref': a.ref, 'data-key': a.ref, 'data-sig': rowSig(a), onclick: foldClick(a) },
1482
- h('div', { class: 'ident' }, rowToggle(a), badge(a.family, 'sm'), h('div', { class: 'ident-text' }, nameLine(a), email || subLine(a))),
1536
+ h('div', { class: 'ident' }, rowToggle(a), badge(a.family, 'sm'), h('div', { class: 'ident-text' }, nameLine(a), metaLine(email || subLine(a), a))),
1483
1537
  quotaBlock(a, now, cols),
1484
1538
  lastUsed(a),
1485
1539
  h('div', { class: 'row-end' }, runButton(a), moreButton(a)),
@@ -1518,7 +1572,7 @@ const MAIN = String.raw `
1518
1572
  const open = isOpen(a)
1519
1573
  const email = emailLine(a)
1520
1574
  return withMenu(h('div', { class: 'row row-login fold-hit' + (open ? ' row-open' : '') + (a.error ? ' row-error' : ''), role: 'listitem', 'aria-label': t('login.label', { names: ms.map((m) => m.name).join(', ') }), 'data-ref': a.ref, 'data-key': loginKey(ms.map((m) => m.ref)), 'data-sig': sig(ms.map(rowSig)), onclick: foldClick(a) },
1521
- h('div', { class: 'ident' }, rowToggle(a), badge(a.family, 'sm'), h('div', { class: 'ident-text' }, nameLine(a, ms), email || subLine(a))),
1575
+ h('div', { class: 'ident' }, rowToggle(a), badge(a.family, 'sm'), h('div', { class: 'ident-text' }, nameLine(a, ms), metaLine(email || subLine(a), newestOf(ms)))),
1522
1576
  quotaBlock(a, now, cols),
1523
1577
  lastUsed(newestOf(ms)),
1524
1578
  h('div', { class: 'row-end' }, runButton(a), loginMoreButton(ms)),
@@ -3515,7 +3569,9 @@ const MAIN = String.raw `
3515
3569
  const look = []
3516
3570
  if (secs.includes('lang')) look.push(seg(t('set.lang'), [['en', 'English'], ['zh', '中文']], lang, setLang))
3517
3571
  if (secs.includes('theme')) look.push(seg(t('set.theme'), CHOICES.theme.map((v) => [v, t('set.theme.' + v)]), viewPrefs().theme, setTheme))
3518
- const start = [autostartRow()]
3572
+ const start = [autostartRow('autostart')]
3573
+ // The menu bar switch shows only where it works (macOS); while its state loads it waits, unseen.
3574
+ if (li.menubar.status && li.menubar.status.supported) start.push(autostartRow('menubar'))
3519
3575
  if (!BOOT.readOnly) start.push(link(t('term.title'), '', '', openTerminals, true))
3520
3576
  const acct = []
3521
3577
  // The arrange mode (spec §3.25) has a place here too, where people look for "how do I change this".
@@ -3569,7 +3625,7 @@ const MAIN = String.raw `
3569
3625
  }
3570
3626
  // Taller than the window, the popover scrolls inside and ends with "More settings…", the same groups in a dialog.
3571
3627
  function settingsPop() {
3572
- if (!as.status && !as.loading && !as.error) loadAutostart()
3628
+ loadAutostart()
3573
3629
  return [...settingsBody(() => closeMenu()),
3574
3630
  h('button', { class: 'menu-item set-more', type: 'button', hidden: true, onclick: () => { closeMenu(); openSettingsDialog() } }, h('span', { class: 'menu-label' }, t('set.more')), icon('chevron'))]
3575
3631
  }
@@ -3581,7 +3637,7 @@ const MAIN = String.raw `
3581
3637
  more.hidden = !(el.scrollHeight > el.clientHeight + 1)
3582
3638
  }
3583
3639
  function openSettingsDialog() {
3584
- if (!as.status && !as.loading) loadAutostart()
3640
+ loadAutostart()
3585
3641
  showDialog('settings')
3586
3642
  renderSettingsDialog()
3587
3643
  }
@@ -3595,85 +3651,105 @@ const MAIN = String.raw `
3595
3651
  if (dlg.kind === 'settings') renderSettingsDialog()
3596
3652
  }
3597
3653
 
3598
- // ---------- start at login (spec §3.29, ADR-0029) ----------
3599
- // The switch reads its state when the settings open; moving it shows the file and what will run, and only the
3600
- // confirmation writes. A read-only Panel shows the state only.
3601
- const as = { status: null, loading: false, error: null, want: null, plan: null, planning: false, planError: null, busy: false }
3602
- async function loadAutostart() {
3603
- as.loading = true
3604
- try { as.status = await api('/api/autostart'); as.error = null } catch (e) { as.error = e }
3605
- as.loading = false
3654
+ // ---------- start at login (spec §3.29, ADR-0029) and the Menu Bar Item (spec §3.31, ADR-0034) ----------
3655
+ // Each switch reads its state when the settings open; moving it shows the file and what will run, and only the
3656
+ // confirmation writes. A read-only Panel shows the state only. mb.* words override as.* for the menu bar.
3657
+ const liState = () => ({ status: null, loading: false, error: null, want: null, plan: null, planning: false, planError: null, busy: false })
3658
+ const li = { autostart: liState(), menubar: liState() }
3659
+ let liKind = 'autostart'
3660
+ function lt(k, key, vars) {
3661
+ const own = (k === 'menubar' ? 'mb.' : 'as.') + key
3662
+ return t(Object.hasOwn(MESSAGES.en, own) ? own : 'as.' + key, vars)
3663
+ }
3664
+ function loadAutostart() {
3665
+ // A failed read is not retried here: the settings re-render after every read, so a retry would loop.
3666
+ for (const k of Object.keys(li)) if (!li[k].status && !li[k].loading && !li[k].error) loadLoginItem(k)
3667
+ }
3668
+ async function loadLoginItem(k) {
3669
+ const st = li[k]
3670
+ st.loading = true
3671
+ try { st.status = await api('/api/' + k); st.error = null } catch (e) { st.error = e }
3672
+ st.loading = false
3606
3673
  refreshSettings()
3674
+ if (k === 'menubar') renderAll()
3607
3675
  }
3608
- function autostartRow() {
3609
- const s = as.status
3676
+ function autostartRow(k) {
3677
+ const st = li[k]
3678
+ const s = st.status
3610
3679
  const n = autostartNote(s, BOOT.readOnly)
3611
- const label = t('as.label')
3612
- const hint = [as.error ? t('as.failed', { msg: as.error.message }) : t(n.key)]
3613
- if (n.action === 'fix') hint.push(' ', h('button', { class: 'link-btn small', type: 'button', onclick: () => autostartAsk(true) }, t('as.fix')))
3614
- if (s && s.state === 'foreign') hint.push(' ', h('button', { class: 'link-btn small', type: 'button', title: s.path, onclick: () => copyText(s.path) }, t('as.copyPath')))
3680
+ const label = lt(k, 'label')
3681
+ const hint = [st.error ? lt(k, 'failed', { msg: st.error.message }) : lt(k, n.key.slice(3))]
3682
+ if (n.action === 'fix') hint.push(' ', h('button', { class: 'link-btn small', type: 'button', onclick: () => autostartAsk(true, k) }, lt(k, 'fix')))
3683
+ if (s && s.state === 'foreign') hint.push(' ', h('button', { class: 'link-btn small', type: 'button', title: s.path, onclick: () => copyText(s.path) }, lt(k, 'copyPath')))
3615
3684
  let ctl = null
3616
- if (!s) ctl = as.loading ? spinner() : null
3685
+ if (!s) ctl = st.loading ? spinner() : null
3617
3686
  else if (n.toggle) ctl = h('div', { class: 'seg', role: 'group', 'aria-label': label }, [[true, t('ah.on')], [false, t('ah.off')]].map(([v, text]) =>
3618
- h('button', { class: 'seg-btn', type: 'button', 'aria-pressed': String(v === n.on), onclick: () => { if (v !== n.on) autostartAsk(v) } }, text)))
3687
+ h('button', { class: 'seg-btn', type: 'button', 'aria-pressed': String(v === n.on), onclick: () => { if (v !== n.on) autostartAsk(v, k) } }, text)))
3619
3688
  else if (s.supported && s.state !== 'foreign') ctl = h('span', { class: 'chip chip-sm' + (n.on ? ' chip-ok' : '') }, n.on ? t('ah.on') : t('ah.off'))
3620
3689
  return h('div', { class: 'set-row set-check' },
3621
3690
  h('div', { class: 'set-text' }, h('span', { class: 'set-label' }, label), h('span', { class: 'set-hint' }, hint)), ctl)
3622
3691
  }
3623
- async function autostartAsk(on) {
3692
+ async function autostartAsk(on, k) {
3624
3693
  if (menu.kind === 'settings') closeMenu()
3625
- as.want = on
3626
- as.plan = null
3627
- as.planError = null
3628
- as.planning = true
3694
+ liKind = k
3695
+ const st = li[k]
3696
+ st.want = on
3697
+ st.plan = null
3698
+ st.planError = null
3699
+ st.planning = true
3629
3700
  showDialog('autostart')
3630
3701
  renderAutostart()
3631
- try { as.plan = (await api('/api/autostart', { on })).plan } catch (e) { as.planError = e }
3632
- as.planning = false
3633
- if (dlg.kind === 'autostart') renderAutostart()
3702
+ try { st.plan = (await api('/api/' + k, { on })).plan } catch (e) { st.planError = e }
3703
+ st.planning = false
3704
+ if (dlg.kind === 'autostart' && liKind === k) renderAutostart()
3634
3705
  }
3635
3706
  function renderAutostart() {
3636
- const p = as.plan
3637
- const on = as.want
3707
+ const k = liKind
3708
+ const st = li[k]
3709
+ const p = st.plan
3710
+ const on = st.want
3638
3711
  const body = []
3639
- if (as.planning) body.push(h('p', { class: 'muted' }, spinner(), ' ', t('as.planning')))
3640
- else if (as.planError) body.push(errorNote(as.planError, () => autostartAsk(on)))
3712
+ if (st.planning) body.push(h('p', { class: 'muted' }, spinner(), ' ', lt(k, 'planning')))
3713
+ else if (st.planError) body.push(errorNote(st.planError, () => autostartAsk(on, k)))
3641
3714
  else if (p && p.blocked) {
3642
3715
  const own = 'as.block.' + p.blocked.code
3643
3716
  body.push(h('p', { class: 'note note-fail' }, Object.hasOwn(MESSAGES.en, own) ? t(own) : p.blocked.message))
3644
3717
  if (['npx-cache', 'temp-dir', 'unsafe-path'].includes(p.blocked.code)) body.push(codeCopy('npm i -g sideby'))
3645
3718
  if (p.blocked.code === 'foreign') body.push(codeCopy(p.path))
3646
- } else if (p && !p.changed) body.push(h('p', null, t(on ? 'as.alreadyOn' : 'as.alreadyOff')))
3719
+ } else if (p && !p.changed) body.push(h('p', null, lt(k, on ? 'alreadyOn' : 'alreadyOff')))
3647
3720
  else if (p && on) {
3648
- body.push(h('p', null, t('as.writes')), h('code', { class: 'as-code' }, p.path))
3649
- body.push(h('p', null, t('as.runs')), h('code', { class: 'as-code' }, (p.programArguments || []).join(' ')))
3650
- body.push(h('p', { class: 'muted small' }, t('as.noWindow')))
3721
+ body.push(h('p', null, lt(k, 'writes')), h('code', { class: 'as-code' }, p.path))
3722
+ body.push(h('p', null, lt(k, 'runs')), h('code', { class: 'as-code' }, (p.programArguments || []).join(' ')))
3723
+ body.push(h('p', { class: 'muted small' }, lt(k, 'noWindow')))
3651
3724
  } else if (p) {
3652
- body.push(h('p', null, t('as.removes')), h('code', { class: 'as-code' }, p.path))
3653
- body.push(h('p', { class: 'muted small' }, t('as.offNote')))
3725
+ body.push(h('p', null, lt(k, 'removes')), h('code', { class: 'as-code' }, p.path))
3726
+ body.push(h('p', { class: 'muted small' }, lt(k, 'offNote')))
3654
3727
  }
3655
- const foot = [h('button', { class: 'btn', type: 'button', disabled: as.busy, onclick: () => dlg.el.close() }, t(p && p.changed && !p.blocked ? 'btn.cancel' : 'btn.close'))]
3728
+ const foot = [h('button', { class: 'btn', type: 'button', disabled: st.busy, onclick: () => dlg.el.close() }, t(p && p.changed && !p.blocked ? 'btn.cancel' : 'btn.close'))]
3656
3729
  if (p && p.changed && !p.blocked)
3657
- foot.push(h('button', { class: 'btn btn-primary', type: 'button', disabled: as.busy, 'aria-busy': as.busy ? 'true' : null, onclick: autostartApply }, as.busy ? spinner() : null, t(on ? 'as.turnOn' : 'as.turnOff')))
3658
- setKids(dlg.el, dialogFrame(t(on ? 'as.onTitle' : 'as.offTitle'), null, body, foot))
3730
+ foot.push(h('button', { class: 'btn btn-primary', type: 'button', disabled: st.busy, 'aria-busy': st.busy ? 'true' : null, onclick: autostartApply }, st.busy ? spinner() : null, lt(k, on ? 'turnOn' : 'turnOff')))
3731
+ setKids(dlg.el, dialogFrame(lt(k, on ? 'onTitle' : 'offTitle'), null, body, foot))
3659
3732
  }
3660
3733
  async function autostartApply() {
3661
- const on = as.want
3662
- as.busy = true
3734
+ const k = liKind
3735
+ const st = li[k]
3736
+ const on = st.want
3737
+ st.busy = true
3663
3738
  dlg.busy = true
3664
3739
  renderAutostart()
3665
3740
  let r = null
3666
- try { r = await api('/api/autostart', { on, confirm: true, programArguments: as.plan.programArguments || [] }) } catch (e) { as.planError = e }
3667
- as.busy = false
3741
+ try { r = await api('/api/' + k, { on, confirm: true, programArguments: st.plan.programArguments || [] }) } catch (e) { st.planError = e }
3742
+ st.busy = false
3668
3743
  dlg.busy = false
3669
3744
  if (r && r.applied) {
3670
- as.status = r.status
3745
+ st.status = r.status
3671
3746
  if (dlg.kind === 'autostart') dlg.el.close()
3672
- toast(t(on ? 'as.doneOn' : 'as.doneOff') + (on && !r.loaded ? ' ' + t('as.nextLogin') : ''))
3747
+ toast(lt(k, on ? 'doneOn' : 'doneOff') + (on && !r.loaded ? ' ' + lt(k, 'nextLogin') : ''))
3673
3748
  refreshSettings()
3749
+ if (k === 'menubar') renderAll()
3674
3750
  return
3675
3751
  }
3676
- if (r) { as.plan = r.plan; if (r.changedSince) toast(t('as.changedSince')) }
3752
+ if (r) { st.plan = r.plan; if (r.changedSince) toast(lt(k, 'changedSince')) }
3677
3753
  if (dlg.kind === 'autostart') renderAutostart()
3678
3754
  }
3679
3755
  function setLang(v) {
@@ -3727,7 +3803,7 @@ const MAIN = String.raw `
3727
3803
  return Boolean(u && u.skillUpdate && u.skillUpdate.installed && u.skillUpdate.installed.length)
3728
3804
  }
3729
3805
  // Example phrases: a click puts one in the Let AI do it box (spec §3.28).
3730
- const AI_ASKS = ['ai.ask.quota', 'ai.ask.new', 'ai.ask.api', 'ai.ask.pin', 'ai.ask.fix', 'ai.ask.handoff', 'ai.ask.rc', 'ai.ask.tool']
3806
+ const AI_ASKS = ['ai.ask.quota', 'ai.ask.new', 'ai.ask.api', 'ai.ask.pin', 'ai.ask.fix', 'ai.ask.handoff', 'ai.ask.menubar', 'ai.ask.rc', 'ai.ask.tool']
3731
3807
  function openRc() {
3732
3808
  if (!S.state || !rcSummary()) return
3733
3809
  rc.target = null
@@ -3787,6 +3863,8 @@ const MAIN = String.raw `
3787
3863
  function openAsk(opts) {
3788
3864
  opts = opts || {}
3789
3865
  closeMenu()
3866
+ // In a Portal that offers AI Tasks itself (createPanelHandler's ask bridge), the task goes to its dialog.
3867
+ if (askBridge(BOOT, opts, window)) return
3790
3868
  ak = { task: opts.task || 'free', text: opts.text || '', context: opts.context || null, account: null, accountChanged: false, terminal: null, terminalChanged: false, pick: null, reason: null, terms: null, loading: true, busy: false, result: null, error: null, removed: false, files: [], els: {} }
3791
3869
  showDialog('ask')
3792
3870
  hookAskDrops()
@@ -4024,7 +4102,12 @@ const MAIN = String.raw `
4024
4102
  rows.push(h('label', { class: 'field', for: 'ak-term' }, h('span', null, t('ask.terminal')), sel))
4025
4103
  }
4026
4104
  if (rows.length) out.push(h('div', { class: 'ask-pick' }, rows))
4027
- if (ak.account) out.push(h('p', { class: 'small' }, t('ask.confirm', { terminal: termName(ak.terminal || 'terminal'), ref: ak.account })))
4105
+ if (ak.account) {
4106
+ // Families whose AI Tasks start with permission checks on (ADR-0031) say so after the confirm line.
4107
+ const acct = S.state && S.state.accounts.find((x) => x.ref === ak.account)
4108
+ const safe = acct && family(acct.family).aiTaskSafe
4109
+ out.push(h('p', { class: 'small' }, t('ask.confirm', { terminal: termName(ak.terminal || 'terminal'), ref: ak.account }) + (safe ? ' ' + t('ask.safe') : '')))
4110
+ }
4028
4111
  return out
4029
4112
  }
4030
4113
  function askResult() {
@@ -4282,6 +4365,23 @@ const MAIN = String.raw `
4282
4365
  }
4283
4366
 
4284
4367
  // ---------- banners ----------
4368
+ // Offered once on macOS (spec §3.31), when quota shows and the menu bar item is off; "No thanks" is for good.
4369
+ function menubarHint() {
4370
+ if (BOOT.readOnly || prefs.mbHintDone) return null
4371
+ const st = li.menubar
4372
+ if (!st.status) {
4373
+ if (!st.loading && !st.error) loadLoginItem('menubar')
4374
+ return null
4375
+ }
4376
+ if (!st.status.supported || st.status.state !== 'off') return null
4377
+ if (!S.state.accounts.some((a) => a.quota && a.quota.status === 'ok')) return null
4378
+ const done = () => { prefs.mbHintDone = true; savePrefs(); renderBanners() }
4379
+ return h('div', { class: 'banner', role: 'status' },
4380
+ h('div', null, h('b', null, t('mb.hintTitle') + ' '), t('mb.hintBody')),
4381
+ h('div', { class: 'banner-actions' },
4382
+ h('button', { class: 'btn btn-sm btn-primary', type: 'button', onclick: () => { done(); autostartAsk(true, 'menubar') } }, t('mb.hintYes')),
4383
+ h('button', { class: 'btn btn-sm', type: 'button', onclick: done }, t('mb.hintNo'))))
4384
+ }
4285
4385
  function renderBanners() {
4286
4386
  const out = []
4287
4387
  if (S.loadError && S.state) out.push(h('div', { class: 'banner banner-fail', role: 'alert' },
@@ -4295,6 +4395,10 @@ const MAIN = String.raw `
4295
4395
  h('div', { class: 'banner-actions' },
4296
4396
  h('button', { class: 'btn btn-sm btn-primary', type: 'button', onclick: () => setPage('handoff') }, t('ah.setUp')),
4297
4397
  h('button', { class: 'btn btn-sm', type: 'button', onclick: () => { prefs.ahHintAt = Date.now(); savePrefs(); renderBanners() } }, t('ah.dismiss')))))
4398
+ else {
4399
+ const mb = menubarHint()
4400
+ if (mb) out.push(mb)
4401
+ }
4298
4402
  const rcBanner = remoteControlBanner()
4299
4403
  if (rcBanner) out.push(rcBanner)
4300
4404
  const errs = S.state.pluginErrors
@@ -4427,7 +4531,7 @@ const MAIN = String.raw `
4427
4531
  }
4428
4532
  function openUpdate() {
4429
4533
  if (!BOOT.updates) return
4430
- up = { busy: false, error: null, done: null, changed: false, skillDone: false, skillChanged: false, autoPlan: null, autoBusy: false, waitUntil: 0, checking: false, checked: false }
4534
+ up = { busy: false, error: null, done: null, confirming: null, unknown: null, changed: false, skillDone: false, skillChanged: false, autoPlan: null, autoBusy: false, waitUntil: 0, checking: false, checked: false }
4431
4535
  showDialog('update')
4432
4536
  renderUpdate()
4433
4537
  }
@@ -4437,24 +4541,36 @@ const MAIN = String.raw `
4437
4541
  up.busy = true
4438
4542
  dlg.busy = true
4439
4543
  up.error = null
4544
+ up.unknown = null
4440
4545
  renderUpdate()
4441
- try {
4442
- const r = await api('/api/update', { confirm: true, version: u.latest })
4443
- if (!r.updated) {
4444
- // The registry names another version than the dialog showed: show the new plan and let the person look again.
4445
- Object.assign(S.state.update, { latest: r.latest, available: r.available, command: r.command, canRun: r.canRun, releaseNotes: r.releaseNotes, method: r.method })
4446
- up.changed = true
4447
- } else {
4448
- up.done = r
4546
+ const target = u.latest
4547
+ const free = () => { up.busy = false; dlg.busy = false }
4548
+ await codeSwap({
4549
+ send: () => api('/api/update', { confirm: true, version: target }),
4550
+ landed: () => { const now = updState(); return now ? now.current === target : null },
4551
+ // The answer was cut: say only that it is being confirmed, never "updated", until the state shows it.
4552
+ confirming: () => { free(); up.confirming = target; renderUpdate() },
4553
+ done: (r) => {
4554
+ free()
4555
+ up.confirming = null
4556
+ if (r && !r.updated) {
4557
+ // The registry names another version than the dialog showed: show the new plan and let the person look again.
4558
+ Object.assign(S.state.update, { latest: r.latest, available: r.available, command: r.command, canRun: r.canRun, releaseNotes: r.releaseNotes, method: r.method })
4559
+ up.changed = true
4560
+ renderUpdate()
4561
+ return false
4562
+ }
4563
+ up.done = r || { updated: true, latest: target }
4449
4564
  up.waitUntil = Date.now() + 20000
4450
- updWait()
4451
- }
4452
- } catch (e) { up.error = e }
4453
- up.busy = false
4454
- dlg.busy = false
4455
- renderUpdate()
4565
+ renderUpdate()
4566
+ return true
4567
+ },
4568
+ stuck: () => { up.waitUntil = 0; renderUpdate() },
4569
+ fail: (e) => { free(); up.confirming = null; up.error = e; renderUpdate() },
4570
+ unknown: () => { free(); up.confirming = null; up.unknown = target; renderUpdate() },
4571
+ })
4456
4572
  }
4457
- // The CLI is current and the skill is behind: update the skill alone, as sideby update --yes does.
4573
+ // The CLI is current and the skill is behind: update the skill alone, as sideby update --skill --yes does.
4458
4574
  async function updSkillRun() {
4459
4575
  up.busy = true
4460
4576
  dlg.busy = true
@@ -4526,7 +4642,7 @@ const MAIN = String.raw `
4526
4642
  }
4527
4643
  // The switch between a Local Build and the npm package (ADR-0024), only where the state offers it: the other side,
4528
4644
  // one button. After the switch the page waits for the server to run the new build and reloads into it.
4529
- const vs = { busy: false, to: null, waitUntil: 0, stuck: false, error: null }
4645
+ const vs = { busy: false, to: null, stuck: false, unknown: false, error: null }
4530
4646
  function localSwitchKids(u) {
4531
4647
  const ls = u && u.localSwitch
4532
4648
  if (!ls || BOOT.readOnly) return null
@@ -4536,8 +4652,8 @@ const MAIN = String.raw `
4536
4652
  const l = ls.local
4537
4653
  const build = l ? l.version + '-dev · ' + (l.commit || '?') + (l.dirty ? '+' : '') : ''
4538
4654
  const kids = [h('p', { class: 'muted small' }, toNpm ? t('loc.toNpmHint') : t('loc.toLocalHint', { b: build, at: l.builtAt ? clock(l.builtAt) : '' }))]
4539
- if (vs.stuck) {
4540
- kids.push(h('p', { class: 'small' }, t('loc.stuck')))
4655
+ if (vs.stuck || vs.unknown) {
4656
+ kids.push(h('p', { class: 'small' }, t(vs.stuck ? 'loc.stuck' : 'loc.unconfirmed')))
4541
4657
  kids.push(h('div', { class: 'popover-actions' }, h('button', { class: 'btn btn-sm btn-primary', type: 'button', onclick: () => location.reload() }, icon('refresh'), t('loc.reload'))))
4542
4658
  } else {
4543
4659
  const newer = toNpm && u.available && u.latest
@@ -4556,27 +4672,36 @@ const MAIN = String.raw `
4556
4672
  vs.to = to
4557
4673
  vs.error = null
4558
4674
  vs.stuck = false
4675
+ vs.unknown = false
4559
4676
  renderSwitch()
4560
- try {
4561
- await api('/api/local', { to, confirm: true })
4562
- } catch (e) {
4563
- // A background Panel restarting from the new code may drop this answer, and a Portal moving to it may answer
4564
- // 5xx (spec §3.23): the state then says whether the switch happened. Only a switch that did not is an error.
4565
- const kind = switchFailure(e)
4566
- if (kind === 'fail') { vs.busy = false; vs.error = e; renderSwitch(); return }
4567
- if (kind === 'check') {
4568
- await load({ silent: true })
4569
- const ls = updState() && updState().localSwitch
4570
- if (!ls || ls.running !== to) { vs.busy = false; vs.error = e; renderSwitch(); return }
4571
- }
4572
- }
4573
- vs.waitUntil = Date.now() + 20000
4574
- localWait()
4677
+ await codeSwap({
4678
+ send: () => api('/api/local', { to, confirm: true }),
4679
+ landed: () => { const now = updState(); return now && now.localSwitch ? now.localSwitch.running === to : null },
4680
+ confirming: () => {},
4681
+ done: () => true,
4682
+ stuck: () => { vs.busy = false; vs.stuck = true; renderSwitch() },
4683
+ fail: (e) => { vs.busy = false; vs.error = e; renderSwitch() },
4684
+ unknown: () => { vs.busy = false; vs.unknown = true; renderSwitch() },
4685
+ })
4575
4686
  }
4576
- function localWait() {
4577
- if (S.newBuild) { location.reload(); return }
4578
- if (Date.now() > vs.waitUntil) { vs.busy = false; vs.stuck = true; renderSwitch(); return }
4579
- setTimeout(() => { void load({ silent: true }).then(localWait, localWait) }, 1500)
4687
+ const pause = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
4688
+ // Reads the state; true when this read answered (a cut connection or a load already running leaves the old state).
4689
+ async function readState() {
4690
+ const before = S.loadedAt
4691
+ try { await load({ silent: true }) } catch {}
4692
+ return S.loadedAt !== before
4693
+ }
4694
+ // A request that may swap the server's code (runCodeSwap): each wait is 20 s, read every 1.5 s.
4695
+ function codeSwap(o) {
4696
+ return runCodeSwap(Object.assign({
4697
+ readState,
4698
+ newBuild: () => !!S.newBuild,
4699
+ reload: () => location.reload(),
4700
+ now: () => Date.now(),
4701
+ pause,
4702
+ windowMs: 20000,
4703
+ pollMs: 1500,
4704
+ }, o))
4580
4705
  }
4581
4706
  async function verPopCheck() {
4582
4707
  vp.checking = true
@@ -4605,12 +4730,6 @@ const MAIN = String.raw `
4605
4730
  up.checking = false
4606
4731
  renderUpdate()
4607
4732
  }
4608
- // After an Update the server (or the Portal's worker) comes back with a new build; load() then reloads the page.
4609
- function updWait() {
4610
- if (!up || !up.done || S.newBuild) { if (S.newBuild) location.reload(); return }
4611
- if (Date.now() > up.waitUntil) { renderUpdate(); return }
4612
- setTimeout(() => { void load({ silent: true }).then(updWait) }, 1500)
4613
- }
4614
4733
  async function updAuto(on) {
4615
4734
  up.autoBusy = true
4616
4735
  up.error = null
@@ -4657,19 +4776,27 @@ const MAIN = String.raw `
4657
4776
  return
4658
4777
  }
4659
4778
  body.push(h('p', null, t('upd.current', { v: u.current })))
4660
- if (up.done) {
4779
+ // While an Update runs, is being confirmed or could not be, the dialog offers nothing else to start.
4780
+ const swapping = Boolean(up.done || up.confirming || up.unknown)
4781
+ if (up.confirming) {
4782
+ body.push(h('p', { class: 'muted small' }, spinner(), ' ', t('upd.confirming', { v: up.confirming })))
4783
+ } else if (up.unknown) {
4784
+ body.push(h('p', { class: 'note note-warn' }, t('upd.unconfirmed', { v: up.unknown })))
4785
+ } else if (up.done) {
4661
4786
  body.push(h('p', { class: 'note' }, t('upd.done', { v: up.done.latest })))
4662
4787
  body.push(h('p', { class: 'muted small' }, Date.now() > up.waitUntil ? t('upd.restartHint') : [spinner(), ' ', t('upd.reloading')]))
4663
4788
  if (up.done.skillUpdated) body.push(h('p', { class: 'small' }, t('upd.skillDone')))
4789
+ else if (up.done.skillSyncStarted) body.push(h('p', { class: 'muted small' }, t('upd.skillSyncing')))
4664
4790
  else body.push(...updSkill(u))
4665
4791
  } else if (up.skillDone && !skillOld(u)) {
4666
4792
  body.push(h('p', { class: 'note' }, t('upd.skillDoneOnly')))
4667
- } else if (u.available && isLocal(u) && (leavesLocal(u) || vs.busy || vs.stuck)) {
4793
+ } else if (u.available && isLocal(u) && (leavesLocal(u) || vs.busy || vs.stuck || vs.unknown)) {
4668
4794
  // A Local Build the Panel can leave (ADR-0024): switching to the release is the update, and brings the skill.
4669
4795
  body.push(h('p', null, t('upd.localSwitch', { v: u.latest }), ' ',
4670
4796
  h('a', { href: u.releaseNotes, target: '_blank', rel: 'noopener noreferrer' }, t('upd.notes'))))
4671
4797
  if (vs.busy) body.push(h('p', { class: 'muted small' }, spinner(), ' ', t('upd.reloading')))
4672
4798
  if (vs.stuck) body.push(h('p', { class: 'note' }, t('loc.stuck')))
4799
+ if (vs.unknown) body.push(h('p', { class: 'note note-warn' }, t('loc.unconfirmed')))
4673
4800
  if (vs.error) body.push(errorNote(vs.error, null))
4674
4801
  body.push(updManual([h('p', { class: 'small' }, t('upd.localManual')), codeCopy(u.command)]))
4675
4802
  } else if (u.available && isLocal(u)) {
@@ -4709,11 +4836,11 @@ const MAIN = String.raw `
4709
4836
  body.push(h('p', { class: 'muted small' }, t('upd.latest') + (u.checkedAt ? ' · ' + t('upd.checked', { ago: ago(u.checkedAt) }) : '')))
4710
4837
  } else body.push(h('p', { class: 'muted small' }, t('upd.notYet')))
4711
4838
  // A read-only Panel sends no request and writes nothing, so it cannot check (spec §3.23).
4712
- if (!BOOT.readOnly && !up.done && !u.available && !skillDue(u))
4839
+ if (!BOOT.readOnly && !swapping && !u.available && !skillDue(u))
4713
4840
  body.push(h('p', null, h('button', { class: 'btn btn-sm', type: 'button', disabled: up.checking || up.busy, 'aria-busy': up.checking ? 'true' : null, onclick: updCheck },
4714
4841
  up.checking ? spinner() : icon('refresh'), up.checking ? t('upd.checking') : t('upd.check'))))
4715
- if (!BOOT.readOnly && !up.done && isLocal(u)) body.push(h('p', { class: 'muted small' }, t('upd.autoLocal')))
4716
- else if (!BOOT.readOnly && !up.done) {
4842
+ if (!BOOT.readOnly && !swapping && isLocal(u)) body.push(h('p', { class: 'muted small' }, t('upd.autoLocal')))
4843
+ else if (!BOOT.readOnly && !swapping) {
4717
4844
  const box = h('input', { type: 'checkbox', disabled: up.autoBusy || !u.method.canUpdate })
4718
4845
  box.checked = up.autoPlan ? up.autoPlan.auto : u.auto
4719
4846
  box.addEventListener('change', () => updAuto(box.checked))
@@ -4726,12 +4853,12 @@ const MAIN = String.raw `
4726
4853
  if (up.error) body.push(errorNote(up.error, null))
4727
4854
  const foot = [h('button', { class: 'btn', type: 'button', disabled: up.busy, onclick: () => dlg.el.close() }, t('btn.close'))]
4728
4855
  const primary = (label, run) => h('button', { class: 'btn btn-primary', type: 'button', disabled: up.busy, 'aria-busy': up.busy ? 'true' : null, onclick: run }, up.busy ? spinner() : null, up.busy ? t('upd.updating') : label)
4729
- if (u.available && isLocal(u) && vs.stuck) foot.push(h('button', { class: 'btn btn-primary', type: 'button', onclick: () => location.reload() }, icon('refresh'), t('loc.reload')))
4856
+ if (up.unknown || (u.available && isLocal(u) && (vs.stuck || vs.unknown))) foot.push(h('button', { class: 'btn btn-primary', type: 'button', onclick: () => location.reload() }, icon('refresh'), t('loc.reload')))
4730
4857
  else if (u.available && isLocal(u) && (leavesLocal(u) || vs.busy))
4731
4858
  foot.push(h('button', { class: 'btn btn-primary', type: 'button', disabled: vs.busy, 'aria-busy': vs.busy ? 'true' : null, onclick: () => localSwitchTo('npm') },
4732
4859
  vs.busy ? spinner() : icon('swap'), vs.busy ? t('loc.switching') : t('loc.toNpmV', { v: u.latest })))
4733
- else if (u.available && u.canRun && !BOOT.readOnly && !up.done) foot.push(primary(t('upd.now', { v: u.latest }), updRun))
4734
- else if (skillDue(u) && !BOOT.readOnly && !up.done) foot.push(primary(t('upd.skillNow'), updSkillRun))
4860
+ else if (u.available && u.canRun && !BOOT.readOnly && !swapping) foot.push(primary(t('upd.now', { v: u.latest }), updRun))
4861
+ else if (skillDue(u) && !BOOT.readOnly && !swapping) foot.push(primary(t('upd.skillNow'), updSkillRun))
4735
4862
  setKids(dlg.el, dialogFrame(t('upd.title'), null, body, foot))
4736
4863
  }
4737
4864
 
@@ -4743,6 +4870,8 @@ const MAIN = String.raw `
4743
4870
  $('ver-top').addEventListener('click', () => openVerPop($('ver-top')))
4744
4871
  $('refresh').addEventListener('click', refreshAll)
4745
4872
  $('ask-ai').addEventListener('click', () => openAsk())
4873
+ // In a Portal that offers AI Tasks itself the Portal has the button; opened on its own, the Panel keeps it.
4874
+ $('ask-ai').hidden = askBridged(BOOT, window)
4746
4875
  $('accounts').addEventListener('dragover', onDragOver)
4747
4876
  $('accounts').addEventListener('drop', onDrop)
4748
4877
  // Escape leaves the arrange mode, as "Done" does, unless a menu or dialog takes it first.