paseo-plugin-account-switcher 0.10.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/OVERVIEW.md CHANGED
@@ -5,7 +5,8 @@ Limits cover every window the provider reports, such as 5-hour and weekly use, w
5
5
  ## How it works
6
6
 
7
7
  - Each account you add gets its own credential profile. Settings, skills, and session history stay shared with your existing CLI setup, so a profile is not a sandbox.
8
- - **Enable** in Accounts points Paseo's Claude and Codex commands at the plugin's launchers, which start the official CLI under the agent's account. **Disable** restores the original commands; use it before removing the plugin.
8
+ - Turn on **Account switching** in Accounts to point Paseo's Claude and Codex commands at the plugin's launchers, which start the official CLI under the agent's account. Turning it off restores the original commands; do this before removing the plugin.
9
+ - Open **Manage** to check sign-in, refresh limits, rename an added account, or make it the default. Each added account has a visible **Remove** button with confirmation and an explanation of any blockers. **Current CLI** entries use the host's own sign-in and cannot be removed here.
9
10
  - A new agent starts on its provider's default account. When the latest readings show the default has used up an account-wide limit that resets later, Codex reports that ordinary usage is not allowed, its plan lacks the Codex model chosen for the agent, or the default needs sign-in, the agent starts on the signed-in account with the largest percentage left instead. Limits of a single model and extra paid usage do not count. With every account ruled out, it stays on the default. **Always use the default** under a provider in Accounts turns this off, so the default stays binding.
10
11
  - A tool that creates agents can name the account to start on: an agent created with `PASEO_ACCOUNT_SWITCHER_ACCOUNT` in its environment, set to an account's name or ID, starts on that account whatever its limits. It is not created when that account cannot be used, or when **Always use the default** is on and that account is not the default.
11
12
  - `/account name` in the message field switches the chat's account, or `/account default` its provider's default: at once when the agent is idle, otherwise in the switcher for **Apply**. The Command Center offers **Make “name” the default** for each signed-in account.
@@ -36,6 +37,7 @@ Limits cover every window the provider reports, such as 5-hour and weekly use, w
36
37
  - Paseo's Usage view can show one managed account twice: after you open the usage details of an agent on that account, Paseo's own Claude or Codex card for the login can appear next to the Account Switcher card. The plugin cannot merge cards of different sources.
37
38
  - Plans differ in the models they offer: after a switch to a plan without the agent's model, its next message fails. For Codex, the switcher compares the agent's model with the models the account's plan offers and warns before **Apply**. Claude does not report its models, so there is no such check for Claude.
38
39
  - Codex's **In browser** sign-in must finish on the daemon's computer. From another device, use **Device code**.
40
+ - Claude credentials in an inaccessible macOS Keychain show as **sign-in unavailable**. Unlock Keychain in the daemon's session, then check sign-in again. A daemon started from SSH may not share the desktop's access. If the official CLI cannot renew an expired token, sign in again.
39
41
  - Providers can change their limit formats. Values the plugin cannot read show as no data.
40
42
 
41
43
  ## Other plugins by dutchakdev
package/OVERVIEW.zh-CN.md CHANGED
@@ -7,7 +7,8 @@ Account Switcher 让你在 Paseo 中使用多个 Claude 和 ChatGPT/Codex 订阅
7
7
  ## 工作原理
8
8
 
9
9
  - 你添加的每个账号都有独立的凭据配置文件。设置、技能和会话历史仍与现有 CLI 配置共享,因此配置文件并不是沙箱。
10
- - 在 Accounts 中选择 **Enable**,会让 Paseo 的 Claude 和 Codex 命令指向插件的启动器,启动器以智能体所选账号运行官方 CLI。**Disable** 会恢复原始命令;移除插件前请先执行它。
10
+ - 在 Accounts 中开启 **Account switching**,会让 Paseo 的 Claude 和 Codex 命令指向插件的启动器,启动器以智能体所选账号运行官方 CLI。关闭该开关会恢复原始命令;移除插件前请先关闭它。
11
+ - 打开 **Manage** 可检查登录、刷新限制、重命名添加的账号或将其设为默认账号。每个添加的账号都有可见的 **Remove** 按钮,确认窗口会说明阻止移除的原因。**Current CLI** 条目使用主机自身的登录,无法在这里移除。
11
12
  - 新智能体会使用其提供商的默认账号。如果最近读取的数据显示:默认账号已用尽某个账号级限制且重置时间尚未到来、Codex 报告不允许常规使用、其套餐不提供为该智能体选择的 Codex 模型,或默认账号需要重新登录,智能体会改用剩余百分比最多的已登录账号。单个模型的限制和额外付费用量不计入。所有账号都被排除时,仍使用默认账号。在 Accounts 中该提供商下选择 **Always use the default** 可关闭此行为,使默认账号始终生效。
12
13
  - 创建智能体的工具可以指定起始账号:创建时在智能体环境中设置 `PASEO_ACCOUNT_SWITCHER_ACCOUNT` 为账号名称或 ID,智能体就会在该账号上启动,不受限制影响。该账号无法使用,或已选择 **Always use the default** 而该账号不是默认账号时,不会创建智能体。
13
14
  - 在输入框中输入 `/account 名称` 可切换当前对话的账号,`/account default` 切换到提供商的默认账号:智能体空闲时立即生效,否则在切换器中通过 **Apply** 应用。命令中心(⌘K)为每个已登录账号提供 **Make “名称” the default**。
@@ -38,6 +39,7 @@ Account Switcher 让你在 Paseo 中使用多个 Claude 和 ChatGPT/Codex 订阅
38
39
  - Paseo 的 Usage 视图可能会把同一个托管账号显示两次:在你打开使用该账号的智能体的用量详情后,Paseo 自带的 Claude 或 Codex 卡片可能会出现在 Account Switcher 卡片旁边。插件无法合并不同来源的卡片。
39
40
  - 不同套餐提供的模型不同:切换到不提供该智能体模型的套餐后,下一条消息会失败。对于 Codex,切换器会将智能体的模型与该账号套餐提供的模型进行比较,并在 **Apply** 前给出提示。Claude 不报告其模型,因此 Claude 没有此项检查。
40
41
  - Codex 的 **In browser** 登录必须在守护进程所在的电脑上完成。在其他设备上请使用 **Device code**。
42
+ - macOS 钥匙串不可访问时,Claude 账号会显示 **sign-in unavailable**。请在守护进程所在会话中解锁钥匙串,然后重新检查登录。通过 SSH 启动的守护进程可能无法共享桌面的访问权限。若官方 CLI 无法续期过期令牌,请重新登录。
41
43
  - 提供商可能更改限制格式。插件无法读取的值显示为无数据。
42
44
 
43
45
  ## dutchakdev 的其他插件
package/README.md CHANGED
@@ -58,11 +58,11 @@ To review or change the source first, install a [local checkout](docs/installati
58
58
  1. In Paseo, turn on **Settings → Plugins → Enable plugins**.
59
59
  2. Check that `paseo plugin ls account-switcher` shows **running**, then open **Accounts** in the sidebar or **Accounts and limits** in the Command Center. An app without Paseo's current screen API shows the same Accounts through the older surface API.
60
60
  3. Accounts lists the sign-ins your daemon already uses as **Current CLI · Claude** and **Current CLI · Codex**. A provider without its CLI has no Current CLI entry.
61
- 4. Select **Enable** in Accounts. This is separate from Paseo's plugin switch: the plugin saves your original Claude and Codex commands and points Paseo at its launchers. It leaves running chats alone, and **Disable** restores the original commands.
61
+ 4. Turn on **Account switching** in Accounts. This is separate from Paseo's plugin switch: the plugin saves your original Claude and Codex commands and points Paseo at its launchers. It leaves running chats alone, and turning it off restores the original commands.
62
62
 
63
63
  ## Add an account
64
64
 
65
- Select **Add**, choose a provider, name the account, and select **Add and sign in**. The official CLI runs in the background; the plugin opens a sign-in dialog without creating a terminal or workspace.
65
+ Select **Add account**, choose a provider, name the account, and select **Add and sign in**. The official CLI runs in the background; the plugin opens a sign-in dialog without creating a terminal or workspace.
66
66
 
67
67
  | Where you use Paseo | How to open sign-in |
68
68
  | --- | --- |
@@ -75,13 +75,13 @@ If clipboard access is unavailable, expand **Show sign-in link** and copy its se
75
75
  - **Codex, Device code:** enter the displayed code on the provider's page. Use it from a phone or another computer.
76
76
  - **Codex, In browser:** finish in a browser on the **daemon's computer**, because the callback uses localhost. From another device, cancel and choose **Device code**.
77
77
 
78
- After sign-in, the plugin verifies the account and refreshes its limits. To check again, use **Check sign-in** in the account's **⋯** menu. Enter passwords only on the provider's official page.
78
+ After sign-in, the plugin verifies the account and refreshes its limits. To check again, open **Manage → Sign-in → Check**. An unverified account also has a visible **Check sign-in** button. Enter passwords only on the provider's official page.
79
79
 
80
80
  Closing the dialog leaves **Continue sign-in** on the account. **Cancel sign-in** stops the process before releasing the profile. While sign-in is active, the account cannot be applied, made the default, or deleted. A failed start leaves the account available for **Retry sign-in** without creating a duplicate. Plugin reloads stop pending sign-ins; start again afterward.
81
81
 
82
82
  ### Manage accounts
83
83
 
84
- The **⋯** menu contains refresh, check sign-in, default, sign-in, rename, and remove actions. Account rows show identity, default status, and counts of current and pending agents.
84
+ Open **Manage** for sign-in, limits, default, and rename actions. Each added account has a visible **Remove** button. Its confirmation explains any blockers and offers **Clear default** when needed. The host’s **Current CLI** entries explain why they cannot be removed. Account rows show identity, default status, and counts of current and pending agents.
85
85
 
86
86
  ### Default for new agents
87
87
 
@@ -110,6 +110,15 @@ paseo run --provider codex --env PASEO_ACCOUNT_SWITCHER_ACCOUNT=Work "Review the
110
110
 
111
111
  The named account is binding: the agent starts there or is not created, and the error says why. Limits do not move it to another account. A name must belong to exactly one account of the agent's provider; use the ID when two accounts share a name. Creation is refused when no such account exists, its sign-in is still in progress, the official sign-in check does not confirm it, **Always use the default** is on and the account is not the default, account switching is off for the provider, or the agent's provider is not Claude or Codex. The variable works only at creation: it reaches neither the provider CLI nor later sessions of the agent, and set in a provider's configured environment it selects nothing. The chat records the start when the account is not the default. Afterwards the agent behaves like any other: switching, and switching when a limit runs out, follow your settings.
112
112
 
113
+ On Paseo 0.16 and later, name the account when importing a provider session into Paseo for the first time:
114
+
115
+ ```sh
116
+ paseo import <session-id> --provider claude --label 'account-switcher.account=Work'
117
+ ```
118
+
119
+ The named account must be signed in and allowed by the provider's account switching settings. Paseo refuses the import if the plugin cannot select it. The label applies to the first import. Restoring an archived Paseo agent keeps its existing account.
120
+
121
+
113
122
  ## Switch an existing chat
114
123
 
115
124
  1. Select the account chip beside the message field to open **Account** over the current chat.
@@ -152,7 +161,7 @@ When a Claude or Codex turn ends because its account's limit is used up, the plu
152
161
  - With another account available: *Work's limit is used up until 18:00.* and a button **Switch to Second and continue**. The time is the latest reset among the used-up windows, in your local time zone; without a reset time from the provider, the sentence ends at *used up*.
153
162
  - Without one: *Work's limit is used up until 18:00. No other account has room.*
154
163
 
155
- The offered account is the one a new agent would try instead: a signed-in account of the same provider, not in the middle of a sign-in, not used up, and for Codex with a plan that offers the agent's model. If several qualify, the one with the most room is offered. Agents on **Current CLI** are included. An agent started while no Paseo app was open, by a schedule or `paseo run`, is included too: the plugin confirms its account from the launcher's startup receipt first. An agent whose account nothing confirms gets no row. Nothing is offered while account switching is off for that provider (**Enable** in Accounts).
164
+ The offered account is the one a new agent would try instead: a signed-in account of the same provider, not in the middle of a sign-in, not used up, and for Codex with a plan that offers the agent's model. If several qualify, the one with the most room is offered. Agents on **Current CLI** are included. An agent started while no Paseo app was open, by a schedule or `paseo run`, is included too: the plugin confirms its account from the launcher's startup receipt first. An agent whose account nothing confirms gets no row. Nothing is offered while account switching is off for that provider (**Account switching** in Accounts).
156
165
 
157
166
  The button switches the chat through the same checks as **Apply** and `/account` (the agent is idle, no permission request is pending, the new account is confirmed at startup), then sends the agent **Continue.** The row follows: *Switching from Work to Second…*, then *Switched from Work to Second.* If the switch is refused or fails, the row says *Could not switch to Second* with the reason:
158
167
 
@@ -188,7 +197,7 @@ The plugin also reports to Paseo's own Usage view, as the source **Account Switc
188
197
 
189
198
  Plugin directory, npm, and Git installations update with `paseo plugin update account-switcher`, which shows the new revision and asks for approval.
190
199
 
191
- Before disabling or removing the plugin, select **Disable** in Accounts to restore the original provider commands. Removal does not delete the separately stored account data. See [update and removal](docs/installation.md#update) for a local checkout, the full steps, and recovery.
200
+ Before disabling or removing the plugin, turn off **Account switching** in Accounts to restore the original provider commands. Removal does not delete the separately stored account data. See [update and removal](docs/installation.md#update) for a local checkout, the full steps, and recovery.
192
201
 
193
202
  ## Scope
194
203
 
@@ -0,0 +1,125 @@
1
+ import { useRpc } from "@getpaseo/plugin/client";
2
+ import { Modal } from "@getpaseo/plugin/client/react-native";
3
+ import { SettingsAction, SettingsCard, SettingsSwitch } from "@getpaseo/plugin/client/ui";
4
+ import { useEffect, useState } from "react";
5
+ import { Text, View } from "react-native";
6
+ import { cancelLogin, checkLogin, refreshUsage, removeAccount, renameAccount, setDefaultAccount, startLogin,
7
+ type Account, type AccountState, type LoginSession, type UsageSnapshot } from "../shared/contracts";
8
+ import type { AccountsProps } from "./accounts";
9
+ import { accountRemovalBlockers, signInFeedback } from "./account-state";
10
+ import { body, Button, Field, heading, muted, Notice, QuotaSummary, row, StatusDot, toneColor } from "./components";
11
+ import { useAction } from "./data";
12
+ import { accountStatus, errorMessage } from "./format";
13
+ import { accountAvailable, type LoginMode } from "./login";
14
+
15
+ export type SignInActions = { onStarted(account: Account, session: LoginSession): void; onResume(account: Account, sessionId: string): void };
16
+
17
+ export function AccountCard({ account, state, snapshot, checksOff, now, theme, layout, host, onChanged, onStarted, onResume }: AccountsProps & SignInActions & {
18
+ account: Account; state: AccountState; snapshot: UsageSnapshot | undefined; checksOff: boolean; now: number;
19
+ }) {
20
+ const rename = useRpc(renameAccount);
21
+ const remove = useRpc(removeAccount);
22
+ const setDefault = useRpc(setDefaultAccount);
23
+ const login = useRpc(startLogin);
24
+ const cancel = useRpc(cancelLogin);
25
+ const check = useRpc(checkLogin);
26
+ const refresh = useRpc(refreshUsage);
27
+ const action = useAction(host.id, onChanged);
28
+ const [panel, setPanel] = useState<"none" | "manage" | "rename" | "remove">("none");
29
+ const [label, setLabel] = useState(account.label);
30
+ const [notice, setNotice] = useState<ReturnType<typeof signInFeedback> | null>(null);
31
+ useEffect(() => setNotice(null), [account.authStatus]);
32
+ const isDefault = state.defaults[account.provider] === account.id;
33
+ const inUse = state.bindings.filter(binding => binding.currentAccountId === account.id).length;
34
+ const pending = state.bindings.filter(binding => binding.pendingAccountId === account.id).length;
35
+ const managed = account.source === "managed";
36
+ const loginSession = account.login;
37
+ const status = accountStatus(account, snapshot);
38
+ const busy = action.isPending;
39
+ const needsLogin = managed && !loginSession && (account.authStatus === "needs_auth" || snapshot?.status === "needs_auth");
40
+ const blockers = accountRemovalBlockers(account, state);
41
+ const beginLogin = (mode?: LoginMode) => action.run(async () => {
42
+ setNotice(null);
43
+ const result = await login({ accountId: account.id, ...(mode ? { mode } : {}) });
44
+ setPanel("none");
45
+ onStarted(account, result);
46
+ });
47
+ const checkSignIn = () => action.run(async () => {
48
+ setNotice(null);
49
+ setNotice(signInFeedback(await check({ accountId: account.id })));
50
+ });
51
+ const changeDefault = (value: boolean) => action.run(() => setDefault({ provider: account.provider, accountId: value ? account.id : null }));
52
+ const saveName = () => {
53
+ if (busy || !label.trim()) return;
54
+ action.run(async () => { await rename({ accountId: account.id, label: label.trim() }); setPanel("none"); });
55
+ };
56
+ const loginButtons = () => account.provider === "codex" ? <>
57
+ <Button theme={theme} variant="primary" disabled={busy} onPress={() => beginLogin("device")}>Sign in with code</Button>
58
+ <Button theme={theme} disabled={busy} onPress={() => beginLogin("browser")}>Use browser</Button>
59
+ </> : <Button theme={theme} variant="primary" disabled={busy} onPress={() => beginLogin()}>Sign in</Button>;
60
+ const meta = [account.email, !managed ? "Host CLI" : null, inUse ? `${inUse} agent${inUse === 1 ? "" : "s"}` : null, pending ? `${pending} pending` : null].filter(Boolean).join(" · ");
61
+ const recovery = !loginSession && account.authStatus !== "ready" && (!snapshot?.error || snapshot.status === "needs_auth") ? signInFeedback(account) : null;
62
+ const visibleNotice = notice?.tone === "success" || !snapshot?.error || snapshot.status === "needs_auth" ? notice || recovery : null;
63
+ return <SettingsCard><View accessibilityLabel={`Account ${account.label}`} style={{ padding: layout.compact ? 12 : 16, gap: 10, minWidth: 0 }}>
64
+ <View style={{ flexDirection: "row", alignItems: "flex-start", gap: 8, flexWrap: "wrap" }}>
65
+ <View style={{ flex: 1, minWidth: 160, gap: 4 }}>
66
+ <View style={row}>
67
+ <Text selectable numberOfLines={1} style={{ ...heading(theme), flexShrink: 1 }}>{account.label}</Text>
68
+ {isDefault ? <Text style={{ ...muted(theme), paddingHorizontal: 6, borderRadius: 4, backgroundColor: theme.colors.surface2 }}>Default</Text> : null}
69
+ </View>
70
+ <View style={{ ...row, gap: 6 }}>
71
+ <StatusDot theme={theme} tone={status.tone} />
72
+ <Text style={{ ...muted(theme), color: status.tone === "muted" || status.tone === "success" ? theme.colors.foregroundMuted : toneColor(theme, status.tone) }}>{status.text}</Text>
73
+ </View>
74
+ {meta ? <Text selectable style={muted(theme)}>{meta}</Text> : null}
75
+ </View>
76
+ <View style={{ ...row, gap: 4 }}>
77
+ <Button theme={theme} variant="ghost" onPress={() => { setNotice(null); setPanel("manage"); }} label={`Manage ${account.label}`}>Manage</Button>
78
+ {managed ? <Button theme={theme} variant="danger" disabled={busy} onPress={() => { setNotice(null); setPanel("remove"); }} label={`Remove ${account.label}`}>Remove</Button> : null}
79
+ </View>
80
+ </View>
81
+ {loginSession ? <View style={{ gap: 6 }}>
82
+ <Notice theme={theme} tone="warning">{"sessionId" in loginSession ? "Sign-in is open. Continue to finish, or cancel to start again." : "Cancel the previous terminal sign-in before starting again."}</Notice>
83
+ <View style={row}>
84
+ {"sessionId" in loginSession ? <Button theme={theme} variant="primary" disabled={busy} onPress={() => onResume(account, loginSession.sessionId)}>Continue sign-in</Button> : null}
85
+ <Button theme={theme} disabled={busy} onPress={() => action.run(async () => {
86
+ await cancel({ accountId: account.id, ...("sessionId" in loginSession ? { sessionId: loginSession.sessionId } : {}) });
87
+ setNotice({ text: "Sign-in canceled.", tone: "muted" });
88
+ })}>Cancel sign-in</Button>
89
+ </View>
90
+ </View> : needsLogin ? <View style={row}>{loginButtons()}</View>
91
+ : account.authStatus !== "ready" ? <View style={row}><Button theme={theme} disabled={busy} onPress={checkSignIn}>{busy ? "Checking…" : "Check sign-in"}</Button></View> : null}
92
+ {panel === "none" && visibleNotice ? <Notice theme={theme} tone={visibleNotice.tone}>{visibleNotice.text}</Notice> : null}
93
+ {panel === "none" && action.error ? <Notice theme={theme} tone="danger">{errorMessage(action.error)}</Notice> : null}
94
+ <QuotaSummary theme={theme} snapshot={snapshot} now={now} compact={layout.compact} hideAuth={Boolean(needsLogin || recovery || notice)}
95
+ onRefresh={loginSession || checksOff ? undefined : () => action.run(() => refresh({ accountId: account.id }))} refreshing={busy} />
96
+ {panel !== "none" ? <Modal title={panel === "remove" ? `Remove “${account.label}”?` : panel === "rename" ? "Rename account" : account.label} open onOpenChange={open => { if (!open) setPanel("none"); }}>
97
+ <Modal.Content>
98
+ {panel === "manage" ? <>
99
+ <SettingsCard>
100
+ <SettingsSwitch label="Default for new agents" hint="Existing chats keep their account." value={isDefault} disabled={busy || (!isDefault && !accountAvailable(account))} onValueChange={changeDefault} />
101
+ <SettingsAction label="Sign-in" actionLabel={busy ? "Checking…" : "Check"} disabled={busy || Boolean(loginSession)} onPress={checkSignIn} />
102
+ <SettingsAction label="Limits" actionLabel="Refresh" disabled={busy || checksOff || Boolean(loginSession)} onPress={() => action.run(() => refresh({ accountId: account.id }))} />
103
+ {managed ? <SettingsAction label="Account name" actionLabel="Rename" disabled={busy} onPress={() => { setLabel(account.label); setNotice(null); setPanel("rename"); }} /> : null}
104
+ </SettingsCard>
105
+ {managed && !loginSession && !needsLogin ? <View style={{ gap: 6 }}><Text style={muted(theme)}>Sign in again</Text><View style={row}>{loginButtons()}</View></View> : null}
106
+ {!managed ? <Text style={muted(theme)}>Uses this host’s CLI sign-in. Manage it in the CLI; it cannot be removed here.</Text> : null}
107
+ {managed ? <Button theme={theme} variant="danger" disabled={busy} onPress={() => { setNotice(null); setPanel("remove"); }}>Remove account</Button> : null}
108
+ </> : panel === "rename" ? <View style={{ gap: 12 }}>
109
+ <Field theme={theme} value={label} onChangeText={setLabel} maxLength={80} accessibilityLabel={`New name for ${account.label}`} placeholder="Account name" autoCapitalize="sentences" autoFocus onSubmitEditing={saveName} />
110
+ <View style={row}><Button theme={theme} variant="primary" disabled={busy || !label.trim()} onPress={saveName}>Save</Button><Button theme={theme} variant="ghost" disabled={busy} onPress={() => setPanel("manage")}>Cancel</Button></View>
111
+ </View> : <>
112
+ <Text style={body(theme)}>This removes the saved sign-in from Paseo. You can add the account again later.</Text>
113
+ {blockers.map(message => <Notice key={message} theme={theme} tone="warning">{message}</Notice>)}
114
+ {isDefault ? <Button theme={theme} disabled={busy} onPress={() => changeDefault(false)}>Clear default</Button> : null}
115
+ <View style={row}>
116
+ <Button theme={theme} variant="danger" disabled={busy || blockers.length > 0} onPress={() => action.run(() => remove({ accountId: account.id }))}>{busy ? "Removing…" : "Remove account"}</Button>
117
+ <Button theme={theme} variant="ghost" disabled={busy} onPress={() => setPanel("none")}>Cancel</Button>
118
+ </View>
119
+ </>}
120
+ {notice ? <Notice theme={theme} tone={notice.tone}>{notice.text}</Notice> : null}
121
+ {action.error ? <Notice theme={theme} tone="danger">{errorMessage(action.error)}</Notice> : null}
122
+ </Modal.Content>
123
+ </Modal> : null}
124
+ </View></SettingsCard>;
125
+ }
@@ -0,0 +1,25 @@
1
+ import type { Account, AccountState } from "../shared/contracts";
2
+ import type { Tone } from "./format";
3
+
4
+ /** A negative CLI probe is not evidence that a browser sign-in is still open. */
5
+ export function signInFeedback(account: Account): { text: string; tone: Tone } {
6
+ if (account.authStatus === "ready") return { text: "Sign-in confirmed.", tone: "success" };
7
+ if (account.authStatus === "error") return { text: account.provider === "claude"
8
+ ? "Cannot check sign-in. Check credential access and, on macOS, unlock Keychain and allow Claude Code access. Then try again."
9
+ : "Cannot check sign-in. Check this host’s Codex credentials, then try again.", tone: "warning" };
10
+ if (account.authStatus === "unknown") return { text: "Sign-in could not be confirmed. Check this host’s CLI configuration, then try again.", tone: "warning" };
11
+ return { text: account.source === "system"
12
+ ? `Sign in with ${account.provider === "claude" ? "claude auth login" : "codex login"} on this host, then check again.`
13
+ : "Sign in to this account to use it in agents.", tone: "warning" };
14
+ }
15
+
16
+ export function accountRemovalBlockers(account: Account, state: AccountState): string[] {
17
+ const blockers: string[] = [];
18
+ if (account.source === "system") blockers.push("This is the host’s CLI sign-in. Manage it in the CLI; it cannot be removed here.");
19
+ if (account.login) blockers.push("Finish or cancel sign-in first.");
20
+ if (state.defaults[account.provider] === account.id) blockers.push("Clear this account’s default first.");
21
+ if (state.bindings.some(binding => binding.currentAccountId === account.id || binding.pendingAccountId === account.id)) {
22
+ blockers.push("Switch agents to another account and clear pending selections first. Include archived agents you may resume.");
23
+ }
24
+ return blockers;
25
+ }
@@ -1,17 +1,18 @@
1
1
  import { useRpc, type PluginSurfaceProps } from "@getpaseo/plugin/client";
2
2
  import { useState } from "react";
3
+ import { SettingsCard, SettingsSection, SettingsSelect, SettingsSwitch } from "@getpaseo/plugin/client/ui";
4
+ import { AccountCard, type SignInActions } from "./account-card";
3
5
  import { ScrollView, Text, View } from "react-native";
4
- import { addAccount, cancelLogin, checkLogin, cliName, missingCli, refreshUsage, removeAccount, renameAccount, setAutoFailover, setDefaultAccount, setFallback, setIntegration, startLogin,
5
- type Account, type AccountState, type LoginSession, type Provider, type UsageSnapshot } from "../shared/contracts";
6
- import { body, Button, Field, heading, IconButton, InlineAction, muted, Notice, QuotaSummary, row, Segmented, StatusDot, toneColor, type ThemeProps } from "./components";
6
+ import { addAccount, cliName, missingCli, refreshUsage, setAutoFailover, setFallback, setIntegration, startLogin,
7
+ type Account, type AccountState, type LoginSession, type Provider } from "../shared/contracts";
8
+ import { body, Button, Field, IconButton, InlineAction, muted, Notice, row, Segmented, type ThemeProps } from "./components";
7
9
  import { useAccountsData, useAction, useNow } from "./data";
8
- import { accountStatus, errorMessage, providerName } from "./format";
9
- import { accountAvailable, addOrResumeLogin, type LoginMode } from "./login";
10
+ import { errorMessage, providerName } from "./format";
11
+ import { addOrResumeLogin, type LoginMode } from "./login";
10
12
  import { SignInDialog, type SignInTarget } from "./sign-in";
11
13
  import { closeSignInTarget, visibleSignInTarget } from "./sign-in-state";
12
14
 
13
15
  export type AccountsProps = PluginSurfaceProps & { onChanged(): void; runtimeError?: string | null };
14
- type SignInActions = { onStarted(account: Account, session: LoginSession): void; onResume(account: Account, sessionId: string): void };
15
16
 
16
17
  const loginModes = [{ value: "device", label: "Device code" }, { value: "browser", label: "In browser" }] as const;
17
18
  const providers = [{ value: "claude", label: providerName.claude }, { value: "codex", label: providerName.codex }] as const;
@@ -22,99 +23,6 @@ function listed(account: Account, state: AccountState): boolean {
22
23
  return state.providers[account.provider].available || account.source === "managed";
23
24
  }
24
25
 
25
- function AccountCard({ account, state, snapshot, checksOff, now, theme, layout, host, onChanged, onStarted, onResume }: AccountsProps & SignInActions & {
26
- account: Account; state: AccountState; snapshot: UsageSnapshot | undefined; checksOff: boolean; now: number;
27
- }) {
28
- const rename = useRpc(renameAccount);
29
- const remove = useRpc(removeAccount);
30
- const setDefault = useRpc(setDefaultAccount);
31
- const login = useRpc(startLogin);
32
- const cancel = useRpc(cancelLogin);
33
- const check = useRpc(checkLogin);
34
- const refresh = useRpc(refreshUsage);
35
- const action = useAction(host.id, onChanged);
36
- const [panel, setPanel] = useState<"none" | "menu" | "rename" | "remove">("none");
37
- const [label, setLabel] = useState(account.label);
38
- const [notice, setNotice] = useState<string | null>(null);
39
- const isDefault = state.defaults[account.provider] === account.id;
40
- const inUse = state.bindings.filter((binding) => binding.currentAccountId === account.id).length;
41
- const pending = state.bindings.filter((binding) => binding.pendingAccountId === account.id).length;
42
- const managed = account.source === "managed";
43
- const loginSession = account.login;
44
- const status = accountStatus(account, snapshot);
45
- const busy = action.isPending;
46
- const needsLogin = managed && !loginSession && !accountAvailable(account);
47
- const beginLogin = (mode?: LoginMode) => action.run(async () => {
48
- setNotice(null); setPanel("none");
49
- const result = await login({ accountId: account.id, ...(mode ? { mode } : {}) });
50
- onStarted(account, result);
51
- });
52
- const loginButtons = (variant: "primary" | "secondary") => account.provider === "codex" ? <>
53
- <Button theme={theme} variant={variant} disabled={busy} onPress={() => beginLogin("device")}>{needsLogin ? "Sign in with code" : "Sign in again with code"}</Button>
54
- <Button theme={theme} disabled={busy} onPress={() => beginLogin("browser")}>{needsLogin ? "In browser" : "Sign in again in browser"}</Button>
55
- </> : <Button theme={theme} variant={variant} disabled={busy} onPress={() => beginLogin()}>{needsLogin ? "Sign in" : "Sign in again"}</Button>;
56
- const meta = [
57
- account.email ?? (managed ? "separate profile" : "system CLI"),
58
- isDefault ? "default for new agents" : null,
59
- inUse ? `agents: ${inUse}` : null,
60
- pending ? `pending: ${pending}` : null,
61
- ].filter(Boolean).join(" · ");
62
- return <View accessibilityLabel={`Account ${account.label}`} style={{ borderWidth: 1, borderColor: theme.colors.border, backgroundColor: theme.colors.surface1, borderRadius: 10, padding: layout.compact ? 10 : 12, gap: 10, minWidth: 0 }}>
63
- <View style={{ flexDirection: "row", alignItems: "flex-start", gap: 8, flexWrap: "wrap" }}>
64
- <View style={{ flex: 1, minWidth: 160, gap: 2 }}>
65
- <Text selectable numberOfLines={1} style={heading(theme)}>{account.label}</Text>
66
- <View style={{ flexDirection: "row", alignItems: "center", gap: 6, flexWrap: "wrap" }}>
67
- <StatusDot theme={theme} tone={status.tone} />
68
- <Text style={{ ...muted(theme), color: status.tone === "muted" || status.tone === "success" ? theme.colors.foregroundMuted : toneColor(theme, status.tone) }}>{status.text}</Text>
69
- <Text selectable numberOfLines={1} style={{ ...muted(theme), flexShrink: 1 }}>· {meta}</Text>
70
- </View>
71
- </View>
72
- <View style={{ ...row, justifyContent: "flex-end" }}>
73
- {loginSession ? <>
74
- {"sessionId" in loginSession ? <Button theme={theme} variant="primary" onPress={() => onResume(account, loginSession.sessionId)}>Continue sign-in</Button> : null}
75
- <Button theme={theme} disabled={busy} onPress={() => action.run(async () => { await cancel({ accountId: account.id, ...("sessionId" in loginSession ? { sessionId: loginSession.sessionId } : {}) }); setNotice("Sign-in canceled. You can start again."); })}>Cancel sign-in</Button>
76
- </> : needsLogin ? loginButtons("primary") : null}
77
- <IconButton theme={theme} icon="MoreHorizontal" label={`Actions for ${account.label}`} active={panel !== "none"} onPress={() => setPanel(panel === "none" ? "menu" : "none")} />
78
- </View>
79
- </View>
80
- {loginSession ? <Notice theme={theme} tone="warning">
81
- {"sessionId" in loginSession ? "Finish signing in in your browser. Status and limits will update automatically." : "A sign-in from an older version is still open. Cancel it, then sign in again to use the browser flow."}
82
- </Notice> : null}
83
- {panel === "menu" ? <View style={{ ...row, paddingTop: 2 }}>
84
- <Button theme={theme} variant="ghost" disabled={busy || checksOff || Boolean(loginSession)} onPress={() => action.run(() => refresh({ accountId: account.id }))}>Refresh limits</Button>
85
- <Button theme={theme} variant="ghost" disabled={busy} onPress={() => action.run(async () => {
86
- const result = await check({ accountId: account.id });
87
- setNotice(result.authStatus === "ready" ? "Sign-in confirmed. You can now select this account for agents." : "Sign-in is not confirmed yet. Finish signing in in your browser, then check again.");
88
- })}>Check sign-in</Button>
89
- {isDefault
90
- ? <Button theme={theme} variant="ghost" disabled={busy} onPress={() => action.run(() => setDefault({ provider: account.provider, accountId: null }))}>Clear default</Button>
91
- : <Button theme={theme} variant="ghost" disabled={busy || !accountAvailable(account)} onPress={() => action.run(() => setDefault({ provider: account.provider, accountId: account.id }))}>Default for new agents</Button>}
92
- {managed && !needsLogin && !loginSession ? loginButtons("secondary") : null}
93
- {managed ? <>
94
- <Button theme={theme} variant="ghost" disabled={busy} onPress={() => { setLabel(account.label); setPanel("rename"); }}>Rename</Button>
95
- <Button theme={theme} variant="danger" disabled={busy || Boolean(loginSession)} onPress={() => setPanel("remove")}>Remove</Button>
96
- </> : null}
97
- </View> : null}
98
- {panel === "rename" ? <View style={row}>
99
- <Field theme={theme} value={label} onChangeText={setLabel} maxLength={80} accessibilityLabel={`New name for ${account.label}`} placeholder="Account name" autoCapitalize="sentences" autoFocus
100
- onSubmitEditing={() => label.trim() && action.run(async () => { await rename({ accountId: account.id, label: label.trim() }); setPanel("none"); })} />
101
- <Button theme={theme} variant="primary" disabled={busy || !label.trim()} onPress={() => action.run(async () => { await rename({ accountId: account.id, label: label.trim() }); setPanel("none"); })}>Save</Button>
102
- <Button theme={theme} variant="ghost" disabled={busy} onPress={() => setPanel("none")}>Cancel</Button>
103
- </View> : null}
104
- {panel === "remove" ? <View style={{ gap: 8 }}>
105
- <Notice theme={theme} tone="danger">Remove “{account.label}” and its saved sign-in? {inUse || pending ? "An agent is using this account or has it pending: choose another account first." : "You will need to sign in again if you add it later."}</Notice>
106
- <View style={row}>
107
- <Button theme={theme} variant="danger" disabled={busy || Boolean(loginSession) || inUse > 0 || pending > 0} onPress={() => action.run(() => remove({ accountId: account.id }))}>Yes, remove</Button>
108
- <Button theme={theme} variant="ghost" disabled={busy} onPress={() => setPanel("none")}>Keep account</Button>
109
- </View>
110
- </View> : null}
111
- {notice ? <Notice theme={theme}>{notice}</Notice> : null}
112
- {action.error ? <Notice theme={theme} tone="danger">{errorMessage(action.error)}</Notice> : null}
113
- <QuotaSummary theme={theme} snapshot={snapshot} now={now} compact={layout.compact}
114
- onRefresh={loginSession || checksOff ? undefined : () => action.run(() => refresh({ accountId: account.id }))} refreshing={busy} />
115
- </View>;
116
- }
117
-
118
26
  function AddAccountForm({ theme, host, onChanged, initialProvider, options, onClose, onStarted }: AccountsProps & Pick<SignInActions, "onStarted"> & { initialProvider: Provider; options: readonly ProviderOption[]; onClose(): void }) {
119
27
  const add = useRpc(addAccount);
120
28
  const login = useRpc(startLogin);
@@ -153,14 +61,10 @@ export function AutoFailoverSetting({ theme, provider, enabled, disabled, run }:
153
61
  provider: Provider; enabled: boolean; disabled: boolean; run(action: () => Promise<unknown>): void;
154
62
  }) {
155
63
  const save = useRpc(setAutoFailover);
156
- return <View style={{ gap: 4 }}>
157
- <Segmented theme={theme} label="When a limit runs out during a chat" value={enabled ? "auto" : "offer"} disabled={disabled}
158
- onChange={(value) => run(() => save({ provider, enabled: value === "auto" }))}
159
- options={[{ value: "offer", label: "Offer a switch" }, { value: "auto", label: "Switch automatically" }]} />
160
- <Text style={muted(theme)}>{enabled
161
- ? "When a turn fails because its account's limit is used up, the chat moves to another signed-in account and continues, at most three times an hour."
162
- : "When a turn fails because its account's limit is used up, the chat offers to move to another signed-in account."}</Text>
163
- </View>;
64
+ return <SettingsSelect label="When a limit runs out during a chat" value={enabled ? "auto" : "offer"} disabled={disabled}
65
+ hint={enabled ? "Switches within this provider, up to 3 times per hour. Failed turns continue automatically." : "The chat offers another signed-in account."}
66
+ onValueChange={value => run(() => save({ provider, enabled: value === "auto" }))}
67
+ options={[{ value: "offer", label: "Offer a switch" }, { value: "auto", label: "Switch automatically" }]} />;
164
68
  }
165
69
 
166
70
  export function AccountsSurface(props: AccountsProps) {
@@ -180,24 +84,19 @@ export function AccountsSurface(props: AccountsProps) {
180
84
  const checksOff = usage.data?.checksOff === true;
181
85
  const enabled = state?.integration.enabled ?? false;
182
86
  const installed = providers.filter((option) => state?.providers[option.value].available ?? true);
183
- const toggleIntegration = () => action.run(() => integration({ enabled: !enabled }));
184
87
  const enableIntegration = () => action.run(() => integration({ enabled: true }));
185
88
  return <><ScrollView style={{ flex: 1, backgroundColor: theme.colors.surface0 }} contentContainerStyle={{ padding: layout.compact ? 12 : 20, gap: 12, width: "100%", maxWidth: 960, alignSelf: "center", paddingBottom: 40 }} keyboardShouldPersistTaps="handled">
186
89
  <View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
187
90
  <View style={{ flex: 1, minWidth: 0, gap: 1 }}>
188
91
  <Text style={{ color: theme.colors.foreground, fontSize: layout.compact ? 20 : 22, fontWeight: "700" }}>Accounts</Text>
189
- {state ? <View style={{ flexDirection: "row", alignItems: "center", gap: 6, flexWrap: "wrap" }}>
190
- <Text style={muted(theme)}>Accounts: {state.accounts.filter((account) => listed(account, state)).length} · switching {enabled ? "on" : "off"}</Text>
191
- {enabled ? <InlineAction theme={theme} disabled={action.isPending} onPress={toggleIntegration}>Disable</InlineAction> : null}
192
- </View> : <Text style={muted(theme)}>{accounts.isPending ? "Loading…" : "Data unavailable"}</Text>}
92
+ <Text style={muted(theme)}>{state ? `${state.accounts.filter(account => listed(account, state)).length} accounts on this host` : accounts.isPending ? "Loading…" : "Data unavailable"}</Text>
193
93
  </View>
194
94
  <IconButton theme={theme} icon="RefreshCw" label="Refresh all limits" disabled={action.isPending || checksOff} onPress={() => action.run(() => refresh({}))} />
195
- <Button theme={theme} variant="primary" disabled={action.isPending || (!adding && !installed.length)} onPress={() => setAdding(adding ? null : installed[0]?.value ?? null)}>{adding ? "Close" : "Add"}</Button>
95
+ <Button theme={theme} variant="primary" disabled={action.isPending || (!adding && !installed.length)} onPress={() => setAdding(adding ? null : installed[0]?.value ?? null)}>{adding ? "Close" : "Add account"}</Button>
196
96
  </View>
197
- {state && !enabled ? <View style={{ flexDirection: "row", alignItems: "center", gap: 8, flexWrap: "wrap" }}>
198
- <View style={{ flex: 1, minWidth: 200 }}><Notice theme={theme} tone="warning">Account switching in the composer is off: agents use the system CLI.</Notice></View>
199
- <Button theme={theme} disabled={action.isPending} onPress={toggleIntegration}>Enable</Button>
200
- </View> : null}
97
+ {state ? <SettingsCard><SettingsSwitch label="Account switching" value={enabled} disabled={action.isPending}
98
+ hint={enabled ? "Choose an account from the chat composer. Running chats keep their account." : "Off. Agents use this host’s CLI sign-in."}
99
+ onValueChange={value => action.run(() => integration({ enabled: value }))} /></SettingsCard> : null}
201
100
  {state?.integration.error ? <Notice theme={theme} tone="danger">{state.integration.error}</Notice> : null}
202
101
  {checksOff ? <Notice theme={theme} tone="warning">Check usage is off in this host's settings: limits stop updating, and a used-up account gets no switch offer.</Notice> : null}
203
102
  {runtimeError ? <Notice theme={theme} tone="danger">{runtimeError}</Notice> : null}
@@ -208,32 +107,26 @@ export function AccountsSurface(props: AccountsProps) {
208
107
  {state ? (["claude", "codex"] as const).map((provider) => {
209
108
  const status = state.providers[provider];
210
109
  const group = state.accounts.filter((account) => account.provider === provider && listed(account, state));
211
- return <View key={provider} style={{ gap: 8 }}>
212
- <View style={{ flexDirection: "row", alignItems: "baseline", gap: 6, paddingTop: 4 }}>
213
- <Text accessibilityRole="header" style={heading(theme)}>{providerName[provider]}</Text>
214
- <Text style={muted(theme)}>{group.length}</Text>
215
- </View>
216
- {state.defaults[provider] && group.length > 1 ? <View style={{ gap: 4 }}>
217
- <Segmented theme={theme} label={`When the ${providerName[provider]} default would fail`} value={state.fallback[provider] ? "fallback" : "default"}
218
- disabled={action.isPending} onChange={(value) => action.run(() => fallback({ provider, enabled: value === "fallback" }))}
219
- options={[{ value: "fallback", label: "Start on another account" }, { value: "default", label: "Always use the default" }]} />
220
- <Text style={muted(theme)}>{state.fallback[provider]
221
- ? "A new agent starts on another signed-in account when the latest limits show the default would fail."
222
- : "New agents always start on the default, even when its limits are used up."}</Text>
223
- </View> : null}
224
- {group.length > 1 ? <AutoFailoverSetting theme={theme} provider={provider} enabled={state.autoFailover[provider]} disabled={action.isPending} run={action.run} /> : null}
110
+ return <SettingsSection key={provider} title={providerName[provider]}>
225
111
  {!status.available ? <Notice theme={theme}>{missingCli(provider)}</Notice>
226
112
  : enabled && !status.integrated ? <View style={{ flexDirection: "row", alignItems: "center", gap: 8, flexWrap: "wrap" }}>
227
113
  <View style={{ flex: 1, minWidth: 200 }}><Notice theme={theme} tone="warning">Account switching is off for {cliName[provider]}: its agents use the system CLI.</Notice></View>
228
114
  <Button theme={theme} disabled={action.isPending} onPress={enableIntegration}>Enable</Button>
229
115
  </View> : null}
230
116
  {group.map((account) => <AccountCard key={account.id} {...props} account={account} state={state} snapshot={usage.data?.accounts.find((item) => item.accountId === account.id)} checksOff={checksOff} now={now} onStarted={onStarted} onResume={onResume} />)}
117
+ {group.length > 1 ? <SettingsCard>
118
+ {state.defaults[provider] ? <SettingsSelect label="When the default is unavailable" value={state.fallback[provider] ? "fallback" : "default"}
119
+ hint="Applies to new agents. Existing chats keep their account." disabled={action.isPending}
120
+ onValueChange={value => action.run(() => fallback({ provider, enabled: value === "fallback" }))}
121
+ options={[{ value: "fallback", label: "Start on another account" }, { value: "default", label: "Always use the default" }]} /> : null}
122
+ <AutoFailoverSetting theme={theme} provider={provider} enabled={state.autoFailover[provider]} disabled={action.isPending} run={action.run} />
123
+ </SettingsCard> : null}
231
124
  {!group.length && status.available ? <View style={{ flexDirection: "row", alignItems: "center", gap: 6 }}>
232
125
  <Text style={muted(theme)}>No accounts.</Text>
233
126
  <InlineAction theme={theme} onPress={() => setAdding(provider)}>Add</InlineAction>
234
127
  </View> : null}
235
- </View>;
128
+ </SettingsSection>;
236
129
  }) : null}
237
- {state ? <Text style={{ ...muted(theme), paddingTop: 4 }}>Limits refresh every minute while this panel is open and every 5 minutes in the background. The default account applies to new agents.</Text> : null}
130
+ {state ? <Text style={muted(theme)}>Limits update every minute here and every 5 minutes in the background.</Text> : null}
238
131
  </ScrollView>{visibleSignIn ? <SignInDialog key={visibleSignIn.sessionId} {...props} target={visibleSignIn} onClose={() => setSignIn(current => closeSignInTarget(current, visibleSignIn, host.id))} /> : null}</>;
239
132
  }
@@ -136,10 +136,11 @@ function DetailLine({ theme, children }: ThemeProps & { children: ReactNode }) {
136
136
  * Compact quota block: measured windows first, then one disclosure with the windows without data,
137
137
  * exact reset times, quota lengths and fetch timestamps. Errors and freshness are always visible.
138
138
  */
139
- export function QuotaSummary({ theme, snapshot, now, compact, onRefresh, refreshing }: ThemeProps & {
140
- snapshot: UsageSnapshot | undefined; now: number; compact: boolean; onRefresh?: () => void; refreshing?: boolean;
139
+ export function QuotaSummary({ theme, snapshot, now, compact, onRefresh, refreshing, hideAuth }: ThemeProps & {
140
+ snapshot: UsageSnapshot | undefined; now: number; compact: boolean; onRefresh?: () => void; refreshing?: boolean; hideAuth?: boolean;
141
141
  }) {
142
142
  const [open, setOpen] = useState(false);
143
+ if (hideAuth && snapshot?.status === "needs_auth") return null;
143
144
  const { known, unknown } = snapshot ? splitWindows(snapshot.windows) : { known: [], unknown: [] };
144
145
  const fresh = freshness(snapshot, now);
145
146
  const detailsTitle = unknown.length ? `${unknown.length} more without data · details` : "Details";
@@ -148,7 +149,7 @@ export function QuotaSummary({ theme, snapshot, now, compact, onRefresh, refresh
148
149
  {known.map((quota) => <View key={quota.id} style={{ flexGrow: 1, flexBasis: compact ? "100%" : "46%", minWidth: 0 }}>
149
150
  <QuotaWindowRow theme={theme} quota={quota} now={now} />
150
151
  </View>)}
151
- </View> : snapshot && snapshot.status !== "needs_auth" ? <Text style={muted(theme)}>{snapshot.windows.length ? "The provider did not return limit values." : "The provider has not returned limit windows yet."}</Text> : null}
152
+ </View> : snapshot && snapshot.status !== "needs_auth" && !snapshot.error ? <Text style={muted(theme)}>{snapshot.windows.length ? "No limit values reported." : "No limit data yet."}</Text> : null}
152
153
  {snapshot?.error ? <Notice theme={theme} tone="danger">{snapshot.error}</Notice> : null}
153
154
  <View style={{ ...row, gap: 10 }}>
154
155
  <View style={{ flexDirection: "row", alignItems: "center", gap: 6 }}>
@@ -157,7 +158,7 @@ export function QuotaSummary({ theme, snapshot, now, compact, onRefresh, refresh
157
158
  </View>
158
159
  {onRefresh ? <InlineAction theme={theme} disabled={refreshing} onPress={onRefresh}>{refreshing ? "Refreshing…" : "Refresh"}</InlineAction> : null}
159
160
  </View>
160
- {snapshot ? <Disclosure theme={theme} title={detailsTitle} open={open} onToggle={() => setOpen(!open)}>
161
+ {snapshot && (snapshot.windows.length > 0 || snapshot.fetchedAt || snapshot.nextRetryAt) ? <Disclosure theme={theme} title={detailsTitle} open={open} onToggle={() => setOpen(!open)}>
161
162
  <View style={{ gap: 4, paddingLeft: 18 }}>
162
163
  {snapshot.windows.map((quota) => <DetailLine key={quota.id} theme={theme}>
163
164
  {quota.label}: {quota.usedPercent === null ? "no data" : `${percent(quota.usedPercent)} used`}
package/client/format.ts CHANGED
@@ -157,7 +157,7 @@ export function accountStatus(account: Account, snapshot: UsageSnapshot | undefi
157
157
  ready: { text: "sign-in confirmed", tone: "success" as Tone },
158
158
  needs_auth: { text: "sign-in required", tone: "warning" as Tone },
159
159
  unknown: { text: "sign-in not checked", tone: "muted" as Tone },
160
- error: { text: "sign-in error", tone: "danger" as Tone },
160
+ error: { text: "sign-in unavailable", tone: "warning" as Tone },
161
161
  }[account.authStatus];
162
162
  }
163
163
 
@@ -80,6 +80,8 @@ export function AgentSwitcher({ theme, host, agentId, onChanged, openAccounts, c
80
80
  const available = accountAvailable(account);
81
81
  const blocked = disabled || actual || !available;
82
82
  const detail = account.login ? "sign-in in progress · finish in Accounts"
83
+ : account.authStatus === "error" ? "cannot access sign-in · check credentials in Accounts"
84
+ : account.authStatus === "unknown" ? "sign-in not confirmed · check in Accounts"
83
85
  : !available ? "sign-in required · check in Accounts"
84
86
  : usageSummary(usage.data?.accounts.find((item) => item.accountId === account.id), now);
85
87
  return <Pressable key={account.id} accessibilityRole="button" accessibilityLabel={`Prepare account ${account.label}`}
package/index.server.ts CHANGED
@@ -15,6 +15,7 @@ import type { AccountNote } from "./shared/timeline";
15
15
  const MODEL_ENV="PASEO_ACCOUNT_SWITCHER_MODEL";
16
16
  // Set by whoever creates the agent (e.g. `paseo run --env PASEO_ACCOUNT_SWITCHER_ACCOUNT=Work`): the account it starts on.
17
17
  const ACCOUNT_ENV="PASEO_ACCOUNT_SWITCHER_ACCOUNT";
18
+ const IMPORT_ACCOUNT_LABEL="account-switcher.account";
18
19
  // The prompt that resumes an agent's work on the account it was switched to.
19
20
  const CONTINUE="Continue.";
20
21
  const reason=(error:unknown)=>error instanceof Error?error.message:String(error);
@@ -139,9 +140,17 @@ export default function contribute(server:PluginServerContext){
139
140
  await controller.ready;
140
141
  // Neither hint from the creation reaches the CLI, on this or any later session of the agent.
141
142
  const {[MODEL_ENV]:model,[ACCOUNT_ENV]:account,...env}=request.env;
142
- const creating=request.purpose==="interactive"&&request.reason==="create",requested=account?.trim()||null;
143
- if(creating&&requested&&request.provider!=="claude"&&request.provider!=="codex")throw new SwitchRefusal(`Account Switcher manages only Claude Code and Codex accounts, so the ${request.provider} agent cannot start on ${requested}.`);
144
- if(creating&&(request.provider==="claude"||request.provider==="codex")){await controller.ensureRuntime(paseo);const bound=await controller.switcher(paseo).bindNewAgent(request.agentId,request.provider,model||null,requested);
143
+ const creating=request.purpose==="interactive"&&request.reason==="create";
144
+ const importing=request.purpose==="interactive"&&request.reason==="import";
145
+ // Newer daemons include labels in session-open requests; the pinned 0.11 SDK does not declare them.
146
+ const labelled=request as typeof request&{labels?:Readonly<Record<string,string>>};
147
+ const importAccount=importing?labelled.labels?.[IMPORT_ACCOUNT_LABEL]:undefined;
148
+ if(importAccount!==undefined&&!importAccount.trim())throw new SwitchRefusal("Name an account in the account-switcher.account import label.");
149
+ const requested=(importing?importAccount:account)?.trim()||null;
150
+ const selecting=creating||importAccount!==undefined;
151
+ if(selecting&&requested&&request.provider!=="claude"&&request.provider!=="codex")throw new SwitchRefusal(`Account Switcher manages only Claude Code and Codex accounts, so the ${request.provider} agent cannot start on ${requested}.`);
152
+ if(selecting&&(request.provider==="claude"||request.provider==="codex")){await controller.ensureRuntime(paseo);const bound=await controller.switcher(paseo).bindNewAgent(request.agentId,request.provider,model||null,requested);
153
+ if(importing&&requested&&!bound)throw new SwitchRefusal("This imported session already has an account binding. Switch it from the composer.");
145
154
  const reason=bound?.reason;
146
155
  if(bound&&reason){
147
156
  const started=await note(request.agentId,async()=>{const state=await controller.store.read(),to=labelOf(state,bound.accountId);return to?{kind:"started",from:labelOf(state,bound.defaultId),to,reason}:null;});
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "paseo-plugin-account-switcher",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "paseo-plugin-account-switcher",
9
- "version": "0.10.1",
9
+ "version": "0.11.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@iarna/toml": "^2.2.5"