sideby 0.26.0 → 0.27.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.
@@ -3,9 +3,13 @@
3
3
  import { groupsToAccept } from '../core/inbound.js';
4
4
  import { quotaIsStale } from '../core/quota-levels.js';
5
5
  import { remoteControlTodo } from '../core/remote-control.js';
6
+ import { catalogMatchLevel, catalogNorm, searchCatalog } from '../core/search-catalog.js';
6
7
  import { aiTaskAccounts, aliasArgsOf, aliasIssue, askBridge, askBridged, askCopy, attentionReasons, attentionWhy, autostartNote, bindingWindow, cacheHitRate, canLeaveLocal, categoryOrder, codeSwapOutcome, dotsKeepKeyboard, enableOutcome, fileSize, fixPrompt, foldSkips, foldToolCalls, formatDuration, handoffChangeOf, handoffHintAccount, handoffTaskFacts, hiddenIn, highlightParts, histFilters, historyEmpty, historyWhen, hotkeyFromKey, hotkeyPressKind, inDisplayOrder, loginClusters, loginKey, maskEmail, matchesQuery, mdBlocks, mdInline, menuPlacement, mergeDaily, mergeUsage, messageChip, messageNews, networkTaskFacts, newAccountDir, nextReset, panelFixes, panelHint, panelLang, panelMigration, panelPrefs, passedWindow, pinnedIn, quotaAskable, quotaHighLevel, quotaPressure, radioStep, remoteControlSummary, reorder, rowBadge, runCodeSwap, saveHandoffChange, sendBlock, sendFileProblem, sendResultView, sessionAge, sessionLabelParts, shortCwd, shortSessionLabel, sortAccounts, sortSessions, steadyOrder, stripSecrets, suggestAlias, suggestName, switchFailure, tailInView, taskFindings, updatedAge, widthFollower, widthTier, windowState, withPinned, } from './page-logic.js';
7
8
  const LOGIC = [
8
9
  quotaIsStale,
10
+ catalogNorm,
11
+ catalogMatchLevel,
12
+ searchCatalog,
9
13
  aiTaskAccounts,
10
14
  askBridge,
11
15
  askBridged,
@@ -237,16 +241,23 @@ const MAIN = String.raw `
237
241
  else el.removeAttribute('aria-label')
238
242
  }
239
243
  // replaceChildren() would render null as the text "null"; route children through add(), which skips it.
244
+ // The toast stack (raiseToasts) may live in the open dialog; redrawing the dialog leaves it where it is.
245
+ const keepsToasts = (n) => n.nodeType === 1 && n.id === 'toasts'
240
246
  function setKids(el, kids) {
241
- el.replaceChildren()
242
- add(el, kids)
247
+ for (const n of Array.from(el.childNodes)) if (!keepsToasts(n)) n.remove()
248
+ const stack = el.lastChild
249
+ if (!stack) return add(el, kids)
250
+ // New content goes before the stack, so a later patch finds it in place and moves nothing (moving loses focus).
251
+ const box = document.createDocumentFragment()
252
+ add(box, kids)
253
+ el.insertBefore(box, stack)
243
254
  }
244
255
  // Re-renders el without the jolt of a rebuild: the focused control keeps focus (matched by data-key), and an element
245
256
  // marked data-enter that was not there before grows in, so a row that appears does not snap the layout open.
246
257
  // A first render (el empty) animates nothing; the container itself has its own entrance.
247
258
  function swapKids(el, kids) {
248
259
  const before = new Set([...el.querySelectorAll('[data-enter]')].map((x) => x.getAttribute('data-enter')))
249
- const shown = el.childNodes.length > 0
260
+ const shown = Array.from(el.childNodes).some((n) => !keepsToasts(n))
250
261
  const active = document.activeElement
251
262
  const focusKey = active && el.contains(active) ? active.getAttribute('data-key') : null
252
263
  setKids(el, kids)
@@ -254,6 +265,20 @@ const MAIN = String.raw `
254
265
  for (const x of el.querySelectorAll('[data-enter]')) if (!before.has(x.getAttribute('data-enter'))) x.classList.add('enter')
255
266
  if (focusKey) { const again = el.querySelector('[data-key="' + CSS.escape(focusKey) + '"]'); if (again) again.focus() }
256
267
  }
268
+ // swapKids for a view that refreshes while open: unchanged elements stay (see patch), so a refresh that brings the
269
+ // same answer redraws nothing; new data-enter elements still grow in.
270
+ function patchEnter(el, kids) {
271
+ const before = new Set([...el.querySelectorAll('[data-enter]')].map((x) => x.getAttribute('data-enter')))
272
+ const shown = Array.from(el.childNodes).some((n) => !keepsToasts(n))
273
+ patch(el, kids)
274
+ if (shown && !REDUCED)
275
+ for (const x of el.querySelectorAll('[data-enter]'))
276
+ if (!before.has(x.getAttribute('data-enter'))) {
277
+ x.classList.add('enter')
278
+ // Gone once it has grown in, so the next refresh sees the same markup and keeps the element.
279
+ x.addEventListener('animationend', () => x.classList.remove('enter'), { once: true })
280
+ }
281
+ }
257
282
  function add(el, kid) {
258
283
  if (kid === null || kid === undefined || kid === false) return
259
284
  if (Array.isArray(kid)) { for (const k of kid) add(el, k); return }
@@ -288,7 +313,7 @@ const MAIN = String.raw `
288
313
  }
289
314
  function patchKids(box, kids) {
290
315
  const next = flat(kids)
291
- const old = Array.from(box.childNodes)
316
+ const old = Array.from(box.childNodes).filter((n) => !keepsToasts(n))
292
317
  const byKey = new Map()
293
318
  for (const o of old) if (o.nodeType === 1 && o.dataset.key) byKey.set(o.dataset.key, o)
294
319
  const used = new Set()
@@ -509,9 +534,13 @@ const MAIN = String.raw `
509
534
  // Hovering a toast pauses it, so an Undo stays reachable.
510
535
  const toasts = []
511
536
  // The toast stack is a manual popover so it sits in the top layer; raising it again after a modal dialog
512
- // opens keeps toasts above that dialog's backdrop. Without popover support it stays a fixed element.
537
+ // opens keeps toasts above that dialog's backdrop. A modal dialog makes everything outside it inert, a popover
538
+ // above it included, so while one is open the stack moves into it and an Undo stays clickable; it moves back
539
+ // when the dialog closes. Without popover support it stays a fixed element.
513
540
  function raiseToasts() {
514
541
  const el = $('toasts')
542
+ const home = dlg.el && dlg.el.open ? dlg.el : document.body
543
+ if (el.parentNode !== home) home.append(el)
515
544
  if (typeof el.showPopover !== 'function') return
516
545
  try { if (el.matches(':popover-open')) el.hidePopover(); el.showPopover() } catch {}
517
546
  }
@@ -1121,6 +1150,8 @@ const MAIN = String.raw `
1121
1150
  for (const el of document.querySelectorAll('[data-i18n]')) el.textContent = t(el.getAttribute('data-i18n'))
1122
1151
  $('refresh').setAttribute('aria-label', t('top.refresh'))
1123
1152
  $('ask-ai').setAttribute('aria-label', t('ask.button'))
1153
+ $('search-btn').setAttribute('aria-label', t('pal.button') + ' (' + palKey() + ')')
1154
+ $('search-kbd').textContent = palKey()
1124
1155
  const repo = $('repo')
1125
1156
  for (const k of ['aria-label', 'title']) repo.setAttribute(k, t('top.repo'))
1126
1157
  if (/^https:\/\/github\.com\//.test(BOOT.repoUrl || '')) { repo.href = BOOT.repoUrl; repo.hidden = false }
@@ -1245,13 +1276,13 @@ const MAIN = String.raw `
1245
1276
  const redo = () => { savePrefs(); renderAccounts(); refreshPopover('display') }
1246
1277
  const emails = S.state && S.state.accounts.some((a) => a.identity && a.identity.email)
1247
1278
  return h('div', { class: 'display-panel' },
1248
- h('div', { class: 'dp-row' }, h('span', { class: 'dp-label' }, t('tb.quota')),
1249
- seg(t('tb.quota'), [['used', t('tb.used')], ['left', t('tb.left')]], prefs.quota, (v) => { prefs.quota = v; redo() })),
1250
- h('div', { class: 'dp-row' }, h('span', { class: 'dp-label' }, t('tb.view')),
1251
- seg(t('tb.view'), [['list', [icon('list'), h('span', null, t('tb.list'))], t('tb.list')], ['cards', [icon('grid'), h('span', null, t('tb.cards'))], t('tb.cards')]], prefs.view, (v) => { prefs.view = v; ui.fade = true; redo() })),
1252
- emails ? h('label', { class: 'dp-row dp-check' },
1279
+ fm('quota', h('div', { class: 'dp-row' }, h('span', { class: 'dp-label' }, t('tb.quota')),
1280
+ seg(t('tb.quota'), [['used', t('tb.used')], ['left', t('tb.left')]], prefs.quota, (v) => { prefs.quota = v; redo() }))),
1281
+ fm('view', h('div', { class: 'dp-row' }, h('span', { class: 'dp-label' }, t('tb.view')),
1282
+ seg(t('tb.view'), [['list', [icon('list'), h('span', null, t('tb.list'))], t('tb.list')], ['cards', [icon('grid'), h('span', null, t('tb.cards'))], t('tb.cards')]], prefs.view, (v) => { prefs.view = v; ui.fade = true; redo() }))),
1283
+ emails ? fm('emails', h('label', { class: 'dp-row dp-check' },
1253
1284
  h('input', { type: 'checkbox', checked: prefs.hideEmail, onchange: (e) => { prefs.hideEmail = e.target.checked; redo() } }),
1254
- h('span', null, t('tb.hideEmails'))) : null)
1285
+ h('span', null, t('tb.hideEmails')))) : null)
1255
1286
  }
1256
1287
  function renderFamilyFilter() {
1257
1288
  if (!tb.family) return
@@ -1609,9 +1640,9 @@ const MAIN = String.raw `
1609
1640
  return h('li', { class: 'br-row' },
1610
1641
  h('span', null, h('b', null, profileName(p.name)), p.email ? h('span', { class: 'muted small' }, ' · ' + emailText(p.email)) : null, ' ', h('span', { class: 'muted small mono' }, p.dir), p.changedAt ? h('span', { class: 'muted small' }, ' · ' + t('br.changed', { when: ago(p.changedAt) })) : null),
1611
1642
  h('span', { class: 'br-acts' },
1643
+ h('button', { class: 'btn btn-sm', type: 'button', disabled: Boolean(ui.browserRef), 'aria-busy': busy ? 'true' : null, onclick: () => openBrowser(a, p) }, t('br.openIt')),
1612
1644
  chosen ? h('span', { class: 'tag', title: t('br.chosenHint') }, t('br.chosen'))
1613
- : h('button', { class: 'link-btn small', type: 'button', disabled: br.busy, title: t('br.chooseHint', { ref: a.ref }), onclick: () => brChoose(a, p.dir) }, t('br.choose')),
1614
- h('button', { class: 'btn btn-sm', type: 'button', disabled: Boolean(ui.browserRef), 'aria-busy': busy ? 'true' : null, onclick: () => openBrowser(a, p) }, t('br.openIt'))))
1645
+ : h('button', { class: 'link-btn small', type: 'button', disabled: br.busy, title: t('br.chooseHint', { ref: a.ref }), onclick: () => brChoose(a, p.dir) }, t('br.choose'))))
1615
1646
  }
1616
1647
  // Remembers the person's own choice for this account, or with null lets sideby find it again; sideby's config only.
1617
1648
  async function brChoose(a, dir) {
@@ -2788,6 +2819,7 @@ const MAIN = String.raw `
2788
2819
  const after = dlg.onClose
2789
2820
  dlg.kind = null
2790
2821
  dlg.onClose = null
2822
+ raiseToasts()
2791
2823
  if (after) after()
2792
2824
  })
2793
2825
  document.body.append(dlg.el)
@@ -2808,7 +2840,8 @@ const MAIN = String.raw `
2808
2840
  // A wide dialog is wide before it opens, so it does not open narrow and then stretch.
2809
2841
  el.classList.toggle('dialog-wide', kind === 'settings' ? el.classList.contains('dialog-wide') : kind === 'history')
2810
2842
  // A dialog that grows as the user adds to it (screenshots, its result) keeps its top edge and grows downward.
2811
- el.classList.toggle('dialog-top', kind === 'send')
2843
+ el.classList.toggle('dialog-top', kind === 'send' || kind === 'palette')
2844
+ el.classList.toggle('dialog-pal', kind === 'palette')
2812
2845
  if (!el.open) { el.showModal(); raiseToasts() }
2813
2846
  }
2814
2847
 
@@ -5716,7 +5749,7 @@ const MAIN = String.raw `
5716
5749
  b.setAttribute('aria-label', t('set.button') + (warn ? colon() + t('set.rcOn') : ''))
5717
5750
  refreshSettings()
5718
5751
  if (dlg.kind === 'rc') renderRc()
5719
- if (dlg.kind === 'net' && net && !net.busy) renderNet()
5752
+ if (dlg.kind === 'net' && net) renderNet()
5720
5753
  }
5721
5754
  // The settings live in two places (spec §3.29, 2026-10-20). The header popover holds only what people change
5722
5755
  // often, one click each and no explanations: language, theme, Auto Handoff, asking an AI, and "All settings…".
@@ -5735,8 +5768,8 @@ const MAIN = String.raw `
5735
5768
  function lookRows() {
5736
5769
  const secs = settingsSections()
5737
5770
  const out = []
5738
- if (secs.includes('lang')) out.push(setSeg(t('set.lang'), [['en', 'English'], ['zh', '中文']], lang, setLang))
5739
- if (secs.includes('theme')) out.push(setSeg(t('set.theme'), CHOICES.theme.map((v) => [v, t('set.theme.' + v)]), viewPrefs().theme, setTheme))
5771
+ if (secs.includes('lang')) out.push(fm('lang', setSeg(t('set.lang'), [['en', 'English'], ['zh', '中文']], lang, setLang)))
5772
+ if (secs.includes('theme')) out.push(fm('theme', setSeg(t('set.theme'), CHOICES.theme.map((v) => [v, t('set.theme.' + v)]), viewPrefs().theme, setTheme)))
5740
5773
  return out
5741
5774
  }
5742
5775
  function ahLink(leave) {
@@ -5756,33 +5789,33 @@ const MAIN = String.raw `
5756
5789
  function settingsGroups(leave) {
5757
5790
  const secs = settingsSections()
5758
5791
  const link = (...args) => setLink(leave, ...args)
5759
- const general = [...lookRows(), link(t('th.title'), themeLabel(), '', openThemes, true), autostartRow('autostart')]
5760
- if (!BOOT.readOnly) general.push(link(t('term.title'), '', '', openTerminals, true))
5792
+ const general = [...lookRows(), fm('themes', link(t('th.title'), themeLabel(), '', openThemes, true)), fm('autostart', autostartRow('autostart'))]
5793
+ if (!BOOT.readOnly) general.push(fm('terminal', link(t('term.title'), '', '', openTerminals, true)))
5761
5794
  // The menu bar switch shows only where it works (macOS); while its state loads it waits, unseen.
5762
5795
  const bar = []
5763
5796
  if (li.menubar.status && li.menubar.status.supported) {
5764
- bar.push(autostartRow('menubar'))
5797
+ bar.push(fm('menubar', autostartRow('menubar')))
5765
5798
  const mbs = li.menubar.status
5766
5799
  if ((mbs.state === 'on' || mbs.state === 'stale') && mbs.hotkey)
5767
- bar.push(link(t('mb.settings'), mbs.hotkey.enabled ? mbs.hotkey.label : t('hk.unset'), mbs.hotkey.registered === false ? 'chip-warn' : '', openMenubarSettings, true, 'mbset'))
5800
+ bar.push(fm('hotkey', link(t('mb.settings'), mbs.hotkey.enabled ? mbs.hotkey.label : t('hk.unset'), mbs.hotkey.registered === false ? 'chip-warn' : '', openMenubarSettings, true, 'mbset')))
5768
5801
  }
5769
5802
  const acct = []
5770
5803
  // The arrange mode (spec §3.25) has a place here too, where people look for "how do I change this".
5771
5804
  if (secs.includes('order')) {
5772
5805
  const d = displayOf()
5773
5806
  const pins = [d.pinned, d.hidden].some((r) => Object.values(r || {}).some((x) => x.length)) || Boolean(d.hiddenFamilies && d.hiddenFamilies.length)
5774
- acct.push(link(t('set.order'), t(ordered() || pins ? 'set.orderMine' : 'set.orderDefault'), '', () => {
5807
+ acct.push(fm('order', link(t('set.order'), t(ordered() || pins ? 'set.orderMine' : 'set.orderDefault'), '', () => {
5775
5808
  setPage('accounts')
5776
5809
  startArrange()
5777
5810
  const bar = document.querySelector('#accounts .arrange-bar')
5778
5811
  if (bar) bar.scrollIntoView({ behavior: REDUCED ? 'auto' : 'smooth', block: 'center' })
5779
- }))
5812
+ })))
5780
5813
  }
5781
5814
  if (pickFamilies().length) {
5782
5815
  const names = Object.keys(S.state.pickCommands || {})
5783
- acct.push(link(t('pk.title'), names.length ? names.join(', ') : t('pk.noneYet'), names.length ? 'chip-ok' : '', () => openPick(null), true))
5816
+ acct.push(fm('pick', link(t('pk.title'), names.length ? names.join(', ') : t('pk.noneYet'), names.length ? 'chip-ok' : '', () => openPick(null), true)))
5784
5817
  }
5785
- if (secs.includes('rc')) acct.push(rcLink(leave))
5818
+ if (secs.includes('rc')) acct.push(fm('rc', rcLink(leave)))
5786
5819
  // Quota checks that ask the Host (spec §3.26): one switch per Family under one shared explanation.
5787
5820
  const checks = []
5788
5821
  let every = 15
@@ -5790,11 +5823,13 @@ const MAIN = String.raw `
5790
5823
  for (const c of S.state.quotaChecks) {
5791
5824
  every = c.everyMinutes
5792
5825
  const label = t('set.quotaCheck', { host: c.title })
5793
- checks.push(h('div', { class: 'set-row' + (c.blocked ? ' set-check' : '') },
5826
+ // The first row is where the palette takes the user.
5827
+ const mark = checks.length ? (el) => el : (el) => fm('checks', el)
5828
+ checks.push(mark(h('div', { class: 'set-row' + (c.blocked ? ' set-check' : '') },
5794
5829
  h('div', { class: 'set-text' }, h('span', { class: 'set-label' }, c.title), c.blocked ? h('span', { class: 'set-hint' }, c.blocked) : null),
5795
5830
  BOOT.readOnly ? h('span', { class: 'chip chip-sm' + (c.on ? ' chip-ok' : '') }, c.on ? t('ah.on') : t('ah.off'))
5796
5831
  : h('div', { class: 'seg', role: 'group', 'aria-label': label }, [[true, t('ah.on')], [false, t('ah.off')]].map(([v, text]) =>
5797
- h('button', { class: 'seg-btn', type: 'button', 'aria-pressed': String(v === c.on), onclick: () => { if (v !== c.on) { leave(false); setCheck(c.family, v) } } }, text)))))
5832
+ h('button', { class: 'seg-btn', type: 'button', 'aria-pressed': String(v === c.on), onclick: () => { if (v !== c.on) { leave(false); setCheck(c.family, v) } } }, text))))))
5798
5833
  }
5799
5834
  }
5800
5835
  // Network Guard (spec §3.35): its own dialog, with the state on the link.
@@ -5802,10 +5837,10 @@ const MAIN = String.raw `
5802
5837
  if (secs.includes('net')) {
5803
5838
  const n = S.state.network
5804
5839
  const bad = netProblem()
5805
- netItems.push(link(t('net.title'), bad ? t('net.blocked') : n.guard ? t('ah.on') : t('ah.off'), bad ? 'chip-fail' : n.guard ? 'chip-ok' : '', openNet, true))
5840
+ netItems.push(fm('net', link(t('net.title'), bad ? t('net.blocked') : n.guard ? t('ah.on') : t('ah.off'), bad ? 'chip-fail' : n.guard ? 'chip-ok' : '', openNet, true)))
5806
5841
  }
5807
5842
  // Everything here can also be asked of an AI assistant through the sideby skill (spec §3.8).
5808
- const ai = [aiLink(leave), link(t('ask.plugin'), '', '', () => openAsk({ task: 'plugin', context: { version: BOOT.version } }), true)]
5843
+ const ai = [fm('skill', aiLink(leave)), link(t('ask.plugin'), '', '', () => openAsk({ task: 'plugin', context: { version: BOOT.version } }), true)]
5809
5844
  return [
5810
5845
  { id: 'general', title: t('set.g.general'), items: general },
5811
5846
  { id: 'menubar', title: t('set.g.menubar'), items: bar },
@@ -5841,15 +5876,21 @@ const MAIN = String.raw `
5841
5876
  const leave = (opens) => { if (!opens && dlg.kind === 'settings') dlg.el.close() }
5842
5877
  const groups = settingsGroups(leave)
5843
5878
  const cur = groups.find((g) => g.id === prefs.setSec) || groups[0]
5844
- const nav = h('div', { class: 'set-nav', role: 'tablist', 'aria-label': t('set.title') }, groups.map((g) =>
5879
+ const nav = h('div', { class: 'set-nav', role: 'tablist', 'aria-label': t('set.title'), 'data-patch': '' }, groups.map((g) =>
5845
5880
  h('button', { class: 'set-tab', type: 'button', role: 'tab', id: 'set-tab-' + g.id, 'aria-selected': String(g === cur), 'aria-controls': 'set-pane', onclick: () => { if (prefs.setSec === g.id || g === cur) return; prefs.setSec = g.id; savePrefs(); renderSettingsDialog(true) } }, g.title)))
5846
- const pane = h('div', { class: 'set-pane' + (switched ? ' view-in' : ''), id: 'set-pane', role: 'tabpanel', 'aria-labelledby': 'set-tab-' + cur.id },
5881
+ const pane = h('div', { class: 'set-pane' + (switched ? ' view-in' : ''), id: 'set-pane', role: 'tabpanel', 'aria-labelledby': 'set-tab-' + cur.id, 'data-patch': '' },
5847
5882
  h('h3', { class: 'set-pane-title' }, cur.title),
5848
5883
  cur.foot ? h('p', { class: 'set-foot' }, cur.foot) : null,
5849
- h('div', { class: 'set-group' }, cur.items))
5884
+ h('div', { class: 'set-group', 'data-patch': '' }, cur.items))
5885
+ // Gone once it has slid in, so the next refresh sees the same markup.
5886
+ if (switched) pane.addEventListener('animationend', () => pane.classList.remove('view-in'), { once: true })
5850
5887
  // It stays wide while it fades out; showDialog drops the width when another dialog takes the element.
5851
5888
  dlg.el.classList.add('dialog-wide')
5852
- setKids(dlg.el, dialogFrame(t('set.title'), null, h('div', { class: 'set-dialog' }, nav, pane)))
5889
+ // Patched in place: the refresh every few seconds redraws only what changed, and a list the user has open stays.
5890
+ const frame = dialogFrame(t('set.title'), null, h('div', { class: 'set-dialog', 'data-patch': '' }, nav, pane))
5891
+ frame[1].setAttribute('data-patch', '')
5892
+ if (switched) setKids(dlg.el, frame)
5893
+ else patch(dlg.el, frame)
5853
5894
  // A redraw replaced the list; a section picked from it keeps the focus on its tab.
5854
5895
  if (switched) { const tab = document.getElementById('set-tab-' + cur.id); if (tab) tab.focus() }
5855
5896
  }
@@ -5858,6 +5899,231 @@ const MAIN = String.raw `
5858
5899
  if (dlg.kind === 'settings') renderSettingsDialog()
5859
5900
  }
5860
5901
 
5902
+ // ---------- Command Palette (spec §3.36, ADR-0054) ----------
5903
+ // The Search button and Cmd/Ctrl+K open one list of pages, settings and actions from the Search Catalog that
5904
+ // sideby commands searches too. It finds features, never Sessions: the last row hands the words to Session History.
5905
+ // A setting opens where it lives and lights up; an action only opens its own preview or confirmation.
5906
+ const CATALOG = JSON.parse(document.getElementById('sideby-catalog').textContent)
5907
+ const PAL_RECENT_KEY = 'sideby.palette.recent'
5908
+ const PAL_SHOWN = 8
5909
+ const pal = { q: '', sel: 0, all: false, els: null, opts: [] }
5910
+ function palKey() { return /Mac|iPhone|iPad/.test(navigator.platform || '') ? '⌘K' : 'Ctrl K' }
5911
+ // Marks a row the palette can take the user to; the Search Catalog names it by this id.
5912
+ function fm(id, el) { if (id && el && el.setAttribute) el.setAttribute('data-find', id); return el }
5913
+ // The actions the catalog names. ok: whether this Panel has it now; nav: it goes to a page instead of a dialog.
5914
+ const PALETTE_ACTIONS = {
5915
+ 'new-account': { run: () => openCreate(null), ok: () => Boolean(S.state) },
5916
+ 'remote-control': { run: openRc, ok: () => Boolean(S.state && rcSummary()) },
5917
+ 'handoff-on': { run: () => setPage('handoff'), ok: () => Boolean(ahState()), nav: true },
5918
+ network: { run: openNet, ok: () => Boolean(netState()) },
5919
+ themes: { run: openThemes, ok: () => true },
5920
+ update: { run: openUpdate, ok: () => Boolean(BOOT.updates) },
5921
+ ask: { run: () => openAsk(), ok: () => !askBridged(BOOT, window) },
5922
+ health: { run: palHealth, ok: () => Boolean(S.state && S.state.accounts.length), nav: true },
5923
+ inbound: { run: openInbound, ok: () => Boolean(S.state) },
5924
+ }
5925
+ function palHealth() {
5926
+ setPage('accounts')
5927
+ const box = $('checkup')
5928
+ if (!box) return
5929
+ box.scrollIntoView({ behavior: REDUCED ? 'auto' : 'smooth', block: 'start' })
5930
+ palFlash(box)
5931
+ }
5932
+ function palRecent() {
5933
+ try {
5934
+ const v = JSON.parse(localStorage.getItem(PAL_RECENT_KEY) || '[]')
5935
+ return Array.isArray(v) ? v.filter((x) => typeof x === 'string').slice(0, 5) : []
5936
+ } catch { return [] }
5937
+ }
5938
+ function palRemember(id) {
5939
+ try { localStorage.setItem(PAL_RECENT_KEY, JSON.stringify([id].concat(palRecent().filter((x) => x !== id)).slice(0, 5))) } catch {}
5940
+ }
5941
+ // Which settings rows this Panel shows now (some depend on the machine, the accounts or a read-only Panel).
5942
+ function palFindable() {
5943
+ const found = new Set()
5944
+ for (const g of settingsGroups(() => {})) for (const it of g.items) {
5945
+ const f = it && it.getAttribute && it.getAttribute('data-find')
5946
+ if (f) found.add('s:' + g.id + ':' + f)
5947
+ }
5948
+ if (document.querySelector('#toolbar:not([hidden]) .tb-display'))
5949
+ for (const el of displayPanel().querySelectorAll('[data-find]')) found.add('d:' + el.getAttribute('data-find'))
5950
+ return found
5951
+ }
5952
+ function palAvailable(e, found) {
5953
+ const g = e.target
5954
+ if (g.page) return g.page === 'accounts' ? true : g.page === 'tuning' ? tuningAvailable() : g.page === 'handoff' ? Boolean(ahState()) : Boolean(S.state)
5955
+ if (g.settings) return found.has('s:' + g.settings + ':' + g.find)
5956
+ if (g.display) return found.has('d:' + g.display)
5957
+ const a = PALETTE_ACTIONS[g.action]
5958
+ return Boolean(a && a.ok())
5959
+ }
5960
+ function palWhyOff(e) { return e.target.action && e.target.write && BOOT.readOnly ? t('pal.readOnly') : '' }
5961
+ function openPalette() {
5962
+ if (dlg.el && dlg.el.open) return
5963
+ closeMenu()
5964
+ pal.q = ''
5965
+ pal.sel = 0
5966
+ pal.all = false
5967
+ pal.found = palFindable()
5968
+ showDialog('palette')
5969
+ const input = h('input', { type: 'search', class: 'pal-input', role: 'combobox', 'aria-expanded': 'true', 'aria-controls': 'pal-list', 'aria-autocomplete': 'list', autocomplete: 'off', spellcheck: 'false', placeholder: t('pal.placeholder'), 'aria-label': t('pal.title') })
5970
+ input.addEventListener('input', () => { pal.q = input.value; pal.sel = 0; pal.all = false; drawPalette() })
5971
+ input.addEventListener('keydown', palKeys)
5972
+ const list = h('div', { id: 'pal-list', class: 'pal-list', role: 'listbox', 'aria-label': t('pal.title') })
5973
+ pal.els = { input, list }
5974
+ setKids(dlg.el, [
5975
+ h('h2', { id: 'dlg-title', class: 'sr-only' }, t('pal.title')),
5976
+ h('div', { class: 'pal-head' }, icon('search', 'pal-ic'), input, h('kbd', { class: 'kbd-inline', 'aria-hidden': 'true' }, 'Esc')),
5977
+ list,
5978
+ h('div', { class: 'pal-foot muted small', 'aria-hidden': 'true' }, t('pal.keys')),
5979
+ ])
5980
+ drawPalette()
5981
+ input.focus()
5982
+ }
5983
+ // The title with the words the user typed marked; a match in the other language or a synonym is named under it.
5984
+ function palText(text, raw) {
5985
+ const q = raw ? catalogNorm(raw) : ''
5986
+ const i = q ? text.toLowerCase().indexOf(q) : -1
5987
+ if (i < 0) return [text]
5988
+ return [text.slice(0, i), h('mark', null, text.slice(i, i + q.length)), text.slice(i + q.length)].filter((x) => x !== '')
5989
+ }
5990
+ function palAlso(e, raw) {
5991
+ const q = raw ? catalogNorm(raw) : ''
5992
+ if (!q) return null
5993
+ const shown = e.title[lang] || e.title.en
5994
+ if (catalogNorm(shown).includes(q)) return null
5995
+ const w = [e.title.en, e.title.zh].concat(e.synonyms).find((x) => catalogNorm(x).includes(q))
5996
+ return w ? h('span', { class: 'pal-also' }, tx('pal.also', { w: h('mark', null, w) })) : null
5997
+ }
5998
+ function palRows() {
5999
+ const found = pal.found
6000
+ const ok = (e) => palAvailable(e, found)
6001
+ const byId = (id) => CATALOG.entries.find((e) => e.id === id)
6002
+ const q = pal.q.trim()
6003
+ if (!q) {
6004
+ const recent = palRecent().map(byId).filter((e) => e && ok(e))
6005
+ const common = CATALOG.common.map(byId).filter((e) => e && ok(e) && !recent.includes(e)).slice(0, 4)
6006
+ return { q, groups: [['recent', recent], ['common', common]].filter((g) => g[1].length), more: 0 }
6007
+ }
6008
+ const hits = searchCatalog(q, CATALOG.entries).map((x) => x.entry).filter(ok)
6009
+ const shown = pal.all ? hits : hits.slice(0, PAL_SHOWN)
6010
+ return { q, groups: shown.length ? [['results', shown]] : [], more: hits.length - shown.length }
6011
+ }
6012
+ function drawPalette() {
6013
+ if (!pal.els) return
6014
+ const r = palRows()
6015
+ const opts = []
6016
+ const kids = []
6017
+ const option = (cls, body, run, disabled) => {
6018
+ const i = opts.length
6019
+ const el = h('div', { class: 'pal-opt ' + cls, role: 'option', id: 'pal-opt-' + i, 'aria-selected': 'false', 'aria-disabled': disabled ? 'true' : null })
6020
+ setKids(el, body)
6021
+ el.addEventListener('mousemove', () => { if (pal.sel !== i) { pal.sel = i; palMark() } })
6022
+ el.addEventListener('click', () => { if (!disabled) run() })
6023
+ opts.push({ el, run, disabled })
6024
+ return el
6025
+ }
6026
+ for (const [g, list] of r.groups) {
6027
+ kids.push(h('div', { class: 'pal-group', role: 'presentation' }, t('pal.' + g)))
6028
+ for (const e of list) {
6029
+ const why = palWhyOff(e)
6030
+ kids.push(option('', [
6031
+ h('span', { class: 'pal-kind' }, t('pal.kind.' + e.kind) === 'pal.kind.' + e.kind ? e.kind : t('pal.kind.' + e.kind)),
6032
+ h('span', { class: 'pal-main' }, h('span', { class: 'pal-title' }, palText(e.title[lang] || e.title.en, r.q)), palAlso(e, r.q)),
6033
+ h('span', { class: 'pal-where' }, why || e.panel[lang] || e.panel.en),
6034
+ ], () => palGo(e), Boolean(why)))
6035
+ }
6036
+ }
6037
+ if (r.more > 0) kids.push(option('pal-more', [h('span', { class: 'pal-main' }, tn('pal.more', r.more))], () => { pal.all = true; drawPalette(); pal.els.input.focus() }))
6038
+ if (r.q && !r.groups.length) kids.push(h('p', { class: 'pal-none muted' }, t('pal.none')))
6039
+ if (r.q) {
6040
+ kids.push(option('pal-hist', [icon('search', 'pal-ic'), h('span', { class: 'pal-main' }, h('span', { class: 'pal-title' }, t('pal.history', { q: r.q }))), h('span', { class: 'pal-where' }, t('pal.historyHint'))], () => palHistory(r.q)))
6041
+ if (!r.groups.length && !BOOT.readOnly && PALETTE_ACTIONS.ask.ok())
6042
+ kids.push(option('pal-ai', [icon('bot', 'pal-ic'), h('span', { class: 'pal-main' }, h('span', { class: 'pal-title' }, t('pal.askAi', { q: r.q })))], () => openAsk({ text: t('pal.askText', { q: r.q }) })))
6043
+ }
6044
+ pal.opts = opts
6045
+ if (pal.sel >= opts.length) pal.sel = Math.max(0, opts.length - 1)
6046
+ pal.els.list.replaceChildren(...kids)
6047
+ palMark()
6048
+ }
6049
+ function palMark() {
6050
+ pal.opts.forEach((o, i) => o.el.setAttribute('aria-selected', String(i === pal.sel)))
6051
+ const cur = pal.opts[pal.sel]
6052
+ if (cur) { pal.els.input.setAttribute('aria-activedescendant', cur.el.id); cur.el.scrollIntoView({ block: 'nearest' }) }
6053
+ else pal.els.input.removeAttribute('aria-activedescendant')
6054
+ }
6055
+ function palKeys(e) {
6056
+ const n = pal.opts.length
6057
+ if (e.key === 'ArrowDown' && n) { e.preventDefault(); pal.sel = (pal.sel + 1) % n; palMark() }
6058
+ else if (e.key === 'ArrowUp' && n) { e.preventDefault(); pal.sel = (pal.sel - 1 + n) % n; palMark() }
6059
+ else if (e.key === 'Home' && n && !pal.q) { e.preventDefault(); pal.sel = 0; palMark() }
6060
+ else if (e.key === 'End' && n && !pal.q) { e.preventDefault(); pal.sel = n - 1; palMark() }
6061
+ else if (e.key === 'Enter') {
6062
+ e.preventDefault()
6063
+ const cur = pal.opts[pal.sel]
6064
+ if (cur && !cur.disabled) cur.run()
6065
+ } else if (e.key === 'Escape') {
6066
+ // Escape first empties the box, as the account search does; a second one closes.
6067
+ if (pal.q) { e.preventDefault(); pal.els.input.value = ''; pal.q = ''; pal.sel = 0; drawPalette() }
6068
+ }
6069
+ }
6070
+ function palClose() { pal.els = null; if (dlg.kind === 'palette') dlg.el.close() }
6071
+ // Lights a row up once it is in view, so the eye finds it; none under reduced motion.
6072
+ function palFlash(el) {
6073
+ if (REDUCED || !el) return
6074
+ el.classList.remove('find-flash')
6075
+ void el.offsetWidth
6076
+ el.classList.add('find-flash')
6077
+ setTimeout(() => el.classList.remove('find-flash'), 1300)
6078
+ }
6079
+ function palReveal(root, id) {
6080
+ const el = root && root.querySelector('[data-find="' + id + '"]')
6081
+ if (!el) return
6082
+ el.scrollIntoView({ block: 'nearest', behavior: REDUCED ? 'auto' : 'smooth' })
6083
+ const f = el.matches('button, input, select') ? el : el.querySelector('button[aria-pressed="true"]:not(:disabled), button:not(:disabled), input:not(:disabled), select:not(:disabled)')
6084
+ if (f) f.focus({ preventScroll: true })
6085
+ palFlash(el)
6086
+ }
6087
+ function palGo(e) {
6088
+ palRemember(e.id)
6089
+ const g = e.target
6090
+ pal.els = null
6091
+ if (g.page) { palClose(); setPage(g.page); window.scrollTo({ top: 0, behavior: REDUCED ? 'auto' : 'smooth' }); return }
6092
+ if (g.settings) {
6093
+ // The settings dialog takes the same dialog element, so it opens in place of the palette.
6094
+ openSettingsDialog(g.settings)
6095
+ requestAnimationFrame(() => palReveal(dlg.el, g.find))
6096
+ return
6097
+ }
6098
+ if (g.display) {
6099
+ palClose()
6100
+ setPage('accounts')
6101
+ requestAnimationFrame(() => {
6102
+ const b = document.querySelector('#toolbar .tb-display')
6103
+ if (!b) return
6104
+ if (menu.anchor !== b) b.click()
6105
+ palReveal(menu.el, g.display)
6106
+ })
6107
+ return
6108
+ }
6109
+ const a = PALETTE_ACTIONS[g.action]
6110
+ if (a.nav) palClose()
6111
+ a.run()
6112
+ // An action that opened nothing (such as a task handed to the Portal) leaves no palette behind.
6113
+ if (dlg.kind === 'palette') palClose()
6114
+ }
6115
+ // The words go to Session History's search box, which reads them as it does typed ones.
6116
+ function palHistory(q) {
6117
+ palClose()
6118
+ hs.q = q.trim()
6119
+ hs.mode = 'history'
6120
+ sp.drawn = ''
6121
+ if (hs.els) hs.els.q.value = hs.q
6122
+ if (hs.data || hs.error) historyChanged(false)
6123
+ else saveHistFilters()
6124
+ setPage('sessions')
6125
+ }
6126
+
5861
6127
  // ---------- start at login (spec §3.29, ADR-0029) and the Menu Bar Item (spec §3.31, ADR-0034) ----------
5862
6128
  // Each switch reads its state when the settings open; moving it shows the file and what will run, and only the
5863
6129
  // confirmation writes. A read-only Panel shows the state only. mb.* words override as.* for the menu bar.
@@ -6181,7 +6447,7 @@ const MAIN = String.raw `
6181
6447
  return Boolean(u && u.skillUpdate && u.skillUpdate.installed && u.skillUpdate.installed.length)
6182
6448
  }
6183
6449
  // Example phrases: a click puts one in the Let AI do it box (spec §3.28).
6184
- const AI_ASKS = ['ai.ask.quota', 'ai.ask.pick', 'ai.ask.new', 'ai.ask.api', 'ai.ask.pin', 'ai.ask.hide', 'ai.ask.relogin', 'ai.ask.fix', 'ai.ask.handoff', 'ai.ask.handoffRules', 'ai.ask.session', 'ai.ask.history', 'ai.ask.send', 'ai.ask.inbound', 'ai.ask.menubar', 'ai.ask.rc', 'ai.ask.network', 'ai.ask.theme', 'ai.ask.tool']
6450
+ const AI_ASKS = ['ai.ask.quota', 'ai.ask.pick', 'ai.ask.new', 'ai.ask.api', 'ai.ask.pin', 'ai.ask.hide', 'ai.ask.relogin', 'ai.ask.fix', 'ai.ask.handoff', 'ai.ask.handoffRules', 'ai.ask.session', 'ai.ask.history', 'ai.ask.send', 'ai.ask.inbound', 'ai.ask.menubar', 'ai.ask.rc', 'ai.ask.network', 'ai.ask.theme', 'ai.ask.find', 'ai.ask.tool']
6185
6451
  // Network Guard (spec §3.35): one dialog with the switch, the allowed countries and the newest result per address.
6186
6452
  // Countries are never ticked for the user, the current one included: a wrong network would allow itself.
6187
6453
  const NET_COMMON = ['US', 'JP', 'SG', 'GB', 'DE', 'FR', 'NL', 'CA', 'AU', 'KR', 'TW', 'HK']
@@ -6204,14 +6470,14 @@ const MAIN = String.raw `
6204
6470
  function openNet() {
6205
6471
  const n = netState()
6206
6472
  if (!n) return
6207
- net = { guard: n.guard, allow: [...n.allow], busy: false, checking: false }
6473
+ net = { guard: n.guard, allow: [...n.allow], checking: false }
6208
6474
  showDialog('net')
6209
6475
  renderNet()
6210
6476
  // Opening it answers "where am I now" at once, unless a result is fresh.
6211
6477
  if (!n.targets.some((x) => x.checkedAt && Date.now() - Date.parse(x.checkedAt) < 60000)) netCheck()
6212
6478
  }
6213
6479
  async function netCheck() {
6214
- if (!net) net = { guard: false, allow: [], busy: false, checking: false }
6480
+ if (!net) net = { guard: false, allow: [], checking: false }
6215
6481
  net.checking = true
6216
6482
  if (dlg.kind === 'net') renderNet()
6217
6483
  renderBanners()
@@ -6220,38 +6486,49 @@ const MAIN = String.raw `
6220
6486
  if (dlg.kind === 'net') renderNet()
6221
6487
  renderBanners()
6222
6488
  }
6223
- async function netSave() {
6224
- net.busy = true
6489
+ // Every change in the dialog applies at once, like a system setting, and its toast carries the undo. Changes are
6490
+ // saved one after another in the order clicked; a failed one puts the dialog back to what the config holds.
6491
+ let netSaving = Promise.resolve()
6492
+ function netApply(next, opts) {
6493
+ opts = opts || {}
6494
+ const prev = { guard: net.guard, allow: [...net.allow] }
6495
+ net.guard = next.guard
6496
+ net.allow = [...next.allow]
6225
6497
  renderNet()
6226
- try {
6227
- await api('/api/network/settings', { guard: net.guard, allow: net.allow, confirm: true })
6228
- toast(t(net.guard ? 'net.savedOn' : 'net.savedOff'))
6229
- await load({ silent: true })
6230
- if (dlg.kind === 'net') dlg.el.close()
6231
- } catch (e) { toast(e.message, { kind: 'fail' }) }
6232
- if (net) net.busy = false
6233
- if (dlg.kind === 'net') renderNet()
6498
+ netSaving = netSaving.then(async () => {
6499
+ try {
6500
+ await api('/api/network/settings', { guard: next.guard, allow: next.allow, confirm: true })
6501
+ await load({ silent: true })
6502
+ const text = opts.undone ? t('net.undone')
6503
+ : next.guard !== prev.guard ? t(next.guard ? 'net.savedOn' : 'net.savedOff')
6504
+ : t('net.savedAllow', { list: next.allow.length ? netList(next.allow.map(netCountry)) : t('net.none') })
6505
+ toast(text, opts.undone ? { key: 'net' } : { key: 'net', action: { label: t('toast.undo'), run: () => netApply(prev, { undone: true }) }, duration: 10000 })
6506
+ } catch (e) {
6507
+ toast(e.message, { kind: 'fail' })
6508
+ const n = netState()
6509
+ if (n && net) { net.guard = n.guard; net.allow = [...n.allow] }
6510
+ }
6511
+ if (dlg.kind === 'net') renderNet()
6512
+ })
6234
6513
  }
6235
6514
  function renderNet() {
6236
6515
  const n = netState()
6237
6516
  if (!n || !net) return
6238
6517
  const here = new Set(n.targets.map((x) => x.loc).filter(Boolean))
6239
6518
  const list = [...new Set([...NET_COMMON, ...net.allow, ...here])]
6240
- const changed = net.guard !== n.guard || net.allow.join() !== n.allow.join()
6241
- const toggle = (c) => {
6242
- net.allow = net.allow.includes(c) ? net.allow.filter((x) => x !== c) : [...net.allow, c]
6243
- renderNet()
6244
- }
6245
- const sw = h('div', { class: 'set-row' }, h('span', { class: 'set-label' }, t('net.switch')),
6246
- h('div', { class: 'seg', role: 'group', 'aria-label': t('net.switch') }, [[true, t('ah.on')], [false, t('ah.off')]].map(([v, text]) =>
6247
- h('button', { class: 'seg-btn', type: 'button', 'data-key': 'net-sw-' + v, disabled: BOOT.readOnly || net.busy || (v && !net.allow.length), 'aria-pressed': String(net.guard === v), onclick: () => { net.guard = v; renderNet() } }, text))))
6248
- const countries = h('div', { class: 'net-countries', role: 'group', 'aria-label': t('net.allow') }, list.map((c) =>
6249
- h('button', { class: 'net-cty', type: 'button', 'data-key': 'net-cty-' + c, disabled: BOOT.readOnly || net.busy, 'aria-pressed': String(net.allow.includes(c)), onclick: () => toggle(c) },
6519
+ const toggle = (c) => netApply({ guard: net.guard, allow: net.allow.includes(c) ? net.allow.filter((x) => x !== c) : [...net.allow, c] })
6520
+ // While it is on, the last country stays: taking it away would leave nothing allowed.
6521
+ const lastOne = (c) => net.guard && net.allow.length === 1 && net.allow[0] === c
6522
+ const sw = h('div', { class: 'set-row', 'data-patch': '' }, h('span', { class: 'set-label' }, t('net.switch')),
6523
+ h('div', { class: 'seg', role: 'group', 'aria-label': t('net.switch'), 'data-patch': '' }, [[true, t('ah.on')], [false, t('ah.off')]].map(([v, text]) =>
6524
+ h('button', { class: 'seg-btn', type: 'button', 'data-key': 'net-sw-' + v, disabled: BOOT.readOnly || (v && !net.allow.length), 'aria-pressed': String(net.guard === v), onclick: () => { if (net.guard !== v) netApply({ guard: v, allow: net.allow }) } }, text))))
6525
+ const countries = h('div', { class: 'net-countries', role: 'group', 'aria-label': t('net.allow'), 'data-patch': '' }, list.map((c) =>
6526
+ h('button', { class: 'net-cty', type: 'button', 'data-key': 'net-cty-' + c, disabled: BOOT.readOnly || lastOne(c), title: lastOne(c) ? t('net.keepOne') : null, 'aria-pressed': String(net.allow.includes(c)), onclick: () => toggle(c) },
6250
6527
  netCountry(c), here.has(c) ? h('span', { class: 'chip chip-sm' }, t('net.current')) : null)))
6251
6528
  const status = (x) => x.status === 'ok' ? ['chip-ok', t('net.ok')] : x.status === 'blocked' ? ['chip-fail', t('net.blocked')] : x.status === 'unknown' ? ['chip-fail', t('net.unknown')] : ['', t('net.notChecked')]
6252
6529
  const rows = n.targets.map((x) => {
6253
6530
  const [cls, label] = n.allow.length || x.status === 'not-checked' ? status(x) : ['', t('net.seen')]
6254
- return h('li', { class: 'rc-row' },
6531
+ return h('li', { class: 'rc-row', 'data-key': 'net-row-' + x.url },
6255
6532
  h('div', null, h('code', null, new URL(x.url).hostname), ' ', x.loc ? h('b', null, netCountry(x.loc)) : null, ' ', h('span', { class: 'chip chip-sm ' + cls }, label)),
6256
6533
  h('div', { class: 'muted small' }, [x.checkedAt ? t('net.checked', { when: ago(x.checkedAt) }) : null, x.error || null, x.accounts.join(', ')].filter(Boolean).join(' · ')),
6257
6534
  x.ipChanged ? h('div', { class: 'muted small' }, t('net.ipChanged')) : null)
@@ -6264,17 +6541,19 @@ const MAIN = String.raw `
6264
6541
  sw,
6265
6542
  h('div', { class: 'set-label' }, t('net.allow')),
6266
6543
  countries,
6267
- !net.allow.length ? h('p', { class: 'small muted', 'data-enter': 'net-pick' }, t(net.guard ? 'net.keepOne' : 'net.pickFirst')) : null,
6544
+ !net.allow.length ? h('p', { class: 'small muted', 'data-enter': 'net-pick' }, t('net.pickFirst')) : null,
6268
6545
  h('div', { class: 'set-row' }, h('span', { class: 'set-label' }, t('net.now')),
6269
6546
  h('button', { class: 'btn btn-sm', type: 'button', 'data-key': 'net-check', disabled: net.checking, 'aria-busy': net.checking ? 'true' : null, onclick: netCheck }, net.checking ? spinner() : icon('refresh'), t('net.recheck'))),
6270
- rows.length ? h('ul', { class: 'rc-list' }, rows) : h('p', { class: 'small muted' }, t('net.noTargets')),
6547
+ rows.length ? h('ul', { class: 'rc-list', 'data-patch': '' }, rows) : h('p', { class: 'small muted' }, t('net.noTargets')),
6271
6548
  skipped.length ? h('p', { class: 'small muted' }, t('net.skipped', { refs: skipped.map((a) => a.ref).join(', ') })) : null,
6272
6549
  h('p', { class: 'small muted' }, t('net.notCovered')),
6273
6550
  BOOT.readOnly ? h('p', { class: 'small' }, t('rc.readOnlyBoth')) : null,
6274
6551
  ]
6275
- const foot = [h('button', { class: 'btn', type: 'button', 'data-key': 'net-close', disabled: net.busy, onclick: () => dlg.el.close() }, t(changed ? 'btn.cancel' : 'btn.close'))]
6276
- if (!BOOT.readOnly && changed) foot.push(h('button', { class: 'btn btn-primary', type: 'button', 'data-key': 'net-save', 'data-enter': 'net-save', disabled: net.busy || (net.guard && !net.allow.length), 'aria-busy': net.busy ? 'true' : null, onclick: netSave }, net.busy ? spinner() : null, t('net.save')))
6277
- swapKids(dlg.el, dialogFrame(t('net.title'), null, body, foot))
6552
+ const foot = [h('button', { class: 'btn', type: 'button', 'data-key': 'net-close', onclick: () => dlg.el.close() }, t('btn.close'))]
6553
+ const frame = dialogFrame(t('net.title'), null, body, foot)
6554
+ // Patched in place, so the state refreshing every few seconds redraws only what changed (a row's "checked … ago").
6555
+ frame[1].setAttribute('data-patch', '')
6556
+ patchEnter(dlg.el, frame)
6278
6557
  }
6279
6558
  // Let AI do it (spec §3.28): the AI asks which countries, shows the change and writes it after the user agrees.
6280
6559
  function askNetwork() {
@@ -7704,6 +7983,14 @@ const MAIN = String.raw `
7704
7983
  $('ver-top').addEventListener('click', () => openVerPop($('ver-top')))
7705
7984
  $('refresh').addEventListener('click', refreshAll)
7706
7985
  $('ask-ai').addEventListener('click', () => openAsk())
7986
+ $('search-btn').addEventListener('click', () => openPalette())
7987
+ // Cmd/Ctrl+K opens the Command Palette from anywhere and closes it again; / and Cmd/Ctrl+F stay on the account search.
7988
+ document.addEventListener('keydown', (e) => {
7989
+ if (!(e.metaKey || e.ctrlKey) || e.altKey || e.shiftKey || (e.key !== 'k' && e.key !== 'K')) return
7990
+ if (dlg.el && dlg.el.open) { if (dlg.kind === 'palette') { e.preventDefault(); palClose() } return }
7991
+ e.preventDefault()
7992
+ openPalette()
7993
+ })
7707
7994
  // In a Portal that offers AI Tasks itself the Portal has the button; opened on its own, the Panel keeps it.
7708
7995
  $('ask-ai').hidden = askBridged(BOOT, window)
7709
7996
  $('accounts').addEventListener('dragover', onDragOver)