sideby 0.20.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/build.json +1 -1
- package/dist/src/cli/commands.js +115 -10
- package/dist/src/cli/format.js +3 -2
- package/dist/src/cli/json-schemas.js +81 -46
- package/dist/src/cli/main.js +6 -3
- package/dist/src/core/accounts.d.ts +6 -1
- package/dist/src/core/accounts.js +16 -3
- package/dist/src/core/ask.d.ts +2 -1
- package/dist/src/core/ask.js +6 -3
- package/dist/src/core/claude-settings-file.d.ts +57 -0
- package/dist/src/core/claude-settings-file.js +104 -2
- package/dist/src/core/config.d.ts +29 -15
- package/dist/src/core/config.js +40 -2
- package/dist/src/core/create.js +4 -1
- package/dist/src/core/desktop-app.js +5 -1
- package/dist/src/core/handoff-overview.d.ts +4 -1
- package/dist/src/core/handoff-overview.js +3 -2
- package/dist/src/core/handoff-rules.d.ts +34 -0
- package/dist/src/core/handoff-rules.js +115 -0
- package/dist/src/core/handoff-select.js +45 -28
- package/dist/src/core/handoff-status.d.ts +37 -7
- package/dist/src/core/handoff-status.js +95 -19
- package/dist/src/core/handoff.d.ts +4 -1
- package/dist/src/core/handoff.js +8 -5
- package/dist/src/core/inbound.d.ts +11 -3
- package/dist/src/core/inbound.js +26 -74
- package/dist/src/core/launch.js +6 -4
- package/dist/src/core/quota-levels.d.ts +6 -0
- package/dist/src/core/quota-levels.js +8 -0
- package/dist/src/core/remote-control.d.ts +10 -12
- package/dist/src/core/remote-control.js +29 -86
- package/dist/src/core/tuning-apply.js +12 -20
- package/dist/src/families/agy/index.d.ts +8 -0
- package/dist/src/families/agy/index.js +53 -0
- package/dist/src/families/agy/quota.d.ts +9 -0
- package/dist/src/families/agy/quota.js +110 -0
- package/dist/src/families/index.js +7 -0
- package/dist/src/families/logos.d.ts +10 -0
- package/dist/src/families/logos.js +12 -1
- package/dist/src/menubar/script.js +26 -3
- package/dist/src/menubar/snapshot.d.ts +23 -6
- package/dist/src/menubar/snapshot.js +126 -39
- package/dist/src/menubar/strings.d.ts +12 -2
- package/dist/src/menubar/strings.js +12 -2
- package/dist/src/panel/handler.d.ts +2 -1
- package/dist/src/panel/handler.js +81 -45
- package/dist/src/panel/i18n.d.ts +58 -7
- package/dist/src/panel/i18n.js +158 -56
- package/dist/src/panel/page-logic.d.ts +52 -19
- package/dist/src/panel/page-logic.js +47 -7
- package/dist/src/panel/page-script.js +333 -115
- package/dist/src/panel/page-styles.js +112 -21
- package/dist/src/panel/page.js +3 -3
- package/dist/src/plugins/check.js +27 -13
- package/dist/src/plugins/loader.d.ts +11 -0
- package/dist/src/plugins/loader.js +47 -1
- package/dist/src/runtime.d.ts +5 -2
- package/dist/src/runtime.js +12 -5
- package/dist/src/types.d.ts +35 -5
- package/package.json +2 -2
- package/schemas/config.json +16 -1
- package/schemas/families.json +8 -5
- package/schemas/handoff-disable.json +22 -0
- package/schemas/handoff-enable.json +22 -0
- package/schemas/handoff-rules.json +302 -0
- package/schemas/handoff-status.json +26 -0
- package/schemas/list.json +5 -0
- package/schemas/menubar-snapshot.json +309 -2
- package/skills/sideby/SKILL.md +3 -2
- package/skills/sideby/references/accounts.md +1 -0
- package/skills/sideby/references/handoff.md +7 -3
- package/skills/sideby/references/quota.md +2 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// The Panel page's inline script. Plain browser JavaScript in a string (no template literals inside, so String.raw
|
|
2
2
|
// keeps it verbatim); the pure helpers from page-logic.ts are prepended so the tested code is the code that runs.
|
|
3
|
+
import { groupsToAccept } from '../core/inbound.js';
|
|
3
4
|
import { quotaIsStale } from '../core/quota-levels.js';
|
|
4
|
-
import {
|
|
5
|
+
import { remoteControlTodo } from '../core/remote-control.js';
|
|
6
|
+
import { aiTaskAccounts, aliasArgsOf, aliasIssue, askBridge, askBridged, askCopy, attentionReasons, attentionWhy, autostartNote, bindingWindow, cacheHitRate, canLeaveLocal, categoryOrder, codeSwapOutcome, enableOutcome, fileSize, fixPrompt, foldSkips, foldToolCalls, formatDuration, handoffChangeOf, handoffHintAccount, handoffTaskFacts, highlightParts, histFilters, historyEmpty, historyWhen, hotkeyFromKey, hotkeyPressKind, inDisplayOrder, loginClusters, loginKey, maskEmail, matchesQuery, mdBlocks, mdInline, menuPlacement, mergeDaily, mergeUsage, messageChip, messageNews, newAccountDir, nextReset, panelFixes, panelHint, panelLang, panelMigration, panelPrefs, passedWindow, pinnedIn, quotaAskable, quotaPressure, 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';
|
|
5
7
|
const LOGIC = [
|
|
6
8
|
quotaIsStale,
|
|
7
9
|
aiTaskAccounts,
|
|
@@ -19,6 +21,7 @@ const LOGIC = [
|
|
|
19
21
|
hotkeyFromKey,
|
|
20
22
|
hotkeyPressKind,
|
|
21
23
|
cacheHitRate,
|
|
24
|
+
categoryOrder,
|
|
22
25
|
fileSize,
|
|
23
26
|
fixPrompt,
|
|
24
27
|
foldSkips,
|
|
@@ -55,6 +58,9 @@ const LOGIC = [
|
|
|
55
58
|
quotaPressure,
|
|
56
59
|
remoteControlSummary,
|
|
57
60
|
remoteControlTodo,
|
|
61
|
+
groupsToAccept,
|
|
62
|
+
saveHandoffChange,
|
|
63
|
+
enableOutcome,
|
|
58
64
|
reorder,
|
|
59
65
|
rowBadge,
|
|
60
66
|
sendBlock,
|
|
@@ -78,6 +84,7 @@ const LOGIC = [
|
|
|
78
84
|
widthFollower,
|
|
79
85
|
widthTier,
|
|
80
86
|
windowState,
|
|
87
|
+
bindingWindow,
|
|
81
88
|
withPinned,
|
|
82
89
|
]
|
|
83
90
|
.map((fn) => fn.toString())
|
|
@@ -150,6 +157,8 @@ const MAIN = String.raw `
|
|
|
150
157
|
const keys = raw.histFold[g] && typeof raw.histFold[g] === 'object' ? Object.keys(raw.histFold[g]).filter((k) => raw.histFold[g][k] === true).slice(0, HIST_FOLD_MAX) : []
|
|
151
158
|
if (keys.length) { p.histFold[g] = {}; for (const k of keys) p.histFold[g][k] = true }
|
|
152
159
|
}
|
|
160
|
+
// The categories of the side list, in the order the user dragged them to.
|
|
161
|
+
p.histCatOrder = Array.isArray(raw.histCatOrder) ? raw.histCatOrder.filter((c) => typeof c === 'string' && c).slice(0, HIST_FOLD_MAX) : []
|
|
153
162
|
// The categories folded in the side list.
|
|
154
163
|
p.histCatFold = {}
|
|
155
164
|
if (raw.histCatFold && typeof raw.histCatFold === 'object')
|
|
@@ -377,6 +386,9 @@ const MAIN = String.raw `
|
|
|
377
386
|
grid: 'M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z',
|
|
378
387
|
list: 'M9 6h11M9 12h11M9 18h11M4 6h.01M4 12h.01M4 18h.01',
|
|
379
388
|
sliders: 'M4 7h10M18 7h2M4 17h4M12 17h8M16 5v4M10 15v4',
|
|
389
|
+
// Lucide "users" and "message-square" (ISC license)
|
|
390
|
+
users: 'M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75',
|
|
391
|
+
messages: 'M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z',
|
|
380
392
|
clock: 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 7v5l3 2',
|
|
381
393
|
mail: 'M3 6h18v12H3zM3 7l9 6 9-6',
|
|
382
394
|
globe: 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM3 12h18M12 3c2.5 2.5 3.8 5.5 3.8 9s-1.3 6.5-3.8 9c-2.5-2.5-3.8-5.5-3.8-9S9.5 5.5 12 3z',
|
|
@@ -589,6 +601,7 @@ const MAIN = String.raw `
|
|
|
589
601
|
function famTitle(a) { return a.familyTitle || family(a.family).title }
|
|
590
602
|
// The email as the page shows it: masked everywhere while "Hide emails" is on (copying still gives the real one).
|
|
591
603
|
function emailText(email) { return prefs.hideEmail ? maskEmail(email) : email }
|
|
604
|
+
let logoWashes = 0
|
|
592
605
|
// A Family's mark: the logo its FamilyDef sets (checked by the loader), or its initials on a color derived from the id.
|
|
593
606
|
// size: '' (cards), 'sm' (rows, groups, dialogs) or 'xs' (inside a chip; no initials fallback there).
|
|
594
607
|
function badge(id, size) {
|
|
@@ -598,10 +611,36 @@ const MAIN = String.raw `
|
|
|
598
611
|
const svg = document.createElementNS(SVG_NS, 'svg')
|
|
599
612
|
svg.setAttribute('viewBox', '0 0 24 24')
|
|
600
613
|
svg.setAttribute('focusable', 'false')
|
|
601
|
-
const
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
614
|
+
const shape = (fill) => {
|
|
615
|
+
const path = document.createElementNS(SVG_NS, 'path')
|
|
616
|
+
path.setAttribute('d', logo.path)
|
|
617
|
+
if (logo.fillRule) path.setAttribute('fill-rule', logo.fillRule)
|
|
618
|
+
if (fill) path.setAttribute('fill', fill)
|
|
619
|
+
return path
|
|
620
|
+
}
|
|
621
|
+
svg.append(shape(null))
|
|
622
|
+
// A multicoloured mark: each wash is the shape again, filled with a gradient that fades out (ids unique per page).
|
|
623
|
+
if (Array.isArray(logo.gradients) && logo.gradients.length) {
|
|
624
|
+
const defs = document.createElementNS(SVG_NS, 'defs')
|
|
625
|
+
svg.prepend(defs)
|
|
626
|
+
for (const g of logo.gradients) {
|
|
627
|
+
const id = 'logo-wash-' + (++logoWashes)
|
|
628
|
+
const lg = document.createElementNS(SVG_NS, 'linearGradient')
|
|
629
|
+
lg.setAttribute('id', id)
|
|
630
|
+
lg.setAttribute('gradientUnits', 'userSpaceOnUse')
|
|
631
|
+
lg.setAttribute('x1', String(g.from[0])); lg.setAttribute('y1', String(g.from[1]))
|
|
632
|
+
lg.setAttribute('x2', String(g.to[0])); lg.setAttribute('y2', String(g.to[1]))
|
|
633
|
+
for (const [offset, opacity] of [['0', '1'], ['1', '0']]) {
|
|
634
|
+
const stop = document.createElementNS(SVG_NS, 'stop')
|
|
635
|
+
stop.setAttribute('offset', offset)
|
|
636
|
+
stop.setAttribute('stop-color', g.color)
|
|
637
|
+
stop.setAttribute('stop-opacity', opacity)
|
|
638
|
+
lg.append(stop)
|
|
639
|
+
}
|
|
640
|
+
defs.append(lg)
|
|
641
|
+
svg.append(shape('url(#' + id + ')'))
|
|
642
|
+
}
|
|
643
|
+
}
|
|
605
644
|
return h('span', { class: cls + ' badge-logo', css: logo.color ? { color: logo.color } : null, title: logo.title || family(id).title, 'aria-hidden': 'true' }, svg)
|
|
606
645
|
}
|
|
607
646
|
if (size === 'xs') return null
|
|
@@ -915,7 +954,8 @@ const MAIN = String.raw `
|
|
|
915
954
|
a.identity && a.identity.email ? { icon: 'mail', label: t('menu.copyEmail'), hint: emailText(a.identity.email), run: () => copyText(a.identity.email) } : null,
|
|
916
955
|
]
|
|
917
956
|
}
|
|
918
|
-
|
|
957
|
+
// A Main-only Family (ADR-0047) has no other Account to create.
|
|
958
|
+
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' }) } }
|
|
919
959
|
// Grouped by what the user wants to do: open, copy, manage. A Same Login row (ADR-0026) passes its other
|
|
920
960
|
// directories: the menu is the one of the directory the row is named after, and each other directory is one item
|
|
921
961
|
// that opens its own actions in the same menu, so the shared actions appear once.
|
|
@@ -1242,18 +1282,20 @@ const MAIN = String.raw `
|
|
|
1242
1282
|
}
|
|
1243
1283
|
// A window's cell: percent and countdown on one line, the bar under them. The label shows where no column
|
|
1244
1284
|
// header does (cards, narrow screens).
|
|
1245
|
-
function meter(w, now, stale, observedAt) {
|
|
1285
|
+
function meter(w, now, stale, observedAt, withLength) {
|
|
1246
1286
|
const st = windowState(w, now, WARN, FAIL)
|
|
1247
1287
|
const passed = passedWindow(w, observedAt, now)
|
|
1248
1288
|
const left = prefs.quota === 'left'
|
|
1249
1289
|
const shown = left ? 100 - st.pct : st.pct
|
|
1250
1290
|
const asOf = stale ? t('quota.asOf', { ago: ago(observedAt) }) : ''
|
|
1251
1291
|
const reset = passed ? t('quota.resetShort') : t('quota.resetsIn', { d: formatDuration(Date.parse(w.resetsAt) - now, lang) })
|
|
1252
|
-
|
|
1292
|
+
// The wide list's column says only the model group, so the hover names which of its limits this is.
|
|
1293
|
+
const title = [withLength ? winTitle(w.label) : '', passed ? t('quota.resetNoData', { date: day(passed.since) }) : t('quota.resetsAt', { at: clock(w.resetsAt) }), asOf].filter(Boolean).join(' · ')
|
|
1253
1294
|
return h('div', { class: 'meter lvl-' + st.level + (stale || passed ? ' lvl-stale' : ''), title },
|
|
1254
1295
|
h('div', { class: 'm-top' },
|
|
1255
1296
|
// Cards show the short window name ("5 小时"); the list and its column titles keep the full one.
|
|
1256
|
-
|
|
1297
|
+
// withLength: the group has other limits too, so name which one this is ("Gemini Models · 5-hour").
|
|
1298
|
+
h('span', { class: 'm-label' }, h('span', { class: 'm-full' }, winTitle(winKey(w)) + (withLength ? ' · ' + winTitle(w.label) : '')), h('span', { class: 'm-short' }, winShort(winKey(w)) + (withLength ? ' · ' + winShort(w.label) : ''))),
|
|
1257
1299
|
h('span', { class: 'm-pct' }, shown + '%', h('span', { class: 'm-unit' }, ' ' + t(left ? 'quota.unitLeft' : 'quota.unitUsed')),
|
|
1258
1300
|
null),
|
|
1259
1301
|
h('span', { class: 'm-reset' + (passed ? ' m-passed' : '') }, Number.isFinite(Date.parse(w.resetsAt)) || passed ? reset : '?')),
|
|
@@ -1304,8 +1346,10 @@ const MAIN = String.raw `
|
|
|
1304
1346
|
// widest Family's, for the wide list's shared columns).
|
|
1305
1347
|
return h('div', { class: 'quota' + (stale ? ' is-stale' : ''), title, css: wins.length ? { '--qr': String(cols.length) } : null },
|
|
1306
1348
|
wins.length ? cols.map((c) => {
|
|
1307
|
-
|
|
1308
|
-
|
|
1349
|
+
// A model group with several limits (Antigravity's 5-hour and weekly) shows the one that binds first.
|
|
1350
|
+
const same = wins.filter((x) => winKey(x) === c)
|
|
1351
|
+
const w = bindingWindow(same, now, WARN, FAIL)
|
|
1352
|
+
return w ? meter(w, now, stale, q.observedAt, same.length > 1) : noMeter(winTitle(c), winShort(c))
|
|
1309
1353
|
}) : h('div', { class: 'q-note' }, t('quota.noWindows')),
|
|
1310
1354
|
// Old numbers keep their colours and say their age once, under the bars.
|
|
1311
1355
|
stale && wins.length ? h('div', { class: 'q-asof', title: failed || t('quota.asOf', { ago: ago(q.observedAt) }) }, icon('clock'), q.fetchError ? t('quota.fetchFailed') + ' · ' : '', t('quota.staleShort', { ago: agoShort(now - Date.parse(q.observedAt)) })) : null)
|
|
@@ -2772,11 +2816,14 @@ const MAIN = String.raw `
|
|
|
2772
2816
|
const mine = useUi && useUi.gid === g.id
|
|
2773
2817
|
const busy = mine && (useUi.step === 'asking' || useUi.step === 'busy')
|
|
2774
2818
|
const asking = mine && (useUi.step === 'confirm' || busy)
|
|
2775
|
-
const rows = [h('
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2819
|
+
const rows = [h('div', { class: 'tg-head' }, badge(entries[0] ? entries[0].family : 'claude', 'sm'),
|
|
2820
|
+
h('p', { class: 'small' }, g.members.length > 1 ? t('tune.groupShared', { list: g.members.join(', ') }) : h('b', { class: 'mono' }, g.members[0])))]
|
|
2821
|
+
// Now, the suggestion and what it saves read as one strip, like the Accounts summary.
|
|
2822
|
+
const saved = pick && pick.savedPercent !== null ? Math.round(pick.savedPercent) : null
|
|
2823
|
+
rows.push(h('div', { class: 'tg-stats' },
|
|
2824
|
+
h('div', { class: 'tg-stat' }, h('span', { class: 'stat-label' }, t('tune.now')), h('div', { class: 'tune-num' }, g.current === null ? defaultSize(claudeModels(entries)) : tuneSize(g.current))),
|
|
2825
|
+
pick ? h('div', { class: 'tg-stat' }, h('span', { class: 'stat-label' }, t('tune.best')), h('div', { class: 'tune-num tune-best' }, tokens(pick.threshold))) : null,
|
|
2826
|
+
saved !== null ? h('div', { class: 'tg-stat', title: t('tune.saved', { n: saved }) }, h('span', { class: 'stat-label' }, t('tune.savedLabel')), h('div', { class: 'tune-num' }, t('tune.savedValue', { n: saved }))) : null))
|
|
2780
2827
|
if (pick) rows.push(h('p', { class: 'muted small' }, t('tune.basis', { model: pick.model, ref: pick.ref })))
|
|
2781
2828
|
if (pick) {
|
|
2782
2829
|
const seen = entries.find((e) => e.ref === pick.ref)
|
|
@@ -2911,9 +2958,21 @@ const MAIN = String.raw `
|
|
|
2911
2958
|
if (canTune) tabs.push(['tuning', t('page.tuning')])
|
|
2912
2959
|
if (canHandoff) tabs.push(['handoff', t('page.handoff')])
|
|
2913
2960
|
nav.hidden = tabs.length < 2
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2961
|
+
// Underline tabs: each page has its mark, the Accounts tab its count and Auto Handoff a dot while it is on.
|
|
2962
|
+
const tabIcon = { accounts: 'users', sessions: 'messages', tuning: 'sliders', handoff: 'swap' }
|
|
2963
|
+
const nAccounts = S.state ? S.state.accounts.length : 0
|
|
2964
|
+
const handoffOn = Boolean(ahState() && ahState().settings.auto)
|
|
2965
|
+
// Redrawn only when something on it changes, so a refresh never replays the underline.
|
|
2966
|
+
const navShape = JSON.stringify([lang, curPage, tabs, nAccounts, handoffOn, sp.opening, pasteCount()])
|
|
2967
|
+
if (nav._drawn !== navShape) {
|
|
2968
|
+
nav._drawn = navShape
|
|
2969
|
+
swapKids(nav, [h('div', { class: 'tabs', role: 'presentation' }, tabs.map(([id, label]) =>
|
|
2970
|
+
h('button', { class: 'tab', type: 'button', role: 'tab', 'data-key': 'tab:' + id, 'aria-selected': curPage === id ? 'true' : 'false', 'aria-busy': id === 'sessions' && sp.opening ? 'true' : null, onclick: () => setPage(id) },
|
|
2971
|
+
id === 'sessions' && sp.opening ? spinner() : icon(tabIcon[id]), h('span', { class: 'tab-label', 'data-label': label }, label),
|
|
2972
|
+
id === 'accounts' && nAccounts ? h('span', { class: 'tab-count' }, String(nAccounts)) : null,
|
|
2973
|
+
id === 'handoff' && handoffOn ? h('span', { class: 'tab-dot', 'aria-label': t('ah.on') }) : null,
|
|
2974
|
+
id === 'sessions' && pasteCount() ? h('span', { class: 'seg-badge', 'data-tip': t('msgn.badge', { n: pasteCount() }), 'aria-label': t('msgn.badge', { n: pasteCount() }) }, String(pasteCount())) : null)))])
|
|
2975
|
+
}
|
|
2917
2976
|
const away = curPage !== 'accounts' && tabs.some(([id]) => id === curPage)
|
|
2918
2977
|
// With no account yet the empty state is the whole page: no summary, no health check.
|
|
2919
2978
|
const none = Boolean(S.state && !S.state.accounts.length)
|
|
@@ -3023,7 +3082,7 @@ const MAIN = String.raw `
|
|
|
3023
3082
|
return ib.loading
|
|
3024
3083
|
}
|
|
3025
3084
|
function inboundGroups() { return (ib.data && ib.data.groups) || [] }
|
|
3026
|
-
function inboundTodo() { return inboundGroups()
|
|
3085
|
+
function inboundTodo() { return groupsToAccept(inboundGroups()) }
|
|
3027
3086
|
function inboundWaiting() { return inboundGroups().filter((g) => g.waits).flatMap((g) => g.accounts).map(shortRef) }
|
|
3028
3087
|
function inboundShape() { return inboundGroups().length > 0 }
|
|
3029
3088
|
const refList = (refs) => refs.join(lang === 'zh' ? '、' : ', ')
|
|
@@ -3090,8 +3149,8 @@ const MAIN = String.raw `
|
|
|
3090
3149
|
return h('li', { class: 'rc-row' },
|
|
3091
3150
|
h('div', null, h('code', null, g.file), ' ', h('span', { class: 'chip chip-sm' + (tone ? ' chip-' + tone : '') }, t(key))),
|
|
3092
3151
|
h('div', { class: 'muted small' }, t('rc.usedBy', { refs: refList(g.accounts.map(shortRef)) })),
|
|
3093
|
-
g.reason ? h('div', { class: 'muted small' }, g.reason) : null,
|
|
3094
|
-
!BOOT.readOnly && todo.includes(g) ? h('div', { class: 'small rc-change' },
|
|
3152
|
+
g.reason ? h('div', { class: 'muted small' }, g.why ? t('settings.why.' + g.why) : g.reason) : null,
|
|
3153
|
+
!BOOT.readOnly && todo.includes(g) ? h('div', { class: 'small rc-change' }, keyChange('crossSessionInbound', g.state === 'hold' ? '"hold"' : null, '"accept"')) : null)
|
|
3095
3154
|
})))
|
|
3096
3155
|
if (BOOT.readOnly) body.push(h('p', { class: 'small' }, t('inb.readOnly')))
|
|
3097
3156
|
else if (todo.length) body.push(h('p', { class: 'small muted' }, t('inb.confirmNote')))
|
|
@@ -3109,8 +3168,9 @@ const MAIN = String.raw `
|
|
|
3109
3168
|
async function inboundAccept() {
|
|
3110
3169
|
inboundBusy(true)
|
|
3111
3170
|
try {
|
|
3112
|
-
const r = await api('/api/messages/inbound/accept', {})
|
|
3113
|
-
if (r.
|
|
3171
|
+
const r = await api('/api/messages/inbound/accept', { confirm: true, files: inboundTodo().map((g) => g.file) })
|
|
3172
|
+
if (r.changedSince) toast(t('as.changedSince'), { kind: 'fail' })
|
|
3173
|
+
else if (r.ok) {
|
|
3114
3174
|
if (dlg.kind === 'inbound' && dlg.el.open) dlg.el.close()
|
|
3115
3175
|
toast(t('inb.done'), { kind: 'ok', key: 'inb', action: { label: t('toast.undo'), run: inboundUndo }, duration: 12000 })
|
|
3116
3176
|
} else toast(t('inb.failed', { msg: r.message }), { kind: 'fail' })
|
|
@@ -3121,7 +3181,7 @@ const MAIN = String.raw `
|
|
|
3121
3181
|
async function inboundUndo() {
|
|
3122
3182
|
inboundBusy(true)
|
|
3123
3183
|
try {
|
|
3124
|
-
const r = await api('/api/messages/inbound/undo', {})
|
|
3184
|
+
const r = await api('/api/messages/inbound/undo', { confirm: true })
|
|
3125
3185
|
if (r.ok && dlg.kind === 'inbound' && dlg.el.open) dlg.el.close()
|
|
3126
3186
|
toast(r.ok ? t('inb.undone') : r.message, { kind: r.ok ? 'ok' : 'fail', key: 'inb' })
|
|
3127
3187
|
} catch (e) { toast(t('toast.undoFailed', { msg: e.message }), { kind: 'fail' }) }
|
|
@@ -3680,7 +3740,7 @@ const MAIN = String.raw `
|
|
|
3680
3740
|
e.search = h('label', { class: 'search hist-search' }, icon('search', 'search-ic'), e.q)
|
|
3681
3741
|
e.head = h('div', { class: 'section-head' })
|
|
3682
3742
|
e.intro = h('p', { class: 'muted small' })
|
|
3683
|
-
e.side = h('nav', { class: 'hist-side' })
|
|
3743
|
+
e.side = h('nav', { class: 'hist-side', ondragover: onCatDragOver, ondrop: onCatDrop })
|
|
3684
3744
|
e.status = h('div', { class: 'hist-status' })
|
|
3685
3745
|
e.list = h('div', { class: 'hist-list' })
|
|
3686
3746
|
e.tail = h('div', { class: 'hist-tail' })
|
|
@@ -3791,7 +3851,7 @@ const MAIN = String.raw `
|
|
|
3791
3851
|
if (!e || !e.root.isConnected) return
|
|
3792
3852
|
const list = hs.projects
|
|
3793
3853
|
const shown = list && list.map((p) => [p.project, p.name, p.sessions, p.gone, p.category])
|
|
3794
|
-
drawIf(e.side, JSON.stringify([lang, hs.project, hs.category, shown, hs.cats, hs.projError ? hs.projError.message : '']), () => {
|
|
3854
|
+
drawIf(e.side, JSON.stringify([lang, hs.project, hs.category, shown, hs.cats, prefs.histCatOrder, hs.projError ? hs.projError.message : '']), () => {
|
|
3795
3855
|
const total = list ? list.reduce((n, p) => n + p.sessions, 0) : 0
|
|
3796
3856
|
const item = (project, name, count, gone, tip) => h('button', { class: 'hist-proj', type: 'button', 'data-key': 'hist-p-' + project, 'aria-pressed': hs.project === project && !(project === '' && hs.category) ? 'true' : 'false', title: tip || null, onclick: () => pickProject(project) },
|
|
3797
3857
|
h('span', { class: 'hist-proj-name' }, name),
|
|
@@ -3802,11 +3862,12 @@ const MAIN = String.raw `
|
|
|
3802
3862
|
const proj = (p) => item(p.project, p.name, p.sessions, p.gone, p.project + (p.gone ? ' · ' + t('hist.gone') : ''))
|
|
3803
3863
|
const all = item('', t('hist.allProjects'), total)
|
|
3804
3864
|
if (!hs.cats) return [h('h3', { class: 'hist-side-h' }, t('hist.projects')), h('div', { class: 'hist-projs' }, all, list.map(proj))]
|
|
3805
|
-
// With a plugin's categories: each category heads its Projects, in the order
|
|
3806
|
-
//
|
|
3865
|
+
// With a plugin's categories: each category heads its Projects, in the order the user dragged them to, else
|
|
3866
|
+
// of their latest Session; a category heading folds them. Projects without one come last.
|
|
3807
3867
|
const cats = new Map()
|
|
3808
3868
|
for (const p of list) { const c = p.category || ''; if (!cats.has(c)) cats.set(c, []); cats.get(c).push(p) }
|
|
3809
|
-
const order = [...cats.keys()].
|
|
3869
|
+
const order = categoryOrder([...cats.keys()], prefs.histCatOrder)
|
|
3870
|
+
hs.catNames = order.filter(Boolean)
|
|
3810
3871
|
return [h('h3', { class: 'hist-side-h' }, groupName('category')), h('div', { class: 'hist-projs' }, all,
|
|
3811
3872
|
order.map((c) => {
|
|
3812
3873
|
const ps = cats.get(c)
|
|
@@ -3814,20 +3875,72 @@ const MAIN = String.raw `
|
|
|
3814
3875
|
const name = c || t('hist.noCategory')
|
|
3815
3876
|
const folded = Boolean(prefs.histCatFold[c])
|
|
3816
3877
|
const bodyId = 'hcat-' + order.indexOf(c)
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
const
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
:
|
|
3823
|
-
|
|
3824
|
-
|
|
3878
|
+
// The whole heading folds the category, so a click anywhere on it opens or closes its Projects.
|
|
3879
|
+
// A named category also moves: dragged, or with Alt and the arrow keys. Projects without one stay last.
|
|
3880
|
+
const head = h('button', { class: 'hist-proj hist-cat', type: 'button', 'data-key': 'hist-cf-' + c, 'aria-expanded': String(!folded), 'aria-controls': bodyId,
|
|
3881
|
+
'aria-label': t('group.toggle', { title: name, count: String(n), action: t(folded ? 'hist.unfoldOne' : 'hist.fold') }),
|
|
3882
|
+
draggable: c ? 'true' : null, title: c ? t('hist.catMove') : null,
|
|
3883
|
+
ondragstart: c ? (ev) => {
|
|
3884
|
+
hs.catDrag = { from: hs.catNames.indexOf(c), to: null }
|
|
3885
|
+
ev.dataTransfer.effectAllowed = 'move'
|
|
3886
|
+
try { ev.dataTransfer.setData('text/plain', c) } catch {}
|
|
3887
|
+
requestAnimationFrame(() => grp.classList.add('is-dragging'))
|
|
3888
|
+
} : null,
|
|
3889
|
+
ondragend: c ? () => endCatDrag() : null,
|
|
3890
|
+
onkeydown: c ? (ev) => {
|
|
3891
|
+
const step = { ArrowUp: -1, ArrowDown: 1 }[ev.key]
|
|
3892
|
+
if (!ev.altKey || !step) return
|
|
3893
|
+
ev.preventDefault()
|
|
3894
|
+
const from = hs.catNames.indexOf(c)
|
|
3895
|
+
moveCategory(from, Math.max(0, Math.min(hs.catNames.length - 1, from + step)), c)
|
|
3896
|
+
} : null },
|
|
3897
|
+
icon('chevron', 'chev'), h('span', { class: 'hist-proj-name' }, name), h('span', { class: 'hist-proj-n' }, String(n)))
|
|
3898
|
+
const grp = h('div', { class: 'hist-catgrp' + (folded ? ' is-folded' : ''), role: 'group', 'aria-label': name, 'data-cat': c },
|
|
3899
|
+
h('div', { class: 'hist-cathead' }, head),
|
|
3825
3900
|
h('div', { class: 'hist-catbody', id: bodyId }, h('div', { class: 'hist-catps' }, ps.map(proj))))
|
|
3826
|
-
|
|
3901
|
+
head.addEventListener('click', () => foldCategory(c, grp, head, name, n))
|
|
3827
3902
|
return grp
|
|
3828
3903
|
}))]
|
|
3829
3904
|
})
|
|
3830
3905
|
}
|
|
3906
|
+
// Dragging a category over the side list marks where it would land: before the category under the pointer, or after
|
|
3907
|
+
// it past its middle. Projects without a category stay last, so nothing lands after them.
|
|
3908
|
+
function onCatDragOver(ev) {
|
|
3909
|
+
const d = hs.catDrag
|
|
3910
|
+
const grp = d && ev.target.closest && ev.target.closest('.hist-catgrp[data-cat]')
|
|
3911
|
+
if (!grp) return
|
|
3912
|
+
ev.preventDefault()
|
|
3913
|
+
ev.dataTransfer.dropEffect = 'move'
|
|
3914
|
+
const c = grp.getAttribute('data-cat')
|
|
3915
|
+
const r = grp.getBoundingClientRect()
|
|
3916
|
+
const after = c !== '' && ev.clientY > r.top + r.height / 2
|
|
3917
|
+
const at = (c === '' ? hs.catNames.length : hs.catNames.indexOf(c)) + (after ? 1 : 0)
|
|
3918
|
+
clearDropMarks()
|
|
3919
|
+
grp.classList.add(after ? 'drop-after' : 'drop-before')
|
|
3920
|
+
// Dropped after itself means one place earlier once it is taken out.
|
|
3921
|
+
d.to = Math.min(hs.catNames.length - 1, at > d.from ? at - 1 : at)
|
|
3922
|
+
}
|
|
3923
|
+
function onCatDrop(ev) {
|
|
3924
|
+
const d = hs.catDrag
|
|
3925
|
+
if (!d || d.to === null) return
|
|
3926
|
+
ev.preventDefault()
|
|
3927
|
+
endCatDrag()
|
|
3928
|
+
moveCategory(d.from, d.to)
|
|
3929
|
+
}
|
|
3930
|
+
function endCatDrag() {
|
|
3931
|
+
hs.catDrag = null
|
|
3932
|
+
clearDropMarks()
|
|
3933
|
+
for (const el of document.querySelectorAll('.hist-catgrp.is-dragging')) el.classList.remove('is-dragging')
|
|
3934
|
+
}
|
|
3935
|
+
// The new order is kept in this browser, with the other preferences; the focus follows a category moved by keys.
|
|
3936
|
+
function moveCategory(from, to, focus) {
|
|
3937
|
+
if (from < 0 || from === to) return
|
|
3938
|
+
prefs.histCatOrder = reorder(hs.catNames, hs.catNames.map((c) => [c]), from, to).slice(0, HIST_FOLD_MAX)
|
|
3939
|
+
savePrefs()
|
|
3940
|
+
renderHistorySide()
|
|
3941
|
+
const el = focus && hs.els && hs.els.side.querySelector('[data-key="' + CSS.escape('hist-cf-' + focus) + '"]')
|
|
3942
|
+
if (el) el.focus()
|
|
3943
|
+
}
|
|
3831
3944
|
// A category in the side list folds in place (CSS eases its height); the list is not drawn again for it.
|
|
3832
3945
|
function foldCategory(c, grp, chev, name, n) {
|
|
3833
3946
|
const folded = !prefs.histCatFold[c]
|
|
@@ -3847,13 +3960,6 @@ const MAIN = String.raw `
|
|
|
3847
3960
|
renderHistorySide()
|
|
3848
3961
|
historyChanged(false)
|
|
3849
3962
|
}
|
|
3850
|
-
function pickCategory(c) {
|
|
3851
|
-
if (hs.category === c) return
|
|
3852
|
-
hs.category = c
|
|
3853
|
-
hs.project = ''
|
|
3854
|
-
renderHistorySide()
|
|
3855
|
-
historyChanged(false)
|
|
3856
|
-
}
|
|
3857
3963
|
// ---------- grouping the list ----------
|
|
3858
3964
|
// A "Display" popover by the filters picks how the list is grouped; a group folds from its header and stays
|
|
3859
3965
|
// folded in this browser. The server pages through the groups in order and counts folded ones without their rows.
|
|
@@ -4016,7 +4122,7 @@ const MAIN = String.raw `
|
|
|
4016
4122
|
open.addEventListener('click', () => openHistoryView(s, open))
|
|
4017
4123
|
const more = h('button', { class: 'icon-btn more', type: 'button', 'aria-haspopup': 'menu', 'aria-expanded': 'false', 'data-key': 'hist-more-' + k, 'aria-label': t('hist.more', { title }), 'data-tip': t('menu.title') }, icon('more'))
|
|
4018
4124
|
more.addEventListener('click', () => historyMenu(more, s))
|
|
4019
|
-
const view = h('button', { class: 'btn
|
|
4125
|
+
const view = h('button', { class: 'icon-btn hist-view', type: 'button', 'data-key': 'hist-view-' + k, 'aria-label': t('hist.openLabel', { title }), 'data-tip': t('hist.viewShort') }, icon('eye'))
|
|
4020
4126
|
view.addEventListener('click', () => openHistoryView(s, view))
|
|
4021
4127
|
const cont = h('button', { class: 'btn btn-sm hist-cont', type: 'button', 'data-key': 'hist-cont-' + k, 'aria-label': t('hist.continueFor', { title }), 'data-tip': t(s.cwdGone ? 'hist.continueGoneTip' : 'hist.continueTip') }, icon('terminal'), h('span', null, t('hist.continueShort')))
|
|
4022
4128
|
cont.addEventListener('click', () => copyContinue(cont, s))
|
|
@@ -4487,6 +4593,7 @@ const MAIN = String.raw `
|
|
|
4487
4593
|
// New account. The form is built once per opening so typing keeps focus; only its derived parts re-render.
|
|
4488
4594
|
let nf = null
|
|
4489
4595
|
function familyStatus(f) {
|
|
4596
|
+
if (f.mainOnly) return 'main-only'
|
|
4490
4597
|
const hasMain = S.state && S.state.accounts.some((a) => a.family === f.id && a.isMain)
|
|
4491
4598
|
if (hasMain) return 'ready'
|
|
4492
4599
|
return f.installed ? 'no-main' : 'missing'
|
|
@@ -4494,7 +4601,7 @@ const MAIN = String.raw `
|
|
|
4494
4601
|
function openCreate(prefill) {
|
|
4495
4602
|
if (BOOT.readOnly || !S.state) return
|
|
4496
4603
|
const fams = S.state.families.slice().sort((x, y) => {
|
|
4497
|
-
const rank = (f) => ({ ready: 0, 'no-main': 1, missing: 2 })[familyStatus(f)]
|
|
4604
|
+
const rank = (f) => ({ ready: 0, 'no-main': 1, missing: 2, 'main-only': 3 })[familyStatus(f)]
|
|
4498
4605
|
return rank(x) - rank(y)
|
|
4499
4606
|
})
|
|
4500
4607
|
const ready = fams.filter((f) => familyStatus(f) === 'ready')
|
|
@@ -4574,7 +4681,7 @@ const MAIN = String.raw `
|
|
|
4574
4681
|
renderPreview()
|
|
4575
4682
|
})
|
|
4576
4683
|
const n = S.state.accounts.filter((a) => a.family === f.id).length
|
|
4577
|
-
const sub = st === 'ready' ? tn('nf.accounts', n) : st === 'no-main' ? tx('nf.runOnce', { bin: h('code', null, f.bin) }) : t(f.brokenBin ? 'nf.broken' : 'nf.notInstalled')
|
|
4684
|
+
const sub = st === 'ready' ? tn('nf.accounts', n) : st === 'main-only' ? t('nf.mainOnly') : st === 'no-main' ? tx('nf.runOnce', { bin: h('code', null, f.bin) }) : t(f.brokenBin ? 'nf.broken' : 'nf.notInstalled')
|
|
4578
4685
|
return h('label', { class: 'fam-card' + (st === 'ready' ? '' : ' is-off') }, input, badge(f.id, 'sm'),
|
|
4579
4686
|
h('span', { class: 'fam-text' }, h('span', { class: 'fam-title' }, f.title), h('span', { class: 'fam-sub' }, sub)))
|
|
4580
4687
|
})
|
|
@@ -4806,7 +4913,7 @@ const MAIN = String.raw `
|
|
|
4806
4913
|
const cur = s.families[f]
|
|
4807
4914
|
orders[f] = { policy: cur && cur.policy === 'order' ? 'order' : 'pressure', order: cur ? cur.order.slice() : [] }
|
|
4808
4915
|
}
|
|
4809
|
-
return { auto: s.auto, sameFamily: s.sameFamily, prepareAt: s.prepareAt, threshold: s.threshold, wait: s.waitIfResetWithinMinutes, countdown: s.countdownSeconds, orders }
|
|
4916
|
+
return { auto: s.auto, sameFamily: s.sameFamily, prepareAt: s.prepareAt, threshold: s.threshold, wait: s.waitIfResetWithinMinutes, countdown: s.countdownSeconds, orders, crossOrganization: s.crossOrganization.slice() }
|
|
4810
4917
|
}
|
|
4811
4918
|
// "Let AI tune it" (spec §3.29): the AI gets the facts of sideby handoff status --json, as far as the page has them.
|
|
4812
4919
|
function askHandoff() {
|
|
@@ -4815,11 +4922,14 @@ const MAIN = String.raw `
|
|
|
4815
4922
|
const status = ah && ah.status ? ah.status : null
|
|
4816
4923
|
openAsk({ task: 'handoff', context: { handoff: handoffTaskFacts(st.settings, st.starters, S.state.accounts, Date.now(), status), version: BOOT.version } })
|
|
4817
4924
|
}
|
|
4818
|
-
|
|
4925
|
+
// focus: the field a rule's "Change…" is about, so the dialog opens at it.
|
|
4926
|
+
async function openHandoff(focus) {
|
|
4819
4927
|
if (!ahState()) return
|
|
4820
4928
|
ah = { form: handoffForm(), loading: true }
|
|
4821
4929
|
showDialog('handoff')
|
|
4822
4930
|
renderHandoff()
|
|
4931
|
+
const field = typeof focus === 'string' ? document.getElementById('ah-' + focus) : null
|
|
4932
|
+
if (field) field.focus()
|
|
4823
4933
|
await loadHandoffStatus()
|
|
4824
4934
|
}
|
|
4825
4935
|
async function loadHandoffStatus() {
|
|
@@ -4883,6 +4993,24 @@ const MAIN = String.raw `
|
|
|
4883
4993
|
} else kids.push(h('p', { class: 'muted small' }, t('ah.byQuotaHint')))
|
|
4884
4994
|
return h('div', { class: 'ah-fam' }, kids)
|
|
4885
4995
|
}
|
|
4996
|
+
// Accounts that may take over although signed in to another organization (config handoff.crossOrganization).
|
|
4997
|
+
function ahCrossOrganization() {
|
|
4998
|
+
const list = ah.form.crossOrganization
|
|
4999
|
+
const accounts = S.state.accounts.filter((a) => a.kind !== 'api')
|
|
5000
|
+
if (!accounts.length) return null
|
|
5001
|
+
return h('details', { class: 'ah-fam', open: list.length > 0 },
|
|
5002
|
+
h('summary', null, h('b', null, t('ah.crossOrg'))),
|
|
5003
|
+
h('p', { class: 'muted small' }, t('ah.crossOrgHint')),
|
|
5004
|
+
h('div', { class: 'ah-cross' }, accounts.map((a) => {
|
|
5005
|
+
const input = h('input', { type: 'checkbox', disabled: BOOT.readOnly })
|
|
5006
|
+
input.checked = list.includes(a.ref) || (a.aliases || []).some((n) => list.includes(n))
|
|
5007
|
+
input.addEventListener('change', () => ahEdit((f) => {
|
|
5008
|
+
f.crossOrganization = f.crossOrganization.filter((r) => r !== a.ref && !(a.aliases || []).includes(r))
|
|
5009
|
+
if (input.checked) f.crossOrganization.push(a.ref)
|
|
5010
|
+
}))
|
|
5011
|
+
return h('label', { class: 'check' }, input, h('span', { class: 'title-logo' }, badge(a.family, 'sm'), h('span', { class: 'mono' }, accountLabel(a.ref))))
|
|
5012
|
+
})))
|
|
5013
|
+
}
|
|
4886
5014
|
function ahReadiness() {
|
|
4887
5015
|
if (ah.loading) return h('p', { class: 'muted' }, spinner(), ' ', t('ah.checking'))
|
|
4888
5016
|
if (ah.error) return errorNote(ah.error, loadHandoffStatus)
|
|
@@ -4915,6 +5043,7 @@ const MAIN = String.raw `
|
|
|
4915
5043
|
ahNumber('countdown', t('ah.countdown'), 0, 60)))
|
|
4916
5044
|
if (f.prepareAt >= f.threshold) body.push(h('p', { class: 'note note-warn' }, t('ah.badLevels')))
|
|
4917
5045
|
for (const fam of st.starters) body.push(ahFamily(fam))
|
|
5046
|
+
body.push(ahCrossOrganization())
|
|
4918
5047
|
// The result of Review or Apply sits right under the form, where the button that made it is.
|
|
4919
5048
|
if (ah.applyError) body.push(errorNote(ah.applyError, null))
|
|
4920
5049
|
if (ah.saved) body.push(h('p', { class: 'note' }, t('ah.saved', { file: ah.saved })))
|
|
@@ -4954,6 +5083,8 @@ const MAIN = String.raw `
|
|
|
4954
5083
|
ah.preview = null
|
|
4955
5084
|
toast(r.settings.auto ? t('toast.ahOn') : t('toast.ahOff'))
|
|
4956
5085
|
await load({ silent: true })
|
|
5086
|
+
// The Handoff Rules behind the dialog show the new settings too.
|
|
5087
|
+
if (curPage === 'handoff') loadHandoffPage()
|
|
4957
5088
|
if (ahState()) ah.form = handoffForm()
|
|
4958
5089
|
ah.loading = true
|
|
4959
5090
|
ah.status = null
|
|
@@ -5089,7 +5220,7 @@ const MAIN = String.raw `
|
|
|
5089
5220
|
// ---------- the Auto Handoff page ----------
|
|
5090
5221
|
// Off: one sentence and one button. On: where each account's work would go next, the last hand-overs and what is
|
|
5091
5222
|
// still missing. Turning on is one plan shown first (hp.preview) and one confirmation; no commands to copy.
|
|
5092
|
-
const hp = { data: null, plan: null, loading: false, error: null, preview: null, previewing: false, applying: false, failed: null, changed: false,
|
|
5223
|
+
const hp = { data: null, plan: null, loading: false, error: null, preview: null, previewing: false, applying: false, failed: null, changed: false, busyOff: false, askSame: false, askApi: false }
|
|
5093
5224
|
async function loadHandoffPage() {
|
|
5094
5225
|
// One read at a time: a second refresh while one runs would end its spinner early.
|
|
5095
5226
|
if (hp.loading) return
|
|
@@ -5105,8 +5236,8 @@ const MAIN = String.raw `
|
|
|
5105
5236
|
hp.loading = false
|
|
5106
5237
|
renderHandoffPage()
|
|
5107
5238
|
}
|
|
5108
|
-
//
|
|
5109
|
-
function hpBody() { return
|
|
5239
|
+
// The Handoff Rules on this page write each setting as it is switched, so turning on keeps whatever is set.
|
|
5240
|
+
function hpBody() { return {} }
|
|
5110
5241
|
async function hpPreview() {
|
|
5111
5242
|
hp.previewing = true
|
|
5112
5243
|
hp.failed = null
|
|
@@ -5122,11 +5253,10 @@ const MAIN = String.raw `
|
|
|
5122
5253
|
renderHandoffPage()
|
|
5123
5254
|
try {
|
|
5124
5255
|
const r = await api('/api/handoff/enable', Object.assign(hpBody(), { confirm: true, expect: hp.preview && hp.preview.key }))
|
|
5125
|
-
const
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
if (
|
|
5129
|
-
else if (bad) hp.failed = { step: bad, plan: r.plan }
|
|
5256
|
+
const out = enableOutcome(r)
|
|
5257
|
+
hp.changed = out.kind === 'changed'
|
|
5258
|
+
if (out.kind === 'changed' || out.kind === 'blocked') hp.preview = out.plan
|
|
5259
|
+
else if (out.kind === 'failed') hp.failed = { step: out.step, plan: out.plan }
|
|
5130
5260
|
else { hp.preview = null; toast(t('toast.ahOn')) }
|
|
5131
5261
|
await load({ silent: true })
|
|
5132
5262
|
await loadHandoffPage()
|
|
@@ -5134,14 +5264,16 @@ const MAIN = String.raw `
|
|
|
5134
5264
|
hp.applying = false
|
|
5135
5265
|
renderHandoffPage()
|
|
5136
5266
|
}
|
|
5137
|
-
|
|
5267
|
+
// Every change on this page applies at once and its toast carries the undo (spec §3.17 "接力规则").
|
|
5268
|
+
async function hpChange(change, message, opts) {
|
|
5138
5269
|
hp.busyOff = true
|
|
5139
5270
|
renderHandoffPage()
|
|
5140
5271
|
try {
|
|
5141
|
-
await
|
|
5272
|
+
const { undo } = await saveHandoffChange(api, change, opts)
|
|
5142
5273
|
hp.preview = null
|
|
5143
5274
|
hp.askSame = false
|
|
5144
|
-
|
|
5275
|
+
hp.askApi = false
|
|
5276
|
+
toast(message, undo ? { action: { label: t('toast.undo'), run: () => hpChange(undo, t('hp.undone'), { noUndo: true }) }, duration: 12000 } : undefined)
|
|
5145
5277
|
await load({ silent: true })
|
|
5146
5278
|
await loadHandoffPage()
|
|
5147
5279
|
} catch (e) { hp.failed = { error: e } }
|
|
@@ -5181,39 +5313,116 @@ const MAIN = String.raw `
|
|
|
5181
5313
|
return h('p', { class: 'note note-fail', role: 'alert' }, t('hp.stepFailed', { step: hpStepTitle(f.step), why: f.step.message || '' }) + ' ' + t('hp.tryAgain'))
|
|
5182
5314
|
}
|
|
5183
5315
|
function hpDecision(d, starts) {
|
|
5184
|
-
|
|
5185
|
-
if (d.kind === 'pick') return starts.includes('quota') ? t('hp.goesTo', { to: accountLabel(d.ref), p: thr }) : t('hp.goesToLimit', { to: accountLabel(d.ref) })
|
|
5316
|
+
if (d.kind === 'pick') return starts.includes('quota') ? t('hp.goesTo', { to: accountLabel(d.ref) }) : t('hp.goesToLimit', { to: accountLabel(d.ref) })
|
|
5186
5317
|
if (d.kind === 'wait') return t('hp.waits', { at: clock(d.until) })
|
|
5187
5318
|
return d.earliestReset ? t('hp.noneBack', { ref: accountLabel(d.earliestReset.ref), at: clock(d.earliestReset.at) }) : t('hp.none')
|
|
5188
5319
|
}
|
|
5189
|
-
// The one case where reaching the threshold does not switch (spec §3.17 "选号" 1); none when waiting is off.
|
|
5190
|
-
function hpWaitRule(st) {
|
|
5191
|
-
const w = st.settings.waitIfResetWithinMinutes
|
|
5192
|
-
return w > 0 ? ' ' + t('hp.waitRule', { w }) : null
|
|
5193
|
-
}
|
|
5194
5320
|
function hpRows(d) {
|
|
5195
5321
|
if (!d.takeover.length) return h('p', { class: 'muted small' }, t('hp.noAccounts'))
|
|
5196
5322
|
return h('ul', { class: 'hp-rows' }, d.takeover.map((r) => {
|
|
5197
5323
|
const a = S.state.accounts.find((x) => x.ref === r.ref)
|
|
5198
5324
|
const p = a ? quotaPressure(a, Date.now()) : -1
|
|
5199
5325
|
return h('li', null,
|
|
5200
|
-
h('span', { class: 'title-logo' }, badge(r.family, 'sm'), h('
|
|
5201
|
-
h('span', { class: 'muted' }, p >= 0 ? t('hp.used', { p: Math.round(p) }) : t('hp.noQuota')),
|
|
5202
|
-
h('span', null, hpDecision(r.decision, r.starts)))
|
|
5326
|
+
h('span', { class: 'title-logo' }, badge(r.family, 'sm'), h('span', { class: 'mono' }, accountLabel(r.ref))),
|
|
5327
|
+
h('span', { class: 'muted num' }, p >= 0 ? t('hp.used', { p: Math.round(p) }) : t('hp.noQuota')),
|
|
5328
|
+
h('span', { class: r.decision.kind === 'none' ? 'muted' : null }, hpDecision(r.decision, r.starts)))
|
|
5203
5329
|
}))
|
|
5204
5330
|
}
|
|
5205
5331
|
function hpRecent(d) {
|
|
5206
5332
|
if (!d.recent.length) return h('p', { class: 'muted small' }, t('hp.noneYet'))
|
|
5207
|
-
return h('ul', { class: 'hp-rows' }, d.recent.map((r) => h('li', null,
|
|
5333
|
+
return h('ul', { class: 'hp-rows hp-recent' }, d.recent.map((r) => h('li', null,
|
|
5208
5334
|
h('span', { class: 'mono' }, accountLabel(r.from) + ' → ' + accountLabel(r.to)),
|
|
5209
|
-
h('span', { class: 'muted' }, clock(r.at) + ' · ' + ago(r.at)),
|
|
5335
|
+
h('span', { class: 'muted num' }, clock(r.at) + ' · ' + ago(r.at)),
|
|
5210
5336
|
h('span', { class: 'muted' }, r.trigger ? t('hp.why.' + r.trigger) : ''))))
|
|
5211
5337
|
}
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5338
|
+
// ---- Handoff Rules (spec §3.17 "接力规则"): every rule in effect, each next to the switch that changes it ----
|
|
5339
|
+
function hpRuleText(r) {
|
|
5340
|
+
const p = r.params
|
|
5341
|
+
const thr = ahState().settings.threshold
|
|
5342
|
+
switch (r.id) {
|
|
5343
|
+
case 'when': return p.adaptive ? t('hp.rule.whenAdaptive', { prepare: p.prepareAt, p: p.threshold, max: p.max }) : t('hp.rule.when', { prepare: p.prepareAt, p: p.threshold })
|
|
5344
|
+
case 'windows': return t('hp.rule.windows')
|
|
5345
|
+
case 'takeover': return t('hp.rule.takeover', { limit: p.limit, p: thr })
|
|
5346
|
+
case 'wait': return p.minutes > 0 ? t('hp.rule.wait', { w: p.minutes }) : t('hp.rule.noWait')
|
|
5347
|
+
case 'sameFamily': return t(p.on ? 'hp.rule.sameOn' : 'hp.rule.sameOff')
|
|
5348
|
+
case 'otherFamilies': return p.on ? t('hp.rule.otherOn') : t('hp.rule.otherOff')
|
|
5349
|
+
case 'api': return t(p.on ? 'hp.rule.apiOn' : 'hp.rule.apiOff')
|
|
5350
|
+
case 'organization': return p.allowed.length ? t('hp.rule.orgExcept', { refs: p.allowed.map(accountLabel).join(', ') }) : t('hp.rule.org')
|
|
5351
|
+
case 'order': return t('hp.rule.order', { host: family(p.family).title, order: p.order.map(accountLabel).join(' → ') })
|
|
5352
|
+
case 'countdown': return p.seconds > 0 ? t('hp.rule.countdown', { s: p.seconds }) : t('hp.rule.noCountdown')
|
|
5353
|
+
}
|
|
5354
|
+
return r.text
|
|
5355
|
+
}
|
|
5356
|
+
// An on/off pair like Remote Control's; onPick(true|false) runs only when the side changes.
|
|
5357
|
+
function hpSwitch(key, label, on, onPick) {
|
|
5358
|
+
return h('div', { class: 'seg', role: 'group', 'aria-label': label }, [true, false].map((v) =>
|
|
5359
|
+
h('button', { class: 'seg-btn', type: 'button', 'data-key': key + ':' + v, disabled: BOOT.readOnly || hp.busyOff, 'aria-pressed': String(on === v), onclick: () => { if (on !== v) onPick(v) } }, t(v ? 'hp.on' : 'hp.off'))))
|
|
5360
|
+
}
|
|
5361
|
+
function hpEditBtn(key) {
|
|
5362
|
+
const field = { when: 'prepareAt', wait: 'wait', countdown: 'countdown' }[key]
|
|
5363
|
+
return h('button', { class: 'link-btn', type: 'button', 'data-key': 'edit:' + key, onclick: () => openHandoff(field) }, t('hp.edit'))
|
|
5364
|
+
}
|
|
5365
|
+
function hpConfirm(key, warn, cancel, confirmLabel, run) {
|
|
5366
|
+
return h('div', { class: 'ah-fam hp-confirm', 'data-enter': key },
|
|
5367
|
+
h('p', { class: 'note note-warn' }, warn),
|
|
5368
|
+
h('div', { class: 'row-actions' },
|
|
5369
|
+
h('button', { class: 'btn btn-sm', type: 'button', disabled: hp.busyOff, onclick: cancel }, t('btn.cancel')),
|
|
5370
|
+
h('button', { class: 'btn btn-sm btn-primary', type: 'button', 'data-key': 'confirm:' + key, disabled: BOOT.readOnly || hp.busyOff, onclick: run }, confirmLabel)))
|
|
5371
|
+
}
|
|
5372
|
+
// The AIs in the order they take over; ↑↓ write familyOrder at once.
|
|
5373
|
+
function hpAiOrder(order) {
|
|
5374
|
+
const move = (i, d) => { const l = order.slice(); const x = l[i]; l[i] = l[i + d]; l[i + d] = x; hpChange({ familyOrder: l }, t('hp.aiOrderSaved')) }
|
|
5375
|
+
return h('ol', { class: 'ah-order hp-ai-order' }, order.map((f, i) => h('li', null,
|
|
5376
|
+
h('span', { class: 'title-logo' }, badge(f, 'sm'), (i + 1) + '. ' + family(f).title),
|
|
5377
|
+
h('button', { class: 'btn btn-sm', type: 'button', 'data-key': 'up:' + f, disabled: BOOT.readOnly || hp.busyOff || i === 0, 'aria-label': t('ah.up'), onclick: () => move(i, -1) }, '↑'),
|
|
5378
|
+
h('button', { class: 'btn btn-sm', type: 'button', 'data-key': 'down:' + f, disabled: BOOT.readOnly || hp.busyOff || i === order.length - 1, 'aria-label': t('ah.down'), onclick: () => move(i, 1) }, '↓'))))
|
|
5379
|
+
}
|
|
5380
|
+
// ctl sits right of the rule's text; below takes the full width under it (a sub-switch, a confirmation, the AI order).
|
|
5381
|
+
function hpRuleControls(r) {
|
|
5382
|
+
const p = r.params
|
|
5383
|
+
switch (r.id) {
|
|
5384
|
+
case 'when': return { ctl: [hpEditBtn('when')], below: [h('div', { class: 'hp-rule-sub' }, h('span', { class: 'muted small' }, t('hp.adaptive')),
|
|
5385
|
+
hpSwitch('adaptive', t('hp.adaptive'), p.adaptive, (v) => hpChange({ adaptive: v }, t(v ? 'hp.adaptiveOn' : 'hp.adaptiveOff'))))] }
|
|
5386
|
+
case 'wait': case 'countdown': case 'order': case 'organization': return { ctl: [hpEditBtn(r.id)], below: [] }
|
|
5387
|
+
case 'sameFamily': return { ctl: [hpSwitch('same', t('hp.sameFamily'), p.on, (v) => {
|
|
5388
|
+
if (v) { hp.askSame = true; renderHandoffPage() } else hpChange({ sameFamily: false }, t('hp.sameOff'))
|
|
5389
|
+
})], below: [hp.askSame && !p.on ? hpConfirm('same', t('ah.sameFamilyWarn'), () => { hp.askSame = false; renderHandoffPage() }, t('hp.sameConfirm'), () => hpChange({ sameFamily: true }, t('hp.sameOn'))) : null] }
|
|
5390
|
+
case 'otherFamilies': return { ctl: [hpSwitch('other', t('hp.otherFamilies'), p.on, (v) => hpChange({ otherFamilies: v }, t(v ? 'hp.otherOn' : 'hp.otherOff')))],
|
|
5391
|
+
below: [p.on && p.order.length > 1 ? hpAiOrder(p.order) : null] }
|
|
5392
|
+
case 'api': return { ctl: [hpSwitch('api', t('hp.api'), p.on, (v) => {
|
|
5393
|
+
if (v) { hp.askApi = true; renderHandoffPage() } else hpChange({ api: false }, t('hp.apiOff'))
|
|
5394
|
+
})], below: [!p.accounts ? h('p', { class: 'muted small' }, t('hp.noApi')) : null,
|
|
5395
|
+
hp.askApi && !p.on ? hpConfirm('api', t('hp.apiWarn'), () => { hp.askApi = false; renderHandoffPage() }, t('hp.apiConfirm'), () => hpChange({ api: true }, t('hp.apiOn'))) : null] }
|
|
5396
|
+
}
|
|
5397
|
+
return { ctl: [], below: [] }
|
|
5398
|
+
}
|
|
5399
|
+
function hpRules(d) {
|
|
5400
|
+
if (!d || !d.rules) return null
|
|
5401
|
+
return [h('div', { class: 'page-sec-head' }, h('h3', { class: 'page-sec' }, t('hp.rules')),
|
|
5402
|
+
h('p', { class: 'muted small' }, t('hp.rulesNote'))),
|
|
5403
|
+
h('ol', { class: 'hp-rules' }, d.rules.map((r) => {
|
|
5404
|
+
const c = hpRuleControls(r)
|
|
5405
|
+
return h('li', { 'data-rule': r.id },
|
|
5406
|
+
h('div', { class: 'hp-rule-text' }, hpRuleText(r)),
|
|
5407
|
+
h('div', { class: 'hp-rule-ctl' }, c.ctl),
|
|
5408
|
+
...c.below.filter(Boolean).map((el) => h('div', { class: 'hp-rule-below' }, el)))
|
|
5409
|
+
}))]
|
|
5410
|
+
}
|
|
5411
|
+
// When no account could take over anywhere, say which switch opens the way instead of leaving a dead end.
|
|
5412
|
+
function hpNoneHint(d) {
|
|
5413
|
+
if (!d.takeover.length || d.takeover.some((r) => r.decision.kind !== 'none')) return null
|
|
5414
|
+
const st = ahState().settings
|
|
5415
|
+
return st.sameFamily && st.otherFamilies ? null : h('p', { class: 'note', 'data-enter': 'none-hint' }, t('hp.noneAll'))
|
|
5416
|
+
}
|
|
5417
|
+
// Up to ADR-0046 API accounts took over by themselves; this asks once, where Auto Handoff is on.
|
|
5418
|
+
function hpApiBanner() {
|
|
5419
|
+
const st = ahState()
|
|
5420
|
+
if (!st || !st.apiUndecided || BOOT.readOnly) return null
|
|
5421
|
+
return h('div', { class: 'banner banner-warn', role: 'status', 'data-enter': 'api-banner' },
|
|
5422
|
+
h('div', null, h('b', null, t('hp.apiAskTitle') + ' '), t('hp.apiAskBody')),
|
|
5423
|
+
h('div', { class: 'banner-actions' },
|
|
5424
|
+
h('button', { class: 'btn btn-sm btn-primary', type: 'button', disabled: hp.busyOff, onclick: () => hpChange({ api: false }, t('hp.apiKeptOff')) }, t('hp.apiKeepOff')),
|
|
5425
|
+
h('button', { class: 'btn btn-sm', type: 'button', disabled: hp.busyOff, onclick: () => hpChange({ api: true }, t('hp.apiOn')) }, t('hp.apiKeepOn'))))
|
|
5217
5426
|
}
|
|
5218
5427
|
function renderHandoffPage() {
|
|
5219
5428
|
const box = $('handoff-page')
|
|
@@ -5224,34 +5433,36 @@ const MAIN = String.raw `
|
|
|
5224
5433
|
h('h2', { id: 'h-handoff' }, t('hp.title')),
|
|
5225
5434
|
h('div', { class: 'row-actions' },
|
|
5226
5435
|
h('button', { class: 'btn btn-sm', type: 'button', onclick: askHandoff }, icon('bot'), t('ask.title.handoff')),
|
|
5227
|
-
h('button', { class: 'btn
|
|
5436
|
+
h('button', { class: 'link-btn small', type: 'button', onclick: () => openHandoff() }, t('hp.advanced')),
|
|
5228
5437
|
hp.loading ? spinner() : null))]
|
|
5229
5438
|
const on = st.settings.auto
|
|
5230
5439
|
if (hp.loading && !hp.data) kids.push(h('p', { class: 'muted' }, spinner(), ' ', t('hp.loading')))
|
|
5231
5440
|
if (hp.error) kids.push(errorNote(hp.error, loadHandoffPage))
|
|
5232
5441
|
if (BOOT.readOnly) kids.push(h('p', { class: 'note' }, t('banner.readOnly')))
|
|
5442
|
+
const d = hp.data
|
|
5443
|
+
// One status card on top: whether it is on, what that means, and the one action that changes it.
|
|
5444
|
+
const status = (text, action) => h('div', { class: 'hp-status' + (on ? ' is-on' : '') },
|
|
5445
|
+
h('span', { class: 'hp-status-ic' }, icon('swap')),
|
|
5446
|
+
h('div', { class: 'hp-status-text' }, h('b', null, on ? t('hp.statusOn') : t('hp.statusOff')), h('p', { class: 'muted' }, text)),
|
|
5447
|
+
action)
|
|
5233
5448
|
if (!on) {
|
|
5234
|
-
|
|
5235
|
-
kids.push(h('
|
|
5236
|
-
if (!
|
|
5237
|
-
else
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
if (!hp.sameTouched) hp.sameFamily = st.settings.sameFamily
|
|
5241
|
-
kids.push(hpSameFamilyBox(hp.sameFamily, (v) => { hp.sameFamily = v; hp.sameTouched = true }))
|
|
5242
|
-
kids.push(h('div', { class: 'row-actions' }, h('button', { class: 'btn btn-primary', type: 'button', disabled: BOOT.readOnly || hp.previewing, 'aria-busy': hp.previewing ? 'true' : null, onclick: hpPreview }, hp.previewing ? spinner() : null, t('hp.turnOn'))))
|
|
5243
|
-
} else kids.push(hpPreviewCard())
|
|
5244
|
-
}
|
|
5449
|
+
const starters = S.state.accounts.some((a) => a.kind !== 'api' && st.starters.includes(a.family))
|
|
5450
|
+
kids.push(status(t('hp.intro'), starters && !hp.preview ? h('button', { class: 'btn btn-primary', type: 'button', 'data-key': 'turn-on', disabled: BOOT.readOnly || hp.previewing, 'aria-busy': hp.previewing ? 'true' : null, onclick: hpPreview }, hp.previewing ? spinner() : null, t('hp.turnOn')) : null))
|
|
5451
|
+
if (!starters) kids.push(h('p', { class: 'note' }, t('hp.noStarters')))
|
|
5452
|
+
else if (hp.preview) kids.push(hpPreviewCard())
|
|
5453
|
+
kids.push(hpRules(d))
|
|
5454
|
+
if (d && d.takeover.length) kids.push(h('h3', { class: 'page-sec' }, t('hp.takeoverIf')), hpRows(d), hpNoneHint(d))
|
|
5245
5455
|
} else {
|
|
5246
|
-
kids.push(
|
|
5247
|
-
|
|
5456
|
+
kids.push(status(t('hp.onNote'),
|
|
5457
|
+
h('button', { class: 'btn', type: 'button', 'data-key': 'turn-off', disabled: BOOT.readOnly || hp.busyOff, onclick: () => hpChange({ auto: false }, t('toast.ahOff')) }, t('hp.turnOff'))))
|
|
5248
5458
|
if (d) {
|
|
5249
|
-
kids.push(h('h3', { class: '
|
|
5250
|
-
kids.push(
|
|
5459
|
+
kids.push(h('h3', { class: 'page-sec' }, t('hp.takeover')), hpRows(d), hpNoneHint(d))
|
|
5460
|
+
kids.push(...(hpRules(d) || []))
|
|
5461
|
+
kids.push(h('h3', { class: 'page-sec' }, t('hp.recent')), hpRecent(d))
|
|
5251
5462
|
}
|
|
5252
5463
|
const plan = hp.plan
|
|
5253
5464
|
if (plan && (plan.blocked || plan.steps.length)) {
|
|
5254
|
-
kids.push(h('h3', { class: '
|
|
5465
|
+
kids.push(h('h3', { class: 'page-sec' }, t('hp.missing')))
|
|
5255
5466
|
if (!hp.preview) {
|
|
5256
5467
|
if (plan.blocked) kids.push(h('p', { class: 'note note-fail' }, t('hp.blocked', { why: plan.blocked })), codeCopy('npm i -g sideby'))
|
|
5257
5468
|
else {
|
|
@@ -5261,18 +5472,9 @@ const MAIN = String.raw `
|
|
|
5261
5472
|
} else kids.push(hpPreviewCard())
|
|
5262
5473
|
} else if (plan) kids.push(...hpManual(plan))
|
|
5263
5474
|
kids.push(h('p', { class: 'muted small' }, t('hp.onlySideby')))
|
|
5264
|
-
kids.push(hpSameFamilyBox(st.settings.sameFamily, (v) => {
|
|
5265
|
-
if (v) { hp.askSame = true; renderHandoffPage() } else { hp.askSame = false; hpChange({ sameFamily: false }, t('hp.sameOff')) }
|
|
5266
|
-
}))
|
|
5267
|
-
if (hp.askSame && !st.settings.sameFamily) kids.push(h('div', { class: 'ah-fam' },
|
|
5268
|
-
h('p', { class: 'note note-warn' }, t('ah.sameFamilyWarn')),
|
|
5269
|
-
h('div', { class: 'row-actions' },
|
|
5270
|
-
h('button', { class: 'btn', type: 'button', disabled: hp.busyOff, onclick: () => { hp.askSame = false; renderHandoffPage() } }, t('btn.cancel')),
|
|
5271
|
-
h('button', { class: 'btn btn-primary', type: 'button', disabled: BOOT.readOnly || hp.busyOff, onclick: () => { hp.askSame = false; hpChange({ sameFamily: true }, t('hp.sameOn')) } }, t('hp.sameConfirm')))))
|
|
5272
|
-
kids.push(h('div', { class: 'row-actions' }, h('button', { class: 'btn', type: 'button', disabled: BOOT.readOnly || hp.busyOff, onclick: () => hpChange({ auto: false }, t('toast.ahOff')) }, hp.busyOff ? spinner() : null, t('hp.turnOff'))))
|
|
5273
5475
|
}
|
|
5274
5476
|
kids.push(hpFailed())
|
|
5275
|
-
|
|
5477
|
+
swapKids(box, kids)
|
|
5276
5478
|
}
|
|
5277
5479
|
|
|
5278
5480
|
// ---------- Remote Control (spec §3.22) ----------
|
|
@@ -5281,13 +5483,18 @@ const MAIN = String.raw `
|
|
|
5281
5483
|
// target: the side the dialog's switch was moved to, waiting for its confirmation; null while nothing is chosen.
|
|
5282
5484
|
const rc = { confirm: false, busy: false, target: null }
|
|
5283
5485
|
const shortRef = (ref) => ref.replace(/^claude:/, '')
|
|
5486
|
+
// One settings key's change: the key and literal values in the code font, "not set" in words.
|
|
5487
|
+
function keyChange(key, from, to) {
|
|
5488
|
+
const val = (v) => (v === null ? t('rc.notSet') : h('code', null, v))
|
|
5489
|
+
return h('span', { class: 'key-change' }, h('code', null, key), ' ', val(from), ' → ', val(to))
|
|
5490
|
+
}
|
|
5284
5491
|
function remoteControlBanner() {
|
|
5285
5492
|
const groups = S.state.remoteControl || []
|
|
5286
5493
|
// API Accounts never sign in to claude.ai, so Remote Control cannot reach their sessions.
|
|
5287
5494
|
const api = new Set(S.state.accounts.filter((a) => a.kind === 'api').map((a) => a.ref))
|
|
5288
5495
|
const refs = groups.filter((g) => g.state === 'on').flatMap((g) => g.accounts).filter((r) => !api.has(r)).map(shortRef)
|
|
5289
5496
|
if (!refs.length || prefs.rcHide) return null
|
|
5290
|
-
const todo = groups
|
|
5497
|
+
const todo = remoteControlTodo(groups, 'off')
|
|
5291
5498
|
const text = h('div', null, h('b', null, t('rc.title') + ' '), tn('rc.body', refs.length, { refs: refs.join(', ') }))
|
|
5292
5499
|
if (BOOT.readOnly) return h('div', { class: 'banner banner-warn', role: 'status' }, h('div', null, text, ' ', t('rc.readOnly')))
|
|
5293
5500
|
if (!rc.confirm)
|
|
@@ -5296,8 +5503,14 @@ const MAIN = String.raw `
|
|
|
5296
5503
|
h('button', { class: 'btn btn-sm btn-primary', type: 'button', onclick: () => { rc.confirm = true; renderBanners() } }, t('rc.turnOff')),
|
|
5297
5504
|
h('button', { class: 'btn btn-sm', type: 'button', onclick: () => { prefs.rcHide = true; savePrefs(); renderBanners(); toast(t('rc.hidden')) } }, t('rc.keep'))))
|
|
5298
5505
|
const lines = todo.map((g) => h('li', null, h('code', null, g.file), ' ',
|
|
5299
|
-
|
|
5506
|
+
keyChange('remoteControlAtStartup', g.state === 'on' ? 'true' : null, 'false'), ' ',
|
|
5300
5507
|
h('span', { class: 'muted' }, t('rc.usedBy', { refs: g.accounts.map(shortRef).join(', ') }))))
|
|
5508
|
+
// Files sideby cannot change stay listed, as in the dialog, so "all" never hides one.
|
|
5509
|
+
for (const g of groups.filter((g) => g.state === 'blocked' || g.state === 'missing'))
|
|
5510
|
+
lines.push(h('li', null, h('code', null, g.file), ' ',
|
|
5511
|
+
h('span', { class: 'chip chip-sm' + (g.state === 'blocked' ? ' chip-fail' : '') }, t('rc.state.' + g.state)), ' ',
|
|
5512
|
+
h('span', { class: 'muted' }, t('rc.usedBy', { refs: g.accounts.map(shortRef).join(', ') })),
|
|
5513
|
+
g.reason ? h('div', { class: 'muted small' }, t('rc.skipped') + (g.why ? t('settings.why.' + g.why) : g.reason)) : null))
|
|
5301
5514
|
return h('div', { class: 'banner banner-warn', role: 'status' },
|
|
5302
5515
|
h('div', null, h('b', null, t('rc.confirmTitle')), h('ul', null, lines), h('div', { class: 'small' }, t('rc.confirmNote'))),
|
|
5303
5516
|
h('div', { class: 'banner-actions' },
|
|
@@ -5310,8 +5523,10 @@ const MAIN = String.raw `
|
|
|
5310
5523
|
if (dlg.kind === 'rc') renderRc()
|
|
5311
5524
|
const fail = to === 'on' ? 'rc.failedOn' : 'rc.failed'
|
|
5312
5525
|
try {
|
|
5313
|
-
const
|
|
5314
|
-
|
|
5526
|
+
const files = remoteControlTodo(S.state.remoteControl || [], to).map((g) => g.file)
|
|
5527
|
+
const r = await api('/api/remote-control/' + to, { confirm: true, files })
|
|
5528
|
+
if (r.changedSince) toast(t('as.changedSince'), { kind: 'fail' })
|
|
5529
|
+
else if (r.ok) {
|
|
5315
5530
|
// Show the new state now; the reload that follows confirms it.
|
|
5316
5531
|
const changed = new Set(remoteControlTodo(S.state.remoteControl || [], to).map((g) => g.file))
|
|
5317
5532
|
S.state.remoteControl = (S.state.remoteControl || []).map((g) => changed.has(g.file) ? { ...g, state: to, undo: true } : g)
|
|
@@ -5328,7 +5543,7 @@ const MAIN = String.raw `
|
|
|
5328
5543
|
}
|
|
5329
5544
|
async function remoteControlUndo() {
|
|
5330
5545
|
try {
|
|
5331
|
-
const r = await api('/api/remote-control/undo', {})
|
|
5546
|
+
const r = await api('/api/remote-control/undo', { confirm: true })
|
|
5332
5547
|
toast(r.ok ? t('rc.undone') : r.message, { kind: r.ok ? 'ok' : 'fail' })
|
|
5333
5548
|
} catch (e) { toast(t('toast.undoFailed', { msg: e.message }), { kind: 'fail' }) }
|
|
5334
5549
|
await load({ silent: true })
|
|
@@ -5842,7 +6057,7 @@ const MAIN = String.raw `
|
|
|
5842
6057
|
return Boolean(u && u.skillUpdate && u.skillUpdate.installed && u.skillUpdate.installed.length)
|
|
5843
6058
|
}
|
|
5844
6059
|
// Example phrases: a click puts one in the Let AI do it box (spec §3.28).
|
|
5845
|
-
const AI_ASKS = ['ai.ask.quota', 'ai.ask.pick', 'ai.ask.new', 'ai.ask.api', 'ai.ask.pin', 'ai.ask.relogin', 'ai.ask.fix', 'ai.ask.handoff', 'ai.ask.session', 'ai.ask.history', 'ai.ask.send', 'ai.ask.inbound', 'ai.ask.menubar', 'ai.ask.rc', 'ai.ask.tool']
|
|
6060
|
+
const AI_ASKS = ['ai.ask.quota', 'ai.ask.pick', 'ai.ask.new', 'ai.ask.api', 'ai.ask.pin', '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.tool']
|
|
5846
6061
|
function openRc() {
|
|
5847
6062
|
if (!S.state || !rcSummary()) return
|
|
5848
6063
|
rc.target = null
|
|
@@ -5861,12 +6076,12 @@ const MAIN = String.raw `
|
|
|
5861
6076
|
const sw = h('div', { class: 'set-row rc-switch' }, h('span', null, t('rc.switch')),
|
|
5862
6077
|
h('div', { class: 'seg', role: 'group', 'aria-label': t('rc.switch') }, ['on', 'off'].map((v) =>
|
|
5863
6078
|
h('button', { class: 'seg-btn', type: 'button', disabled: BOOT.readOnly || rc.busy, 'aria-pressed': String((to || sum) === v), onclick: () => pick(v) }, t('rc.state.' + v)))))
|
|
5864
|
-
const fromOf = (g) => g.state === 'on' ? 'true' : g.state === 'off' ? 'false' :
|
|
6079
|
+
const fromOf = (g) => g.state === 'on' ? 'true' : g.state === 'off' ? 'false' : null
|
|
5865
6080
|
const rows = groups.map((g) => h('li', { class: 'rc-row' },
|
|
5866
6081
|
h('div', null, h('code', null, g.file), ' ', h('span', { class: 'chip chip-sm ' + (g.state === 'on' ? 'chip-warn' : g.state === 'off' ? 'chip-ok' : g.state === 'blocked' ? 'chip-fail' : '') }, t('rc.state.' + g.state))),
|
|
5867
6082
|
h('div', { class: 'muted small' }, t('rc.usedBy', { refs: g.accounts.map(shortRef).join(', ') })),
|
|
5868
|
-
g.reason ? h('div', { class: 'muted small' }, g.reason) : null,
|
|
5869
|
-
changing.has(g.file) ? h('div', { class: 'small rc-change' },
|
|
6083
|
+
g.reason ? h('div', { class: 'muted small' }, g.why ? t('settings.why.' + g.why) : g.reason) : null,
|
|
6084
|
+
changing.has(g.file) ? h('div', { class: 'small rc-change' }, keyChange('remoteControlAtStartup', fromOf(g), to === 'on' ? 'true' : 'false')) : null))
|
|
5870
6085
|
const body = [h('p', { class: 'small' }, t('rc.explain')), sw, h('ul', { class: 'rc-list' }, rows)]
|
|
5871
6086
|
if (to === 'on') body.push(h('div', { class: 'note note-warn small' }, t('rc.onWarn')))
|
|
5872
6087
|
else if (to === 'off') body.push(h('p', { class: 'small muted' }, t('rc.confirmNote')))
|
|
@@ -6622,6 +6837,9 @@ const MAIN = String.raw `
|
|
|
6622
6837
|
const mb = curPage === 'accounts' ? menubarHint() : null
|
|
6623
6838
|
if (mb) out.push(mb)
|
|
6624
6839
|
}
|
|
6840
|
+
// On every page until answered: whether API accounts may still take over (ADR-0046).
|
|
6841
|
+
const apiBanner = hpApiBanner()
|
|
6842
|
+
if (apiBanner) out.push(apiBanner)
|
|
6625
6843
|
const rcBanner = remoteControlBanner()
|
|
6626
6844
|
if (rcBanner) out.push(rcBanner)
|
|
6627
6845
|
const inbBanner = inboundBanner()
|