sideby 0.35.0 → 0.35.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.
@@ -5,7 +5,10 @@ import { groupsToAccept } from '../core/inbound.js';
5
5
  import { quotaIsStale } from '../core/quota-levels.js';
6
6
  import { remoteControlTodo } from '../core/remote-control.js';
7
7
  import { catalogMatchLevel, catalogNorm, searchCatalog } from '../core/search-catalog.js';
8
- import { accountTitle, aiTaskAccounts, aliasArgsOf, aliasIssue, aliasPrefix, 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, longWindow, maskEmail, matchesQuery, mdBlocks, mdInline, menuPlacement, mergeDaily, mergeUsage, messageChip, messageNews, messageToCheck, networkTaskFacts, newAccountDir, nextReset, orderedAliases, panelFixes, panelHint, panelLang, panelMigration, panelPrefs, passedWindow, pinnedIn, quotaAskable, quotaHighLevel, quotaPressure, radioStep, reloadForBuild, remoteControlSummary, reorder, resetWhen, rowBadge, runCodeSwap, saveHandoffChange, sendBlock, sendFileProblem, sendResultView, sessionAge, sessionLabelParts, sessionRowShape, shortCwd, shortSessionLabel, sortAccounts, sortSessions, steadyOrder, stripSecrets, suggestAlias, suggestName, switchFailure, tailInView, taskFindings, uaDayRuns, uaGroupPending, uaOnChoices, uaParseClock, uaPickTime, uaSameSlot, uaShouldRead, uaSlotNight, uaStatusParts, uaStepClock, uaToggleDay, uaWaitingCount, uaWhen, updatedAge, vendorAlias, widthFollower, widthTier, windowState, withPinned, } from './page-logic.js';
8
+ import { accountTitle, aiTaskAccounts, aliasArgsOf, aliasIssue, aliasPrefix, 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, longWindow, maskEmail, matchesQuery, mdBlocks, mdInline, menuPlacement, mergeDaily, mergeUsage, messageChip, messageNews, messageToCheck, networkTaskFacts, newAccountDir, nextReset, orderedAliases, panelFixes, panelHint, panelLang, panelMigration, panelPrefs, passedWindow, pinnedIn, quotaAskable, quotaHighLevel, quotaPressure, radioStep, reloadForBuild, remoteControlSummary, reorder, resetWhen, rowBadge, runCodeSwap, saveHandoffChange, sendBlock, sendFileProblem, sendResultView, sessionAge, sessionLabelParts, sessionRowShape, shortCwd, shortSessionLabel, sortAccounts, sortMenu, sortSessions, steadyOrder, stripSecrets, suggestAlias, suggestName, switchFailure, tailInView, taskFindings, uaDayRuns, uaGroupPending, uaOnChoices, uaParseClock, uaPickTime, uaSameSlot, uaShouldRead, uaSlotNight, uaStatusParts, uaStepClock, uaToggleDay, uaWaitingCount, uaWhen, updatedAge, vendorAlias, widthFollower, widthTier, windowState, withPinned, } from './page-logic.js';
9
+ // The component library's dropdown menu, copied by the brand repo's add script (--html into ui/); do not edit it.
10
+ import { CHECK, menuItem, menuScript } from './ui/dropdown-menu/dropdown-menu.html.js';
11
+ import { cn, esc } from './ui/lib/cn.js';
9
12
  const LOGIC = [
10
13
  quotaIsStale,
11
14
  catalogNorm,
@@ -80,6 +83,7 @@ const LOGIC = [
80
83
  saveHandoffChange,
81
84
  enableOutcome,
82
85
  reorder,
86
+ sortMenu,
83
87
  rowBadge,
84
88
  sendBlock,
85
89
  sendFileProblem,
@@ -122,6 +126,13 @@ const LOGIC = [
122
126
  ]
123
127
  .map((fn) => fn.toString())
124
128
  .join('\n');
129
+ // The menu item markup of the component library, so the pickers (selectMenu) draw the same items as its other pages.
130
+ const MENU_LIB = [
131
+ `const CHECK = ${JSON.stringify(CHECK)}`,
132
+ `const esc = ${esc.toString()}`,
133
+ cn.toString(),
134
+ menuItem.toString(),
135
+ ].join('\n');
125
136
  const MAIN = String.raw `
126
137
  const BOOT = JSON.parse(document.getElementById('sideby-boot').textContent)
127
138
  const MESSAGES = JSON.parse(document.getElementById('sideby-i18n').textContent)
@@ -310,6 +321,91 @@ const MAIN = String.raw `
310
321
  if (Array.isArray(kid)) { for (const k of kid) add(el, k); return }
311
322
  el.append(kid instanceof Node ? kid : document.createTextNode(String(kid)))
312
323
  }
324
+ // A picker in place of a native select: a field-like button that opens the component library's single-choice menu
325
+ // (menuItem; menuScript moves focus with Up, Down, Home and End, and puts the checked item in view; Enter picks, Esc
326
+ // closes). It keeps the select interface the page uses: h('option') children (also through replaceChildren), .value,
327
+ // a 'change' event (or an onchange prop), hidden, disabled and focus(). id, data-key and aria-label go on the button,
328
+ // so a <label for> still names and opens it. Beyond a select: an h('optgroup', { label }) puts a heading over its
329
+ // options, an h('hr') a line between items, data-meta grey words at an option's end and data-button shorter or longer
330
+ // words on the button than in the menu. An option with data-action (and data-icon) is an action, not a choice: it
331
+ // never holds the check or changes .value, and fires an 'action' event (or the onaction prop) with its value. An
332
+ // option with data-placeholder ("Add account…") is not a choice either: its words show, greyed, on the button while
333
+ // nothing is picked (.value ''), and it is not in the menu, so nothing there is checked.
334
+ let selectSeq = 0
335
+ function selectMenu(props, ...kids) {
336
+ const p = Object.assign({}, props)
337
+ const id = 'select-menu-' + (++selectSeq)
338
+ const onchange = p.onchange
339
+ const onaction = p.onaction
340
+ delete p.onchange
341
+ delete p.onaction
342
+ const text = h('span', { class: 'select-text' })
343
+ const btn = h('button', Object.assign(p, { type: 'button', class: 'select-btn' + (p.class ? ' ' + p.class : ''), popovertarget: id, 'aria-haspopup': 'menu' }), text)
344
+ const list = h('div', { popover: 'auto', id, role: 'menu', class: 'ui-menu', 'aria-label': p['aria-label'] || null })
345
+ const wrap = h('span', { class: 'select-wrap' }, btn, list)
346
+ let opts = []
347
+ let cur = ''
348
+ let drawn = ''
349
+ let placeholder = ''
350
+ // Only the choices carry aria-checked: a heading, a line or an action never shows the check.
351
+ const mark = () => {
352
+ for (const it of list.querySelectorAll('[role="menuitemradio"]')) it.setAttribute('aria-checked', String(it.getAttribute('data-value') === cur))
353
+ const on = opts.find((o) => o.value === cur)
354
+ text.textContent = on ? on.button : placeholder
355
+ btn.classList.toggle('is-placeholder', !on && Boolean(placeholder))
356
+ }
357
+ const setOptions = (nodes) => {
358
+ opts = []
359
+ placeholder = ''
360
+ const parts = []
361
+ const walk = (n) => {
362
+ if (Array.isArray(n)) n.forEach(walk)
363
+ else if (!n || !n.tagName) return
364
+ else if (n.tagName === 'OPTGROUP') { parts.push('<div class="ui-menu-label" role="presentation">' + esc(n.label) + '</div>'); walk(Array.from(n.children)) }
365
+ else if (n.tagName === 'OPTION' && n.hasAttribute('data-placeholder')) placeholder = n.textContent
366
+ else if (n.tagName === 'HR') parts.push('<hr class="ui-menu-separator" role="separator">')
367
+ else if (n.tagName === 'OPTION' && n.hasAttribute('data-action')) {
368
+ const ic = n.getAttribute('data-icon')
369
+ parts.push(menuItem({ label: n.textContent, icon: ic ? icon(ic).outerHTML : undefined, attrs: 'data-action="' + esc(n.value) + '"' }, id))
370
+ } else if (n.tagName === 'OPTION') {
371
+ const o = { value: n.value, label: n.textContent, button: n.getAttribute('data-button') || n.textContent, selected: n.hasAttribute('selected') }
372
+ opts.push(o)
373
+ parts.push(menuItem({ label: o.label, meta: n.getAttribute('data-meta') || undefined, radio: true, checked: false, attrs: 'data-value="' + esc(o.value) + '"' }, id))
374
+ }
375
+ }
376
+ walk(nodes)
377
+ const pre = opts.find((o) => o.selected) || (placeholder ? null : opts[0])
378
+ cur = pre ? pre.value : ''
379
+ // Same items, same markup: the open menu keeps its elements (and its focus) when a refresh brings the same options.
380
+ const html = parts.join('')
381
+ if (html !== drawn) { list.innerHTML = html; drawn = html }
382
+ mark()
383
+ }
384
+ // As in a select, a value no option has selects nothing.
385
+ Object.defineProperty(wrap, 'value', { get: () => cur, set: (v) => { const s = String(v); cur = opts.some((o) => o.value === s) ? s : ''; mark() } })
386
+ Object.defineProperty(wrap, 'disabled', { get: () => btn.disabled, set: (v) => { btn.disabled = Boolean(v) } })
387
+ wrap.replaceChildren = (...nodes) => setOptions(nodes)
388
+ wrap.focus = (o) => btn.focus(o)
389
+ if (onchange) wrap.addEventListener('change', onchange)
390
+ if (onaction) wrap.addEventListener('action', onaction)
391
+ // Picking an item closes the menu (its popovertargetaction); a new value fires 'change' on the wrapper, as a select
392
+ // does. The click stops here: the library's own radio script would otherwise check the clicked item after a
393
+ // 'change' handler has set another value (2026-11-02: "Arrange order…" kept the check while the sort read "My order").
394
+ list.addEventListener('click', (e) => {
395
+ const act = e.target.closest('[data-action]')
396
+ if (act && !act.disabled) { wrap.dispatchEvent(new CustomEvent('action', { detail: act.getAttribute('data-action') })); return }
397
+ const it = e.target.closest('[role="menuitemradio"]')
398
+ if (!it || it.disabled) return
399
+ e.stopPropagation()
400
+ if (it.getAttribute('data-value') === cur) return
401
+ cur = it.getAttribute('data-value')
402
+ mark()
403
+ wrap.dispatchEvent(new Event('change', { bubbles: true }))
404
+ mark()
405
+ })
406
+ setOptions(kids)
407
+ return wrap
408
+ }
313
409
  function dots(parts) {
314
410
  const out = []
315
411
  for (const p of parts) {
@@ -1020,6 +1116,7 @@ const MAIN = String.raw `
1020
1116
  ]
1021
1117
  }
1022
1118
  // A Main-only Family (ADR-0047) has no other Account to create.
1119
+ function aliasItem(a) { return BOOT.readOnly ? null : { icon: 'terminal', label: t('menu.setAlias'), hint: (a.aliases || [])[0], run: () => openAlias(a) } }
1023
1120
  function likeItem(a) { return BOOT.readOnly || family(a.family).mainOnly ? null : { icon: 'userPlus', label: t('menu.like'), run: () => openCreate({ family: a.family, api: a.kind === 'api' }) } }
1024
1121
  // Grouped by what the user wants to do: open, copy, manage. A Same Login row (ADR-0026) passes its other
1025
1122
  // directories: the menu is the one of the directory the row is named after, and each other directory is one item
@@ -1042,7 +1139,7 @@ const MAIN = String.raw `
1042
1139
  const items = [pinItem(a), ...hideItems(a),
1043
1140
  opens.length ? '-' : null, opens.length ? { header: t('menu.groupOpen') } : null, ...opens,
1044
1141
  '-', { header: t('menu.groupCopy') }, run, ...(fold ? [fold] : more),
1045
- '-', { header: t('menu.groupManage') }, signInItem, key, ...dirTools(a), likeItem(a),
1142
+ '-', { header: t('menu.groupManage') }, signInItem, key, aliasItem(a), ...dirTools(a), likeItem(a),
1046
1143
  ...(dirs.length ? ['-', { header: t('menu.groupOtherDirs') }, ...dirs.map((d) => d.item)] : [])]
1047
1144
  back.sub = items
1048
1145
  for (const d of dirs) d.up.sub = items
@@ -1271,17 +1368,15 @@ const MAIN = String.raw `
1271
1368
  e.preventDefault()
1272
1369
  if (tb.search.value) { tb.search.value = ''; ui.query = ''; renderAccounts() } else tb.search.blur()
1273
1370
  })
1274
- tb.family = h('select', { class: 'tb-select', 'aria-label': t('tb.family') })
1371
+ tb.family = selectMenu({ class: 'tb-select', 'aria-label': t('tb.family') })
1275
1372
  tb.family.addEventListener('change', () => { prefs.family = tb.family.value; savePrefs(); renderAccounts() })
1276
- // "Arrange order…" is not a sort: it opens the arrange mode (spec §3.25), and the sort shows "my order".
1277
- tb.sort = h('select', { class: 'tb-select', 'aria-label': t('tb.sort') },
1278
- CHOICES.sort.map((v) => h('option', { value: v }, t('sort.' + v))),
1279
- BOOT.readOnly ? null : h('option', { value: 'arrange' }, t('sort.arrange')))
1280
- tb.sort.value = prefs.sort
1373
+ // "Arrange order and pins…" is an action under the sorts, not a sort: it opens the arrange mode (spec §3.25), and
1374
+ // the sort then reads "My order".
1375
+ tb.sort = selectMenu({ class: 'tb-select', 'aria-label': t('tb.sort'), onaction: startArrange }, sortOptions())
1281
1376
  tb.sort.addEventListener('change', () => {
1282
1377
  const v = tb.sort.value
1283
1378
  // "My order" before any order of one's own would show nothing new: it opens the arrange mode instead.
1284
- if (v === 'arrange' || (v === 'manual' && !ordered() && !BOOT.readOnly)) { startArrange(); return }
1379
+ if (v === 'manual' && !ordered() && !BOOT.readOnly) { startArrange(); return }
1285
1380
  if (ui.arrange) endArrange()
1286
1381
  prefs.sort = v
1287
1382
  savePrefs()
@@ -1298,6 +1393,14 @@ const MAIN = String.raw `
1298
1393
  renderFamilyFilter()
1299
1394
  if (hadFocus) tb.search.focus()
1300
1395
  }
1396
+ // The sort menu's items (page-logic.ts, sortMenu): redrawn with the list, so "Not set" follows the saved order.
1397
+ function sortOptions() {
1398
+ const items = sortMenu(CHOICES.sort, prefs.sort, ordered(), BOOT.readOnly)
1399
+ const choices = items.filter((e) => e.kind === 'choice').map((e) => h('option', { value: e.value, selected: e.checked ? '' : undefined, 'data-meta': e.meta ? t(e.meta) : undefined, 'data-button': t('sort.button', { choice: t(e.key) }) }, t(e.key)))
1400
+ const label = items.find((e) => e.kind === 'label')
1401
+ const action = items.find((e) => e.kind === 'action')
1402
+ return [h('optgroup', { label: t(label.key) }, choices)].concat(action ? [h('hr'), h('option', { value: action.value, 'data-action': '', 'data-icon': 'grip' }, t(action.key))] : [])
1403
+ }
1301
1404
  // "Display": the view settings people change rarely, one popover instead of three buttons in the toolbar.
1302
1405
  // "Hide emails" shows once any account has one.
1303
1406
  function displayPanel() {
@@ -2473,7 +2576,7 @@ const MAIN = String.raw `
2473
2576
  pinMark(a),
2474
2577
  h('span', { class: 'name', title: a.name }, a.name),
2475
2578
  loginMark(ms),
2476
- aliasText(a),
2579
+ aliasText(a, accountTitle(a).aliases),
2477
2580
  hiddenMark(hidden && !famHidden(fam))))),
2478
2581
  h('div', { class: 'arrange-tools' },
2479
2582
  // In a hidden Family the row keeps its eye, greyed, so the columns stay in line; the group's eye shows it again.
@@ -2627,6 +2730,7 @@ const MAIN = String.raw `
2627
2730
  }
2628
2731
  function renderAccounts() {
2629
2732
  closeMenu()
2733
+ if (tb.sort) tb.sort.replaceChildren(...sortOptions())
2630
2734
  const box = $('accounts')
2631
2735
  const count = $('acct-count')
2632
2736
  if (!S.state) {
@@ -2982,7 +3086,7 @@ const MAIN = String.raw `
2982
3086
  if (g.current && !g.outOfRange) sizes.add(g.current)
2983
3087
  const key = (v) => (v === null ? 'default' : String(v))
2984
3088
  const chosen = tuneSel[g.id] !== undefined ? tuneSel[g.id] : key(g.current)
2985
- const sel = h('select', { 'aria-label': t('tune.setting') },
3089
+ const sel = selectMenu({ 'aria-label': t('tune.setting') },
2986
3090
  h('option', { value: 'default' }, t('tune.hostDefaultLong')),
2987
3091
  [...sizes].sort((x, y) => x - y).map((v) => h('option', { value: String(v) }, tokens(v) + (pick && v === pick.threshold ? ' (' + t('tune.suggestedTag') + ')' : ''))))
2988
3092
  sel.value = chosen
@@ -3947,9 +4051,9 @@ const MAIN = String.raw `
3947
4051
  ev.preventDefault()
3948
4052
  if (e.q.value) { e.q.value = ''; clearTimeout(hs.debounce); hs.q = ''; historyChanged(false) } else e.q.blur()
3949
4053
  })
3950
- e.since = h('select', { class: 'tb-select' })
4054
+ e.since = selectMenu({ class: 'tb-select' })
3951
4055
  e.since.addEventListener('change', () => { hs.since = e.since.value; historyChanged(true) })
3952
- e.family = h('select', { class: 'tb-select' })
4056
+ e.family = selectMenu({ class: 'tb-select' })
3953
4057
  e.family.addEventListener('change', () => {
3954
4058
  hs.family = e.family.value
3955
4059
  // An Account of another AI would match nothing: it is dropped before the lists are asked for again.
@@ -3957,7 +4061,7 @@ const MAIN = String.raw `
3957
4061
  relabelHistory(e)
3958
4062
  historyChanged(true)
3959
4063
  })
3960
- e.account = h('select', { class: 'tb-select' })
4064
+ e.account = selectMenu({ class: 'tb-select' })
3961
4065
  e.account.addEventListener('change', () => { hs.account = e.account.value; historyChanged(true) })
3962
4066
  e.tools = h('input', { type: 'checkbox' })
3963
4067
  e.tools.addEventListener('change', () => {
@@ -5245,7 +5349,7 @@ const MAIN = String.raw `
5245
5349
  function ahFamily(fam) {
5246
5350
  const o = ah.form.orders[fam]
5247
5351
  const f = family(fam)
5248
- const policy = h('select', { 'aria-label': t('ah.order', { host: f.title }), disabled: BOOT.readOnly },
5352
+ const policy = selectMenu({ 'aria-label': t('ah.order', { host: f.title }), disabled: BOOT.readOnly },
5249
5353
  h('option', { value: 'pressure' }, t('ah.byQuota')), h('option', { value: 'order' }, t('ah.myOrder')))
5250
5354
  policy.value = o.policy
5251
5355
  policy.addEventListener('change', () => ahEdit((form) => { form.orders[fam].policy = policy.value }))
@@ -5261,7 +5365,7 @@ const MAIN = String.raw `
5261
5365
  const free = S.state.accounts.filter((a) => !taken.has(a.ref) && !(a.aliases || []).some((n) => taken.has(n)))
5262
5366
  if (!o.order.length) kids.push(h('p', { class: 'note note-warn' }, t('ah.emptyOrder')))
5263
5367
  if (free.length && !BOOT.readOnly) {
5264
- const pick = h('select', { 'aria-label': t('ah.add') }, h('option', { value: '' }, t('ah.add') + '…'), free.map((a) => h('option', { value: a.ref }, accountLabel(a.ref))))
5368
+ const pick = selectMenu({ 'aria-label': t('ah.add') }, h('option', { value: '', 'data-placeholder': '' }, t('ah.add') + '…'), free.map((a) => h('option', { value: a.ref }, accountLabel(a.ref))))
5265
5369
  pick.addEventListener('change', () => { if (pick.value) ahEdit((form) => { form.orders[fam].order.push(pick.value) }) })
5266
5370
  kids.push(h('div', { class: 'ah-add' }, pick))
5267
5371
  }
@@ -5411,7 +5515,7 @@ const MAIN = String.raw `
5411
5515
  const list = h('datalist', { id: 'md-models' }, mi.models.map((m) => h('option', { value: m })))
5412
5516
  const model = h('input', { type: 'text', list: 'md-models', autocomplete: 'off', spellcheck: 'false', placeholder: t('md.default') + ' (' + t('md.decides', { host }) + ')', disabled: BOOT.readOnly })
5413
5517
  model.value = mi.sideby.model || ''
5414
- const effort = h('select', { disabled: BOOT.readOnly }, h('option', { value: '' }, t('md.default') + ' (' + t('md.decides', { host }) + ')'), mi.efforts.map((e) => h('option', { value: e }, e)))
5518
+ const effort = selectMenu({ disabled: BOOT.readOnly }, h('option', { value: '' }, t('md.default') + ' (' + t('md.decides', { host }) + ')'), mi.efforts.map((e) => h('option', { value: e }, e)))
5415
5519
  effort.value = mi.sideby.effort || ''
5416
5520
  const changed = () => { md.preview = null; md.error = null; renderModel() }
5417
5521
  model.addEventListener('input', () => { if (md.preview) changed() })
@@ -7043,7 +7147,7 @@ const MAIN = String.raw `
7043
7147
  const opts = HOTKEY_PRESETS.map((k) => [k, hotkeyLabel(k) + (k === HOTKEY_PRESETS[0] ? t('hk.isDefault') : '')])
7044
7148
  if (v.enabled && HOTKEY_PRESETS.indexOf(v.keys) < 0) opts.unshift([v.keys, v.label])
7045
7149
  opts.push(['off', t('hk.offOption')], ['custom', t('hk.custom')])
7046
- return h('select', { class: 'hk-select', 'data-key': 'hk-select', 'aria-label': t('hk.label'), disabled: hk.busy,
7150
+ return selectMenu({ class: 'hk-select', 'data-key': 'hk-select', 'aria-label': t('hk.label'), disabled: hk.busy,
7047
7151
  onchange: (e) => {
7048
7152
  const val = e.target.value
7049
7153
  hk.error = ''
@@ -7233,6 +7337,7 @@ const MAIN = String.raw `
7233
7337
  else if (dlg.kind === 'setup' && qs) renderSetup()
7234
7338
  else if (dlg.kind === 'tune' && tuneState) renderTune()
7235
7339
  else if (dlg.kind === 'model' && md) { md.form = null; renderModel() }
7340
+ else if (dlg.kind === 'alias' && al) renderAlias()
7236
7341
  else if (dlg.kind === 'browser') renderBrowser()
7237
7342
  else if (dlg.kind === 'update' && up) renderUpdate()
7238
7343
  else if (dlg.kind === 'rc') renderRc()
@@ -7679,8 +7784,8 @@ const MAIN = String.raw `
7679
7784
  }
7680
7785
  const rows = []
7681
7786
  if (choices.length) {
7682
- const sel = h('select', { id: 'ak-account', 'aria-label': t('ask.account') },
7683
- ak.account ? null : h('option', { value: '' }, t('ask.chooseAccount')),
7787
+ const sel = selectMenu({ id: 'ak-account', 'aria-label': t('ask.account') },
7788
+ ak.account ? null : h('option', { value: '', 'data-placeholder': '' }, t('ask.chooseAccount')),
7684
7789
  choices.map((a) => h('option', { value: a.ref }, a.ref + (a.kind === 'api' ? ' · API' : ''))))
7685
7790
  sel.value = ak.account || ''
7686
7791
  sel.addEventListener('change', () => { ak.account = sel.value || null; ak.accountChanged = Boolean(sel.value); renderAsk() })
@@ -7688,7 +7793,7 @@ const MAIN = String.raw `
7688
7793
  }
7689
7794
  const installed = ak.terms ? ak.terms.installed : []
7690
7795
  if (installed.length && ak.account) {
7691
- const sel = h('select', { id: 'ak-term', 'aria-label': t('ask.terminal') }, installed.map((id) => h('option', { value: id }, termName(id))))
7796
+ const sel = selectMenu({ id: 'ak-term', 'aria-label': t('ask.terminal') }, installed.map((id) => h('option', { value: id }, termName(id))))
7692
7797
  sel.value = ak.terminal || installed[0]
7693
7798
  sel.addEventListener('change', () => { ak.terminal = sel.value; ak.terminalChanged = true; renderAsk() })
7694
7799
  rows.push(h('label', { class: 'field', for: 'ak-term' }, h('span', null, t('ask.terminal')), sel))
@@ -7930,7 +8035,7 @@ const MAIN = String.raw `
7930
8035
  const name = (id) => { const f = d.terminals.find((x) => x.id === id); return f ? f.name : id }
7931
8036
  if (!d.installed.length) body.push(h('p', { class: 'note' }, t('term.none')))
7932
8037
  else {
7933
- const sel = h('select', { id: 'tm-pick', disabled: tm.busy, 'aria-label': t('term.pick') },
8038
+ const sel = selectMenu({ id: 'tm-pick', disabled: tm.busy, 'aria-label': t('term.pick') },
7934
8039
  h('option', { value: '' }, t('term.auto')),
7935
8040
  d.installed.map((id) => h('option', { value: id }, name(id))))
7936
8041
  sel.value = d.preferred && d.installed.includes(d.preferred) ? d.preferred : ''
@@ -8228,6 +8333,98 @@ const MAIN = String.raw `
8228
8333
  if (pk.error) body.push(errorNote(pk.error, null))
8229
8334
  setKids(dlg.el, dialogFrame(t('pk.title'), null, body, [h('button', { class: 'btn', type: 'button', onclick: () => dlg.el.close() }, t('btn.close'))]))
8230
8335
  }
8336
+ // Short commands of one Account (spec §3.13): add one, rename or remove it. A terminal that loads shell-init picks
8337
+ // the change up at its next prompt, so the page says that instead of "open a new terminal".
8338
+ let al = null
8339
+ function openAlias(a) {
8340
+ al = { ref: a.ref, family: a.family, editing: (a.aliases || []).length ? null : '', draft: null, busy: false, error: null }
8341
+ showDialog('alias')
8342
+ renderAlias()
8343
+ const el = document.getElementById('al-name')
8344
+ if (el) el.focus()
8345
+ }
8346
+ function alAccount() { return S.state && S.state.accounts.find((x) => x.ref === al.ref) }
8347
+ async function alSave(name, replaces) {
8348
+ al.busy = true
8349
+ al.error = null
8350
+ renderAlias()
8351
+ try {
8352
+ const r = await api('/api/alias/set', replaces ? { account: al.ref, name, replaces } : { account: al.ref, name })
8353
+ al.editing = null
8354
+ al.draft = null
8355
+ const later = S.state.shellSetup && !S.state.shellSetup.loaded
8356
+ pickToast([r], t((replaces ? 'al.renamed' : 'al.added') + (later ? 'Setup' : ''), { name, old: replaces }))
8357
+ await load({ silent: true })
8358
+ } catch (e) { al.error = e }
8359
+ if (!al) return
8360
+ al.busy = false
8361
+ if (dlg.kind === 'alias') renderAlias()
8362
+ }
8363
+ async function alRemove(name) {
8364
+ al.busy = true
8365
+ al.error = null
8366
+ renderAlias()
8367
+ try {
8368
+ const r = await api('/api/alias/remove', { name })
8369
+ const back = r.account ? Object.assign({ account: r.account, name }, r.args ? { args: r.args } : {}) : null
8370
+ toast(t('al.removed', { name }), back ? { action: { label: t('ss.undo'), run: async () => { try { await api('/api/alias/set', back); await load({ silent: true }); if (dlg.kind === 'alias') renderAlias() } catch (e) { toast(e.message, { kind: 'fail' }) } } } } : undefined)
8371
+ await load({ silent: true })
8372
+ } catch (e) { al.error = e }
8373
+ if (!al) return
8374
+ al.busy = false
8375
+ if (dlg.kind === 'alias') renderAlias()
8376
+ }
8377
+ // The field is built per render, but keeps what was typed in al.draft; Enter saves.
8378
+ function alEditor(replaces) {
8379
+ const input = h('input', { id: 'al-name', type: 'text', class: 'mono', autocomplete: 'off', autocapitalize: 'none', spellcheck: 'false', maxlength: '64', placeholder: t('al.namePh'), disabled: al.busy, 'aria-describedby': 'al-name-hint' })
8380
+ input.value = al.draft !== null ? al.draft : replaces || ''
8381
+ const go = h('button', { class: 'btn btn-sm btn-primary', type: 'button' }, t(replaces ? 'pk.save' : 'pk.add'))
8382
+ const hint = h('p', { class: 'field-hint', id: 'al-name-hint' }, t('al.hint'))
8383
+ // The same rule as the config (ALIAS_NAME), said in words while typing, so a bad name never reaches the server.
8384
+ const ok = (n) => /^[A-Za-z_][A-Za-z0-9_-]*$/.test(n)
8385
+ const sync = () => {
8386
+ const n = input.value.trim()
8387
+ const bad = Boolean(n) && !ok(n)
8388
+ hint.textContent = t(bad ? 'al.badName' : 'al.hint')
8389
+ hint.className = bad ? 'field-error' : 'field-hint'
8390
+ input.classList.toggle('invalid', bad)
8391
+ input.setAttribute('aria-invalid', bad ? 'true' : 'false')
8392
+ go.disabled = al.busy || !n || bad || n === replaces
8393
+ }
8394
+ const save = () => { const n = input.value.trim(); if (n && ok(n) && n !== replaces) alSave(n, replaces) }
8395
+ input.addEventListener('input', () => { al.draft = input.value; sync() })
8396
+ input.addEventListener('keydown', (e) => { if (e.key === 'Enter') { e.preventDefault(); save() } })
8397
+ go.addEventListener('click', save)
8398
+ sync()
8399
+ return [
8400
+ h('label', { class: 'field', for: 'al-name' }, h('span', null, t('al.nameLabel')), input),
8401
+ hint,
8402
+ h('div', { class: 'actions' }, go,
8403
+ replaces || (alAccount() && (alAccount().aliases || []).length) ? h('button', { class: 'btn btn-sm btn-ghost', type: 'button', disabled: al.busy, onclick: () => { al.editing = null; al.draft = null; renderAlias() } }, t('btn.cancel')) : null),
8404
+ ]
8405
+ }
8406
+ function renderAlias() {
8407
+ if (!al || dlg.kind !== 'alias') return
8408
+ const a = alAccount()
8409
+ if (!a) { dlg.el.close(); return }
8410
+ const names = a.aliases || []
8411
+ const body = [h('p', { class: 'muted small' }, t('al.intro', { ref: a.ref }))]
8412
+ for (const n of names) {
8413
+ if (al.editing === n) { body.push(h('div', { class: 'pk-row' }, alEditor(n))); continue }
8414
+ const args = (a.aliasArgs || {})[n]
8415
+ body.push(h('div', { class: 'pk-row' },
8416
+ h('p', { class: 'small' }, h('code', { class: 'mono' }, n + (args ? ' → ' + args.join(' ') : ''))),
8417
+ h('div', { class: 'actions' },
8418
+ h('button', { class: 'btn btn-sm', type: 'button', disabled: al.busy, onclick: () => copyText(n) }, icon('copy'), t('al.copy')),
8419
+ h('button', { class: 'btn btn-sm btn-ghost', type: 'button', disabled: al.busy || al.editing !== null, onclick: () => { al.editing = n; al.draft = null; renderAlias(); const el = document.getElementById('al-name'); if (el) el.focus() } }, t('pk.rename')),
8420
+ h('button', { class: 'btn btn-sm btn-ghost', type: 'button', disabled: al.busy, onclick: () => alRemove(n) }, t('pk.remove')))))
8421
+ }
8422
+ if (al.editing === '') body.push(h('div', { class: 'pk-row' }, alEditor(null)))
8423
+ else if (al.editing === null) body.push(h('div', { class: 'actions' }, h('button', { class: 'btn btn-sm', type: 'button', disabled: al.busy, onclick: () => { al.editing = ''; al.draft = null; renderAlias(); const el = document.getElementById('al-name'); if (el) el.focus() } }, t(names.length ? 'al.addAnother' : 'pk.add'))))
8424
+ body.push(shellSetupNote() || h('p', { class: 'muted small' }, t('al.live')))
8425
+ if (al.error) body.push(errorNote(al.error, null))
8426
+ setKids(dlg.el, dialogFrame(t('al.title', { ref: a.ref }), a.family, body, [h('button', { class: 'btn', type: 'button', onclick: () => dlg.el.close() }, t('btn.close'))]))
8427
+ }
8231
8428
  // New terminals load short commands only through one line in the shell's rc file (ADR-0036). Where a short command
8232
8429
  // is added and that line is missing, say so and offer to add it: the line and the file shown are the preview.
8233
8430
  let ssBusy = false
@@ -8245,7 +8442,8 @@ const MAIN = String.raw `
8245
8442
  renderShellSetupHosts()
8246
8443
  }
8247
8444
  function renderShellSetupHosts() {
8248
- if (dlg.kind === 'pick' && pk) renderPick()
8445
+ if (dlg.kind === 'alias' && al) renderAlias()
8446
+ else if (dlg.kind === 'pick' && pk) renderPick()
8249
8447
  else if (dlg.kind === 'create' && nf && nf.result) renderCreate()
8250
8448
  }
8251
8449
  function shellSetupNote() {
@@ -8836,7 +9034,7 @@ const MAIN = String.raw `
8836
9034
  $('accounts').addEventListener('drop', onDrop)
8837
9035
  // Escape leaves the arrange mode, as "Done" does, unless a menu or dialog takes it first.
8838
9036
  document.addEventListener('keydown', (e) => {
8839
- if (e.key !== 'Escape' || e.defaultPrevented || !ui.arrange || menu.el || (dlg.el && dlg.el.open) || e.target.closest('input, select, textarea')) return
9037
+ if (e.key !== 'Escape' || e.defaultPrevented || !ui.arrange || menu.el || (dlg.el && dlg.el.open) || e.target.closest('input, select, textarea, .ui-menu')) return
8840
9038
  endArrange()
8841
9039
  })
8842
9040
  $('settings').addEventListener('click', () => openPopover($('settings'), 'settings', t('set.button'), settingsPop, 'end'))
@@ -8861,4 +9059,4 @@ const MAIN = String.raw `
8861
9059
  window.addEventListener('focus', wake)
8862
9060
  `;
8863
9061
  /** The page script: the tested helpers, then the page logic, in one strict-mode function. */
8864
- export const PAGE_SCRIPT = `(() => {\n 'use strict'\n${LOGIC}\n${MAIN}})()\n`;
9062
+ export const PAGE_SCRIPT = `(() => {\n 'use strict'\n${LOGIC}\n${MENU_LIB}\n${MAIN}\n${menuScript}\n})()\n`;