sideby 0.34.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.
- package/dist/build.json +1 -1
- package/dist/src/cli/commands.d.ts +2 -0
- package/dist/src/cli/commands.js +66 -22
- package/dist/src/cli/json-schemas.js +10 -3
- package/dist/src/cli/main.js +13 -6
- package/dist/src/core/cli-commands.js +2 -2
- package/dist/src/core/shell-init.d.ts +16 -2
- package/dist/src/core/shell-init.js +67 -12
- package/dist/src/panel/handler.js +26 -0
- package/dist/src/panel/i18n.d.ts +25 -0
- package/dist/src/panel/i18n.js +60 -10
- package/dist/src/panel/page-logic.d.ts +56 -5
- package/dist/src/panel/page-logic.js +69 -10
- package/dist/src/panel/page-script.js +270 -38
- package/dist/src/panel/page-styles.js +507 -459
- package/dist/src/panel/ui/dropdown-menu/dropdown-menu.html.d.ts +48 -0
- package/dist/src/panel/ui/dropdown-menu/dropdown-menu.html.js +38 -0
- package/dist/src/panel/ui/lib/cn.d.ts +4 -0
- package/dist/src/panel/ui/lib/cn.js +6 -0
- package/dist/src/panel/ui-css.d.ts +6 -0
- package/dist/src/panel/ui-css.js +88 -0
- package/dist/src/runtime.d.ts +16 -3
- package/dist/src/runtime.js +40 -13
- package/package.json +1 -1
- package/schemas/alias.json +9 -1
- package/schemas/new.json +4 -1
- package/skills/sideby/SKILL.md +4 -3
- package/skills/sideby/references/accounts.md +12 -0
- package/skills/sideby/references/ai-tasks.md +1 -1
- package/skills/sideby/references/setup.md +1 -1
|
@@ -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 { 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, longWindow, maskEmail, matchesQuery, mdBlocks, mdInline, menuPlacement, mergeDaily, mergeUsage, messageChip, messageNews, messageToCheck, networkTaskFacts, newAccountDir, nextReset, 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, 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,
|
|
@@ -21,6 +24,10 @@ const LOGIC = [
|
|
|
21
24
|
taskFindings,
|
|
22
25
|
aliasArgsOf,
|
|
23
26
|
aliasIssue,
|
|
27
|
+
aliasPrefix,
|
|
28
|
+
orderedAliases,
|
|
29
|
+
accountTitle,
|
|
30
|
+
vendorAlias,
|
|
24
31
|
attentionReasons,
|
|
25
32
|
attentionWhy,
|
|
26
33
|
quotaHighLevel,
|
|
@@ -76,6 +83,7 @@ const LOGIC = [
|
|
|
76
83
|
saveHandoffChange,
|
|
77
84
|
enableOutcome,
|
|
78
85
|
reorder,
|
|
86
|
+
sortMenu,
|
|
79
87
|
rowBadge,
|
|
80
88
|
sendBlock,
|
|
81
89
|
sendFileProblem,
|
|
@@ -118,6 +126,13 @@ const LOGIC = [
|
|
|
118
126
|
]
|
|
119
127
|
.map((fn) => fn.toString())
|
|
120
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');
|
|
121
136
|
const MAIN = String.raw `
|
|
122
137
|
const BOOT = JSON.parse(document.getElementById('sideby-boot').textContent)
|
|
123
138
|
const MESSAGES = JSON.parse(document.getElementById('sideby-i18n').textContent)
|
|
@@ -306,6 +321,91 @@ const MAIN = String.raw `
|
|
|
306
321
|
if (Array.isArray(kid)) { for (const k of kid) add(el, k); return }
|
|
307
322
|
el.append(kid instanceof Node ? kid : document.createTextNode(String(kid)))
|
|
308
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
|
+
}
|
|
309
409
|
function dots(parts) {
|
|
310
410
|
const out = []
|
|
311
411
|
for (const p of parts) {
|
|
@@ -1016,6 +1116,7 @@ const MAIN = String.raw `
|
|
|
1016
1116
|
]
|
|
1017
1117
|
}
|
|
1018
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) } }
|
|
1019
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' }) } }
|
|
1020
1121
|
// Grouped by what the user wants to do: open, copy, manage. A Same Login row (ADR-0026) passes its other
|
|
1021
1122
|
// directories: the menu is the one of the directory the row is named after, and each other directory is one item
|
|
@@ -1038,7 +1139,7 @@ const MAIN = String.raw `
|
|
|
1038
1139
|
const items = [pinItem(a), ...hideItems(a),
|
|
1039
1140
|
opens.length ? '-' : null, opens.length ? { header: t('menu.groupOpen') } : null, ...opens,
|
|
1040
1141
|
'-', { header: t('menu.groupCopy') }, run, ...(fold ? [fold] : more),
|
|
1041
|
-
'-', { header: t('menu.groupManage') }, signInItem, key, ...dirTools(a), likeItem(a),
|
|
1142
|
+
'-', { header: t('menu.groupManage') }, signInItem, key, aliasItem(a), ...dirTools(a), likeItem(a),
|
|
1042
1143
|
...(dirs.length ? ['-', { header: t('menu.groupOtherDirs') }, ...dirs.map((d) => d.item)] : [])]
|
|
1043
1144
|
back.sub = items
|
|
1044
1145
|
for (const d of dirs) d.up.sub = items
|
|
@@ -1267,17 +1368,15 @@ const MAIN = String.raw `
|
|
|
1267
1368
|
e.preventDefault()
|
|
1268
1369
|
if (tb.search.value) { tb.search.value = ''; ui.query = ''; renderAccounts() } else tb.search.blur()
|
|
1269
1370
|
})
|
|
1270
|
-
tb.family =
|
|
1371
|
+
tb.family = selectMenu({ class: 'tb-select', 'aria-label': t('tb.family') })
|
|
1271
1372
|
tb.family.addEventListener('change', () => { prefs.family = tb.family.value; savePrefs(); renderAccounts() })
|
|
1272
|
-
// "Arrange order…" is not a sort: it opens the arrange mode (spec §3.25), and
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
BOOT.readOnly ? null : h('option', { value: 'arrange' }, t('sort.arrange')))
|
|
1276
|
-
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())
|
|
1277
1376
|
tb.sort.addEventListener('change', () => {
|
|
1278
1377
|
const v = tb.sort.value
|
|
1279
1378
|
// "My order" before any order of one's own would show nothing new: it opens the arrange mode instead.
|
|
1280
|
-
if (v === '
|
|
1379
|
+
if (v === 'manual' && !ordered() && !BOOT.readOnly) { startArrange(); return }
|
|
1281
1380
|
if (ui.arrange) endArrange()
|
|
1282
1381
|
prefs.sort = v
|
|
1283
1382
|
savePrefs()
|
|
@@ -1294,6 +1393,14 @@ const MAIN = String.raw `
|
|
|
1294
1393
|
renderFamilyFilter()
|
|
1295
1394
|
if (hadFocus) tb.search.focus()
|
|
1296
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
|
+
}
|
|
1297
1404
|
// "Display": the view settings people change rarely, one popover instead of three buttons in the toolbar.
|
|
1298
1405
|
// "Hide emails" shows once any account has one.
|
|
1299
1406
|
function displayPanel() {
|
|
@@ -1516,12 +1623,12 @@ const MAIN = String.raw `
|
|
|
1516
1623
|
if (k === 'api') return h('span', { class: 'tag tag-warn', title: t('tip.api.body') }, t('acct.api'))
|
|
1517
1624
|
return null
|
|
1518
1625
|
}
|
|
1519
|
-
//
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
if (!
|
|
1523
|
-
const
|
|
1524
|
-
return h('span', { class: '
|
|
1626
|
+
// An Account's short commands, as quiet text after its title: those that only start it first, then those with Host
|
|
1627
|
+
// arguments; each says on hover what it adds. A card too narrow for all of them ends in an ellipsis.
|
|
1628
|
+
function aliasText(a, list) {
|
|
1629
|
+
if (!list.length) return null
|
|
1630
|
+
const line = (x) => { const args = aliasArgsOf(a, x); return x + ' · ' + (args ? t('acct.aliasArgs', { args: args.join(' ') }) : t('acct.alias')) }
|
|
1631
|
+
return h('span', { class: 'aliases', title: list.map(line).join('\n') }, list.map((x) => h('span', { class: 'alias', title: line(x) }, x)))
|
|
1525
1632
|
}
|
|
1526
1633
|
// A Same Login row (spec §3.21) gets a link mark after the name; what it means is on hover.
|
|
1527
1634
|
function loginMark(members) {
|
|
@@ -1533,11 +1640,13 @@ const MAIN = String.raw `
|
|
|
1533
1640
|
// opts.linked: the directories a card marks as one login without speaking for them (its badge stays its own).
|
|
1534
1641
|
function nameLine(a, members, opts) {
|
|
1535
1642
|
const o = opts || {}
|
|
1643
|
+
// An API Account with a short command is named by it (cc-kimi); its ref is in the line under it.
|
|
1644
|
+
const named = accountTitle(a)
|
|
1536
1645
|
return h('div', { class: 'ident-name' },
|
|
1537
1646
|
pinSlot(a),
|
|
1538
|
-
h('span', { class: 'name', title: a.name },
|
|
1647
|
+
h('span', { class: 'name', title: named.byAlias ? t('acct.titleAlias', { alias: named.title, ref: a.ref }) : a.name }, named.title),
|
|
1539
1648
|
loginMark(o.linked || members),
|
|
1540
|
-
aliasText(a),
|
|
1649
|
+
aliasText(a, named.aliases),
|
|
1541
1650
|
hiddenMark(isHidden(a) && !famHidden(a.family)),
|
|
1542
1651
|
statusBadge(a, members))
|
|
1543
1652
|
}
|
|
@@ -2467,7 +2576,7 @@ const MAIN = String.raw `
|
|
|
2467
2576
|
pinMark(a),
|
|
2468
2577
|
h('span', { class: 'name', title: a.name }, a.name),
|
|
2469
2578
|
loginMark(ms),
|
|
2470
|
-
aliasText(a),
|
|
2579
|
+
aliasText(a, accountTitle(a).aliases),
|
|
2471
2580
|
hiddenMark(hidden && !famHidden(fam))))),
|
|
2472
2581
|
h('div', { class: 'arrange-tools' },
|
|
2473
2582
|
// In a hidden Family the row keeps its eye, greyed, so the columns stay in line; the group's eye shows it again.
|
|
@@ -2621,6 +2730,7 @@ const MAIN = String.raw `
|
|
|
2621
2730
|
}
|
|
2622
2731
|
function renderAccounts() {
|
|
2623
2732
|
closeMenu()
|
|
2733
|
+
if (tb.sort) tb.sort.replaceChildren(...sortOptions())
|
|
2624
2734
|
const box = $('accounts')
|
|
2625
2735
|
const count = $('acct-count')
|
|
2626
2736
|
if (!S.state) {
|
|
@@ -2976,7 +3086,7 @@ const MAIN = String.raw `
|
|
|
2976
3086
|
if (g.current && !g.outOfRange) sizes.add(g.current)
|
|
2977
3087
|
const key = (v) => (v === null ? 'default' : String(v))
|
|
2978
3088
|
const chosen = tuneSel[g.id] !== undefined ? tuneSel[g.id] : key(g.current)
|
|
2979
|
-
const sel =
|
|
3089
|
+
const sel = selectMenu({ 'aria-label': t('tune.setting') },
|
|
2980
3090
|
h('option', { value: 'default' }, t('tune.hostDefaultLong')),
|
|
2981
3091
|
[...sizes].sort((x, y) => x - y).map((v) => h('option', { value: String(v) }, tokens(v) + (pick && v === pick.threshold ? ' (' + t('tune.suggestedTag') + ')' : ''))))
|
|
2982
3092
|
sel.value = chosen
|
|
@@ -3941,9 +4051,9 @@ const MAIN = String.raw `
|
|
|
3941
4051
|
ev.preventDefault()
|
|
3942
4052
|
if (e.q.value) { e.q.value = ''; clearTimeout(hs.debounce); hs.q = ''; historyChanged(false) } else e.q.blur()
|
|
3943
4053
|
})
|
|
3944
|
-
e.since =
|
|
4054
|
+
e.since = selectMenu({ class: 'tb-select' })
|
|
3945
4055
|
e.since.addEventListener('change', () => { hs.since = e.since.value; historyChanged(true) })
|
|
3946
|
-
e.family =
|
|
4056
|
+
e.family = selectMenu({ class: 'tb-select' })
|
|
3947
4057
|
e.family.addEventListener('change', () => {
|
|
3948
4058
|
hs.family = e.family.value
|
|
3949
4059
|
// An Account of another AI would match nothing: it is dropped before the lists are asked for again.
|
|
@@ -3951,7 +4061,7 @@ const MAIN = String.raw `
|
|
|
3951
4061
|
relabelHistory(e)
|
|
3952
4062
|
historyChanged(true)
|
|
3953
4063
|
})
|
|
3954
|
-
e.account =
|
|
4064
|
+
e.account = selectMenu({ class: 'tb-select' })
|
|
3955
4065
|
e.account.addEventListener('change', () => { hs.account = e.account.value; historyChanged(true) })
|
|
3956
4066
|
e.tools = h('input', { type: 'checkbox' })
|
|
3957
4067
|
e.tools.addEventListener('change', () => {
|
|
@@ -4845,7 +4955,7 @@ const MAIN = String.raw `
|
|
|
4845
4955
|
const ready = fams.filter((f) => familyStatus(f) === 'ready')
|
|
4846
4956
|
const pick = prefill && ready.some((f) => f.id === prefill.family) ? prefill.family : prefs.family && ready.some((f) => f.id === prefs.family) ? prefs.family : ready.length ? ready[0].id : ''
|
|
4847
4957
|
// name / alias: what the user typed, or null while the field shows the suggestion (an emptied alias stays empty).
|
|
4848
|
-
nf = { fams, family: pick, api: Boolean(prefill && prefill.api), name: null, alias: null, creating: false, result: null, error: null, els: {} }
|
|
4958
|
+
nf = { fams, family: pick, api: Boolean(prefill && prefill.api), vendor: '', name: null, alias: null, creating: false, result: null, error: null, els: {} }
|
|
4849
4959
|
showDialog('create')
|
|
4850
4960
|
renderCreate()
|
|
4851
4961
|
if (nf.els.name) { nf.els.name.focus(); nf.els.name.select() }
|
|
@@ -4861,10 +4971,13 @@ const MAIN = String.raw `
|
|
|
4861
4971
|
if (S.state && S.state.accounts.some((a) => a.ref === nf.family + ':' + name)) return t('nf.exists', { ref: nf.family + ':' + name })
|
|
4862
4972
|
return ''
|
|
4863
4973
|
}
|
|
4864
|
-
// The short command offered for the typed name: the Family's
|
|
4974
|
+
// The short command offered for the typed name: for an API account the Family's prefix and the Vendor (cc-ds), shown
|
|
4975
|
+
// even when it cannot be used so the error under it says why; otherwise the Family's alias pattern (cc001… gives
|
|
4976
|
+
// cc008), if it is usable. An API account never gets a numbered one.
|
|
4865
4977
|
function aliasSuggestion() {
|
|
4866
4978
|
const name = nf.els.name.value.trim()
|
|
4867
4979
|
if (!nf.family || !name || nameProblem()) return ''
|
|
4980
|
+
if (nf.api) return vendorAlias(S.state.accounts, nf.family, nf.vendor)
|
|
4868
4981
|
const sug = suggestAlias(S.state.accounts, nf.family, name)
|
|
4869
4982
|
return sug && !aliasIssue(sug, BOOT.aliasPattern, BOOT.reservedAliases, S.state.configAliases, nf.family + ':' + name) ? sug : ''
|
|
4870
4983
|
}
|
|
@@ -4891,18 +5004,31 @@ const MAIN = String.raw `
|
|
|
4891
5004
|
e.alias = h('input', { id: 'nf-alias', name: 'alias', type: 'text', autocomplete: 'off', autocapitalize: 'none', spellcheck: 'false', placeholder: t('nf.aliasPh'), maxlength: '64', 'aria-describedby': 'nf-alias-hint nf-alias-err', 'aria-invalid': 'false' })
|
|
4892
5005
|
e.aliasHint = h('p', { class: 'field-hint', id: 'nf-alias-hint' })
|
|
4893
5006
|
e.aliasErr = h('p', { class: 'field-error', id: 'nf-alias-err', role: 'alert' })
|
|
4894
|
-
e.api = h('input', { id: 'nf-api', type: 'checkbox', 'aria-label': t('nf.api') })
|
|
5007
|
+
e.api = h('input', { id: 'nf-api', type: 'checkbox', 'aria-label': t('nf.api'), 'aria-controls': 'nf-vendor-field' })
|
|
4895
5008
|
e.api.checked = nf.api
|
|
5009
|
+
e.vendor = h('input', { id: 'nf-vendor', name: 'vendor', type: 'text', autocomplete: 'off', autocapitalize: 'none', spellcheck: 'false', placeholder: t('nf.vendorPh'), maxlength: '32', 'aria-describedby': 'nf-vendor-hint' })
|
|
5010
|
+
e.vendor.value = nf.vendor
|
|
5011
|
+
// Grows in under "API key" when it is ticked; inert while folded, so Tab skips it.
|
|
5012
|
+
e.vendorField = h('div', { class: 'reveal' + (nf.api ? ' is-open' : ''), id: 'nf-vendor-field', inert: nf.api ? undefined : true },
|
|
5013
|
+
h('div', { class: 'reveal-in' }, h('div', { class: 'field' },
|
|
5014
|
+
h('label', { class: 'field', for: 'nf-vendor' }, h('span', null, t('nf.vendor')), e.vendor),
|
|
5015
|
+
h('p', { class: 'field-hint', id: 'nf-vendor-hint' }, t('nf.vendorHint')))))
|
|
4896
5016
|
e.suggest = h('p', { class: 'field-hint', id: 'nf-sug' })
|
|
4897
5017
|
e.error = h('p', { class: 'field-error', id: 'nf-err', role: 'alert' })
|
|
4898
5018
|
e.preview = h('dl', { class: 'preview' })
|
|
4899
5019
|
e.submit = h('button', { class: 'btn btn-primary', type: 'submit', form: 'nf-form', 'aria-label': t('nf.create') }, t('nf.create'))
|
|
4900
5020
|
e.name.addEventListener('input', () => { nf.name = e.name.value; followAlias(); validateCreate(); renderPreview() })
|
|
4901
5021
|
e.alias.addEventListener('input', () => { nf.alias = e.alias.value; validateCreate(); renderPreview() })
|
|
5022
|
+
e.vendor.addEventListener('input', () => { nf.vendor = e.vendor.value; followAlias(); validateCreate(); renderPreview() })
|
|
4902
5023
|
e.api.addEventListener('change', () => {
|
|
4903
5024
|
nf.api = e.api.checked
|
|
5025
|
+
e.vendorField.classList.toggle('is-open', nf.api)
|
|
5026
|
+
e.vendorField.inert = !nf.api
|
|
4904
5027
|
// A refusal was about the old choice; the hint under it no longer applies.
|
|
4905
5028
|
if (e.errNote) { e.errNote.remove(); e.errNote = null; nf.error = null }
|
|
5029
|
+
followAlias()
|
|
5030
|
+
validateCreate()
|
|
5031
|
+
renderPreview()
|
|
4906
5032
|
})
|
|
4907
5033
|
const cards = nf.fams.map((f) => {
|
|
4908
5034
|
const st = familyStatus(f)
|
|
@@ -4930,10 +5056,13 @@ const MAIN = String.raw `
|
|
|
4930
5056
|
h('span', { class: 'fam-text' }, h('span', { class: 'fam-title' }, t('ask.otherTool')), h('span', { class: 'fam-sub' }, t('ask.otherToolSub')))))),
|
|
4931
5057
|
h('div', { class: 'field' }, h('label', { class: 'field', for: 'nf-name' }, h('span', null, t('nf.name')), e.name), e.suggest),
|
|
4932
5058
|
// The first screen asks only for the tool and a name; the rest waits behind "More options".
|
|
5059
|
+
// "API key" comes before the short command: its Vendor names the short command (cc-ds).
|
|
4933
5060
|
h('details', { class: 'more-opts', open: nf.api || Boolean(nf.alias) || Boolean(nf.error) || undefined },
|
|
4934
5061
|
h('summary', null, t('nf.more')),
|
|
5062
|
+
h('div', null,
|
|
5063
|
+
h('div', { class: 'check-row' }, h('label', { class: 'check' }, e.api, h('span', null, h('b', null, t('nf.api')), h('span', { class: 'muted small' }, t('nf.apiHint')))), tip('api')),
|
|
5064
|
+
e.vendorField),
|
|
4935
5065
|
h('div', { class: 'field' }, h('label', { class: 'field', for: 'nf-alias' }, h('span', null, t('nf.alias'), ' ', h('span', { class: 'muted small' }, t('nf.optional'))), e.alias), e.aliasHint, e.aliasErr),
|
|
4936
|
-
h('div', { class: 'check-row' }, h('label', { class: 'check' }, e.api, h('span', null, h('b', null, t('nf.api')), h('span', { class: 'muted small' }, t('nf.apiHint')))), tip('api')),
|
|
4937
5066
|
e.preview),
|
|
4938
5067
|
e.error,
|
|
4939
5068
|
e.errNote = nf.error ? errorNote(nf.error, create, nf.error.code === 'create-refused' && !nf.api ? t('nf.refusedApi') : null) : null,
|
|
@@ -4962,10 +5091,19 @@ const MAIN = String.raw `
|
|
|
4962
5091
|
e.alias.classList.toggle('invalid', Boolean(aliasMsg))
|
|
4963
5092
|
e.alias.setAttribute('aria-invalid', String(Boolean(aliasMsg)))
|
|
4964
5093
|
e.aliasErr.textContent = aliasMsg
|
|
4965
|
-
e.aliasHint.textContent = alias
|
|
5094
|
+
e.aliasHint.textContent = aliasHintText(alias)
|
|
4966
5095
|
if (!nf.creating) e.submit.disabled = Boolean(msg) || Boolean(aliasMsg) || !name || !nf.family
|
|
4967
5096
|
return msg || aliasMsg
|
|
4968
5097
|
}
|
|
5098
|
+
// What the line under the short command says: where a suggestion came from, or, for an API account without a
|
|
5099
|
+
// Vendor yet, that typing one gives cc-<vendor>.
|
|
5100
|
+
function aliasHintText(alias) {
|
|
5101
|
+
const host = nf.family ? family(nf.family).title : ''
|
|
5102
|
+
if (alias && alias === aliasSuggestion()) return t(nf.api ? 'nf.aliasVendor' : 'nf.aliasSuggested', { host })
|
|
5103
|
+
const example = nf.api && nf.family ? vendorAlias(S.state.accounts, nf.family, '<' + t('nf.vendorWord') + '>') : ''
|
|
5104
|
+
if (example && !alias && !nf.vendor.trim()) return t('nf.aliasVendorTip', { example })
|
|
5105
|
+
return t('nf.aliasHint')
|
|
5106
|
+
}
|
|
4969
5107
|
function renderPreview() {
|
|
4970
5108
|
const name = nf.els.name.value.trim()
|
|
4971
5109
|
const ok = name && !nameProblem() && nf.family
|
|
@@ -5211,7 +5349,7 @@ const MAIN = String.raw `
|
|
|
5211
5349
|
function ahFamily(fam) {
|
|
5212
5350
|
const o = ah.form.orders[fam]
|
|
5213
5351
|
const f = family(fam)
|
|
5214
|
-
const policy =
|
|
5352
|
+
const policy = selectMenu({ 'aria-label': t('ah.order', { host: f.title }), disabled: BOOT.readOnly },
|
|
5215
5353
|
h('option', { value: 'pressure' }, t('ah.byQuota')), h('option', { value: 'order' }, t('ah.myOrder')))
|
|
5216
5354
|
policy.value = o.policy
|
|
5217
5355
|
policy.addEventListener('change', () => ahEdit((form) => { form.orders[fam].policy = policy.value }))
|
|
@@ -5227,7 +5365,7 @@ const MAIN = String.raw `
|
|
|
5227
5365
|
const free = S.state.accounts.filter((a) => !taken.has(a.ref) && !(a.aliases || []).some((n) => taken.has(n)))
|
|
5228
5366
|
if (!o.order.length) kids.push(h('p', { class: 'note note-warn' }, t('ah.emptyOrder')))
|
|
5229
5367
|
if (free.length && !BOOT.readOnly) {
|
|
5230
|
-
const pick =
|
|
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))))
|
|
5231
5369
|
pick.addEventListener('change', () => { if (pick.value) ahEdit((form) => { form.orders[fam].order.push(pick.value) }) })
|
|
5232
5370
|
kids.push(h('div', { class: 'ah-add' }, pick))
|
|
5233
5371
|
}
|
|
@@ -5377,7 +5515,7 @@ const MAIN = String.raw `
|
|
|
5377
5515
|
const list = h('datalist', { id: 'md-models' }, mi.models.map((m) => h('option', { value: m })))
|
|
5378
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 })
|
|
5379
5517
|
model.value = mi.sideby.model || ''
|
|
5380
|
-
const effort =
|
|
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)))
|
|
5381
5519
|
effort.value = mi.sideby.effort || ''
|
|
5382
5520
|
const changed = () => { md.preview = null; md.error = null; renderModel() }
|
|
5383
5521
|
model.addEventListener('input', () => { if (md.preview) changed() })
|
|
@@ -7009,7 +7147,7 @@ const MAIN = String.raw `
|
|
|
7009
7147
|
const opts = HOTKEY_PRESETS.map((k) => [k, hotkeyLabel(k) + (k === HOTKEY_PRESETS[0] ? t('hk.isDefault') : '')])
|
|
7010
7148
|
if (v.enabled && HOTKEY_PRESETS.indexOf(v.keys) < 0) opts.unshift([v.keys, v.label])
|
|
7011
7149
|
opts.push(['off', t('hk.offOption')], ['custom', t('hk.custom')])
|
|
7012
|
-
return
|
|
7150
|
+
return selectMenu({ class: 'hk-select', 'data-key': 'hk-select', 'aria-label': t('hk.label'), disabled: hk.busy,
|
|
7013
7151
|
onchange: (e) => {
|
|
7014
7152
|
const val = e.target.value
|
|
7015
7153
|
hk.error = ''
|
|
@@ -7199,6 +7337,7 @@ const MAIN = String.raw `
|
|
|
7199
7337
|
else if (dlg.kind === 'setup' && qs) renderSetup()
|
|
7200
7338
|
else if (dlg.kind === 'tune' && tuneState) renderTune()
|
|
7201
7339
|
else if (dlg.kind === 'model' && md) { md.form = null; renderModel() }
|
|
7340
|
+
else if (dlg.kind === 'alias' && al) renderAlias()
|
|
7202
7341
|
else if (dlg.kind === 'browser') renderBrowser()
|
|
7203
7342
|
else if (dlg.kind === 'update' && up) renderUpdate()
|
|
7204
7343
|
else if (dlg.kind === 'rc') renderRc()
|
|
@@ -7645,8 +7784,8 @@ const MAIN = String.raw `
|
|
|
7645
7784
|
}
|
|
7646
7785
|
const rows = []
|
|
7647
7786
|
if (choices.length) {
|
|
7648
|
-
const sel =
|
|
7649
|
-
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')),
|
|
7650
7789
|
choices.map((a) => h('option', { value: a.ref }, a.ref + (a.kind === 'api' ? ' · API' : ''))))
|
|
7651
7790
|
sel.value = ak.account || ''
|
|
7652
7791
|
sel.addEventListener('change', () => { ak.account = sel.value || null; ak.accountChanged = Boolean(sel.value); renderAsk() })
|
|
@@ -7654,7 +7793,7 @@ const MAIN = String.raw `
|
|
|
7654
7793
|
}
|
|
7655
7794
|
const installed = ak.terms ? ak.terms.installed : []
|
|
7656
7795
|
if (installed.length && ak.account) {
|
|
7657
|
-
const sel =
|
|
7796
|
+
const sel = selectMenu({ id: 'ak-term', 'aria-label': t('ask.terminal') }, installed.map((id) => h('option', { value: id }, termName(id))))
|
|
7658
7797
|
sel.value = ak.terminal || installed[0]
|
|
7659
7798
|
sel.addEventListener('change', () => { ak.terminal = sel.value; ak.terminalChanged = true; renderAsk() })
|
|
7660
7799
|
rows.push(h('label', { class: 'field', for: 'ak-term' }, h('span', null, t('ask.terminal')), sel))
|
|
@@ -7896,7 +8035,7 @@ const MAIN = String.raw `
|
|
|
7896
8035
|
const name = (id) => { const f = d.terminals.find((x) => x.id === id); return f ? f.name : id }
|
|
7897
8036
|
if (!d.installed.length) body.push(h('p', { class: 'note' }, t('term.none')))
|
|
7898
8037
|
else {
|
|
7899
|
-
const sel =
|
|
8038
|
+
const sel = selectMenu({ id: 'tm-pick', disabled: tm.busy, 'aria-label': t('term.pick') },
|
|
7900
8039
|
h('option', { value: '' }, t('term.auto')),
|
|
7901
8040
|
d.installed.map((id) => h('option', { value: id }, name(id))))
|
|
7902
8041
|
sel.value = d.preferred && d.installed.includes(d.preferred) ? d.preferred : ''
|
|
@@ -8194,6 +8333,98 @@ const MAIN = String.raw `
|
|
|
8194
8333
|
if (pk.error) body.push(errorNote(pk.error, null))
|
|
8195
8334
|
setKids(dlg.el, dialogFrame(t('pk.title'), null, body, [h('button', { class: 'btn', type: 'button', onclick: () => dlg.el.close() }, t('btn.close'))]))
|
|
8196
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
|
+
}
|
|
8197
8428
|
// New terminals load short commands only through one line in the shell's rc file (ADR-0036). Where a short command
|
|
8198
8429
|
// is added and that line is missing, say so and offer to add it: the line and the file shown are the preview.
|
|
8199
8430
|
let ssBusy = false
|
|
@@ -8211,7 +8442,8 @@ const MAIN = String.raw `
|
|
|
8211
8442
|
renderShellSetupHosts()
|
|
8212
8443
|
}
|
|
8213
8444
|
function renderShellSetupHosts() {
|
|
8214
|
-
if (dlg.kind === '
|
|
8445
|
+
if (dlg.kind === 'alias' && al) renderAlias()
|
|
8446
|
+
else if (dlg.kind === 'pick' && pk) renderPick()
|
|
8215
8447
|
else if (dlg.kind === 'create' && nf && nf.result) renderCreate()
|
|
8216
8448
|
}
|
|
8217
8449
|
function shellSetupNote() {
|
|
@@ -8802,7 +9034,7 @@ const MAIN = String.raw `
|
|
|
8802
9034
|
$('accounts').addEventListener('drop', onDrop)
|
|
8803
9035
|
// Escape leaves the arrange mode, as "Done" does, unless a menu or dialog takes it first.
|
|
8804
9036
|
document.addEventListener('keydown', (e) => {
|
|
8805
|
-
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
|
|
8806
9038
|
endArrange()
|
|
8807
9039
|
})
|
|
8808
9040
|
$('settings').addEventListener('click', () => openPopover($('settings'), 'settings', t('set.button'), settingsPop, 'end'))
|
|
@@ -8827,4 +9059,4 @@ const MAIN = String.raw `
|
|
|
8827
9059
|
window.addEventListener('focus', wake)
|
|
8828
9060
|
`;
|
|
8829
9061
|
/** The page script: the tested helpers, then the page logic, in one strict-mode function. */
|
|
8830
|
-
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`;
|