sideby 0.28.1 → 0.28.3

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":"20261028T142001-4db631"}
1
+ {"id":"20261029T042753-69f9e3"}
@@ -636,7 +636,7 @@ export async function cmdNext(a, io) {
636
636
  const runCmd = ['sideby run', plan.pick, ...(a.rest.length ? ['--', ...a.rest.map(shellQuote)] : [])].join(' ');
637
637
  if (!plan.hasQuota) {
638
638
  // Without any Quota the pick is a guess, often the Account that just ran out: recommend nothing, start nothing.
639
- const setup = (await rt.quotaSetups()).some((s) => s.family === family && s.plan.status === 'ready');
639
+ const setup = (await rt.quotaSetups()).some((s) => s.family === family && s.plan.status === 'ready' && !s.plan.upgrade);
640
640
  io.err(c.yellow(`\nno ${family} account has quota data yet, so sideby cannot tell which one has room; ${setup ? `turn it on with \`sideby quota setup ${family}\`, or ` : ''}start one yourself, for example \`${runCmd}\`.`));
641
641
  return 1;
642
642
  }
@@ -1094,7 +1094,8 @@ async function runSetup(a, io, rt, command, sub, familyId, setup) {
1094
1094
  else {
1095
1095
  io.out(plan.message);
1096
1096
  if (plan.status === 'ready') {
1097
- io.out(`\n${setup.summary}\nChange to ${tildify(plan.file, rt.paths.home)}:\n`);
1097
+ // An upgrade's message already says what the one added key does; the summary describes the first setup.
1098
+ io.out(`\n${plan.upgrade ? '' : `${setup.summary}\n`}Change to ${tildify(plan.file, rt.paths.home)}:\n`);
1098
1099
  io.out(plan.diff);
1099
1100
  io.out(c.cyan(`\nApply it with \`sideby ${command} setup ${familyId} --yes\`; undo any time with \`sideby ${command} teardown ${familyId}\`.`));
1100
1101
  }
@@ -267,6 +267,9 @@ const QuotaSetupPlan = Type.Object({
267
267
  file: Str,
268
268
  diff: Str,
269
269
  message: Str,
270
+ upgrade: Type.Optional(Type.Boolean({
271
+ description: 'With `ready`: the setup is already on and only an addition from a newer sideby is missing (Claude: `statusLine.refreshInterval`).',
272
+ })),
270
273
  });
271
274
  const ShellInitFiles = Type.Array(Type.Object({
272
275
  shell: Type.Union([Type.Literal('zsh'), Type.Literal('bash')]),
@@ -690,7 +690,7 @@ export async function main(argv) {
690
690
  // so a Host never gets a version error from its own hook (spec §3.17).
691
691
  if (first === 'handoff-hook') {
692
692
  const { runHandoffHook } = await import('../handoff/hook.js');
693
- return runHandoffHook(rest, process.env, process.stdin, process.stdout);
693
+ return runHandoffHook(rest, process.env, process.stdin, process.stdout, process.stderr);
694
694
  }
695
695
  // Network Guard's hook runs before every prompt and tool call it guards (spec §3.35); same fast path.
696
696
  if (first === 'network-hook') {
@@ -94,6 +94,8 @@ export declare const FILES: {
94
94
  readonly waiting: 'waiting.json';
95
95
  readonly chain: 'chain.json';
96
96
  readonly run: (runId: string) => string;
97
+ /** `{ id }` of the run's current `IdleWatch` (ADR-0056): a later one replaces it, and the earlier one then ends. */
98
+ readonly watch: (runId: string) => string;
97
99
  };
98
100
  /** A short random id for a chain or a run: safe in file names and environment values. */
99
101
  export declare function newId(): string;
@@ -1,8 +1,8 @@
1
1
  // The files one Handoff chain keeps under `<state>/handoffs/<chain>/` (spec §3.17). The handoff hook runs on every
2
2
  // tool call, so this module imports only Node built-ins and leaf modules (never the Runtime or a Family index).
3
3
  // The parent `sideby run` writes `plan.json`, `chain.json` and, while a session waits for a reset, `waiting.json`; the
4
- // hook writes `run-<id>.json` and `ready.json`; `sideby handoff ready` writes `request.json` (`ready.json` while the
5
- // session waits). Every file is mode 600 in a mode 700 directory.
4
+ // hook writes `run-<id>.json`, `ready.json` and, for Claude's background `IdleWatch`, `watch-<id>.json`; `sideby
5
+ // handoff ready` writes `request.json` (`ready.json` while the session waits). Every file is mode 600 in a mode 700 directory.
6
6
  import { randomBytes } from 'node:crypto';
7
7
  import { chmod, mkdir, readFile } from 'node:fs/promises';
8
8
  import { join } from 'node:path';
@@ -22,6 +22,8 @@ export const FILES = {
22
22
  waiting: 'waiting.json',
23
23
  chain: 'chain.json',
24
24
  run: (runId) => `run-${runId}.json`,
25
+ /** `{ id }` of the run's current `IdleWatch` (ADR-0056): a later one replaces it, and the earlier one then ends. */
26
+ watch: (runId) => `watch-${runId}.json`,
25
27
  };
26
28
  /** A short random id for a chain or a run: safe in file names and environment values. */
27
29
  export function newId() {
@@ -1,5 +1,7 @@
1
- import type { Account, Finding } from '../types.ts';
1
+ import type { Account, Finding, QuotaSetupPlan } from '../types.ts';
2
2
  import type { HandoffSettings } from './config.ts';
3
+ /** What Claude's quota setup plan says about the tap, for `claudeTap`. */
4
+ export declare function tapState(plan: QuotaSetupPlan): 'on' | 'off' | 'stale';
3
5
  export declare function handoffFindings(input: {
4
6
  settings: HandoffSettings;
5
7
  /** Family ids this Doctor run checks. */
@@ -7,7 +9,10 @@ export declare function handoffFindings(input: {
7
9
  /** Every Account on disk, to resolve `order` entries in any Family. */
8
10
  accounts: readonly Account[];
9
11
  aliases: Readonly<Record<string, string>>;
10
- /** Whether Claude's quota tap is on; undefined when Claude is not part of the run. */
11
- claudeTap?: boolean;
12
+ /**
13
+ * Claude's quota tap: on, off, or on without the refresh that keeps it current while a session idles (`stale`,
14
+ * ADR-0056); undefined when Claude is not part of the run.
15
+ */
16
+ claudeTap?: 'on' | 'off' | 'stale';
12
17
  home: string;
13
18
  }): Promise<Finding[]>;
@@ -1,6 +1,12 @@
1
1
  // Doctor warnings for Auto Handoff (spec §3.17): only when `handoff.auto` is on, never a failure, never fixed.
2
2
  import { join } from 'node:path';
3
3
  import { statOrNull } from './fs-safe.js';
4
+ /** What Claude's quota setup plan says about the tap, for `claudeTap`. */
5
+ export function tapState(plan) {
6
+ if (plan.status === 'enabled')
7
+ return 'on';
8
+ return plan.status === 'ready' && plan.upgrade ? 'stale' : 'off';
9
+ }
4
10
  export async function handoffFindings(input) {
5
11
  const { settings: s } = input;
6
12
  if (!s.auto)
@@ -17,8 +23,10 @@ export async function handoffFindings(input) {
17
23
  fixable: false,
18
24
  });
19
25
  const has = (family) => input.families.includes(family) && input.accounts.some((a) => a.family === family);
20
- if (has('claude') && input.claudeTap === false)
26
+ if (has('claude') && input.claudeTap === 'off')
21
27
  out.push(warn('claude:main', 'handoff.no-quota-tap', 'Auto Handoff is on, but Claude Code reports no quota to sideby, so Claude sessions never hand over', 'run `sideby quota setup claude` (it shows the change first)'));
28
+ if (has('claude') && input.claudeTap === 'stale')
29
+ out.push(warn('claude:main', 'handoff.quota-refresh', "Auto Handoff is on, but Claude's quota stops updating while a session waits on background agents, so such a session hands over late", 'run `sideby quota setup claude` (it shows the change first)'));
22
30
  if (has('grok') && !(await statOrNull(join(input.home, '.grok', 'hooks', 'sideby-handoff.json'))))
23
31
  out.push(warn('grok:main', 'handoff.setup-missing', 'Auto Handoff is on, but Grok has no sideby hook file, so a Grok session that hits its limit cannot hand over', 'run `sideby handoff setup grok`, then `sideby doctor grok --fix` to copy it to every Grok account'));
24
32
  const refs = new Set(input.accounts.map((a) => a.ref));
@@ -8,6 +8,8 @@ export interface EnableStep {
8
8
  diff?: string;
9
9
  /** For `copy`: the Accounts that get the file. */
10
10
  accounts?: string[];
11
+ /** For `quota`: the display is on, and the step only adds what keeps it current (Claude's refresh, ADR-0056). */
12
+ upgrade?: true;
11
13
  }
12
14
  export interface EnableManual {
13
15
  /** `codex-trust`: each Codex account trusts the hooks once, in `/hooks`; `setup-blocked`: a setup that cannot be applied. */
@@ -87,7 +87,13 @@ export async function planHandoffEnable(rt, opts = {}) {
87
87
  .plan()
88
88
  .catch(() => null);
89
89
  if (plan?.status === 'ready')
90
- steps.push({ id: 'quota', family: f.family, file: plan.file, diff: plan.diff });
90
+ steps.push({
91
+ id: 'quota',
92
+ family: f.family,
93
+ file: plan.file,
94
+ diff: plan.diff,
95
+ ...(plan.upgrade ? { upgrade: true } : {}),
96
+ });
91
97
  else if (plan?.status === 'blocked')
92
98
  manual.push({ id: 'setup-blocked', family: f.family, message: plan.message });
93
99
  }
@@ -43,7 +43,10 @@ export async function handoffStatus(rt) {
43
43
  .plan()
44
44
  .catch(() => null);
45
45
  if (plan?.status !== 'enabled') {
46
- problems.push(`${f.title} reports no quota to sideby yet`);
46
+ // On, but without the refresh that keeps the reading current while a session idles (ADR-0056).
47
+ problems.push(plan?.status === 'ready' && plan.upgrade
48
+ ? `${f.title}'s quota stops updating while a session waits on background agents, so it hands over late`
49
+ : `${f.title} reports no quota to sideby yet`);
47
50
  steps.push(`sideby quota setup ${f.id}`);
48
51
  }
49
52
  }
@@ -88,7 +88,16 @@ export const claudeHandoff = {
88
88
  hooks: {
89
89
  SessionStart: hook('SessionStart'),
90
90
  PostToolUse: hook('PostToolUse'),
91
- Stop: hook('Stop'),
91
+ // The second Stop hook runs in the background (`asyncRewake`): while the session waits on background work it
92
+ // watches the Quota and wakes the session at the hand-over level (ADR-0056). 18000 s: five hours.
93
+ Stop: [
94
+ {
95
+ hooks: [
96
+ { type: 'command', command: command('Stop') },
97
+ { type: 'command', command: command('IdleWatch'), asyncRewake: true, timeout: 18000 },
98
+ ],
99
+ },
100
+ ],
92
101
  StopFailure: [
93
102
  { matcher: 'rate_limit', hooks: [{ type: 'command', command: command('StopFailure') }] },
94
103
  ],
@@ -30,8 +30,9 @@ async function withoutCache(account, ctx) {
30
30
  reason: 'not-enabled',
31
31
  detail: "this account's settings.json is not shared with the main account, so its quota needs its own status line setup",
32
32
  };
33
- const planStatus = await claudeStatusline.plan(ctx).then((p) => p.status, () => 'blocked');
34
- if (wiring === 'shared' && planStatus !== 'enabled')
33
+ // A plan that only adds the refresh (ADR-0056) means the wrapper is already on.
34
+ const on = await claudeStatusline.plan(ctx).then((p) => p.status === 'enabled' || (p.status === 'ready' && p.upgrade === true), () => false);
35
+ if (wiring === 'shared' && !on)
35
36
  return {
36
37
  status: 'unavailable',
37
38
  reason: 'not-enabled',
@@ -3,6 +3,9 @@ import { type HookInput } from './reader.ts';
3
3
  export declare const HOOK_COMMAND = "sideby handoff-hook";
4
4
  /** Families whose hooks this entry understands; only they can start a Handoff. */
5
5
  export declare const HOOK_FAMILIES: readonly string[];
6
+ /** How often `IdleWatch` reads the Quota, and how long it watches at most: under its five-hour hook timeout. */
7
+ export declare const WATCH_EVERY_MS = 15000;
8
+ export declare const WATCH_FOR_MS: number;
6
9
  /** What one hook call decided: output for the Host, and files to write. Separate from I/O for the tests. */
7
10
  export declare function decide(opts: {
8
11
  family: string;
@@ -13,4 +16,28 @@ export declare function decide(opts: {
13
16
  }): Promise<{
14
17
  output?: unknown;
15
18
  }>;
16
- export declare function runHandoffHook(argv: readonly string[], env: Env, stdin: AsyncIterable<Uint8Array | string>, stdout: NodeJS.WritableStream): Promise<number>;
19
+ export interface IdleWatchOptions {
20
+ family: string;
21
+ input: HookInput;
22
+ env: Env;
23
+ /** Replaced in tests; the defaults are the clock, a real wait, and whether the parent is gone (`ppid` 1). */
24
+ clock?: () => Date;
25
+ sleep?: (ms: number) => Promise<void>;
26
+ parentGone?: () => boolean;
27
+ everyMs?: number;
28
+ forMs?: number;
29
+ /** This watch's id in `watch-<run>.json`; random by default. */
30
+ id?: string;
31
+ }
32
+ /**
33
+ * Claude's background `Stop` hook (spec §3.17 "主会话等后台任务时", ADR-0056). While the session waits on background
34
+ * work, reads the Quota every 15 s; when a window reaches its Hand-over Level under a `pick` plan, marks the threshold
35
+ * as sent and returns the message with exit 2, which wakes the session. Ends with exit 0 when a later `Stop` starts a
36
+ * new watch, the run is over or handing over, the session handled the threshold itself, the parent is gone, or time
37
+ * runs out. A `wait` or `none` plan never wakes the session.
38
+ */
39
+ export declare function idleWatch(o: IdleWatchOptions): Promise<{
40
+ exit: 0 | 2;
41
+ message?: string;
42
+ }>;
43
+ export declare function runHandoffHook(argv: readonly string[], env: Env, stdin: AsyncIterable<Uint8Array | string>, stdout: NodeJS.WritableStream, stderr?: NodeJS.WritableStream, watch?: Partial<IdleWatchOptions>): Promise<number>;
@@ -1,6 +1,8 @@
1
1
  // Entry for `sideby handoff-hook <family> <event>` (spec §3.17). A Host runs it on PostToolUse, Stop and
2
- // StopFailure, so it imports only Node built-ins and leaf modules: never the Runtime, a Family index or
3
- // core/accounts.ts. It never fails the Host: any problem means no output and exit 0.
2
+ // StopFailure, and Claude also runs `IdleWatch` in the background after a Stop (ADR-0056), so it imports only Node
3
+ // built-ins and leaf modules: never the Runtime, a Family index or core/accounts.ts. It never fails the Host: any
4
+ // problem means no output and exit 0.
5
+ import { randomBytes } from 'node:crypto';
4
6
  import { readFile, rm, stat } from 'node:fs/promises';
5
7
  import { join } from 'node:path';
6
8
  import { BRIEF_DONE, FILES, HANDOFF_ENV, readJsonFile, writeJsonFile, } from '../core/handoff-chain.js';
@@ -8,7 +10,7 @@ import { claudeHookReader } from '../families/claude/handoff-hook.js';
8
10
  import { codexHookReader } from '../families/codex/handoff-hook.js';
9
11
  import { grokHookReader } from '../families/grok/handoff-hook.js';
10
12
  import { crossedWindow, firstMark, fullestWindow, recordTurn } from './levels.js';
11
- import { endTurnMessage, notifySequence, prepareMessage, sessionStartMessage, stopMessage, thresholdMessage, waitNotice, } from './messages.js';
13
+ import { endTurnMessage, idleThresholdMessage, notifySequence, prepareMessage, sessionStartMessage, stopMessage, thresholdMessage, waitNotice, } from './messages.js';
12
14
  import { field } from './reader.js';
13
15
  export const HOOK_COMMAND = 'sideby handoff-hook';
14
16
  const READERS = {
@@ -18,7 +20,10 @@ const READERS = {
18
20
  };
19
21
  /** Families whose hooks this entry understands; only they can start a Handoff. */
20
22
  export const HOOK_FAMILIES = Object.keys(READERS);
21
- const EVENTS = new Set(['SessionStart', 'PostToolUse', 'Stop', 'StopFailure']);
23
+ const EVENTS = new Set(['SessionStart', 'PostToolUse', 'Stop', 'StopFailure', 'IdleWatch']);
24
+ /** How often `IdleWatch` reads the Quota, and how long it watches at most: under its five-hour hook timeout. */
25
+ export const WATCH_EVERY_MS = 15_000;
26
+ export const WATCH_FOR_MS = (4 * 60 + 55) * 60_000;
22
27
  async function readAll(stream) {
23
28
  const chunks = [];
24
29
  try {
@@ -54,6 +59,12 @@ export async function decide(opts) {
54
59
  // Not a run sideby started for a Handoff, or another Family's hook (Grok also runs Claude's settings hooks).
55
60
  if (!runId || !dir || env[HANDOFF_ENV.family] !== family || !reader)
56
61
  return {};
62
+ // `IdleWatch` has its own entry; a `PostToolUse` inside a subagent or teammate (`agent_id`) would speak to that agent,
63
+ // not the main conversation, so it says nothing and marks nothing sent (ADR-0056).
64
+ if (event === 'IdleWatch')
65
+ return {};
66
+ if (event === 'PostToolUse' && field(input, 'agent_id', 'agentId'))
67
+ return {};
57
68
  const plan = await readJsonFile(join(dir, FILES.plan));
58
69
  const usable = plan && plan.runId === runId ? plan : null;
59
70
  const runFile = join(dir, FILES.run(runId));
@@ -176,7 +187,65 @@ export async function decide(opts) {
176
187
  }
177
188
  return {};
178
189
  }
179
- export async function runHandoffHook(argv, env, stdin, stdout) {
190
+ /**
191
+ * Claude's background `Stop` hook (spec §3.17 "主会话等后台任务时", ADR-0056). While the session waits on background
192
+ * work, reads the Quota every 15 s; when a window reaches its Hand-over Level under a `pick` plan, marks the threshold
193
+ * as sent and returns the message with exit 2, which wakes the session. Ends with exit 0 when a later `Stop` starts a
194
+ * new watch, the run is over or handing over, the session handled the threshold itself, the parent is gone, or time
195
+ * runs out. A `wait` or `none` plan never wakes the session.
196
+ */
197
+ export async function idleWatch(o) {
198
+ const { family, input, env } = o;
199
+ const runId = env[HANDOFF_ENV.run];
200
+ const dir = env[HANDOFF_ENV.dir];
201
+ const reader = READERS[family];
202
+ // Only Claude Code can wake an idle session from a hook.
203
+ if (family !== 'claude' || !runId || !dir || env[HANDOFF_ENV.family] !== family || !reader?.windows)
204
+ return { exit: 0 };
205
+ const clock = o.clock ?? (() => new Date());
206
+ const sleep = o.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
207
+ const parentGone = o.parentGone ?? (() => process.ppid === 1);
208
+ const id = o.id ?? randomBytes(8).toString('hex');
209
+ const watchFile = join(dir, FILES.watch(runId));
210
+ const runFile = join(dir, FILES.run(runId));
211
+ // Written first, so a watch left by an earlier Stop ends even when this one has nothing to watch.
212
+ await writeJsonFile(watchFile, { id });
213
+ const tasks = input.background_tasks ?? input.backgroundTasks;
214
+ if (!Array.isArray(tasks) || tasks.length === 0)
215
+ return { exit: 0 };
216
+ const start = clock().getTime();
217
+ for (;;) {
218
+ // The Stop that started this watch judged the Quota itself; the first reading comes one interval later.
219
+ await sleep(o.everyMs ?? WATCH_EVERY_MS);
220
+ const now = clock();
221
+ if (now.getTime() - start >= (o.forMs ?? WATCH_FOR_MS) || parentGone())
222
+ return { exit: 0 };
223
+ if ((await readJsonFile(watchFile))?.id !== id)
224
+ return { exit: 0 };
225
+ const plan = await readJsonFile(join(dir, FILES.plan));
226
+ if (!plan || plan.runId !== runId)
227
+ return { exit: 0 };
228
+ if (await readJsonFile(join(dir, FILES.ready)))
229
+ return { exit: 0 };
230
+ const state = (await readJsonFile(runFile)) ?? {};
231
+ if (state.thresholdSentAt)
232
+ return { exit: 0 };
233
+ if (plan.decision !== 'pick')
234
+ continue;
235
+ const windows = await reader.windows(input, env, now);
236
+ const crossed = windows ? crossedWindow(windows, plan, state) : undefined;
237
+ if (!crossed)
238
+ continue;
239
+ // Read again just before marking, so a turn that handled the threshold meanwhile is neither repeated nor undone.
240
+ const fresh = (await readJsonFile(runFile)) ?? {};
241
+ if (fresh.thresholdSentAt)
242
+ return { exit: 0 };
243
+ await writeJsonFile(runFile, { ...fresh, thresholdSentAt: now.toISOString(), thresholdWindow: crossed });
244
+ const message = plan.agentBrief === false ? endTurnMessage(crossed) : idleThresholdMessage(plan.brief, crossed);
245
+ return { exit: 2, message };
246
+ }
247
+ }
248
+ export async function runHandoffHook(argv, env, stdin, stdout, stderr = process.stderr, watch = {}) {
180
249
  // `sideby run` asks this first, so an older sideby on PATH without the hook entry is caught before any hook runs.
181
250
  if (argv[0] === '--check') {
182
251
  stdout.write('ok\n');
@@ -195,6 +264,15 @@ export async function runHandoffHook(argv, env, stdin, stdout) {
195
264
  }
196
265
  if (input === null || typeof input !== 'object' || Array.isArray(input))
197
266
  return 0;
267
+ if (event === 'IdleWatch') {
268
+ const w = await idleWatch({ ...watch, family, input: input, env });
269
+ // Exit 2 wakes the session (asyncRewake), which shows stderr to the model.
270
+ if (w.exit === 2 && w.message) {
271
+ stderr.write(`${w.message}\n`);
272
+ return 2;
273
+ }
274
+ return 0;
275
+ }
198
276
  const r = await decide({
199
277
  family,
200
278
  event: event,
@@ -3,6 +3,11 @@ import { type WindowReading } from '../core/handoff-chain.ts';
3
3
  export declare function windowText(w: WindowReading): string;
4
4
  export declare function prepareMessage(brief: string, window: WindowReading): string;
5
5
  export declare function thresholdMessage(brief: string, window: WindowReading): string;
6
+ /**
7
+ * At the threshold while the session waits on background work (ADR-0056): sideby woke it, so it says who is speaking,
8
+ * and the Brief must carry the background tasks, which stop when sideby ends the session.
9
+ */
10
+ export declare function idleThresholdMessage(brief: string, window: WindowReading): string;
6
11
  /** At the threshold when the session cannot write a Brief: sideby puts one together from its records. */
7
12
  export declare function endTurnMessage(window: WindowReading): string;
8
13
  export declare function stopMessage(brief: string): string;
@@ -27,6 +27,13 @@ export function prepareMessage(brief, window) {
27
27
  export function thresholdMessage(brief, window) {
28
28
  return `sideby: this account's ${windowText(window)}. Finish the current step, update the handoff brief at ${brief} (${TEMPLATE}; ${RULES}), then end your turn. sideby will start the next account from that brief.`;
29
29
  }
30
+ /**
31
+ * At the threshold while the session waits on background work (ADR-0056): sideby woke it, so it says who is speaking,
32
+ * and the Brief must carry the background tasks, which stop when sideby ends the session.
33
+ */
34
+ export function idleThresholdMessage(brief, window) {
35
+ return `sideby: this is sideby Auto Handoff, set up when this session started. While you wait on background work, this account's ${windowText(window)}. Update the handoff brief at ${brief} (${TEMPLATE}; also name each background task still running, what it is doing and where its work lives: they stop when sideby ends this session, so the next account has to pick them up; ${RULES}). Start no new background work, then end your turn. sideby will start the next account from that brief.`;
36
+ }
30
37
  /** At the threshold when the session cannot write a Brief: sideby puts one together from its records. */
31
38
  export function endTurnMessage(window) {
32
39
  return `sideby: this account's ${windowText(window)}. Finish the current step and end your turn; sideby will start the next account and tell it what you did.`;
@@ -121,6 +121,7 @@ declare const en: {
121
121
  'toast.created': string;
122
122
  'toast.createdProblems': string;
123
123
  'toast.quotaOn': string;
124
+ 'toast.quotaUpdated': string;
124
125
  'toast.quotaOff': string;
125
126
  'toast.undo': string;
126
127
  'toast.undoFailed': string;
@@ -830,6 +831,7 @@ declare const en: {
830
831
  'hp.willDo': string;
831
832
  'hp.step.config': string;
832
833
  'hp.step.quota': string;
834
+ 'hp.step.quotaRefresh': string;
833
835
  'hp.step.hook': string;
834
836
  'hp.step.copy': string;
835
837
  'hp.showChange': string;
@@ -1261,6 +1263,7 @@ declare const en: {
1261
1263
  'toast.ahOn': string;
1262
1264
  'toast.ahOff': string;
1263
1265
  'qs.title': string;
1266
+ 'qs.titleUpdate': string;
1264
1267
  'qs.preparing': string;
1265
1268
  'qs.changes': string;
1266
1269
  'qs.undoHint': string;
@@ -123,6 +123,7 @@ const en = {
123
123
  'toast.created': 'Created {ref}',
124
124
  'toast.createdProblems': 'Created {ref} with problems',
125
125
  'toast.quotaOn': '{host} quota display is on',
126
+ 'toast.quotaUpdated': '{host} quota now stays current while a session waits',
126
127
  'toast.quotaOff': '{host} quota display is off again; the settings file is restored',
127
128
  'toast.undo': 'Undo',
128
129
  'toast.undoFailed': 'Could not undo: {msg}',
@@ -832,6 +833,7 @@ const en = {
832
833
  'hp.willDo': 'To turn it on, sideby will:',
833
834
  'hp.step.config': 'Switch Auto Handoff on in sideby’s settings',
834
835
  'hp.step.quota': 'Show {host} quota (Auto Handoff needs it to track usage)',
836
+ 'hp.step.quotaRefresh': 'Keep {host} quota current while a session waits on background agents',
835
837
  'hp.step.hook': 'Add sideby’s handoff hook to {host}',
836
838
  'hp.step.copy': 'Copy the hook file into your other {host} accounts ({accounts}); nothing else in them changes',
837
839
  'hp.showChange': 'Show the change',
@@ -1263,6 +1265,7 @@ const en = {
1263
1265
  'toast.ahOn': 'Auto Handoff is on for sessions you start with sideby.',
1264
1266
  'toast.ahOff': 'Auto Handoff is off.',
1265
1267
  'qs.title': 'Turn on {host} quota',
1268
+ 'qs.titleUpdate': 'Update {host} quota display',
1266
1269
  'qs.preparing': 'Preparing the change…',
1267
1270
  'qs.changes': 'This changes {file}:',
1268
1271
  'qs.undoHint': 'You can undo it right after, or later with sideby quota teardown.',
@@ -1598,6 +1601,7 @@ const zh = {
1598
1601
  'toast.created': '已创建 {ref}',
1599
1602
  'toast.createdProblems': '已创建 {ref},但有问题',
1600
1603
  'toast.quotaOn': '已开启 {host} 额度显示',
1604
+ 'toast.quotaUpdated': '{host} 的额度在会话等待时也会保持更新',
1601
1605
  'toast.quotaOff': '已关闭 {host} 额度显示,设置文件已还原',
1602
1606
  'toast.undo': '撤销',
1603
1607
  'toast.undoFailed': '撤销失败:{msg}',
@@ -2307,6 +2311,7 @@ const zh = {
2307
2311
  'hp.willDo': '开启时 sideby 会:',
2308
2312
  'hp.step.config': '在 sideby 的设置里打开自动接力',
2309
2313
  'hp.step.quota': '打开 {host} 的额度显示(自动接力需要查看当前用量)',
2314
+ 'hp.step.quotaRefresh': '让 {host} 的额度在会话等后台任务时也保持更新',
2310
2315
  'hp.step.hook': '给 {host} 装上 sideby 的接力钩子',
2311
2316
  'hp.step.copy': '把钩子文件复制到你的其他 {host} 账号({accounts}),它们的其他文件不动',
2312
2317
  'hp.showChange': '查看改动',
@@ -2738,6 +2743,7 @@ const zh = {
2738
2743
  'toast.ahOn': '自动接力已开启,对用 sideby 启动的会话生效。',
2739
2744
  'toast.ahOff': '自动接力已关闭。',
2740
2745
  'qs.title': '开启 {host} 额度显示',
2746
+ 'qs.titleUpdate': '更新 {host} 额度显示',
2741
2747
  'qs.preparing': '正在准备改动…',
2742
2748
  'qs.changes': '将修改 {file}:',
2743
2749
  'qs.undoHint': '应用后可以马上撤销,之后也能用 sideby quota teardown 还原。',
@@ -2004,7 +2004,8 @@ const MAIN = String.raw `
2004
2004
  // Quota is on but no account of the Family has numbers yet: say what brings the first ones.
2005
2005
  function waitingForQuota(fam) {
2006
2006
  const setup = setupFor(fam)
2007
- if (!setup || setup.plan.status !== 'enabled') return false
2007
+ // A plan that only adds the refresh (ADR-0056) means quota is already on.
2008
+ if (!setup || !(setup.plan.status === 'enabled' || setup.plan.upgrade)) return false
2008
2009
  const all = S.state.accounts.filter((a) => a.family === fam && a.kind !== 'api')
2009
2010
  const waiting = all.some((a) => a.quota && a.quota.status === 'unavailable' && a.quota.reason === 'no-session')
2010
2011
  const any = all.some((a) => a.quota && a.quota.status === 'ok')
@@ -4991,7 +4992,8 @@ const MAIN = String.raw `
4991
4992
  if (p.status === 'enabled') body.push(h('p', null, p.message || t('qs.alreadyOn', { host: fam.title })))
4992
4993
  else if (p.status === 'blocked') body.push(h('p', { class: 'note note-warn' }, p.message))
4993
4994
  else {
4994
- body.push(h('p', { class: 'muted' }, qs.summary || p.message))
4995
+ // An update adds one key to a setup that is already on; its own message says what that key does.
4996
+ body.push(h('p', { class: 'muted' }, p.upgrade ? p.message : qs.summary || p.message))
4995
4997
  if (p.file) body.push(h('p', { class: 'small' }, tx('qs.changes', { file: h('code', null, p.file) })))
4996
4998
  if (p.diff) body.push(diffView(p.diff))
4997
4999
  body.push(h('p', { class: 'muted small' }, t('qs.undoHint')))
@@ -5000,7 +5002,7 @@ const MAIN = String.raw `
5000
5002
  }
5001
5003
  }
5002
5004
  if (!foot.length) foot.push(h('button', { class: 'btn', type: 'button', onclick: () => dlg.el.close() }, t('btn.close')))
5003
- setKids(dlg.el, dialogFrame(t('qs.title', { host: fam.title }), qs.family, body, foot))
5005
+ setKids(dlg.el, dialogFrame(t(qs.plan && qs.plan.upgrade ? 'qs.titleUpdate' : 'qs.title', { host: fam.title }), qs.family, body, foot))
5004
5006
  }
5005
5007
  async function applySetup() {
5006
5008
  const st = qs
@@ -5014,7 +5016,9 @@ const MAIN = String.raw `
5014
5016
  if (r.plan.status === 'enabled') {
5015
5017
  const fam = st.family
5016
5018
  dlg.el.close()
5017
- toast(t('toast.quotaOn', { host: family(fam).title }), { action: { label: t('toast.undo'), run: () => undoSetup(fam) }, duration: 10000 })
5019
+ // Teardown undoes the whole setup, not just an update's one key, so an update gets no undo here.
5020
+ if (st.plan && st.plan.upgrade) toast(t('toast.quotaUpdated', { host: family(fam).title }))
5021
+ else toast(t('toast.quotaOn', { host: family(fam).title }), { action: { label: t('toast.undo'), run: () => undoSetup(fam) }, duration: 10000 })
5018
5022
  // The first numbers arrive with the next status line refresh; poll quickly for a while to show them soon.
5019
5023
  S.fastUntil = Date.now() + FAST_FOR_MS
5020
5024
  S.fastFamily = fam
@@ -5426,7 +5430,8 @@ const MAIN = String.raw `
5426
5430
  }
5427
5431
  function hpStepTitle(step) {
5428
5432
  const host = step.family ? family(step.family).title : ''
5429
- return t('hp.step.' + step.id, { host, accounts: (step.accounts || []).join(', ') })
5433
+ const id = step.id === 'quota' && step.upgrade ? 'quotaRefresh' : step.id
5434
+ return t('hp.step.' + id, { host, accounts: (step.accounts || []).join(', ') })
5430
5435
  }
5431
5436
  function hpSteps(plan) {
5432
5437
  return h('ul', { class: 'hp-steps' }, plan.steps.map((step) => h('li', null, h('div', null,
@@ -11,6 +11,11 @@ export declare function backupFile(stateDir: string): string;
11
11
  export declare function mainSettingsFile(home: string): string;
12
12
  export declare function isWrapped(command: unknown): boolean;
13
13
  export declare function wrapCommand(original: string | undefined): string;
14
+ /**
15
+ * Seconds between status line runs while a session is idle (ADR-0056): without it Claude Code runs the status line only
16
+ * on events in the main conversation, so the cache goes stale while the session waits on background agents.
17
+ */
18
+ export declare const REFRESH_INTERVAL = 30;
14
19
  export declare const claudeStatusline: QuotaSetup;
15
20
  /**
16
21
  * Hides values of secret-looking JSON keys in a diff line. settings.json often keeps API keys in `env`,
@@ -25,6 +25,15 @@ export function wrapCommand(original) {
25
25
  function isPlainObject(v) {
26
26
  return typeof v === 'object' && v !== null && !Array.isArray(v);
27
27
  }
28
+ /**
29
+ * Seconds between status line runs while a session is idle (ADR-0056): without it Claude Code runs the status line only
30
+ * on events in the main conversation, so the cache goes stale while the session waits on background agents.
31
+ */
32
+ export const REFRESH_INTERVAL = 30;
33
+ /** Whether the status line already says how often it re-runs; a value the user set is kept. */
34
+ function hasRefresh(statusLine) {
35
+ return statusLine?.refreshInterval !== undefined && statusLine.refreshInterval !== null;
36
+ }
28
37
  /** Keeps the file's own indentation so the diff shows only the changed lines. */
29
38
  function serializeLike(original, value) {
30
39
  const body = original.trimEnd();
@@ -69,29 +78,72 @@ async function analyze(ctx) {
69
78
  const command = current?.command;
70
79
  if (command !== undefined && typeof command !== 'string')
71
80
  return blocked(`statusLine.command in ${targetName} is not a string`, target);
72
- if (isWrapped(command))
81
+ if (isWrapped(command)) {
82
+ if (hasRefresh(current))
83
+ return {
84
+ plan: {
85
+ status: 'enabled',
86
+ file: target,
87
+ diff: '',
88
+ message: `already enabled in ${targetName}${note}`,
89
+ },
90
+ };
91
+ // Wrapped by an older sideby, without `refreshInterval` (ADR-0056): offer only that key.
92
+ const statusLine = { ...current, refreshInterval: REFRESH_INTERVAL };
73
93
  return {
74
- plan: { status: 'enabled', file: target, diff: '', message: `already enabled in ${targetName}${note}` },
94
+ plan: {
95
+ status: 'ready',
96
+ upgrade: true,
97
+ file: target,
98
+ diff: statusLineDiff(current, statusLine, targetName),
99
+ message: `adds statusLine.refreshInterval (${REFRESH_INTERVAL} seconds) in ${targetName} so Claude quota stays current while a session waits on background agents${note}; \`sideby quota teardown claude\` still restores the file as it was before quota setup`,
100
+ },
101
+ target,
102
+ original,
103
+ wrapped: serializeLike(text, { ...settings, statusLine }),
75
104
  };
105
+ }
76
106
  const problem = await sidebyBinProblem(ctx.env, `the status line runs \`${TAP_COMMAND}\` on every refresh`);
77
107
  if (problem)
78
108
  return blocked(problem, target);
109
+ const addRefresh = !hasRefresh(current);
110
+ const refresh = addRefresh ? { refreshInterval: REFRESH_INTERVAL } : {};
79
111
  const statusLine = current
80
- ? { type: 'command', ...current, command: wrapCommand(command) }
81
- : { type: 'command', command: TAP_COMMAND };
112
+ ? { type: 'command', ...current, command: wrapCommand(command), ...refresh }
113
+ : { type: 'command', command: TAP_COMMAND, ...refresh };
82
114
  const wrapped = serializeLike(text, { ...settings, statusLine });
83
115
  return {
84
116
  plan: {
85
117
  status: 'ready',
86
118
  file: target,
87
119
  diff: statusLineDiff(current, statusLine, targetName),
88
- message: `wraps statusLine.command in ${targetName} so sideby can record Claude's rate limits${note}; undo with \`sideby quota teardown claude\``,
120
+ message: `wraps statusLine.command in ${targetName} so sideby can record Claude's rate limits${addRefresh ? `, and re-runs it every ${REFRESH_INTERVAL} seconds so they stay current while a session waits` : ''}${note}; undo with \`sideby quota teardown claude\``,
89
121
  },
90
122
  target,
91
123
  original,
92
124
  wrapped,
93
125
  };
94
126
  }
127
+ /**
128
+ * Adds `refreshInterval` to a status line sideby wrapped earlier (ADR-0056). The backup's wrapped hash follows the new
129
+ * bytes only while it named the file as it was, so teardown still restores the original; otherwise it stays as it is
130
+ * and teardown refuses as before.
131
+ */
132
+ async function applyUpgrade(ctx, a, mode) {
133
+ const { upgrade: _, ...plan } = a.plan;
134
+ const before = sha256(a.original);
135
+ if (!(await writeIfUnchanged(a.target, before, a.wrapped, mode)))
136
+ return {
137
+ ...plan,
138
+ status: 'blocked',
139
+ message: `${tildify(a.target, ctx.home)} changed while applying; nothing was written, run setup again`,
140
+ };
141
+ const bf = backupFile(ctx.stateDir);
142
+ const b = await readBackup(bf);
143
+ if (b && b.file === a.target && b.wrappedHash === before)
144
+ await writeFileAtomic(bf, `${JSON.stringify({ ...b, wrappedHash: sha256(a.wrapped) }, null, 2)}\n`, 0o600);
145
+ return { ...plan, status: 'enabled', message: `updated: ${plan.message}` };
146
+ }
95
147
  async function readBackup(file) {
96
148
  try {
97
149
  const b = JSON.parse(await readFile(file, 'utf8'));
@@ -107,7 +159,7 @@ async function readBackup(file) {
107
159
  }
108
160
  }
109
161
  export const claudeStatusline = {
110
- summary: "Wrap the status line command in ~/.claude/settings.json with `sideby statusline-tap` so sideby can cache Claude's 5h and 7d rate limits. Your status line keeps working; teardown restores the file byte for byte.",
162
+ summary: "Wrap the status line command in ~/.claude/settings.json with `sideby statusline-tap` so sideby can cache Claude's 5h and 7d rate limits, re-run every 30 seconds so they stay current while a session waits. Your status line keeps working; teardown restores the file byte for byte.",
111
163
  async plan(ctx) {
112
164
  return (await analyze(ctx)).plan;
113
165
  },
@@ -116,6 +168,8 @@ export const claudeStatusline = {
116
168
  if (a.plan.status !== 'ready' || !a.target || !a.original || a.wrapped === undefined)
117
169
  return a.plan;
118
170
  const mode = (await stat(a.target)).mode & 0o777;
171
+ if (a.plan.upgrade)
172
+ return applyUpgrade(ctx, a, mode);
119
173
  const backup = {
120
174
  file: a.target,
121
175
  originalBase64: a.original.toString('base64'),
@@ -234,7 +288,7 @@ export function statusLineDiff(before, after, file) {
234
288
  const show = (v) => v === undefined ? '' : `${JSON.stringify({ statusLine: redactStatusLine(v) }, null, 2)}\n`;
235
289
  return unifiedDiff(show(before), show(after), `${file} (statusLine only)`);
236
290
  }
237
- const SHOWN_STATUSLINE_KEYS = new Set(['type', 'command', 'padding']);
291
+ const SHOWN_STATUSLINE_KEYS = new Set(['type', 'command', 'padding', 'refreshInterval']);
238
292
  /** Shows the statusLine fields sideby touches as they are; any other value becomes "<redacted>". */
239
293
  export function redactStatusLine(v) {
240
294
  if (typeof v !== 'object' || v === null || Array.isArray(v))
@@ -7,7 +7,7 @@ import { applyFixes, runDoctor } from './core/doctor.js';
7
7
  import { hostSettingsFile } from './core/edit-settings.js';
8
8
  import { UserError } from './core/errors.js';
9
9
  import { planHandoff } from './core/handoff.js';
10
- import { handoffFindings } from './core/handoff-doctor.js';
10
+ import { handoffFindings, tapState } from './core/handoff-doctor.js';
11
11
  import { selectNext } from './core/handoff-select.js';
12
12
  import { identityOf } from './core/identity.js';
13
13
  import { inboundFindings } from './core/inbound.js';
@@ -436,7 +436,7 @@ export async function createRuntime(opts = {}) {
436
436
  accounts: all,
437
437
  aliases: aliasRefs(config.aliases),
438
438
  ...(claude?.quotaSetup
439
- ? { claudeTap: (await bindSetup(claude, claude.quotaSetup).plan()).status === 'enabled' }
439
+ ? { claudeTap: tapState(await bindSetup(claude, claude.quotaSetup).plan()) }
440
440
  : {}),
441
441
  home: paths.home,
442
442
  });
@@ -658,6 +658,10 @@ export async function createRuntime(opts = {}) {
658
658
  return out;
659
659
  },
660
660
  async prepareLaunch(ref, userArgs, command, opts = {}) {
661
+ // A Handoff chain can run for hours: an Account's arguments changed meanwhile apply to its next start.
662
+ const fresh = await loadConfig(paths.configFile).catch(() => null);
663
+ if (fresh)
664
+ config.accounts = fresh.accounts;
661
665
  const all = await accounts();
662
666
  const inputs = launchInputs(ref, all, userArgs, command);
663
667
  const p = await prepareLaunch({
@@ -284,8 +284,11 @@ export interface FamilyDef {
284
284
  /** How this Family takes part in a Handoff (spec §3.17); without it the Family neither starts nor receives one. */
285
285
  handoff?: FamilyHandoff;
286
286
  }
287
- /** A Host hook event sideby's handoff hook listens to. */
288
- export type HandoffHookEvent = 'SessionStart' | 'PostToolUse' | 'Stop' | 'StopFailure';
287
+ /**
288
+ * A Host hook event sideby's handoff hook listens to. `IdleWatch` is sideby's own name for a second, background Claude
289
+ * `Stop` hook that wakes a session waiting on background work (ADR-0056).
290
+ */
291
+ export type HandoffHookEvent = 'SessionStart' | 'PostToolUse' | 'Stop' | 'StopFailure' | 'IdleWatch';
289
292
  /** Whether one run may start a Handoff, or start as the next Account of one, and why not. */
290
293
  export interface HandoffEligibility {
291
294
  start: boolean;
@@ -343,6 +346,11 @@ export interface QuotaSetupPlan {
343
346
  /** Unified diff of the change, empty when nothing would change. */
344
347
  diff: string;
345
348
  message: string;
349
+ /**
350
+ * With `ready`: the setup is already on and only an addition from a newer sideby is missing (Claude's
351
+ * `statusLine.refreshInterval`, ADR-0056); quota already shows, but `apply` should still run.
352
+ */
353
+ upgrade?: boolean;
346
354
  }
347
355
  export interface QuotaSetup {
348
356
  /** One sentence shown before the user confirms. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sideby",
3
- "version": "0.28.1",
3
+ "version": "0.28.3",
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)",
@@ -66,6 +66,7 @@
66
66
  "format": "biome check --write .",
67
67
  "test": "node --test --test-concurrency=4 \"src/**/*.test.ts\" \"testing/**/*.test.ts\" \"scripts/**/*.test.ts\"",
68
68
  "schemas": "node src/cli/schemas.ts",
69
+ "design-system": "node scripts/design-system.ts",
69
70
  "leak-check": "sh scripts/leak-check.sh",
70
71
  "check": "pnpm typecheck && pnpm lint && pnpm test && pnpm leak-check",
71
72
  "preversion": "node scripts/readme-assets.ts",
@@ -77,9 +78,9 @@
77
78
  "typebox": "^1.3.34"
78
79
  },
79
80
  "devDependencies": {
80
- "@biomejs/biome": "2.5.15",
81
+ "@biomejs/biome": "2.6.2",
81
82
  "@types/node": "^22.18.0",
82
- "motion": "14.3.0",
83
+ "motion": "14.5.0",
83
84
  "typescript": "^7.0.2"
84
85
  },
85
86
  "packageManager": "pnpm@10.15.0",
@@ -52,6 +52,10 @@
52
52
  },
53
53
  "message": {
54
54
  "type": "string"
55
+ },
56
+ "upgrade": {
57
+ "type": "boolean",
58
+ "description": "With `ready`: the setup is already on and only an addition from a newer sideby is missing (Claude: `statusLine.refreshInterval`)."
55
59
  }
56
60
  }
57
61
  },
@@ -52,6 +52,10 @@
52
52
  },
53
53
  "message": {
54
54
  "type": "string"
55
+ },
56
+ "upgrade": {
57
+ "type": "boolean",
58
+ "description": "With `ready`: the setup is already on and only an addition from a newer sideby is missing (Claude: `statusLine.refreshInterval`)."
55
59
  }
56
60
  }
57
61
  },
@@ -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.28.1"
5
+ version: "0.28.3"
6
6
  requires:
7
7
  bins: [sideby, node]
8
8
  cliHelp: sideby --help
@@ -50,7 +50,7 @@ With config `"handoff": { "auto": true }`, a session sideby started hands its ta
50
50
  1. Run `sideby handoff status --json`. Read `auto`, `sideby` (is the `sideby` on PATH able to run the hook), each family's `starts`, `ready`, `problems` and `notes`, and `nextSteps`.
51
51
  2. Tell the user what Auto Handoff does, that it is off by default, and the risk: hand-over between two subscriptions of one vendor (`--same-family`, cc001 → cc002) is the kind vendors may act on. Add `--same-family` only when the user asks for it. Other AI tools take over only with `--other-ai` (order with `--ai-order claude,codex`), and API accounts only with `--api`: they are billed per request and sideby does not cap spending, so say so and add `--api` only when the user asks. Ask which accounts each family should hand over to if they care about the order (`--order claude=codex001,cc002`; accounts or short commands, any family).
52
52
  3. Run `sideby handoff enable [flags] --json`. Exit 10 means the config change was shown: show the user `diff`, ask, and only after a clear yes run the same command with `--yes`. It writes only the `handoff` key of the config and returns `nextSteps`.
53
- 4. Work through `nextSteps` in order. `sideby quota setup claude` and `sideby handoff setup grok` also exit 10 first: ask before adding `--yes`. `npm i -g sideby` installs or upgrades sideby on PATH; ask first. Codex needs the user to trust sideby's hooks once per account (`/hooks` in Codex); you cannot do that for them.
53
+ 4. Work through `nextSteps` in order. `sideby quota setup claude` and `sideby handoff setup grok` also exit 10 first: ask before adding `--yes`. `sideby quota setup claude` also shows up when Claude's quota is on but stops updating while a session waits on background agents; it then adds only `statusLine.refreshInterval`. `npm i -g sideby` installs or upgrades sideby on PATH; ask first. Codex needs the user to trust sideby's hooks once per account (`/hooks` in Codex); you cannot do that for them.
54
54
  5. Run `sideby handoff status --json` again and report which families are `ready`.
55
55
 
56
56
  To turn it off: `sideby handoff disable --json`, then `--yes` after the user agrees; the other settings stay. The panel's **Auto Handoff** page does all of this in one click (turn on, with one confirmation; turn off) and shows where each account's work goes next; for a user who is not in a terminal, point them there instead of walking through the commands.
@@ -7,6 +7,8 @@ Claude quota needs a one-time change to `~/.claude/settings.json`: the status li
7
7
  3. Only after the user approves, run `sideby quota setup claude --yes`.
8
8
  4. To undo: `sideby quota teardown claude`. It restores the file byte for byte only if nothing changed since setup. If it refuses, show its diff and tell the user to set `statusLine.command` back to the original command (the base64 after `--orig-b64`), or delete `statusLine` if there was none.
9
9
 
10
+ Setup also sets `statusLine.refreshInterval: 30` (kept if the user set one), so the quota stays current while a session waits on background agents. When `sideby handoff status` or `sideby doctor` (`handoff.quota-refresh`) asks for it, the status line was wrapped by an older sideby: run `sideby quota setup claude` again; the plan has `upgrade: true` and adds only that key. Ask before `--yes` as above.
11
+
10
12
  Accounts with their own (not linked) `settings.json` show quota `not-enabled` until that file's status line is wrapped the same way; tell the user instead of editing it.
11
13
 
12
14
  After setup, each account shows quota once it has had one session with a reply. Codex quota needs no setup: sideby asks the official `codex app-server` every 15 minutes, without a conversation. `sideby quota codex --refresh --json` asks now; `sideby quota check codex off --json` disables querying, as does CI. Local session records are a fallback only until the first successful query; they cannot overwrite fetched quota afterward. On failure, relay `fetchError` and `observedAt`, never call old numbers current. The menu's checked time is separate from each row's `observedAt` and `stale`; readings older than one hour or with a query failure show as older readings, except a reading over an hour old whose login has had no local session since (it stays current; use on the web or other computers is not seen). Claude Code quota cannot be refreshed on demand: tell the user it updates when a session runs in that account. Tested with Codex CLI 0.163.0.