sideby 0.26.1 → 0.27.1

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,
@@ -1146,6 +1150,8 @@ const MAIN = String.raw `
1146
1150
  for (const el of document.querySelectorAll('[data-i18n]')) el.textContent = t(el.getAttribute('data-i18n'))
1147
1151
  $('refresh').setAttribute('aria-label', t('top.refresh'))
1148
1152
  $('ask-ai').setAttribute('aria-label', t('ask.button'))
1153
+ $('search-btn').setAttribute('aria-label', t('pal.button') + ' (' + palKey() + ')')
1154
+ $('search-kbd').textContent = palKey()
1149
1155
  const repo = $('repo')
1150
1156
  for (const k of ['aria-label', 'title']) repo.setAttribute(k, t('top.repo'))
1151
1157
  if (/^https:\/\/github\.com\//.test(BOOT.repoUrl || '')) { repo.href = BOOT.repoUrl; repo.hidden = false }
@@ -1270,13 +1276,13 @@ const MAIN = String.raw `
1270
1276
  const redo = () => { savePrefs(); renderAccounts(); refreshPopover('display') }
1271
1277
  const emails = S.state && S.state.accounts.some((a) => a.identity && a.identity.email)
1272
1278
  return h('div', { class: 'display-panel' },
1273
- h('div', { class: 'dp-row' }, h('span', { class: 'dp-label' }, t('tb.quota')),
1274
- seg(t('tb.quota'), [['used', t('tb.used')], ['left', t('tb.left')]], prefs.quota, (v) => { prefs.quota = v; redo() })),
1275
- h('div', { class: 'dp-row' }, h('span', { class: 'dp-label' }, t('tb.view')),
1276
- 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() })),
1277
- 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' },
1278
1284
  h('input', { type: 'checkbox', checked: prefs.hideEmail, onchange: (e) => { prefs.hideEmail = e.target.checked; redo() } }),
1279
- h('span', null, t('tb.hideEmails'))) : null)
1285
+ h('span', null, t('tb.hideEmails')))) : null)
1280
1286
  }
1281
1287
  function renderFamilyFilter() {
1282
1288
  if (!tb.family) return
@@ -1634,9 +1640,9 @@ const MAIN = String.raw `
1634
1640
  return h('li', { class: 'br-row' },
1635
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),
1636
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')),
1637
1644
  chosen ? h('span', { class: 'tag', title: t('br.chosenHint') }, t('br.chosen'))
1638
- : 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')),
1639
- 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'))))
1640
1646
  }
1641
1647
  // Remembers the person's own choice for this account, or with null lets sideby find it again; sideby's config only.
1642
1648
  async function brChoose(a, dir) {
@@ -2834,7 +2840,8 @@ const MAIN = String.raw `
2834
2840
  // A wide dialog is wide before it opens, so it does not open narrow and then stretch.
2835
2841
  el.classList.toggle('dialog-wide', kind === 'settings' ? el.classList.contains('dialog-wide') : kind === 'history')
2836
2842
  // A dialog that grows as the user adds to it (screenshots, its result) keeps its top edge and grows downward.
2837
- 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')
2838
2845
  if (!el.open) { el.showModal(); raiseToasts() }
2839
2846
  }
2840
2847
 
@@ -5761,8 +5768,8 @@ const MAIN = String.raw `
5761
5768
  function lookRows() {
5762
5769
  const secs = settingsSections()
5763
5770
  const out = []
5764
- if (secs.includes('lang')) out.push(setSeg(t('set.lang'), [['en', 'English'], ['zh', '中文']], lang, setLang))
5765
- 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)))
5766
5773
  return out
5767
5774
  }
5768
5775
  function ahLink(leave) {
@@ -5782,33 +5789,33 @@ const MAIN = String.raw `
5782
5789
  function settingsGroups(leave) {
5783
5790
  const secs = settingsSections()
5784
5791
  const link = (...args) => setLink(leave, ...args)
5785
- const general = [...lookRows(), link(t('th.title'), themeLabel(), '', openThemes, true), autostartRow('autostart')]
5786
- 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)))
5787
5794
  // The menu bar switch shows only where it works (macOS); while its state loads it waits, unseen.
5788
5795
  const bar = []
5789
5796
  if (li.menubar.status && li.menubar.status.supported) {
5790
- bar.push(autostartRow('menubar'))
5797
+ bar.push(fm('menubar', autostartRow('menubar')))
5791
5798
  const mbs = li.menubar.status
5792
5799
  if ((mbs.state === 'on' || mbs.state === 'stale') && mbs.hotkey)
5793
- 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')))
5794
5801
  }
5795
5802
  const acct = []
5796
5803
  // The arrange mode (spec §3.25) has a place here too, where people look for "how do I change this".
5797
5804
  if (secs.includes('order')) {
5798
5805
  const d = displayOf()
5799
5806
  const pins = [d.pinned, d.hidden].some((r) => Object.values(r || {}).some((x) => x.length)) || Boolean(d.hiddenFamilies && d.hiddenFamilies.length)
5800
- 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'), '', () => {
5801
5808
  setPage('accounts')
5802
5809
  startArrange()
5803
5810
  const bar = document.querySelector('#accounts .arrange-bar')
5804
5811
  if (bar) bar.scrollIntoView({ behavior: REDUCED ? 'auto' : 'smooth', block: 'center' })
5805
- }))
5812
+ })))
5806
5813
  }
5807
5814
  if (pickFamilies().length) {
5808
5815
  const names = Object.keys(S.state.pickCommands || {})
5809
- 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)))
5810
5817
  }
5811
- if (secs.includes('rc')) acct.push(rcLink(leave))
5818
+ if (secs.includes('rc')) acct.push(fm('rc', rcLink(leave)))
5812
5819
  // Quota checks that ask the Host (spec §3.26): one switch per Family under one shared explanation.
5813
5820
  const checks = []
5814
5821
  let every = 15
@@ -5816,11 +5823,13 @@ const MAIN = String.raw `
5816
5823
  for (const c of S.state.quotaChecks) {
5817
5824
  every = c.everyMinutes
5818
5825
  const label = t('set.quotaCheck', { host: c.title })
5819
- 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' : '') },
5820
5829
  h('div', { class: 'set-text' }, h('span', { class: 'set-label' }, c.title), c.blocked ? h('span', { class: 'set-hint' }, c.blocked) : null),
5821
5830
  BOOT.readOnly ? h('span', { class: 'chip chip-sm' + (c.on ? ' chip-ok' : '') }, c.on ? t('ah.on') : t('ah.off'))
5822
5831
  : h('div', { class: 'seg', role: 'group', 'aria-label': label }, [[true, t('ah.on')], [false, t('ah.off')]].map(([v, text]) =>
5823
- 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))))))
5824
5833
  }
5825
5834
  }
5826
5835
  // Network Guard (spec §3.35): its own dialog, with the state on the link.
@@ -5828,10 +5837,10 @@ const MAIN = String.raw `
5828
5837
  if (secs.includes('net')) {
5829
5838
  const n = S.state.network
5830
5839
  const bad = netProblem()
5831
- 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)))
5832
5841
  }
5833
5842
  // Everything here can also be asked of an AI assistant through the sideby skill (spec §3.8).
5834
- 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)]
5835
5844
  return [
5836
5845
  { id: 'general', title: t('set.g.general'), items: general },
5837
5846
  { id: 'menubar', title: t('set.g.menubar'), items: bar },
@@ -5890,6 +5899,231 @@ const MAIN = String.raw `
5890
5899
  if (dlg.kind === 'settings') renderSettingsDialog()
5891
5900
  }
5892
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
+
5893
6127
  // ---------- start at login (spec §3.29, ADR-0029) and the Menu Bar Item (spec §3.31, ADR-0034) ----------
5894
6128
  // Each switch reads its state when the settings open; moving it shows the file and what will run, and only the
5895
6129
  // confirmation writes. A read-only Panel shows the state only. mb.* words override as.* for the menu bar.
@@ -6213,7 +6447,7 @@ const MAIN = String.raw `
6213
6447
  return Boolean(u && u.skillUpdate && u.skillUpdate.installed && u.skillUpdate.installed.length)
6214
6448
  }
6215
6449
  // Example phrases: a click puts one in the Let AI do it box (spec §3.28).
6216
- 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']
6217
6451
  // Network Guard (spec §3.35): one dialog with the switch, the allowed countries and the newest result per address.
6218
6452
  // Countries are never ticked for the user, the current one included: a wrong network would allow itself.
6219
6453
  const NET_COMMON = ['US', 'JP', 'SG', 'GB', 'DE', 'FR', 'NL', 'CA', 'AU', 'KR', 'TW', 'HK']
@@ -7374,7 +7608,14 @@ const MAIN = String.raw `
7374
7608
  const skillOld = (u) => !!(u && !u.available && !isLocal(u) && u.skillUpdate && u.skillUpdate.outdated)
7375
7609
  const skillDue = (u) => skillOld(u) && u.skillUpdate.canRun
7376
7610
  function skillFor(u) {
7377
- const v = u.skillUpdate.installed.find((x) => x !== u.current)
7611
+ // Only a skill for an older sideby is behind; one for a newer sideby means the CLI is the one to update.
7612
+ const older = (a, b) => {
7613
+ const p = (x) => String(x).split(/[.+-]/).slice(0, 3).map(Number)
7614
+ const x = p(a), y = p(b)
7615
+ for (let i = 0; i < 3; i++) if (x[i] !== y[i]) return x[i] < y[i]
7616
+ return false
7617
+ }
7618
+ const v = u.skillUpdate.installed.find((x) => x !== u.current && (x === null || older(x, u.current)))
7378
7619
  return v ? v : t('upd.skillNoVer')
7379
7620
  }
7380
7621
  // Why sideby cannot do something itself, in the viewer's language; the English reason when the code is unknown.
@@ -7480,6 +7721,12 @@ const MAIN = String.raw `
7480
7721
  openPopover(anchor, 'version', t('upd.title'), verPopKids)
7481
7722
  }
7482
7723
  function renderVerPop() { refreshPopover('version') }
7724
+ // Where an update fails (spec §3.28): the AI checks the network, the proxy and the install method, and fixes them.
7725
+ function updAskKids(err) {
7726
+ if (BOOT.readOnly) return []
7727
+ const go = () => { closeMenu(); if (dlg.el && dlg.el.open) dlg.el.close(); openAsk({ task: 'update', context: { updateError: err.message, version: BOOT.version } }) }
7728
+ return [h('p', { class: 'small', 'data-enter': 'upd-ai' }, h('button', { class: 'link-btn small', type: 'button', onclick: go }, icon('bot'), ' ', t('upd.askAi')))]
7729
+ }
7483
7730
  // A Local Build (ADR-0024) names its commit, with + when the working tree had changes, so the viewer can tell
7484
7731
  // which code they are looking at.
7485
7732
  function verLabel() {
@@ -7511,7 +7758,7 @@ const MAIN = String.raw `
7511
7758
  kids.push(h('div', { class: 'popover-actions' }, h('button', { class: 'btn btn-sm', type: 'button', disabled: vp.checking, 'aria-busy': vp.checking ? 'true' : null, onclick: verPopCheck },
7512
7759
  vp.checking ? spinner() : icon('refresh'), vp.checking ? t('upd.checking') : t('upd.check'))))
7513
7760
  }
7514
- if (vp.error) kids.push(errorNote(vp.error, null))
7761
+ if (vp.error) kids.push(errorNote(vp.error, null), ...updAskKids(vp.error))
7515
7762
  const sw = localSwitchKids(u)
7516
7763
  if (sw) kids.push(sw)
7517
7764
  if (u && !BOOT.readOnly && !isLocal(u))
@@ -7729,7 +7976,7 @@ const MAIN = String.raw `
7729
7976
  h('button', { class: 'btn btn-sm btn-primary', type: 'button', disabled: up.autoBusy, onclick: updAutoSave }, t('upd.save'))))
7730
7977
  }
7731
7978
  if (BOOT.readOnly) body.push(h('p', { class: 'note' }, t('banner.readOnly')))
7732
- if (up.error) body.push(errorNote(up.error, null))
7979
+ if (up.error) body.push(errorNote(up.error, null), ...updAskKids(up.error))
7733
7980
  const foot = [h('button', { class: 'btn', type: 'button', disabled: up.busy, onclick: () => dlg.el.close() }, t('btn.close'))]
7734
7981
  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)
7735
7982
  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')))
@@ -7749,6 +7996,14 @@ const MAIN = String.raw `
7749
7996
  $('ver-top').addEventListener('click', () => openVerPop($('ver-top')))
7750
7997
  $('refresh').addEventListener('click', refreshAll)
7751
7998
  $('ask-ai').addEventListener('click', () => openAsk())
7999
+ $('search-btn').addEventListener('click', () => openPalette())
8000
+ // Cmd/Ctrl+K opens the Command Palette from anywhere and closes it again; / and Cmd/Ctrl+F stay on the account search.
8001
+ document.addEventListener('keydown', (e) => {
8002
+ if (!(e.metaKey || e.ctrlKey) || e.altKey || e.shiftKey || (e.key !== 'k' && e.key !== 'K')) return
8003
+ if (dlg.el && dlg.el.open) { if (dlg.kind === 'palette') { e.preventDefault(); palClose() } return }
8004
+ e.preventDefault()
8005
+ openPalette()
8006
+ })
7752
8007
  // In a Portal that offers AI Tasks itself the Portal has the button; opened on its own, the Panel keeps it.
7753
8008
  $('ask-ai').hidden = askBridged(BOOT, window)
7754
8009
  $('accounts').addEventListener('dragover', onDragOver)
@@ -1294,6 +1294,33 @@ select:is(:hover, :focus) { --chevron: var(--text); }
1294
1294
  .hide-btn .ic { width: 16px; height: 16px; }
1295
1295
  .hide-btn.is-on { color: var(--muted); }
1296
1296
  .hide-btn:disabled { opacity: .4; cursor: not-allowed; }
1297
+
1298
+ /* Command Palette (spec §3.36): a search box over one list; the dialog keeps its top edge while the list changes. */
1299
+ .kbd-inline { font: 11px/16px var(--mono); color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; margin-left: 2px; }
1300
+ .dialog.dialog-pal { width: min(620px, calc(100vw - 24px)); flex-direction: column; }
1301
+ .pal-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
1302
+ .pal-ic { flex: none; color: var(--muted); }
1303
+ .dialog .pal-input, .dialog .pal-input:focus, .dialog .pal-input:focus-visible { flex: 1; min-width: 0; height: 32px; padding: 0; border: 0; box-shadow: none; outline: none; background: none; color: var(--text); font: inherit; font-size: var(--large); outline: none; }
1304
+ .pal-input::-webkit-search-cancel-button { display: none; }
1305
+ .pal-list { overflow-y: auto; overscroll-behavior: contain; padding: 6px; display: flex; flex-direction: column; gap: 1px; max-height: min(56vh, 460px); }
1306
+ .pal-group { padding: 8px 10px 4px; font-size: 11px; font-weight: 600; color: var(--muted); }
1307
+ .pal-opt { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 5px 10px; border-radius: calc(var(--ctl-radius) - 2px); color: var(--text); cursor: pointer; transition: background-color .12s ease; }
1308
+ .pal-opt[aria-selected=true] { background: var(--hover); }
1309
+ .pal-opt[aria-disabled=true] { color: var(--faint); cursor: not-allowed; }
1310
+ .pal-kind { flex: none; min-width: 52px; font-size: 11px; line-height: 18px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0 7px; text-align: center; }
1311
+ .pal-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
1312
+ .pal-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
1313
+ .pal-also { font-size: 11px; color: var(--muted); }
1314
+ .pal-where { flex: none; max-width: 42%; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
1315
+ .pal-opt mark { background: var(--accent-soft); color: inherit; border-radius: 2px; padding: 0 1px; }
1316
+ .pal-more .pal-main, .pal-hist .pal-title, .pal-ai .pal-title { color: var(--accent); }
1317
+ .pal-hist { margin-top: 4px; }
1318
+ .pal-none { padding: 14px 10px 4px; margin: 0; }
1319
+ .pal-foot { padding: 8px 16px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
1320
+ [data-width=narrow] .pal-where, [data-width=narrow] .pal-foot { display: none; }
1321
+ .find-flash { animation: find-flash 1.2s ease-out; border-radius: var(--ctl-radius); }
1322
+ @keyframes find-flash { 0%, 35% { box-shadow: 0 0 0 6px var(--accent-soft); background: var(--accent-soft); } to { box-shadow: 0 0 0 6px transparent; background: transparent; } }
1323
+ @media (prefers-reduced-motion: reduce) { .find-flash { animation: none; } .pal-opt { transition: none; } }
1297
1324
  @media (prefers-reduced-motion: reduce) {
1298
1325
  .sk, .spin, .hidden-bar, .is-spinning svg, .toast, .toast.bump, .toast.toast-out, .view-in > *, .set-pane.view-in, .row.flash, .sess-row.flash, .sess-msg, .seg-badge, .card.flash, .pulse, .sess-busy .sess-dot, .menu, .menu.float-out, .dialog[open], .dialog[open]::backdrop, .enter, .fade-in, .hist-list.swap-in, .tip-body, .tip-float, .row-run.is-done .ic, .tab[aria-selected=true]::after { animation: none; }
1299
1326
  .bar > span, .chev, .row, .sess-row, .sess-copy, .hist-row, .hist-cont, .hist-proj, .hist-catbody, .hist-opt, .hist-list, .icon-btn, .seg-btn, .menu-item, .set-tab, .link-btn, .tag-btn, .email-btn, .btn, .chip-btn, .set-link .ic, .dialog, .dialog[open], .dialog::backdrop, .tab, .tab::before, .tab .ic, .hp-status { transition: none; }
@@ -5,6 +5,7 @@ import { createHash } from 'node:crypto';
5
5
  import { FAVICON_SVG, MARK_SVG } from '../core/brand-mark.js';
6
6
  import { ALIAS_NAME, RESERVED_ALIASES } from '../core/config.js';
7
7
  import { QUOTA_FAIL_PERCENT, QUOTA_WARN_PERCENT, USAGE_DAYS } from '../core/quota-levels.js';
8
+ import { COMMON_ENTRIES, SEARCH_CATALOG } from '../core/search-catalog.js';
8
9
  import { REPO_URL, SKILL_INSTALL } from '../core/skill-check.js';
9
10
  import { MESSAGES } from './i18n.js';
10
11
  import { widthTier } from './page-logic.js';
@@ -90,6 +91,7 @@ export function renderPage(opts) {
90
91
  </div>
91
92
  <div class="top-actions">
92
93
  <button id="update" class="btn update-btn" type="button" hidden></button>
94
+ <button id="search-btn" class="btn" type="button" aria-haspopup="dialog" aria-label="Search"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14zM20 20l-4.2-4.2"/></svg><span class="hide-sm" data-i18n="pal.button">Search</span><kbd id="search-kbd" class="kbd-inline hide-sm" aria-hidden="true"></kbd></button>
93
95
  <button id="ask-ai" class="btn" type="button" aria-haspopup="dialog" aria-label="Let AI do it"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 9h12a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-6a2 2 0 0 1 2-2zM12 5v4M9.5 13.5v1M14.5 13.5v1"/></svg><span class="hide-sm" data-i18n="ask.button">Let AI do it</span></button>
94
96
  <a id="repo" class="icon-btn repo-link" target="_blank" rel="noopener noreferrer" aria-label="sideby on GitHub" title="sideby on GitHub" hidden><svg viewBox="0 0 24 24" aria-hidden="true"><path d="${GITHUB_MARK}"/></svg></a>
95
97
  <button id="settings" class="btn" type="button" aria-haspopup="dialog" aria-expanded="false"${lang === 'auto' ? '' : ' hidden'}><span data-i18n="set.button">Settings</span></button>
@@ -118,6 +120,7 @@ export function renderPage(opts) {
118
120
  <div id="conn" class="conn" role="status" hidden></div>
119
121
  <div id="toasts" class="toasts" aria-live="polite" popover="manual"></div>
120
122
  <script type="application/json" id="sideby-boot">${boot}</script>
123
+ <script type="application/json" id="sideby-catalog">${jsonForScript({ entries: SEARCH_CATALOG, common: COMMON_ENTRIES })}</script>
121
124
  <script type="application/json" id="sideby-i18n">${jsonForScript(MESSAGES)}</script>
122
125
  <script${nonce}>${PAGE_SCRIPT}</script>
123
126
  </body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sideby",
3
- "version": "0.26.1",
3
+ "version": "0.27.1",
4
4
  "description": "Run work, personal and API-key accounts at the same time, without their configs drifting apart.",
5
5
  "license": "MIT",
6
6
  "author": "Adonis0123 (https://github.com/Adonis0123)",
@@ -0,0 +1,117 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "sideby/commands.json",
4
+ "type": "object",
5
+ "required": [
6
+ "schemaVersion",
7
+ "results"
8
+ ],
9
+ "properties": {
10
+ "schemaVersion": {
11
+ "type": "number",
12
+ "const": 1
13
+ },
14
+ "results": {
15
+ "type": "array",
16
+ "items": {
17
+ "type": "object",
18
+ "required": [
19
+ "id",
20
+ "kind",
21
+ "title",
22
+ "panel",
23
+ "cliCommand"
24
+ ],
25
+ "properties": {
26
+ "id": {
27
+ "type": "string"
28
+ },
29
+ "kind": {
30
+ "type": "string",
31
+ "description": "'page', 'setting' or 'action'; an open set, so tolerate others."
32
+ },
33
+ "title": {
34
+ "type": "string"
35
+ },
36
+ "panel": {
37
+ "type": "string",
38
+ "description": "Where it lives in the Panel, such as \"Settings → General → Language\"."
39
+ },
40
+ "cliCommand": {
41
+ "anyOf": [
42
+ {
43
+ "type": "string"
44
+ },
45
+ {
46
+ "type": "null"
47
+ }
48
+ ]
49
+ }
50
+ }
51
+ }
52
+ },
53
+ "_notice": {
54
+ "type": "object",
55
+ "properties": {
56
+ "update": {
57
+ "type": "object",
58
+ "required": [
59
+ "current",
60
+ "latest",
61
+ "command",
62
+ "message"
63
+ ],
64
+ "properties": {
65
+ "current": {
66
+ "type": "string"
67
+ },
68
+ "latest": {
69
+ "type": "string"
70
+ },
71
+ "command": {
72
+ "type": "string",
73
+ "description": "Run it after the user agrees: it shows the plan and exits 10; then --yes."
74
+ },
75
+ "message": {
76
+ "type": "string"
77
+ }
78
+ }
79
+ },
80
+ "skill": {
81
+ "type": "object",
82
+ "required": [
83
+ "installed",
84
+ "current",
85
+ "command",
86
+ "message"
87
+ ],
88
+ "properties": {
89
+ "installed": {
90
+ "anyOf": [
91
+ {
92
+ "type": "string"
93
+ },
94
+ {
95
+ "type": "null"
96
+ }
97
+ ],
98
+ "description": "The skill's version; null when it has none."
99
+ },
100
+ "current": {
101
+ "type": "string"
102
+ },
103
+ "command": {
104
+ "type": "string",
105
+ "description": "`sideby update`, which updates the skill with sideby: run it after the user agrees; it shows the plan and exits 10, then --yes."
106
+ },
107
+ "message": {
108
+ "type": "string"
109
+ }
110
+ }
111
+ }
112
+ },
113
+ "description": "Not the answer to the task: mention it briefly afterwards and offer to update."
114
+ }
115
+ },
116
+ "title": "sideby commands --json"
117
+ }