sideby 0.26.0 → 0.26.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 CHANGED
@@ -1 +1 @@
1
- {"id":"20261027T054352-a40a27"}
1
+ {"id":"20261027T064256-56957b"}
@@ -1294,8 +1294,10 @@ declare const en: {
1294
1294
  'net.noTargets': string;
1295
1295
  'net.skipped': string;
1296
1296
  'net.notCovered': string;
1297
- 'net.save': string;
1298
1297
  'net.savedOn': string;
1298
+ 'net.savedAllow': string;
1299
+ 'net.none': string;
1300
+ 'net.undone': string;
1299
1301
  'net.savedOff': string;
1300
1302
  'net.checkFailed': string;
1301
1303
  'net.bannerTitle': string;
@@ -1296,8 +1296,10 @@ const en = {
1296
1296
  'net.noTargets': 'No Claude or Codex account is checked here.',
1297
1297
  'net.skipped': '{refs}: API accounts are checked when they start (a third-party endpoint is not checked).',
1298
1298
  'net.notCovered': 'Only sessions sideby starts are checked; running claude or codex directly is not. sideby asks the vendor’s own /cdn-cgi/trace with your proxy settings and no credential, and keeps only the country.',
1299
- 'net.save': 'Save',
1300
1299
  'net.savedOn': 'Network check is on.',
1300
+ 'net.savedAllow': 'Allowed: {list}.',
1301
+ 'net.none': 'no country yet',
1302
+ 'net.undone': 'Changed back.',
1301
1303
  'net.savedOff': 'Network check is off.',
1302
1304
  'net.checkFailed': 'Could not check: {msg}',
1303
1305
  'net.bannerTitle': 'Wrong network.',
@@ -2740,8 +2742,10 @@ const zh = {
2740
2742
  'net.noTargets': '这里没有要检查的 Claude 或 Codex 账号。',
2741
2743
  'net.skipped': '{refs}:API 账号在启动时检查(第三方接口不检查)。',
2742
2744
  'net.notCovered': '只检查 sideby 启动的会话,直接运行 claude 或 codex 不检查。sideby 带着你的代理设置访问服务商自己的 /cdn-cgi/trace,不带任何凭证,只保留国家或地区。',
2743
- 'net.save': '保存',
2744
2745
  'net.savedOn': '网络检查已打开。',
2746
+ 'net.savedAllow': '允许的地区:{list}。',
2747
+ 'net.none': '还没有选',
2748
+ 'net.undone': '已改回。',
2745
2749
  'net.savedOff': '网络检查已关闭。',
2746
2750
  'net.checkFailed': '没能检查:{msg}',
2747
2751
  'net.bannerTitle': '网络不对。',
@@ -237,16 +237,23 @@ const MAIN = String.raw `
237
237
  else el.removeAttribute('aria-label')
238
238
  }
239
239
  // replaceChildren() would render null as the text "null"; route children through add(), which skips it.
240
+ // The toast stack (raiseToasts) may live in the open dialog; redrawing the dialog leaves it where it is.
241
+ const keepsToasts = (n) => n.nodeType === 1 && n.id === 'toasts'
240
242
  function setKids(el, kids) {
241
- el.replaceChildren()
242
- add(el, kids)
243
+ for (const n of Array.from(el.childNodes)) if (!keepsToasts(n)) n.remove()
244
+ const stack = el.lastChild
245
+ if (!stack) return add(el, kids)
246
+ // New content goes before the stack, so a later patch finds it in place and moves nothing (moving loses focus).
247
+ const box = document.createDocumentFragment()
248
+ add(box, kids)
249
+ el.insertBefore(box, stack)
243
250
  }
244
251
  // Re-renders el without the jolt of a rebuild: the focused control keeps focus (matched by data-key), and an element
245
252
  // marked data-enter that was not there before grows in, so a row that appears does not snap the layout open.
246
253
  // A first render (el empty) animates nothing; the container itself has its own entrance.
247
254
  function swapKids(el, kids) {
248
255
  const before = new Set([...el.querySelectorAll('[data-enter]')].map((x) => x.getAttribute('data-enter')))
249
- const shown = el.childNodes.length > 0
256
+ const shown = Array.from(el.childNodes).some((n) => !keepsToasts(n))
250
257
  const active = document.activeElement
251
258
  const focusKey = active && el.contains(active) ? active.getAttribute('data-key') : null
252
259
  setKids(el, kids)
@@ -254,6 +261,20 @@ const MAIN = String.raw `
254
261
  for (const x of el.querySelectorAll('[data-enter]')) if (!before.has(x.getAttribute('data-enter'))) x.classList.add('enter')
255
262
  if (focusKey) { const again = el.querySelector('[data-key="' + CSS.escape(focusKey) + '"]'); if (again) again.focus() }
256
263
  }
264
+ // swapKids for a view that refreshes while open: unchanged elements stay (see patch), so a refresh that brings the
265
+ // same answer redraws nothing; new data-enter elements still grow in.
266
+ function patchEnter(el, kids) {
267
+ const before = new Set([...el.querySelectorAll('[data-enter]')].map((x) => x.getAttribute('data-enter')))
268
+ const shown = Array.from(el.childNodes).some((n) => !keepsToasts(n))
269
+ patch(el, kids)
270
+ if (shown && !REDUCED)
271
+ for (const x of el.querySelectorAll('[data-enter]'))
272
+ if (!before.has(x.getAttribute('data-enter'))) {
273
+ x.classList.add('enter')
274
+ // Gone once it has grown in, so the next refresh sees the same markup and keeps the element.
275
+ x.addEventListener('animationend', () => x.classList.remove('enter'), { once: true })
276
+ }
277
+ }
257
278
  function add(el, kid) {
258
279
  if (kid === null || kid === undefined || kid === false) return
259
280
  if (Array.isArray(kid)) { for (const k of kid) add(el, k); return }
@@ -288,7 +309,7 @@ const MAIN = String.raw `
288
309
  }
289
310
  function patchKids(box, kids) {
290
311
  const next = flat(kids)
291
- const old = Array.from(box.childNodes)
312
+ const old = Array.from(box.childNodes).filter((n) => !keepsToasts(n))
292
313
  const byKey = new Map()
293
314
  for (const o of old) if (o.nodeType === 1 && o.dataset.key) byKey.set(o.dataset.key, o)
294
315
  const used = new Set()
@@ -509,9 +530,13 @@ const MAIN = String.raw `
509
530
  // Hovering a toast pauses it, so an Undo stays reachable.
510
531
  const toasts = []
511
532
  // The toast stack is a manual popover so it sits in the top layer; raising it again after a modal dialog
512
- // opens keeps toasts above that dialog's backdrop. Without popover support it stays a fixed element.
533
+ // opens keeps toasts above that dialog's backdrop. A modal dialog makes everything outside it inert, a popover
534
+ // above it included, so while one is open the stack moves into it and an Undo stays clickable; it moves back
535
+ // when the dialog closes. Without popover support it stays a fixed element.
513
536
  function raiseToasts() {
514
537
  const el = $('toasts')
538
+ const home = dlg.el && dlg.el.open ? dlg.el : document.body
539
+ if (el.parentNode !== home) home.append(el)
515
540
  if (typeof el.showPopover !== 'function') return
516
541
  try { if (el.matches(':popover-open')) el.hidePopover(); el.showPopover() } catch {}
517
542
  }
@@ -2788,6 +2813,7 @@ const MAIN = String.raw `
2788
2813
  const after = dlg.onClose
2789
2814
  dlg.kind = null
2790
2815
  dlg.onClose = null
2816
+ raiseToasts()
2791
2817
  if (after) after()
2792
2818
  })
2793
2819
  document.body.append(dlg.el)
@@ -5716,7 +5742,7 @@ const MAIN = String.raw `
5716
5742
  b.setAttribute('aria-label', t('set.button') + (warn ? colon() + t('set.rcOn') : ''))
5717
5743
  refreshSettings()
5718
5744
  if (dlg.kind === 'rc') renderRc()
5719
- if (dlg.kind === 'net' && net && !net.busy) renderNet()
5745
+ if (dlg.kind === 'net' && net) renderNet()
5720
5746
  }
5721
5747
  // The settings live in two places (spec §3.29, 2026-10-20). The header popover holds only what people change
5722
5748
  // often, one click each and no explanations: language, theme, Auto Handoff, asking an AI, and "All settings…".
@@ -5841,15 +5867,21 @@ const MAIN = String.raw `
5841
5867
  const leave = (opens) => { if (!opens && dlg.kind === 'settings') dlg.el.close() }
5842
5868
  const groups = settingsGroups(leave)
5843
5869
  const cur = groups.find((g) => g.id === prefs.setSec) || groups[0]
5844
- const nav = h('div', { class: 'set-nav', role: 'tablist', 'aria-label': t('set.title') }, groups.map((g) =>
5870
+ const nav = h('div', { class: 'set-nav', role: 'tablist', 'aria-label': t('set.title'), 'data-patch': '' }, groups.map((g) =>
5845
5871
  h('button', { class: 'set-tab', type: 'button', role: 'tab', id: 'set-tab-' + g.id, 'aria-selected': String(g === cur), 'aria-controls': 'set-pane', onclick: () => { if (prefs.setSec === g.id || g === cur) return; prefs.setSec = g.id; savePrefs(); renderSettingsDialog(true) } }, g.title)))
5846
- const pane = h('div', { class: 'set-pane' + (switched ? ' view-in' : ''), id: 'set-pane', role: 'tabpanel', 'aria-labelledby': 'set-tab-' + cur.id },
5872
+ const pane = h('div', { class: 'set-pane' + (switched ? ' view-in' : ''), id: 'set-pane', role: 'tabpanel', 'aria-labelledby': 'set-tab-' + cur.id, 'data-patch': '' },
5847
5873
  h('h3', { class: 'set-pane-title' }, cur.title),
5848
5874
  cur.foot ? h('p', { class: 'set-foot' }, cur.foot) : null,
5849
- h('div', { class: 'set-group' }, cur.items))
5875
+ h('div', { class: 'set-group', 'data-patch': '' }, cur.items))
5876
+ // Gone once it has slid in, so the next refresh sees the same markup.
5877
+ if (switched) pane.addEventListener('animationend', () => pane.classList.remove('view-in'), { once: true })
5850
5878
  // It stays wide while it fades out; showDialog drops the width when another dialog takes the element.
5851
5879
  dlg.el.classList.add('dialog-wide')
5852
- setKids(dlg.el, dialogFrame(t('set.title'), null, h('div', { class: 'set-dialog' }, nav, pane)))
5880
+ // Patched in place: the refresh every few seconds redraws only what changed, and a list the user has open stays.
5881
+ const frame = dialogFrame(t('set.title'), null, h('div', { class: 'set-dialog', 'data-patch': '' }, nav, pane))
5882
+ frame[1].setAttribute('data-patch', '')
5883
+ if (switched) setKids(dlg.el, frame)
5884
+ else patch(dlg.el, frame)
5853
5885
  // A redraw replaced the list; a section picked from it keeps the focus on its tab.
5854
5886
  if (switched) { const tab = document.getElementById('set-tab-' + cur.id); if (tab) tab.focus() }
5855
5887
  }
@@ -6204,14 +6236,14 @@ const MAIN = String.raw `
6204
6236
  function openNet() {
6205
6237
  const n = netState()
6206
6238
  if (!n) return
6207
- net = { guard: n.guard, allow: [...n.allow], busy: false, checking: false }
6239
+ net = { guard: n.guard, allow: [...n.allow], checking: false }
6208
6240
  showDialog('net')
6209
6241
  renderNet()
6210
6242
  // Opening it answers "where am I now" at once, unless a result is fresh.
6211
6243
  if (!n.targets.some((x) => x.checkedAt && Date.now() - Date.parse(x.checkedAt) < 60000)) netCheck()
6212
6244
  }
6213
6245
  async function netCheck() {
6214
- if (!net) net = { guard: false, allow: [], busy: false, checking: false }
6246
+ if (!net) net = { guard: false, allow: [], checking: false }
6215
6247
  net.checking = true
6216
6248
  if (dlg.kind === 'net') renderNet()
6217
6249
  renderBanners()
@@ -6220,38 +6252,49 @@ const MAIN = String.raw `
6220
6252
  if (dlg.kind === 'net') renderNet()
6221
6253
  renderBanners()
6222
6254
  }
6223
- async function netSave() {
6224
- net.busy = true
6255
+ // Every change in the dialog applies at once, like a system setting, and its toast carries the undo. Changes are
6256
+ // saved one after another in the order clicked; a failed one puts the dialog back to what the config holds.
6257
+ let netSaving = Promise.resolve()
6258
+ function netApply(next, opts) {
6259
+ opts = opts || {}
6260
+ const prev = { guard: net.guard, allow: [...net.allow] }
6261
+ net.guard = next.guard
6262
+ net.allow = [...next.allow]
6225
6263
  renderNet()
6226
- try {
6227
- await api('/api/network/settings', { guard: net.guard, allow: net.allow, confirm: true })
6228
- toast(t(net.guard ? 'net.savedOn' : 'net.savedOff'))
6229
- await load({ silent: true })
6230
- if (dlg.kind === 'net') dlg.el.close()
6231
- } catch (e) { toast(e.message, { kind: 'fail' }) }
6232
- if (net) net.busy = false
6233
- if (dlg.kind === 'net') renderNet()
6264
+ netSaving = netSaving.then(async () => {
6265
+ try {
6266
+ await api('/api/network/settings', { guard: next.guard, allow: next.allow, confirm: true })
6267
+ await load({ silent: true })
6268
+ const text = opts.undone ? t('net.undone')
6269
+ : next.guard !== prev.guard ? t(next.guard ? 'net.savedOn' : 'net.savedOff')
6270
+ : t('net.savedAllow', { list: next.allow.length ? netList(next.allow.map(netCountry)) : t('net.none') })
6271
+ toast(text, opts.undone ? { key: 'net' } : { key: 'net', action: { label: t('toast.undo'), run: () => netApply(prev, { undone: true }) }, duration: 10000 })
6272
+ } catch (e) {
6273
+ toast(e.message, { kind: 'fail' })
6274
+ const n = netState()
6275
+ if (n && net) { net.guard = n.guard; net.allow = [...n.allow] }
6276
+ }
6277
+ if (dlg.kind === 'net') renderNet()
6278
+ })
6234
6279
  }
6235
6280
  function renderNet() {
6236
6281
  const n = netState()
6237
6282
  if (!n || !net) return
6238
6283
  const here = new Set(n.targets.map((x) => x.loc).filter(Boolean))
6239
6284
  const list = [...new Set([...NET_COMMON, ...net.allow, ...here])]
6240
- const changed = net.guard !== n.guard || net.allow.join() !== n.allow.join()
6241
- const toggle = (c) => {
6242
- net.allow = net.allow.includes(c) ? net.allow.filter((x) => x !== c) : [...net.allow, c]
6243
- renderNet()
6244
- }
6245
- const sw = h('div', { class: 'set-row' }, h('span', { class: 'set-label' }, t('net.switch')),
6246
- h('div', { class: 'seg', role: 'group', 'aria-label': t('net.switch') }, [[true, t('ah.on')], [false, t('ah.off')]].map(([v, text]) =>
6247
- h('button', { class: 'seg-btn', type: 'button', 'data-key': 'net-sw-' + v, disabled: BOOT.readOnly || net.busy || (v && !net.allow.length), 'aria-pressed': String(net.guard === v), onclick: () => { net.guard = v; renderNet() } }, text))))
6248
- const countries = h('div', { class: 'net-countries', role: 'group', 'aria-label': t('net.allow') }, list.map((c) =>
6249
- h('button', { class: 'net-cty', type: 'button', 'data-key': 'net-cty-' + c, disabled: BOOT.readOnly || net.busy, 'aria-pressed': String(net.allow.includes(c)), onclick: () => toggle(c) },
6285
+ const toggle = (c) => netApply({ guard: net.guard, allow: net.allow.includes(c) ? net.allow.filter((x) => x !== c) : [...net.allow, c] })
6286
+ // While it is on, the last country stays: taking it away would leave nothing allowed.
6287
+ const lastOne = (c) => net.guard && net.allow.length === 1 && net.allow[0] === c
6288
+ const sw = h('div', { class: 'set-row', 'data-patch': '' }, h('span', { class: 'set-label' }, t('net.switch')),
6289
+ h('div', { class: 'seg', role: 'group', 'aria-label': t('net.switch'), 'data-patch': '' }, [[true, t('ah.on')], [false, t('ah.off')]].map(([v, text]) =>
6290
+ h('button', { class: 'seg-btn', type: 'button', 'data-key': 'net-sw-' + v, disabled: BOOT.readOnly || (v && !net.allow.length), 'aria-pressed': String(net.guard === v), onclick: () => { if (net.guard !== v) netApply({ guard: v, allow: net.allow }) } }, text))))
6291
+ const countries = h('div', { class: 'net-countries', role: 'group', 'aria-label': t('net.allow'), 'data-patch': '' }, list.map((c) =>
6292
+ h('button', { class: 'net-cty', type: 'button', 'data-key': 'net-cty-' + c, disabled: BOOT.readOnly || lastOne(c), title: lastOne(c) ? t('net.keepOne') : null, 'aria-pressed': String(net.allow.includes(c)), onclick: () => toggle(c) },
6250
6293
  netCountry(c), here.has(c) ? h('span', { class: 'chip chip-sm' }, t('net.current')) : null)))
6251
6294
  const status = (x) => x.status === 'ok' ? ['chip-ok', t('net.ok')] : x.status === 'blocked' ? ['chip-fail', t('net.blocked')] : x.status === 'unknown' ? ['chip-fail', t('net.unknown')] : ['', t('net.notChecked')]
6252
6295
  const rows = n.targets.map((x) => {
6253
6296
  const [cls, label] = n.allow.length || x.status === 'not-checked' ? status(x) : ['', t('net.seen')]
6254
- return h('li', { class: 'rc-row' },
6297
+ return h('li', { class: 'rc-row', 'data-key': 'net-row-' + x.url },
6255
6298
  h('div', null, h('code', null, new URL(x.url).hostname), ' ', x.loc ? h('b', null, netCountry(x.loc)) : null, ' ', h('span', { class: 'chip chip-sm ' + cls }, label)),
6256
6299
  h('div', { class: 'muted small' }, [x.checkedAt ? t('net.checked', { when: ago(x.checkedAt) }) : null, x.error || null, x.accounts.join(', ')].filter(Boolean).join(' · ')),
6257
6300
  x.ipChanged ? h('div', { class: 'muted small' }, t('net.ipChanged')) : null)
@@ -6264,17 +6307,19 @@ const MAIN = String.raw `
6264
6307
  sw,
6265
6308
  h('div', { class: 'set-label' }, t('net.allow')),
6266
6309
  countries,
6267
- !net.allow.length ? h('p', { class: 'small muted', 'data-enter': 'net-pick' }, t(net.guard ? 'net.keepOne' : 'net.pickFirst')) : null,
6310
+ !net.allow.length ? h('p', { class: 'small muted', 'data-enter': 'net-pick' }, t('net.pickFirst')) : null,
6268
6311
  h('div', { class: 'set-row' }, h('span', { class: 'set-label' }, t('net.now')),
6269
6312
  h('button', { class: 'btn btn-sm', type: 'button', 'data-key': 'net-check', disabled: net.checking, 'aria-busy': net.checking ? 'true' : null, onclick: netCheck }, net.checking ? spinner() : icon('refresh'), t('net.recheck'))),
6270
- rows.length ? h('ul', { class: 'rc-list' }, rows) : h('p', { class: 'small muted' }, t('net.noTargets')),
6313
+ rows.length ? h('ul', { class: 'rc-list', 'data-patch': '' }, rows) : h('p', { class: 'small muted' }, t('net.noTargets')),
6271
6314
  skipped.length ? h('p', { class: 'small muted' }, t('net.skipped', { refs: skipped.map((a) => a.ref).join(', ') })) : null,
6272
6315
  h('p', { class: 'small muted' }, t('net.notCovered')),
6273
6316
  BOOT.readOnly ? h('p', { class: 'small' }, t('rc.readOnlyBoth')) : null,
6274
6317
  ]
6275
- const foot = [h('button', { class: 'btn', type: 'button', 'data-key': 'net-close', disabled: net.busy, onclick: () => dlg.el.close() }, t(changed ? 'btn.cancel' : 'btn.close'))]
6276
- if (!BOOT.readOnly && changed) foot.push(h('button', { class: 'btn btn-primary', type: 'button', 'data-key': 'net-save', 'data-enter': 'net-save', disabled: net.busy || (net.guard && !net.allow.length), 'aria-busy': net.busy ? 'true' : null, onclick: netSave }, net.busy ? spinner() : null, t('net.save')))
6277
- swapKids(dlg.el, dialogFrame(t('net.title'), null, body, foot))
6318
+ const foot = [h('button', { class: 'btn', type: 'button', 'data-key': 'net-close', onclick: () => dlg.el.close() }, t('btn.close'))]
6319
+ const frame = dialogFrame(t('net.title'), null, body, foot)
6320
+ // Patched in place, so the state refreshing every few seconds redraws only what changed (a row's "checked … ago").
6321
+ frame[1].setAttribute('data-patch', '')
6322
+ patchEnter(dlg.el, frame)
6278
6323
  }
6279
6324
  // Let AI do it (spec §3.28): the AI asks which countries, shows the change and writes it after the user agrees.
6280
6325
  function askNetwork() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sideby",
3
- "version": "0.26.0",
3
+ "version": "0.26.1",
4
4
  "description": "Run work, personal and API-key accounts at the same time, without their configs drifting apart.",
5
5
  "license": "MIT",
6
6
  "author": "Adonis0123 (https://github.com/Adonis0123)",
@@ -2,7 +2,7 @@
2
2
  name: sideby
3
3
  description: Use when the user runs, or wants to run, several AI coding accounts (Claude Code, Codex, Grok Build, pi) side by side. Covers installing sideby and setting up a new account ("install sideby", "set up another Claude account", "add cc008", "配置一个 cc00x", "再加一个 Codex 账号"), explaining what accounts share and what stays separate ("what do my accounts share?", "这些账号共享了什么"), showing which account a session is ("show [cc001] in the status line", "加上账号标识"), finding a past session of any account ("找一下我上周改登录页的那个会话"), seeing accounts, quota and usage, moving on when one hits its 5-hour or weekly limit, moving the current task to another account ("用 cc008 继续", "交回 cc008"), adding a short command (alias) or a pick command that starts whichever account has the most quota ("加个 cc"), adding an API account from a vendor's docs ("加一个 DeepSeek API 账号"), supporting a new tool, and repairing drifted account directories (skills, hooks, rules or settings not shared, wrong symlinks, credential file permissions). Drives the `sideby` CLI with `--json`; the agent does every step except browser sign-in, filling in secrets and starting interactive sessions, which it hands to the user as one command (inside an Auto Handoff session, `sideby handoff ready --to` moves the task itself).
4
4
  metadata:
5
- version: "0.26.0"
5
+ version: "0.26.1"
6
6
  requires:
7
7
  bins: [sideby, node]
8
8
  cliHelp: sideby --help