sideby 0.18.0 → 0.19.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/README.md +8 -0
- package/dist/build.json +1 -1
- package/dist/src/cli/commands.js +159 -13
- package/dist/src/cli/json-schemas.js +39 -1
- package/dist/src/cli/main.js +23 -6
- package/dist/src/core/ask.d.ts +14 -0
- package/dist/src/core/ask.js +16 -1
- package/dist/src/core/browser-profiles.js +7 -32
- package/dist/src/core/config.d.ts +14 -0
- package/dist/src/core/config.js +64 -1
- package/dist/src/core/file-memo.js +26 -4
- package/dist/src/core/pick-commands.d.ts +42 -0
- package/dist/src/core/pick-commands.js +44 -0
- package/dist/src/core/shell-init.js +3 -1
- package/dist/src/core/shell-setup.d.ts +40 -0
- package/dist/src/core/shell-setup.js +54 -0
- package/dist/src/core/skill-check.d.ts +2 -0
- package/dist/src/core/skill-check.js +2 -0
- package/dist/src/core/terminal.d.ts +21 -4
- package/dist/src/core/terminal.js +149 -9
- package/dist/src/core/update.js +2 -2
- package/dist/src/core/windows-dirs.d.ts +19 -0
- package/dist/src/core/windows-dirs.js +39 -0
- package/dist/src/panel/handler.d.ts +18 -0
- package/dist/src/panel/handler.js +69 -1
- package/dist/src/panel/i18n.d.ts +39 -0
- package/dist/src/panel/i18n.js +78 -0
- package/dist/src/panel/page-script.js +184 -3
- package/dist/src/panel/page-styles.js +3 -0
- package/dist/src/panel/page.js +6 -1
- package/dist/src/plugins/account-script.js +61 -27
- package/dist/src/runtime.d.ts +35 -1
- package/dist/src/runtime.js +96 -3
- package/package.json +2 -2
- package/schemas/alias-list.json +119 -0
- package/schemas/alias.json +27 -1
- package/schemas/config.json +11 -0
- package/schemas/new.json +19 -0
- package/schemas/shell-init-setup.json +124 -0
- package/skills/sideby/SKILL.md +6 -3
- package/skills/sideby/references/accounts.md +10 -0
- package/skills/sideby/references/setup.md +1 -1
package/dist/src/core/update.js
CHANGED
|
@@ -8,7 +8,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
8
8
|
import { afterInstall, runSkillUpdate } from './after-install.js';
|
|
9
9
|
import { writeFileAtomic } from './fs-safe.js';
|
|
10
10
|
import { processAlive, takeFileLock } from './lock.js';
|
|
11
|
-
import { installedSkills, SKILL_UPDATE, SKILL_UPDATE_SHOWN, skillOwnerRepo } from './skill-check.js';
|
|
11
|
+
import { installedSkills, REPO_URL, SKILL_UPDATE, SKILL_UPDATE_SHOWN, skillOwnerRepo } from './skill-check.js';
|
|
12
12
|
import { localBuild, packageVersion, parseLocalBuild } from './version.js';
|
|
13
13
|
export { isZombieStat } from './lock.js';
|
|
14
14
|
export const DEFAULT_REGISTRY = 'https://registry.npmjs.org';
|
|
@@ -19,7 +19,7 @@ export const RETRY_INTERVAL_MS = 60 * 60 * 1000;
|
|
|
19
19
|
/** A failed Auto Update of one version is tried again after this long (a mirror may not have it yet). */
|
|
20
20
|
export const AUTO_RETRY_MS = 24 * 60 * 60 * 1000;
|
|
21
21
|
const FETCH_TIMEOUT_MS = 5000;
|
|
22
|
-
export const RELEASE_NOTES = (v) =>
|
|
22
|
+
export const RELEASE_NOTES = (v) => `${REPO_URL}/releases/tag/v${v}`;
|
|
23
23
|
/** Swapped in tests through `bindUpdateDeps`; the real machine otherwise. */
|
|
24
24
|
/**
|
|
25
25
|
* Whether `sideby autostart --refresh --json` rewrote the login item: it exits 0 also when nothing changed or the
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface WindowsDir {
|
|
2
|
+
win: string;
|
|
3
|
+
unix: string;
|
|
4
|
+
}
|
|
5
|
+
export interface WindowsDirs {
|
|
6
|
+
localAppData?: WindowsDir;
|
|
7
|
+
programs: WindowsDir[];
|
|
8
|
+
}
|
|
9
|
+
export type WindowsExec = (file: string, args: readonly string[]) => Promise<{
|
|
10
|
+
code: number;
|
|
11
|
+
stdout: string;
|
|
12
|
+
}>;
|
|
13
|
+
/** A Windows drive path (`C:\Windows`) as WSL mounts it (`/mnt/c/Windows`); undefined for anything else. */
|
|
14
|
+
export declare function toUnix(win: string, mount: string): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* The current Windows user's folders, from one `cmd.exe` call, remembered for the process; null when cmd.exe does not
|
|
17
|
+
* answer (WSL interop off, or no C: drive), for the caller to fall back without guessing between users.
|
|
18
|
+
*/
|
|
19
|
+
export declare function askWindowsDirs(exec: WindowsExec, mount: string): Promise<WindowsDirs | null>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Windows' own folders as WSL sees them (spec §3.24, §3.28): one `cmd.exe` call names the current Windows user's
|
|
2
|
+
// `%LOCALAPPDATA%` and the Program Files folders, so sideby never guesses between the users under `C:\Users`.
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
/** A Windows drive path (`C:\Windows`) as WSL mounts it (`/mnt/c/Windows`); undefined for anything else. */
|
|
5
|
+
export function toUnix(win, mount) {
|
|
6
|
+
const m = /^([A-Za-z]):\\(.*)$/.exec(win.trim());
|
|
7
|
+
if (!m)
|
|
8
|
+
return undefined;
|
|
9
|
+
return join(mount, m[1].toLowerCase(), ...m[2].split('\\').filter(Boolean));
|
|
10
|
+
}
|
|
11
|
+
const memo = new Map();
|
|
12
|
+
/**
|
|
13
|
+
* The current Windows user's folders, from one `cmd.exe` call, remembered for the process; null when cmd.exe does not
|
|
14
|
+
* answer (WSL interop off, or no C: drive), for the caller to fall back without guessing between users.
|
|
15
|
+
*/
|
|
16
|
+
export async function askWindowsDirs(exec, mount) {
|
|
17
|
+
const hit = memo.get(mount);
|
|
18
|
+
if (hit)
|
|
19
|
+
return hit;
|
|
20
|
+
const r = await exec(join(mount, 'c', 'Windows', 'System32', 'cmd.exe'), [
|
|
21
|
+
'/d',
|
|
22
|
+
'/c',
|
|
23
|
+
'echo %LOCALAPPDATA%^|%ProgramFiles%^|%ProgramFiles(x86)%',
|
|
24
|
+
]).catch(() => null);
|
|
25
|
+
const parts = r?.code === 0 ? r.stdout.trim().split('|') : [];
|
|
26
|
+
const dir = (win) => {
|
|
27
|
+
const unix = win ? toUnix(win, mount) : undefined;
|
|
28
|
+
return win && unix ? { win: win.trim(), unix } : undefined;
|
|
29
|
+
};
|
|
30
|
+
const local = dir(parts[0]);
|
|
31
|
+
if (!local)
|
|
32
|
+
return null;
|
|
33
|
+
const found = {
|
|
34
|
+
localAppData: local,
|
|
35
|
+
programs: [dir(parts[1]), dir(parts[2])].filter((d) => d !== undefined),
|
|
36
|
+
};
|
|
37
|
+
memo.set(mount, found);
|
|
38
|
+
return found;
|
|
39
|
+
}
|
|
@@ -149,6 +149,24 @@ export interface PanelState {
|
|
|
149
149
|
history?: DoctorHistory;
|
|
150
150
|
/** The config `aliases` as alias → Account ref (arguments left out), so the page can tell which names are taken. */
|
|
151
151
|
configAliases?: Record<string, string>;
|
|
152
|
+
/** The config `pickCommands`, name → Family (spec §3.13, ADR-0035). */
|
|
153
|
+
pickCommands?: Record<string, string>;
|
|
154
|
+
/**
|
|
155
|
+
* Family → the Pick Command the page offers to add: a Family with two or more Subscription Accounts and none yet,
|
|
156
|
+
* with the command on PATH the name would hide; `name: null` when no default name is free (the user types one).
|
|
157
|
+
*/
|
|
158
|
+
pickOffers?: Record<string, {
|
|
159
|
+
name: string | null;
|
|
160
|
+
shadows?: string;
|
|
161
|
+
}>;
|
|
162
|
+
/** Whether new terminals load the short commands (`sideby shell-init setup`, ADR-0036), and the rc file it would edit. */
|
|
163
|
+
shellSetup: {
|
|
164
|
+
shell: 'zsh' | 'bash';
|
|
165
|
+
rc: string;
|
|
166
|
+
loaded: boolean;
|
|
167
|
+
added: boolean;
|
|
168
|
+
block: string;
|
|
169
|
+
};
|
|
152
170
|
/**
|
|
153
171
|
* Family → the Account `sideby next <family>` would pick (spec §3.13). Only Families with a Quota source,
|
|
154
172
|
* at least two subscription Accounts, some Quota data and a pick; API Accounts are left out as in the CLI default.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { randomBytes, timingSafeEqual } from 'node:crypto';
|
|
3
3
|
import { aliasesByAccount } from '../core/accounts.js';
|
|
4
4
|
import { listAppProfiles, openAppProfile, removeAppProfile, } from '../core/app-profiles.js';
|
|
5
|
-
import { openLoginInTerminal, pickTaskAccount, previewAttachments, promptForTask, setCustomTerminal, setPreferredTerminal, startAiTask, taskContext, terminals, tryAccount, } from '../core/ask.js';
|
|
5
|
+
import { openLoginInTerminal, openPickInTerminal, pickTaskAccount, previewAttachments, promptForTask, setCustomTerminal, setPreferredTerminal, startAiTask, taskContext, terminals, tryAccount, } from '../core/ask.js';
|
|
6
6
|
import { MAX_ATTACHMENTS, MAX_UPLOAD_BYTES, removeStaged, stageUpload } from '../core/attachments.js';
|
|
7
7
|
import { applyAutostart, autostartStatus, PANEL_AGENT, planAutostart, } from '../core/autostart.js';
|
|
8
8
|
import { FAVICON_SVG, ICON_SVG } from '../core/brand-mark.js';
|
|
@@ -382,6 +382,14 @@ async function buildState(rt, opts) {
|
|
|
382
382
|
};
|
|
383
383
|
});
|
|
384
384
|
const handoff = handoffByFamily(rt, list, ctx.now);
|
|
385
|
+
const pickOffers = {};
|
|
386
|
+
for (const f of families) {
|
|
387
|
+
const offer = await rt.pickSuggestion(f.id, accounts).catch(() => null);
|
|
388
|
+
if (offer && !offer.exists)
|
|
389
|
+
pickOffers[f.id] = { name: offer.name, ...(offer.shadows ? { shadows: offer.shadows } : {}) };
|
|
390
|
+
}
|
|
391
|
+
const { setupBlock, shellSetupStatus, userShell } = await import('../core/shell-setup.js');
|
|
392
|
+
const shellSt = await shellSetupStatus(userShell(rt.env), ctx.home, rt.env, rt.config.shellInitFile);
|
|
385
393
|
const browser = await browserReport(rt, accounts).catch(() => undefined);
|
|
386
394
|
const showBrowser = browser && (browser.families.matched.length || browser.families.openOnly.length);
|
|
387
395
|
return {
|
|
@@ -401,6 +409,9 @@ async function buildState(rt, opts) {
|
|
|
401
409
|
quotaSetups,
|
|
402
410
|
...(history ? { history } : {}),
|
|
403
411
|
...(rt.config.aliases ? { configAliases: aliasRefs(rt.config.aliases) } : {}),
|
|
412
|
+
...(rt.config.pickCommands ? { pickCommands: { ...rt.config.pickCommands } } : {}),
|
|
413
|
+
...(Object.keys(pickOffers).length ? { pickOffers } : {}),
|
|
414
|
+
shellSetup: { ...shellSt, rc: tildify(shellSt.rc, ctx.home), block: setupBlock(shellSt.shell) },
|
|
404
415
|
...(Object.keys(handoff).length ? { handoff } : {}),
|
|
405
416
|
...(remoteControl.length ? { remoteControl: rcView(remoteControl, ctx.home) } : {}),
|
|
406
417
|
...(appProfiles.length
|
|
@@ -741,6 +752,63 @@ export function createPanelHandler(opts) {
|
|
|
741
752
|
return rt.createAccount(family, name, { api, ...(alias ? { alias } : {}) });
|
|
742
753
|
},
|
|
743
754
|
},
|
|
755
|
+
// Pick Commands (spec §3.13, ADR-0035): start the Account with the most room in the Preferred Terminal, add one
|
|
756
|
+
// (a name that hides a command on PATH comes back as `confirm` until the page sends confirm: true), remove one.
|
|
757
|
+
'/api/pick/start': {
|
|
758
|
+
async run(body) {
|
|
759
|
+
const name = optString(body, 'name');
|
|
760
|
+
if (!name)
|
|
761
|
+
throw new HttpError(400, '"name" is required');
|
|
762
|
+
const rt = await getRuntime();
|
|
763
|
+
const { family, choice } = await rt.pickChoice(name);
|
|
764
|
+
if (choice.ref === null)
|
|
765
|
+
throw new UserError(choice.earliestReset
|
|
766
|
+
? `Every ${family} account is at its limit; ${choice.earliestReset.ref} is back first.`
|
|
767
|
+
: `No ${family} account can be used now; sign one in first.`, { code: 'none-usable' });
|
|
768
|
+
// The terminal runs the Pick Command itself, so it picks again as it starts and prints which and why.
|
|
769
|
+
const r = opened(await openPickInTerminal(rt, name));
|
|
770
|
+
return {
|
|
771
|
+
...r,
|
|
772
|
+
name,
|
|
773
|
+
family,
|
|
774
|
+
picked: choice.ref,
|
|
775
|
+
reason: choice.reason,
|
|
776
|
+
...('pressure' in choice ? { pressure: choice.pressure } : {}),
|
|
777
|
+
};
|
|
778
|
+
},
|
|
779
|
+
},
|
|
780
|
+
'/api/pick/add': {
|
|
781
|
+
async run(body) {
|
|
782
|
+
const name = optString(body, 'name')?.trim();
|
|
783
|
+
const family = optString(body, 'family');
|
|
784
|
+
if (!name || !family)
|
|
785
|
+
throw new HttpError(400, 'enter a name and pick a family');
|
|
786
|
+
const rt = await getRuntime();
|
|
787
|
+
return rt.addPickCommand(name, family, { yes: optBool(body, 'confirm') });
|
|
788
|
+
},
|
|
789
|
+
},
|
|
790
|
+
'/api/pick/remove': {
|
|
791
|
+
async run(body) {
|
|
792
|
+
const name = optString(body, 'name');
|
|
793
|
+
if (!name)
|
|
794
|
+
throw new HttpError(400, '"name" is required');
|
|
795
|
+
const rt = await getRuntime();
|
|
796
|
+
if (rt.pickCommandFamily(name) === undefined)
|
|
797
|
+
throw new HttpError(400, `no pick command "${name}"`);
|
|
798
|
+
return rt.removeAlias(name);
|
|
799
|
+
},
|
|
800
|
+
},
|
|
801
|
+
// `sideby shell-init setup` (ADR-0036): the page has shown the line and the file; undo takes out only that line.
|
|
802
|
+
'/api/shell-init/setup': {
|
|
803
|
+
async run(body) {
|
|
804
|
+
const rt = await getRuntime();
|
|
805
|
+
const { applyShellSetup, userShell } = await import('../core/shell-setup.js');
|
|
806
|
+
const r = await applyShellSetup(userShell(rt.env), rt.paths.home, rt.env, rt.config.shellInitFile, {
|
|
807
|
+
undo: optBool(body, 'undo'),
|
|
808
|
+
});
|
|
809
|
+
return { status: r.status, shell: r.shell, rc: tildify(r.rc, rt.paths.home) };
|
|
810
|
+
},
|
|
811
|
+
},
|
|
744
812
|
'/api/quota/setup': {
|
|
745
813
|
writes: (body) => body.confirm === true,
|
|
746
814
|
async run(body) {
|
package/dist/src/panel/i18n.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export type PanelLang = 'en' | 'zh';
|
|
|
2
2
|
declare const en: {
|
|
3
3
|
'top.tagline': string;
|
|
4
4
|
'top.refresh': string;
|
|
5
|
+
'top.repo': string;
|
|
5
6
|
'top.loading': string;
|
|
6
7
|
'top.refreshing': string;
|
|
7
8
|
'top.updated': string;
|
|
@@ -411,6 +412,7 @@ declare const en: {
|
|
|
411
412
|
'ai.examples': string;
|
|
412
413
|
'ai.copy': string;
|
|
413
414
|
'ai.ask.quota': string;
|
|
415
|
+
'ai.ask.pick': string;
|
|
414
416
|
'ai.ask.new': string;
|
|
415
417
|
'ai.ask.pin': string;
|
|
416
418
|
'ai.ask.fix': string;
|
|
@@ -508,6 +510,43 @@ declare const en: {
|
|
|
508
510
|
'ask.otherTool': string;
|
|
509
511
|
'ask.otherToolSub': string;
|
|
510
512
|
'ask.plugin': string;
|
|
513
|
+
'pk.title': string;
|
|
514
|
+
'pk.intro': string;
|
|
515
|
+
'pk.none': string;
|
|
516
|
+
'pk.noneYet': string;
|
|
517
|
+
'pk.exists': string;
|
|
518
|
+
'pk.start': string;
|
|
519
|
+
'pk.startTip': string;
|
|
520
|
+
'pk.remove': string;
|
|
521
|
+
'pk.removed': string;
|
|
522
|
+
'pk.nameLabel': string;
|
|
523
|
+
'pk.hint': string;
|
|
524
|
+
'pk.shadows': string;
|
|
525
|
+
'pk.add': string;
|
|
526
|
+
'pk.addAnyway': string;
|
|
527
|
+
'pk.added': string;
|
|
528
|
+
'pk.newShell': string;
|
|
529
|
+
'pk.offerShort': string;
|
|
530
|
+
'pk.offerMore': string;
|
|
531
|
+
'pk.rename': string;
|
|
532
|
+
'pk.addedSetup': string;
|
|
533
|
+
'pk.renamedSetup': string;
|
|
534
|
+
'ss.title': string;
|
|
535
|
+
'ss.body': string;
|
|
536
|
+
'ss.add': string;
|
|
537
|
+
'ss.adding': string;
|
|
538
|
+
'ss.added': string;
|
|
539
|
+
'ss.undo': string;
|
|
540
|
+
'ss.removed': string;
|
|
541
|
+
'pk.save': string;
|
|
542
|
+
'pk.renamed': string;
|
|
543
|
+
'pk.fileFailed': string;
|
|
544
|
+
'pk.why.othersFull': string;
|
|
545
|
+
'pk.offerNoName': string;
|
|
546
|
+
'pk.namePh': string;
|
|
547
|
+
'pk.started': string;
|
|
548
|
+
'pk.why.room': string;
|
|
549
|
+
'pk.why.noData': string;
|
|
511
550
|
'login.opened': string;
|
|
512
551
|
'login.failed': string;
|
|
513
552
|
'login.automation': string;
|
package/dist/src/panel/i18n.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
const en = {
|
|
5
5
|
'top.tagline': 'Every AI coding account, side by side.',
|
|
6
6
|
'top.refresh': 'Refresh',
|
|
7
|
+
'top.repo': 'sideby on GitHub',
|
|
7
8
|
'top.loading': 'Loading…',
|
|
8
9
|
'top.refreshing': 'Refreshing…',
|
|
9
10
|
'top.updated': 'Read {ago} · refreshes every {s} s',
|
|
@@ -413,6 +414,7 @@ const en = {
|
|
|
413
414
|
'ai.examples': 'Things you can say (click to copy):',
|
|
414
415
|
'ai.copy': 'Copy',
|
|
415
416
|
'ai.ask.quota': 'Which of my Claude accounts has the most quota left?',
|
|
417
|
+
'ai.ask.pick': 'Add cc: start whichever Claude account has the most quota left.',
|
|
416
418
|
'ai.ask.new': 'Add another Claude account with the short command cc009.',
|
|
417
419
|
'ai.ask.pin': 'Pin claude:work to the top.',
|
|
418
420
|
'ai.ask.fix': 'Check my accounts and fix what they should share.',
|
|
@@ -510,6 +512,43 @@ const en = {
|
|
|
510
512
|
'ask.otherTool': 'Other tool…',
|
|
511
513
|
'ask.otherToolSub': 'Not in this list',
|
|
512
514
|
'ask.plugin': 'Let AI write a plugin',
|
|
515
|
+
'pk.title': 'Start the account with the most quota left',
|
|
516
|
+
'pk.intro': 'Set one short command per tool. Typing it starts the account with the most quota left. If no account has quota data yet, it starts your main account and tells you.',
|
|
517
|
+
'pk.none': 'Add a second account for a tool first. With only one account, there is nothing to choose between.',
|
|
518
|
+
'pk.noneYet': 'Not set',
|
|
519
|
+
'pk.exists': 'starts the {host} account with the most quota left.',
|
|
520
|
+
'pk.start': 'Start account with most quota:',
|
|
521
|
+
'pk.startTip': 'Type {name} in a terminal to start the {host} account with the most quota left',
|
|
522
|
+
'pk.remove': 'Remove',
|
|
523
|
+
'pk.removed': 'Removed {name}.',
|
|
524
|
+
'pk.nameLabel': 'Short command for {host}',
|
|
525
|
+
'pk.hint': 'Type this in a terminal to start the {host} account with the most quota left.',
|
|
526
|
+
'pk.shadows': '{name} is already a command on this computer ({path}). If you add it, typing {name} in your terminal will start {host} instead.',
|
|
527
|
+
'pk.add': 'Add',
|
|
528
|
+
'pk.addAnyway': 'Add anyway',
|
|
529
|
+
'pk.added': 'Added {name}. Open a new terminal window to use it.',
|
|
530
|
+
'pk.newShell': 'Changes take effect in new terminal windows.',
|
|
531
|
+
'pk.offerShort': 'Add {name}',
|
|
532
|
+
'pk.offerMore': ': start the account with the most quota left',
|
|
533
|
+
'pk.rename': 'Rename',
|
|
534
|
+
'pk.addedSetup': 'Added {name}. Turn on terminal setup above so new terminals can use it.',
|
|
535
|
+
'pk.renamedSetup': 'Renamed {old} to {name}. Turn on terminal setup above so new terminals can use it.',
|
|
536
|
+
'ss.title': 'New terminals can’t use your short commands yet.',
|
|
537
|
+
'ss.body': 'sideby can add this line to the end of {rc}:',
|
|
538
|
+
'ss.add': 'Add to {rc}',
|
|
539
|
+
'ss.adding': 'Adding…',
|
|
540
|
+
'ss.added': 'Added to {rc}. Open a new terminal window to use your short commands.',
|
|
541
|
+
'ss.undo': 'Undo',
|
|
542
|
+
'ss.removed': 'Removed sideby’s line from {rc}.',
|
|
543
|
+
'pk.save': 'Save',
|
|
544
|
+
'pk.renamed': 'Renamed {old} to {name}. Open a new terminal window to use it.',
|
|
545
|
+
'pk.fileFailed': 'Saved your setting, but couldn’t update the terminal command file: {msg}',
|
|
546
|
+
'pk.why.othersFull': 'no quota data yet, and the other accounts are full',
|
|
547
|
+
'pk.offerNoName': 'Add short command: start the account with the most quota left',
|
|
548
|
+
'pk.namePh': 'e.g. cc',
|
|
549
|
+
'pk.started': 'Opened {ref} in {terminal} ({why}).',
|
|
550
|
+
'pk.why.room': '{n}% used, most quota left',
|
|
551
|
+
'pk.why.noData': 'no quota data yet',
|
|
513
552
|
'login.opened': 'Opened {terminal}: sign in to {ref} there.',
|
|
514
553
|
'login.failed': 'Could not open a terminal. Copied: paste it into your terminal and press Return.',
|
|
515
554
|
'login.automation': 'Copied. To let sideby open {terminal}, turn it on in System Settings → Privacy & Security → Automation.',
|
|
@@ -959,6 +998,7 @@ const en = {
|
|
|
959
998
|
const zh = {
|
|
960
999
|
'top.tagline': '所有 AI 编程账号,并排运行。',
|
|
961
1000
|
'top.refresh': '刷新',
|
|
1001
|
+
'top.repo': 'sideby 的 GitHub 仓库',
|
|
962
1002
|
'top.loading': '加载中…',
|
|
963
1003
|
'top.refreshing': '刷新中…',
|
|
964
1004
|
'top.updated': '{ago}读取 · 每 {s} 秒自动刷新',
|
|
@@ -1368,6 +1408,7 @@ const zh = {
|
|
|
1368
1408
|
'ai.examples': '可以这样说(点一下复制):',
|
|
1369
1409
|
'ai.copy': '复制',
|
|
1370
1410
|
'ai.ask.quota': '我哪个 Claude 账号剩余额度最多?',
|
|
1411
|
+
'ai.ask.pick': '加个 cc:每次自动启动剩余额度最多的 Claude 账号。',
|
|
1371
1412
|
'ai.ask.new': '再加一个 Claude 账号,短命令叫 cc009。',
|
|
1372
1413
|
'ai.ask.pin': '把 claude:work 置顶。',
|
|
1373
1414
|
'ai.ask.fix': '检查一下我的账号,把该共享的修好。',
|
|
@@ -1465,6 +1506,43 @@ const zh = {
|
|
|
1465
1506
|
'ask.otherTool': '其他工具……',
|
|
1466
1507
|
'ask.otherToolSub': '列表里没有',
|
|
1467
1508
|
'ask.plugin': '让 AI 写插件',
|
|
1509
|
+
'pk.title': '自动启动剩余额度最多的账号',
|
|
1510
|
+
'pk.intro': '给每个工具设一个短命令,每次自动启动剩余额度最多的账号。如果暂时没有额度数据,就启动主账号并提醒你。',
|
|
1511
|
+
'pk.none': '请先给任意工具再加一个账号。只有一个账号时不用挑。',
|
|
1512
|
+
'pk.noneYet': '未设置',
|
|
1513
|
+
'pk.exists': '启动剩余额度最多的 {host} 账号。',
|
|
1514
|
+
'pk.start': '启动剩余额度最多的账号:',
|
|
1515
|
+
'pk.startTip': '在终端输入 {name},启动剩余额度最多的 {host} 账号',
|
|
1516
|
+
'pk.remove': '删除',
|
|
1517
|
+
'pk.removed': '已删除 {name}。',
|
|
1518
|
+
'pk.nameLabel': '{host} 的短命令',
|
|
1519
|
+
'pk.hint': '在终端输入这个命令,就会启动剩余额度最多的 {host} 账号。',
|
|
1520
|
+
'pk.shadows': '电脑上已经有 {name} 命令({path})。添加后,在终端输入 {name} 会改为启动 {host}。',
|
|
1521
|
+
'pk.add': '添加',
|
|
1522
|
+
'pk.addAnyway': '仍然添加',
|
|
1523
|
+
'pk.added': '已添加 {name},新开一个终端窗口就能用。',
|
|
1524
|
+
'pk.newShell': '新设的短命令在新开的终端窗口里生效。',
|
|
1525
|
+
'pk.offerShort': '添加 {name}',
|
|
1526
|
+
'pk.offerMore': ':自动启动剩余额度最多的账号',
|
|
1527
|
+
'pk.rename': '改名',
|
|
1528
|
+
'pk.addedSetup': '已添加 {name}。点击上方按钮写入终端配置,新开的终端就能直接用。',
|
|
1529
|
+
'pk.renamedSetup': '已将 {old} 改名为 {name}。点击上方按钮写入终端配置,新开的终端就能直接用。',
|
|
1530
|
+
'ss.title': '新开的终端还用不了短命令。',
|
|
1531
|
+
'ss.body': 'sideby 可以把下面这行加到 {rc} 末尾:',
|
|
1532
|
+
'ss.add': '写入 {rc}',
|
|
1533
|
+
'ss.adding': '正在写入…',
|
|
1534
|
+
'ss.added': '已写入 {rc},新开一个终端窗口就能用短命令。',
|
|
1535
|
+
'ss.undo': '撤销',
|
|
1536
|
+
'ss.removed': '已从 {rc} 移除了那行配置。',
|
|
1537
|
+
'pk.save': '保存',
|
|
1538
|
+
'pk.renamed': '已把 {old} 改为 {name},新开一个终端窗口就能用。',
|
|
1539
|
+
'pk.fileFailed': '设置已保存,但没能更新终端命令文件:{msg}',
|
|
1540
|
+
'pk.why.othersFull': '它还没有额度数据,其他有数据的账号都用完了',
|
|
1541
|
+
'pk.offerNoName': '添加短命令:自动启动剩余额度最多的账号',
|
|
1542
|
+
'pk.namePh': '例如 cc',
|
|
1543
|
+
'pk.started': '已在 {terminal} 启动 {ref}({why})。',
|
|
1544
|
+
'pk.why.room': '已用 {n}%,剩余额度最多',
|
|
1545
|
+
'pk.why.noData': '还没有额度数据',
|
|
1468
1546
|
'login.opened': '已打开 {terminal},请在那里登录 {ref}。',
|
|
1469
1547
|
'login.failed': '终端没打开,命令已复制:粘贴到你的终端,按回车。',
|
|
1470
1548
|
'login.automation': '命令已复制。要让 sideby 打开 {terminal},请在「系统设置 → 隐私与安全性 → 自动化」里打开它。',
|
|
@@ -907,6 +907,9 @@ const MAIN = String.raw `
|
|
|
907
907
|
for (const el of document.querySelectorAll('[data-i18n]')) el.textContent = t(el.getAttribute('data-i18n'))
|
|
908
908
|
$('refresh').setAttribute('aria-label', t('top.refresh'))
|
|
909
909
|
$('ask-ai').setAttribute('aria-label', t('ask.button'))
|
|
910
|
+
const repo = $('repo')
|
|
911
|
+
for (const k of ['aria-label', 'title']) repo.setAttribute(k, t('top.repo'))
|
|
912
|
+
if (/^https:\/\/github\.com\//.test(BOOT.repoUrl || '')) { repo.href = BOOT.repoUrl; repo.hidden = false }
|
|
910
913
|
renderSettingsButton()
|
|
911
914
|
}
|
|
912
915
|
function applyTheme() {
|
|
@@ -1832,7 +1835,8 @@ const MAIN = String.raw `
|
|
|
1832
1835
|
h('span', { class: 'muted small' }, t('quota.turnOnFamilyNote', { host: info.title })),
|
|
1833
1836
|
h('button', { class: 'btn btn-sm', type: 'button', title: setup.summary, 'aria-label': t('quota.turnOnFamilyLabel', { host: info.title }), onclick: () => openSetup(fam) }, t('quota.turnOnFamily')))
|
|
1834
1837
|
: null,
|
|
1835
|
-
off && setup && setup.plan.status === 'blocked' ? h('span', { class: 'muted small label-tip' }, t('quota.blocked'), tipRaw(t('quota.blocked'), setup.plan.message)) : null
|
|
1838
|
+
off && setup && setup.plan.status === 'blocked' ? h('span', { class: 'muted small label-tip' }, t('quota.blocked'), tipRaw(t('quota.blocked'), setup.plan.message)) : null,
|
|
1839
|
+
ui.arrange ? null : pickHead(fam)))
|
|
1836
1840
|
const body = collapsedNow ? null : cards
|
|
1837
1841
|
? h('div', { class: 'grid', id: bodyId, 'data-key': 'cards', 'data-patch': '' }, list.map((a) => card(a, now, cols)))
|
|
1838
1842
|
: h('div', { class: 'rows', id: bodyId, role: 'list', 'data-key': ui.arrange ? 'rows-arrange' : 'rows', 'data-patch': '' }, loginClusters(list).map((x) => Array.isArray(x) ? loginRow(x, now, cols) : row(x, now, cols)))
|
|
@@ -2867,6 +2871,7 @@ const MAIN = String.raw `
|
|
|
2867
2871
|
r.hookErrors.map((e) => h('span', { class: 'small' }, 'plugin ' + e.plugin + ': ' + e.message))) : null,
|
|
2868
2872
|
r.account.dir ? h('p', { class: 'small' }, h('span', { class: 'muted' }, t('nf.dir') + ' '), h('code', null, r.account.dir)) : null,
|
|
2869
2873
|
r.alias && r.alias.added ? h('div', { class: 'small created-alias' }, h('span', { class: 'muted' }, t('nf.alias') + ' '), codeCopy(r.alias.name), h('span', { class: 'muted' }, ' ' + t('nf.aliasNewShell'))) : null,
|
|
2874
|
+
r.alias && r.alias.added ? shellSetupNote() : null,
|
|
2870
2875
|
r.alias && !r.alias.added ? h('div', { class: 'note note-warn' }, h('b', null, t('nf.aliasNotAdded')), ' ', h('span', { class: 'small' }, r.alias.message || '')) : null,
|
|
2871
2876
|
(r.shellInitFiles || []).map((f) => f.ok
|
|
2872
2877
|
? h('p', { class: 'muted small' }, t(f.action === 'unchanged' ? 'nf.shellFileSame' : 'nf.shellFileUpdated', { file: f.path }))
|
|
@@ -3595,6 +3600,10 @@ const MAIN = String.raw `
|
|
|
3595
3600
|
h('button', { class: 'seg-btn', type: 'button', 'aria-pressed': String(v === c.on), onclick: () => { if (v !== c.on) { leave(false); setCheck(c.family, v) } } }, text)))))
|
|
3596
3601
|
}
|
|
3597
3602
|
}
|
|
3603
|
+
if (pickFamilies().length) {
|
|
3604
|
+
const names = Object.keys(S.state.pickCommands || {})
|
|
3605
|
+
acct.push(link(t('pk.title'), names.length ? names.join(', ') : t('pk.noneYet'), names.length ? 'chip-ok' : '', () => openPick(null), true))
|
|
3606
|
+
}
|
|
3598
3607
|
if (secs.includes('rc')) {
|
|
3599
3608
|
const sum = rcSummary()
|
|
3600
3609
|
acct.push(link(t('rc.button'), t('rc.state.' + sum), sum === 'on' ? 'chip-warn' : sum === 'off' ? 'chip-ok' : '', openRc, true))
|
|
@@ -3791,6 +3800,7 @@ const MAIN = String.raw `
|
|
|
3791
3800
|
else if (dlg.kind === 'key' && ky && ky.step !== 'enter') renderKey()
|
|
3792
3801
|
else if (dlg.kind === 'terminal' && tm) renderTerminals()
|
|
3793
3802
|
else if (dlg.kind === 'autostart') renderAutostart()
|
|
3803
|
+
else if (dlg.kind === 'pick' && pk) renderPick()
|
|
3794
3804
|
}
|
|
3795
3805
|
function setTheme(v) {
|
|
3796
3806
|
if (CFG) { cfgPanel.theme = v; saveCfg({ theme: v }) } else { prefs.theme = v; savePrefs() }
|
|
@@ -3803,7 +3813,7 @@ const MAIN = String.raw `
|
|
|
3803
3813
|
return Boolean(u && u.skillUpdate && u.skillUpdate.installed && u.skillUpdate.installed.length)
|
|
3804
3814
|
}
|
|
3805
3815
|
// Example phrases: a click puts one in the Let AI do it box (spec §3.28).
|
|
3806
|
-
const AI_ASKS = ['ai.ask.quota', 'ai.ask.new', 'ai.ask.api', 'ai.ask.pin', 'ai.ask.fix', 'ai.ask.handoff', 'ai.ask.menubar', 'ai.ask.rc', 'ai.ask.tool']
|
|
3816
|
+
const AI_ASKS = ['ai.ask.quota', 'ai.ask.pick', 'ai.ask.new', 'ai.ask.api', 'ai.ask.pin', 'ai.ask.fix', 'ai.ask.handoff', 'ai.ask.menubar', 'ai.ask.rc', 'ai.ask.tool']
|
|
3807
3817
|
function openRc() {
|
|
3808
3818
|
if (!S.state || !rcSummary()) return
|
|
3809
3819
|
rc.target = null
|
|
@@ -3843,7 +3853,7 @@ const MAIN = String.raw `
|
|
|
3843
3853
|
// One dialog for every "let AI do it" entry: what to do, then the account and the terminal it will use, then one
|
|
3844
3854
|
// button. When nothing can run it, or the panel is read-only, it copies the prompt instead.
|
|
3845
3855
|
let ak = null
|
|
3846
|
-
const TERM_NAMES = { terminal: 'Terminal', iterm2: 'iTerm2', ghostty: 'Ghostty', orca: 'Orca', wezterm: 'WezTerm', kitty: 'kitty', alacritty: 'Alacritty', custom: 'Custom' }
|
|
3856
|
+
const TERM_NAMES = { terminal: 'Terminal', iterm2: 'iTerm2', ghostty: 'Ghostty', orca: 'Orca', wezterm: 'WezTerm', kitty: 'kitty', alacritty: 'Alacritty', 'windows-terminal': 'Windows Terminal', custom: 'Custom' }
|
|
3847
3857
|
function termName(id) {
|
|
3848
3858
|
const list = ak && ak.terms ? ak.terms.terminals : []
|
|
3849
3859
|
const f = list.find((x) => x.id === id)
|
|
@@ -4364,6 +4374,177 @@ const MAIN = String.raw `
|
|
|
4364
4374
|
setKids(dlg.el, dialogFrame(t('term.title'), null, body, [h('button', { class: 'btn', type: 'button', onclick: () => dlg.el.close() }, t('btn.close'))]))
|
|
4365
4375
|
}
|
|
4366
4376
|
|
|
4377
|
+
// ---------- pick commands (spec §3.13, ADR-0035) ----------
|
|
4378
|
+
// A short command per tool that starts, each time, the account with the most quota left. The dialog lists every
|
|
4379
|
+
// tool that has one or could have one; adding shows what the name would hide in the shell before it writes.
|
|
4380
|
+
let pk = null
|
|
4381
|
+
function pickOf(fam) { const e = Object.entries(S.state.pickCommands || {}).find(([, f]) => f === fam); return e ? e[0] : null }
|
|
4382
|
+
function pickFamilies() { return S.state.families.map((f) => f.id).filter((id) => pickOf(id) || (S.state.pickOffers || {})[id]) }
|
|
4383
|
+
function openPick(fam) {
|
|
4384
|
+
closeMenu()
|
|
4385
|
+
pk = { focus: fam || null, busy: false, drafts: {}, confirm: {}, renaming: {}, error: null }
|
|
4386
|
+
showDialog('pick')
|
|
4387
|
+
renderPick()
|
|
4388
|
+
const input = fam && document.getElementById('pk-name-' + fam)
|
|
4389
|
+
if (input) input.focus()
|
|
4390
|
+
}
|
|
4391
|
+
async function startPick(name) {
|
|
4392
|
+
if (BOOT.readOnly) { copyText(name, name); return }
|
|
4393
|
+
try {
|
|
4394
|
+
const r = await api('/api/pick/start', { name })
|
|
4395
|
+
const why = r.reason === 'most-room' ? t('pk.why.room', { n: String(r.pressure) }) : t(r.reason === 'others-full' ? 'pk.why.othersFull' : 'pk.why.noData')
|
|
4396
|
+
if (r.opened) { toast(t('pk.started', { terminal: TERM_NAMES[r.terminal] || r.terminal, ref: r.picked, why })); return }
|
|
4397
|
+
await copyText(name, name)
|
|
4398
|
+
toast(r.automation ? t('login.automation', { terminal: TERM_NAMES[r.terminal] || r.terminal }) : t('login.failed'), { kind: 'info' })
|
|
4399
|
+
} catch (e) { toast(e.message, { kind: 'fail' }) }
|
|
4400
|
+
}
|
|
4401
|
+
// The dialog is the preview: a name that hides nothing is added at once; one that hides a command on PATH shows
|
|
4402
|
+
// that first and needs a second click. A rename adds the new name, then removes the old one.
|
|
4403
|
+
async function pickAdd(fam, name, shown, replaces) {
|
|
4404
|
+
pk.busy = true
|
|
4405
|
+
pk.error = null
|
|
4406
|
+
renderPick()
|
|
4407
|
+
try {
|
|
4408
|
+
let r = await api('/api/pick/add', { name, family: fam, confirm: Boolean(shown) })
|
|
4409
|
+
if (r.status === 'confirm' && !r.shadows) r = await api('/api/pick/add', { name, family: fam, confirm: true })
|
|
4410
|
+
if (r.status === 'confirm') pk.confirm[fam] = { name, shadows: r.shadows }
|
|
4411
|
+
else {
|
|
4412
|
+
const old = replaces && replaces !== name ? await api('/api/pick/remove', { name: replaces }) : null
|
|
4413
|
+
delete pk.renaming[fam]
|
|
4414
|
+
delete pk.drafts[fam]
|
|
4415
|
+
const later = S.state.shellSetup && !S.state.shellSetup.loaded
|
|
4416
|
+
pickToast([r, old], t((old ? 'pk.renamed' : 'pk.added') + (later ? 'Setup' : ''), { name, old: replaces }))
|
|
4417
|
+
await load({ silent: true })
|
|
4418
|
+
}
|
|
4419
|
+
} catch (e) { pk.error = e }
|
|
4420
|
+
if (!pk) return
|
|
4421
|
+
pk.busy = false
|
|
4422
|
+
if (dlg.kind === 'pick') renderPick()
|
|
4423
|
+
}
|
|
4424
|
+
async function pickRemove(name) {
|
|
4425
|
+
pk.busy = true
|
|
4426
|
+
pk.error = null
|
|
4427
|
+
renderPick()
|
|
4428
|
+
try {
|
|
4429
|
+
pickToast([await api('/api/pick/remove', { name })], t('pk.removed', { name }))
|
|
4430
|
+
await load({ silent: true })
|
|
4431
|
+
} catch (e) { pk.error = e }
|
|
4432
|
+
if (!pk) return
|
|
4433
|
+
pk.busy = false
|
|
4434
|
+
if (dlg.kind === 'pick') renderPick()
|
|
4435
|
+
}
|
|
4436
|
+
// The config is written first; a shell-init file sideby could not rewrite is said, not hidden behind "added".
|
|
4437
|
+
function pickToast(results, done) {
|
|
4438
|
+
const failed = results.filter(Boolean).flatMap((r) => (r.shellInitFiles || []).filter((f) => !f.ok).map((f) => f.message))
|
|
4439
|
+
if (failed.length) toast(t('pk.fileFailed', { msg: failed.join('; ') }), { kind: 'fail', duration: 12000 })
|
|
4440
|
+
else toast(done)
|
|
4441
|
+
}
|
|
4442
|
+
// A name field with what it would hide and its button; typing updates them in place, so the caret stays put.
|
|
4443
|
+
function nameEditor(fam, info, initial, replaces) {
|
|
4444
|
+
const id = 'pk-name-' + fam
|
|
4445
|
+
const input = h('input', { id, type: 'text', class: 'mono', autocomplete: 'off', autocapitalize: 'none', spellcheck: 'false', maxlength: '64', placeholder: t('pk.namePh'), disabled: pk.busy, 'aria-describedby': id + '-hint' })
|
|
4446
|
+
input.value = pk.drafts[fam] !== undefined ? pk.drafts[fam] : initial || ''
|
|
4447
|
+
const offer = (S.state.pickOffers || {})[fam]
|
|
4448
|
+
const note = h('p', { class: 'note' })
|
|
4449
|
+
const go = h('button', { class: 'btn btn-sm btn-primary', type: 'button' })
|
|
4450
|
+
const shadowsOf = (n) => {
|
|
4451
|
+
const asked = pk.confirm[fam]
|
|
4452
|
+
return asked && asked.name === n ? asked.shadows : offer && n && n === offer.name ? offer.shadows : null
|
|
4453
|
+
}
|
|
4454
|
+
const sync = () => {
|
|
4455
|
+
const n = input.value.trim()
|
|
4456
|
+
const shadows = shadowsOf(n)
|
|
4457
|
+
note.hidden = !shadows
|
|
4458
|
+
note.textContent = shadows ? t('pk.shadows', { name: n, path: shadows, host: info.title }) : ''
|
|
4459
|
+
go.textContent = t(shadows ? 'pk.addAnyway' : replaces ? 'pk.save' : 'pk.add')
|
|
4460
|
+
go.disabled = pk.busy || !n || n === replaces
|
|
4461
|
+
}
|
|
4462
|
+
const add = () => { const n = input.value.trim(); if (n && n !== replaces) pickAdd(fam, n, shadowsOf(n), replaces) }
|
|
4463
|
+
input.addEventListener('input', () => { pk.drafts[fam] = input.value; sync() })
|
|
4464
|
+
input.addEventListener('keydown', (e) => { if (e.key === 'Enter') { e.preventDefault(); add() } })
|
|
4465
|
+
go.addEventListener('click', add)
|
|
4466
|
+
sync()
|
|
4467
|
+
return [
|
|
4468
|
+
h('label', { class: 'field', for: id }, h('span', null, t('pk.nameLabel', { host: info.title })), input),
|
|
4469
|
+
h('p', { class: 'field-hint', id: id + '-hint' }, t('pk.hint', { host: info.title })),
|
|
4470
|
+
note,
|
|
4471
|
+
h('div', { class: 'actions' }, go,
|
|
4472
|
+
replaces ? h('button', { class: 'btn btn-sm btn-ghost', type: 'button', disabled: pk.busy, onclick: () => { delete pk.renaming[fam]; delete pk.drafts[fam]; renderPick() } }, t('btn.cancel')) : null),
|
|
4473
|
+
]
|
|
4474
|
+
}
|
|
4475
|
+
function renderPick() {
|
|
4476
|
+
if (!pk) return
|
|
4477
|
+
const body = [h('p', { class: 'muted small' }, t('pk.intro'))]
|
|
4478
|
+
const fams = pickFamilies()
|
|
4479
|
+
// Once a pick command exists, the line that makes terminals load it is the next step: first, not below the fold.
|
|
4480
|
+
const setupFirst = Object.keys(S.state.pickCommands || {}).length ? shellSetupNote() : null
|
|
4481
|
+
if (setupFirst) body.push(setupFirst)
|
|
4482
|
+
if (!fams.length) body.push(h('p', { class: 'note' }, t('pk.none')))
|
|
4483
|
+
for (const fam of fams) {
|
|
4484
|
+
const info = family(fam)
|
|
4485
|
+
const name = pickOf(fam)
|
|
4486
|
+
const head = h('div', { class: 'title-logo' }, badge(fam, 'sm'), h('b', null, info.title))
|
|
4487
|
+
if (name && pk.renaming[fam] && !BOOT.readOnly) {
|
|
4488
|
+
body.push(h('div', { class: 'pk-row' }, head, nameEditor(fam, info, name, name)))
|
|
4489
|
+
continue
|
|
4490
|
+
}
|
|
4491
|
+
if (name) {
|
|
4492
|
+
body.push(h('div', { class: 'pk-row' }, head,
|
|
4493
|
+
h('p', { class: 'small' }, h('code', { class: 'mono' }, name), ' ', t('pk.exists', { host: info.title })),
|
|
4494
|
+
h('div', { class: 'actions' },
|
|
4495
|
+
h('button', { class: 'btn btn-sm', type: 'button', disabled: pk.busy, onclick: () => startPick(name) }, icon('terminal'), pickStartLabel(), h('code', { class: 'mono' }, name)),
|
|
4496
|
+
BOOT.readOnly ? null : h('button', { class: 'btn btn-sm btn-ghost', type: 'button', disabled: pk.busy, onclick: () => { pk.renaming[fam] = true; renderPick(); const el = document.getElementById('pk-name-' + fam); if (el) el.focus() } }, t('pk.rename')),
|
|
4497
|
+
BOOT.readOnly ? null : h('button', { class: 'btn btn-sm btn-ghost', type: 'button', disabled: pk.busy, onclick: () => pickRemove(name) }, t('pk.remove')))))
|
|
4498
|
+
continue
|
|
4499
|
+
}
|
|
4500
|
+
if (BOOT.readOnly) continue
|
|
4501
|
+
body.push(h('div', { class: 'pk-row' }, head, nameEditor(fam, info, S.state.pickOffers[fam].name, null)))
|
|
4502
|
+
}
|
|
4503
|
+
if (fams.length && !setupFirst) body.push(shellSetupNote() || h('p', { class: 'muted small' }, t('pk.newShell')))
|
|
4504
|
+
if (pk.error) body.push(errorNote(pk.error, null))
|
|
4505
|
+
setKids(dlg.el, dialogFrame(t('pk.title'), null, body, [h('button', { class: 'btn', type: 'button', onclick: () => dlg.el.close() }, t('btn.close'))]))
|
|
4506
|
+
}
|
|
4507
|
+
// New terminals load short commands only through one line in the shell's rc file (ADR-0036). Where a short command
|
|
4508
|
+
// is added and that line is missing, say so and offer to add it: the line and the file shown are the preview.
|
|
4509
|
+
let ssBusy = false
|
|
4510
|
+
async function shellSetup(undo) {
|
|
4511
|
+
if (ssBusy) return
|
|
4512
|
+
ssBusy = true
|
|
4513
|
+
renderShellSetupHosts()
|
|
4514
|
+
try {
|
|
4515
|
+
const r = await api('/api/shell-init/setup', undo ? { undo: true } : {})
|
|
4516
|
+
if (r.status === 'added') toast(t('ss.added', { rc: r.rc }), { action: { label: t('ss.undo'), run: () => shellSetup(true) } })
|
|
4517
|
+
else if (r.status === 'removed') toast(t('ss.removed', { rc: r.rc }))
|
|
4518
|
+
await load({ silent: true })
|
|
4519
|
+
} catch (e) { toast(e.message, { kind: 'fail' }) }
|
|
4520
|
+
ssBusy = false
|
|
4521
|
+
renderShellSetupHosts()
|
|
4522
|
+
}
|
|
4523
|
+
function renderShellSetupHosts() {
|
|
4524
|
+
if (dlg.kind === 'pick' && pk) renderPick()
|
|
4525
|
+
else if (dlg.kind === 'create' && nf && nf.result) renderCreate()
|
|
4526
|
+
}
|
|
4527
|
+
function shellSetupNote() {
|
|
4528
|
+
const ss = S.state.shellSetup
|
|
4529
|
+
if (!ss || ss.loaded || BOOT.readOnly) return null
|
|
4530
|
+
const line = ss.block.split('\n').find((l) => l.startsWith('eval '))
|
|
4531
|
+
return h('div', { class: 'note note-warn ss-note', role: 'status' },
|
|
4532
|
+
h('div', { class: 'note-line' }, h('b', null, t('ss.title')), ' ', t('ss.body', { rc: ss.rc })),
|
|
4533
|
+
h('code', { class: 'mono note-line' }, line),
|
|
4534
|
+
h('button', { class: 'btn btn-sm btn-primary', type: 'button', disabled: ssBusy, onclick: () => shellSetup(false) }, ssBusy ? t('ss.adding') : t('ss.add', { rc: ss.rc })))
|
|
4535
|
+
}
|
|
4536
|
+
// The label ends in a colon and the command name follows: a space after an English colon, none after a Chinese one.
|
|
4537
|
+
function pickStartLabel() { const l = t('pk.start'); return /[::]$/.test(l) && lang !== 'zh' ? l + ' ' : l }
|
|
4538
|
+
// In a tool's group head: the button that starts the account with the most room, or the offer to add one.
|
|
4539
|
+
function pickHead(fam) {
|
|
4540
|
+
const name = pickOf(fam)
|
|
4541
|
+
// On a narrow screen only the icon and the name stay; the words are in the hover text and the label.
|
|
4542
|
+
if (name) return h('button', { class: 'btn btn-sm', type: 'button', title: t('pk.startTip', { name, host: family(fam).title }), 'aria-label': t('pk.startTip', { name, host: family(fam).title }), onclick: () => startPick(name) }, icon('terminal'), h('span', { class: 'hide-sm' }, pickStartLabel()), h('code', { class: 'mono' }, name))
|
|
4543
|
+
const offer = (S.state.pickOffers || {})[fam]
|
|
4544
|
+
if (!offer || BOOT.readOnly) return null
|
|
4545
|
+
return h('button', { class: 'link-btn small', type: 'button', onclick: () => openPick(fam) }, offer.name ? [t('pk.offerShort', { name: offer.name }), h('span', { class: 'hide-sm' }, t('pk.offerMore'))] : t('pk.offerNoName'))
|
|
4546
|
+
}
|
|
4547
|
+
|
|
4367
4548
|
// ---------- banners ----------
|
|
4368
4549
|
// Offered once on macOS (spec §3.31), when quota shows and the menu bar item is off; "No thanks" is for good.
|
|
4369
4550
|
function menubarHint() {
|
|
@@ -139,6 +139,8 @@ code, .mono { font-family: var(--mono); font-size: 0.92em; }
|
|
|
139
139
|
.pages { margin: 0 0 14px; }
|
|
140
140
|
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
|
|
141
141
|
.tune-confirm { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--border); padding-top: 10px; }
|
|
142
|
+
.pk-row { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border-top: 1px solid var(--border); }
|
|
143
|
+
.pk-row p { margin: 0; }
|
|
142
144
|
.tune-confirm ul { margin: 0; padding-left: 18px; }
|
|
143
145
|
.tune-undo { margin: 0; }
|
|
144
146
|
.tune-details { margin-top: 4px; }
|
|
@@ -446,6 +448,7 @@ a.btn:hover { text-decoration: none; }
|
|
|
446
448
|
.icon-btn:disabled { color: var(--faint); cursor: not-allowed; }
|
|
447
449
|
.top-actions .icon-btn { width: var(--ctl-h); height: var(--ctl-h); border-color: var(--border-strong); background: var(--surface); }
|
|
448
450
|
.top-actions .icon-btn:hover { background: var(--hover); }
|
|
451
|
+
.repo-link svg { width: 17px; height: 17px; fill: currentColor; }
|
|
449
452
|
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, .stat-btn:focus-visible { outline: var(--focus-outline); outline-offset: 2px; box-shadow: var(--focus-ring); }
|
|
450
453
|
.btn:focus-visible { border-color: var(--focus); }
|
|
451
454
|
.note a, .banner a { color: inherit; text-decoration: underline; text-underline-offset: 2px; font-weight: var(--strong-weight); }
|