Skip to content

The open source AI video agent: turns any coding agent into a video agent, with an editor to change anything it makes.

Desktop: switch an agent's account from Settings, and from a sign-in error (#263)

riverisbuilding257dd8de7307
diff --git a/.changeset/agent-switch-account.md b/.changeset/agent-switch-account.md
new file mode 100644
index 0000000..4989aaf
--- /dev/null
+++ b/.changeset/agent-switch-account.md
@@ -0,0 +1,6 @@
+---
+"@openfilm/desktop": patch
+"openfilm": patch
+---
+
+Switch account for the chat's agents. Claude Code keeps its own sign-in, apart from the Claude app's, so switching accounts in the Claude app did not change the one OpenFilm used. Settings → Agents now has Switch account: Claude Code, Cursor and MiniMax Code sign out with their own command and open their sign-in for another account, and their chats carry on with the new one; the other agents say where they switch (the Codex app, the DeepSeek Harness app, or the agent itself). A turn that fails for its account (signed out, an expired or refused sign-in, an organization that turned off Claude subscription access) offers Switch account and names the account signed in. Cursor's row shows its account's email.
diff --git a/apps/desktop/chat/src/App.tsx b/apps/desktop/chat/src/App.tsx
index a20ba31..585248e 100644
--- a/apps/desktop/chat/src/App.tsx
+++ b/apps/desktop/chat/src/App.tsx
@@ -60,6 +60,7 @@ import type { TurnFileChanges } from '@/lib/file-changes';
import { readBalance, type TurnBalance } from '@/lib/balance';
import { BalanceNotice } from '@/components/BalanceNotice';
import { CopyDiagnostics } from '@/components/CopyDiagnostics';
+import { accountName, accountTrouble } from '@/lib/account-trouble';
import { readStudioFilm } from '@/lib/studio-film';
import { studioRefsFromTransfer, transferHasStudioRefs } from '@/lib/studio-transfer';
import { agentModelSummary, agentOptions, currentAgent, effectivePrefs, offeredOption, useLocalAgents } from '@/state/local-agent-store';
@@ -793,6 +794,10 @@ function ChatPane({ project, banners, selection, assetsOpen }: { project: Projec
);
const agentName = agent === 'byok' ? t('composer.agentOwnKey') : la.roster?.find((a) => a.id === agent)?.name ?? agent;
+ /* the last turn failed for the account of the person's own agent it ran on: Switch account, and whose it is */
+ const failedOn = asset?.localAgent?.id ?? agent;
+ const switchFor = turnError && failedOn !== 'byok' && accountTrouble(turnError) && desktopBridge()?.openSettings
+ ? { who: accountName(la.roster?.find((a) => a.id === failedOn)?.account) } : null;
const wasName = agentWas === 'byok' ? t('composer.agentOwnKey') : agentWas ? la.roster?.find((a) => a.id === agentWas)?.name ?? AGENT_DEFINITIONS[agentWas]?.name ?? agentWas : '';
const editComposerCard = (
@@ -1098,6 +1103,15 @@ function ChatPane({ project, banners, selection, assetsOpen }: { project: Projec
{turnError ? (
<p role="alert" className="text-xs text-[var(--err)]">
{turnError}{' '}
+ {/* failed for its account: whose it is, and Settings → Agents to switch it */}
+ {switchFor ? (
+ <span className="text-[var(--text-muted)]">
+ {switchFor.who ? `${t('composer.signedInAs').replace('{account}', switchFor.who)} ` : null}
+ <button type="button" onClick={() => desktopBridge()?.openSettings?.('agents')} className="underline underline-offset-2 hover:text-[var(--text)]">
+ {t('composer.switchAccount')}
+ </button>{' '}
+ </span>
+ ) : null}
{/* what to send when it keeps failing */}
<span className="text-[var(--text-muted)]"><CopyDiagnostics /></span>
</p>
diff --git a/apps/desktop/chat/src/i18n/locales/en-US.ts b/apps/desktop/chat/src/i18n/locales/en-US.ts
index aecd92b..374e697 100644
--- a/apps/desktop/chat/src/i18n/locales/en-US.ts
+++ b/apps/desktop/chat/src/i18n/locales/en-US.ts
@@ -161,6 +161,8 @@ export const enUS = {
copyDiagnostics: 'Copy diagnostic report',
copyDiagnosticsHint: 'What OpenFilm finds on this computer and its recent problems, to paste into an issue',
diagnosticsCopied: 'Copied',
+ switchAccount: 'Switch account',
+ signedInAs: 'Signed in as {account}.',
removeFile: 'Remove file',
removeImage: 'Remove image',
speed: 'Speed',
diff --git a/apps/desktop/chat/src/i18n/locales/es.ts b/apps/desktop/chat/src/i18n/locales/es.ts
index 8ca2640..84e1b5b 100644
--- a/apps/desktop/chat/src/i18n/locales/es.ts
+++ b/apps/desktop/chat/src/i18n/locales/es.ts
@@ -161,6 +161,8 @@ export const es: Words = {
copyDiagnostics: 'Copiar informe de diagnóstico',
copyDiagnosticsHint: 'Lo que OpenFilm encuentra en este equipo y sus problemas recientes, para pegar en un issue',
diagnosticsCopied: 'Copiado',
+ switchAccount: 'Cambiar de cuenta',
+ signedInAs: 'Sesión iniciada como {account}.',
removeFile: 'Quitar archivo',
removeImage: 'Quitar imagen',
speed: 'Velocidad',
diff --git a/apps/desktop/chat/src/i18n/locales/ja.ts b/apps/desktop/chat/src/i18n/locales/ja.ts
index 17fdafc..09f6a39 100644
--- a/apps/desktop/chat/src/i18n/locales/ja.ts
+++ b/apps/desktop/chat/src/i18n/locales/ja.ts
@@ -161,6 +161,8 @@ export const ja: Words = {
copyDiagnostics: '診断レポートをコピー',
copyDiagnosticsHint: 'このコンピュータで OpenFilm が見つけた状況と最近の問題。issue に貼り付けられます',
diagnosticsCopied: 'コピーしました',
+ switchAccount: 'アカウントを切り替え',
+ signedInAs: '{account} でサインイン中です。',
removeFile: 'ファイルを削除',
removeImage: '画像を削除',
speed: '速度',
diff --git a/apps/desktop/chat/src/i18n/locales/ko.ts b/apps/desktop/chat/src/i18n/locales/ko.ts
index 4942ea4..eb0e8de 100644
--- a/apps/desktop/chat/src/i18n/locales/ko.ts
+++ b/apps/desktop/chat/src/i18n/locales/ko.ts
@@ -157,6 +157,8 @@ export const ko: Words = {
copyDiagnostics: '진단 보고서 복사',
copyDiagnosticsHint: '이 컴퓨터에서 OpenFilm이 확인한 상태와 최근 문제, issue에 붙여 넣을 수 있습니다',
diagnosticsCopied: '복사됨',
+ switchAccount: '계정 전환',
+ signedInAs: '{account}(으)로 로그인되어 있습니다.',
removeFile: '파일 제거',
removeImage: '이미지 제거',
speed: '속도',
diff --git a/apps/desktop/chat/src/i18n/locales/zh-CN.ts b/apps/desktop/chat/src/i18n/locales/zh-CN.ts
index fd893d3..4b83fdc 100644
--- a/apps/desktop/chat/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/chat/src/i18n/locales/zh-CN.ts
@@ -161,6 +161,8 @@ export const zhCN: Words = {
copyDiagnostics: '复制诊断信息',
copyDiagnosticsHint: 'OpenFilm 在这台电脑上找到的情况和最近的问题,可以贴进 issue',
diagnosticsCopied: '已复制',
+ switchAccount: '切换账号',
+ signedInAs: '当前登录:{account}。',
removeFile: '移除文件',
removeImage: '移除图片',
speed: '速度',
diff --git a/apps/desktop/chat/src/lib/account-trouble.ts b/apps/desktop/chat/src/lib/account-trouble.ts
new file mode 100644
index 0000000..90b1676
--- /dev/null
+++ b/apps/desktop/chat/src/lib/account-trouble.ts
@@ -0,0 +1,36 @@
+/**
+ * A turn that failed for the account the agent is signed in to, not for the work: signed out, a sign-in that expired
+ * or was refused, or an account its organization does not let use the agent (Claude Code: "Your organization has
+ * disabled Claude subscription access for Claude Code"). The chat offers Switch account by it, and names the account
+ * signed in when the app knows it. Read from the error's words, so a turn kept from before says it too.
+ */
+import type { RosterAgent } from './desktop-bridge';
+
+const ACCOUNT_TROUBLE = [
+ /* Claude Code's subscription turned off by the person's organization */
+ /\borganization has disabled\b/i,
+ /* signed out: the agents' words ("Not logged in · Please run /login") and the app's ("… is not signed in.") */
+ /\bnot (?:signed|logged) in\b/i,
+ /\bplease run \/login\b/i,
+ /* a sign-in refused or gone */
+ /\b(?:session|token|credentials?) (?:has )?expired\b/i,
+ /\binvalid (?:api key|token|credentials?|x-api-key)\b/i,
+ /\bauthentication (?:failed|required|error)\b/i,
+ /\bunauthori[sz]ed\b/i,
+ /\b(?:401|403)\b/,
+];
+
+export function accountTrouble(error: string | null | undefined): boolean {
+ return Boolean(error) && ACCOUNT_TROUBLE.some((re) => re.test(String(error)));
+}
+
+/**
+ * Whose account it is, as the app's roster says: its organization (unless it only repeats the email, as a personal
+ * Claude account's "<email>'s Organization" does) and its email; null when the agent does not tell.
+ */
+export function accountName(account: RosterAgent['account']): string | null {
+ if (!account) return null;
+ const org = account.org && !(account.email && account.org === `${account.email}'s Organization`) ? account.org : null;
+ const parts = [org, account.email].filter(Boolean);
+ return parts.length ? parts.join(' · ') : null;
+}
diff --git a/apps/desktop/chat/src/lib/desktop-bridge.ts b/apps/desktop/chat/src/lib/desktop-bridge.ts
index 3ddbf63..ede1d4b 100644
--- a/apps/desktop/chat/src/lib/desktop-bridge.ts
+++ b/apps/desktop/chat/src/lib/desktop-bridge.ts
@@ -24,6 +24,8 @@ export interface RosterAgent {
install?: string | null;
setupRequired?: string | null;
error?: string;
+ /** Whose sign-in it uses, when the agent tells (no key or token). */
+ account?: { method: string; email?: string; org?: string; plan?: string };
/**
* The own key's models, each set up on its own (its name, its service, the model asked for there), with the reasoning
* efforts it offers and the one it starts on (apps/desktop src/pi-config.mjs EFFORTS); the first one to begin with.
diff --git a/apps/desktop/src/account-trouble.test.mjs b/apps/desktop/src/account-trouble.test.mjs
new file mode 100644
index 0000000..eb8c658
--- /dev/null
+++ b/apps/desktop/src/account-trouble.test.mjs
@@ -0,0 +1,32 @@
+import assert from 'node:assert/strict';
+import { test } from 'node:test';
+import { accountName, accountTrouble } from '../chat/src/lib/account-trouble.ts';
+
+test('a turn that failed for the account offers Switch account; one that failed for the work does not', () => {
+ for (const error of [
+ 'Your organization has disabled Claude subscription access for Claude Code · Use an Anthropic API key instead, or ask your admin to enable access',
+ 'Not logged in · Please run /login',
+ 'Session expired. Please run /login to sign in again.',
+ 'Claude Code is not signed in. Sign in under Settings → Agents.',
+ 'Kimi is not signed in. Sign in under Settings → Agents.',
+ 'API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"Invalid bearer token"}}',
+ 'Request failed with status 403 Forbidden',
+ 'Unauthorized: invalid API key',
+ 'Cursor: Authentication required',
+ ]) assert.equal(accountTrouble(error), true, error);
+ for (const error of [
+ 'Claude Code stopped while answering without saying why. If it cannot reach its service, check the network or proxy, then try again.',
+ 'Codex 0.120.0 is older than OpenFilm needs (0.132.0 or later): update Codex, then try again.',
+ 'The model gpt-5 does not exist',
+ 'Rate limit reached: 429',
+ '',
+ ]) assert.equal(accountTrouble(error), false, error);
+ assert.equal(accountTrouble(null), false);
+});
+
+test("the account a failed turn names: its organization and email, not a personal account's organization again", () => {
+ assert.equal(accountName({ method: 'claude.ai', email: '[email protected]', org: 'Acme Films' }), 'Acme Films · [email protected]');
+ assert.equal(accountName({ method: 'claude.ai', email: '[email protected]', org: "[email protected]'s Organization" }), '[email protected]');
+ assert.equal(accountName({ method: 'chatgpt' }), null);
+ assert.equal(accountName(undefined), null);
+});
diff --git a/apps/desktop/src/agent-roster.mjs b/apps/desktop/src/agent-roster.mjs
index b942b62..81136f0 100644
--- a/apps/desktop/src/agent-roster.mjs
+++ b/apps/desktop/src/agent-roster.mjs
@@ -3,10 +3,11 @@
*
* · codex, claude, copilot, cursor, opencode, codebuddy, qwen, kimi, minimax, deepseek — the person's own agents
* (agents.mjs): Codex, Claude Code, GitHub Copilot, Cursor, OpenCode, CodeBuddy, Qwen Code, Kimi, MiniMax Code and
- * DeepSeek Harness. Each uses the account signed in on the computer as it is: connecting opens Terminal for its own
+ * DeepSeek Harness. Each uses the account its own program is signed in to: connecting opens Terminal for its own
* sign-in command only when it is signed out (never Codex's or DeepSeek Harness's: each is signed in in its own
* app, so one found is connected), disconnecting only stops OpenFilm using it, and connecting again uses whichever
- * account is signed in then (one switched in the agent or its maker's app). `account` says whose it is. Codex and
+ * account is signed in then. `account` says whose it is. One with a sign-out command (`signOut`) switches account
+ * here (`switchAccount`): signed out, its sessions closed, its sign-in opened and waited for. Codex and
* Claude Code are shown in the chat's menu from the start; the others once the person connects one or switches it
* on. Codex is connected from the start, Claude Code once the person connects it.
* · byok — the app's own agent (Pi, pi-agent.mjs) on the person's own models, each set up on its own: the name the
@@ -214,6 +215,7 @@ export async function probeModel({ format, baseUrl, key, model, fetch: fetchImpl
* localAgents: () => Promise<Array<{ id: string, cli: { path: string } | null, signedIn: boolean | null, account?: object | null, problem?: string, install: string | null, setupRequired: string | null, app?: string | null, installer?: string | null }>>,
* localAgent?: (id: string, options?: { fresh?: boolean }) => Promise<{ id: string, cli: { path: string } | null, signedIn: boolean | null, account?: object | null, problem?: string, install: string | null, setupRequired: string | null, app?: string | null, installer?: string | null }>,
* openSignIn: (id: string) => Promise<{ ok: boolean, error?: string, isOpen?: () => Promise<boolean | null> }>,
+ * signOut?: (id: string) => Promise<{ ok: boolean, error?: string }>,
* openInstaller?: (id: string) => Promise<{ ok: boolean, error?: string }>,
* usePaths?: (paths: Record<string, string>) => void,
* pickProgram?: (id: string, words?: { title?: string, button?: string }) => Promise<string | null>,
@@ -268,7 +270,8 @@ export function createRoster(deps) {
}
if (choices.disconnected.includes(id)) return { status: 'off', ...where };
if (found.signedIn === false) return { status: live.waiting[id] ? 'waiting' : 'sign-in', ...where };
- return { status: 'ready', ...where, ...(found.account ? { account: { ...found.account } } : {}), ...(found.problem ? { problem: found.problem } : {}) };
+ return { status: 'ready', ...where, ...(found.account ? { account: { ...found.account } } : {}), ...(found.problem ? { problem: found.problem } : {}),
+ ...(found.signOut && deps.signOut ? { signOut: true } : {}) };
}
if (choices.disconnected.includes(id)) return { status: 'off' };
if (!keyed().length) return { status: 'key' };
@@ -409,6 +412,28 @@ export function createRoster(deps) {
}
},
+ /**
+ * Another account, for one that signs out with its own command: its sessions close (the next message starts on the
+ * new account), it signs out with no window, and its sign-in opens and is waited for, as Sign in's is. A sign-out
+ * that fails leaves it as it was, with what it said.
+ */
+ async switchAccount(id) {
+ if (!isOwn(id) || !deps.signOut) return { ok: false, error: `No agent ${id}` };
+ delete live.errors[id];
+ cancelSignIn(id);
+ deps.closeSessions(id);
+ const out = await deps.signOut(id).catch((e) => ({ ok: false, error: e instanceof Error ? e.message : String(e) }));
+ if (!out.ok) { live.errors[id] = out.error || `${AGENT_NAMES[id]} did not sign out.`; changed(); return { ok: false, error: live.errors[id] }; }
+ /* signed out now: said at once, and kept over an older answer still on its way */
+ local = (local ?? []).map((a) => (a.id === id ? { ...a, signedIn: false, account: null } : a));
+ revision.set(id, (revision.get(id) ?? 0) + 1);
+ changed();
+ const opened = await deps.openSignIn(id);
+ if (!opened.ok) { live.errors[id] = opened.error ?? 'Terminal did not open.'; changed(); return { ok: false, error: live.errors[id] }; }
+ void waitForSignIn(id, opened.isOpen);
+ return { ok: true };
+ },
+
/** Disconnect here only: its sessions close; its own sign-in stays as it is (connecting again uses it as it is then). */
disconnect(id) {
if (!isAgentId(id)) return;
diff --git a/apps/desktop/src/agent-roster.test.mjs b/apps/desktop/src/agent-roster.test.mjs
index 4cf76df..1ee25ff 100644
--- a/apps/desktop/src/agent-roster.test.mjs
+++ b/apps/desktop/src/agent-roster.test.mjs
@@ -380,6 +380,60 @@ test('disconnecting only stops OpenFilm using an agent; connecting again uses th
assert.deepEqual(closed, ['claude', 'claude', 'claude'], 'its sessions closed each time: none goes on with the old account');
});
+test('switching account signs the agent out with no window, closes its sessions, and waits for its sign-in to another account', async () => {
+ const dir = mkdtempSync(join(tmpdir(), 'of-roster-'));
+ let state = { signedIn: true, account: { method: 'claude.ai', email: '[email protected]', org: 'Old Org' } };
+ const claude = () => ({ id: 'claude', cli: { path: '/bin/claude' }, ...state, signOut: true, install: null, setupRequired: null });
+ const steps = [];
+ const r = roster(dir, undefined, {
+ localAgents: async () => [claude()],
+ localAgent: async () => claude(),
+ closeSessions: (id) => steps.push(`close ${id}`),
+ signOut: async (id) => { steps.push(`sign out ${id}`); state = { signedIn: false, account: null }; return { ok: true }; },
+ openSignIn: async (id) => { steps.push(`sign in ${id}`); return { ok: true }; },
+ signInWait: { ms: 2000, pollMs: 10 },
+ });
+ await r.connect('claude');
+ const before = r.list().find((a) => a.id === 'claude');
+ assert.equal(before.status, 'ready');
+ assert.equal(before.signOut, true, 'it can switch here');
+ steps.length = 0;
+ assert.deepEqual(await r.switchAccount('claude'), { ok: true });
+ assert.deepEqual(steps, ['close claude', 'sign out claude', 'sign in claude'], 'no session goes on with the old account');
+ const waiting = r.list().find((a) => a.id === 'claude');
+ assert.equal(waiting.status, 'waiting');
+ assert.equal(waiting.account, undefined, 'the old account is no longer shown');
+ state = { signedIn: true, account: { method: 'claude.ai', email: '[email protected]' } };
+ await new Promise((done) => setTimeout(done, 60));
+ const after = r.list().find((a) => a.id === 'claude');
+ assert.equal(after.status, 'ready');
+ assert.equal(after.account.email, '[email protected]');
+});
+
+test('a sign-out that fails leaves the agent signed in as it was, with what it said; one that cannot switch here is refused', async () => {
+ const dir = mkdtempSync(join(tmpdir(), 'of-roster-'));
+ const cursor = { id: 'cursor', cli: { path: '/bin/cursor-agent' }, signedIn: true, account: { method: 'other', email: '[email protected]' }, signOut: true, install: null, setupRequired: null };
+ const opened = [];
+ const r = roster(dir, undefined, {
+ localAgents: async () => [cursor],
+ signOut: async () => ({ ok: false, error: 'Cursor did not sign out. Keychain is locked' }),
+ openSignIn: async (id) => { opened.push(id); return { ok: true }; },
+ });
+ await r.connect('cursor');
+ assert.deepEqual(await r.switchAccount('cursor'), { ok: false, error: 'Cursor did not sign out. Keychain is locked' });
+ const row = r.list().find((a) => a.id === 'cursor');
+ assert.equal(row.status, 'ready');
+ assert.equal(row.account.email, '[email protected]');
+ assert.equal(row.error, 'Cursor did not sign out. Keychain is locked');
+ assert.deepEqual(opened, [], 'no sign-in opened');
+ assert.equal((await r.switchAccount('byok')).ok, false);
+ /* an app without the sign-out: Settings says where to switch instead */
+ const older = roster(mkdtempSync(join(tmpdir(), 'of-roster-')), undefined, { localAgents: async () => [cursor] });
+ await older.connect('cursor');
+ assert.equal(older.list().find((a) => a.id === 'cursor').signOut, undefined);
+ assert.equal((await older.switchAccount('cursor')).ok, false);
+});
+
test("Codex found but unable to read its own settings says so, with what it said", async () => {
const dir = mkdtempSync(join(tmpdir(), 'of-roster-'));
const problem = 'Error loading configuration: config.toml:2:16: unknown variant `full`';
diff --git a/apps/desktop/src/agents.mjs b/apps/desktop/src/agents.mjs
index 4431eba..e818756 100644
--- a/apps/desktop/src/agents.mjs
+++ b/apps/desktop/src/agents.mjs
@@ -16,8 +16,10 @@
* else hold or pass on their credentials. The app runs their own program, sign-in is its own (`claude auth login`
* in Terminal, or a command window on Windows; Codex in Codex itself), and the app never sees a token.
*
- * Each uses the account signed in on the computer, as it is: one switched in the agent (or its maker's app) is the
- * one used once the agent is connected again here.
+ * Each uses the account its own program is signed in to, which is not always its maker's app's: Claude Code keeps its
+ * own sign-in (`claude auth`), apart from the Claude app's, even the copy inside that app. One with a sign-out command
+ * (`logout`) switches account from Settings → Agents (agent-roster.mjs switchAccount); the others in the agent itself,
+ * or its maker's app where they share it (Codex, DeepSeek Harness).
*
* The agent works the way it would in a terminal: in the project's folder, with the `openfilm` command on its PATH
* (this app's copy, so its Studio is the one in the window) and a few lines saying where it is (INSTRUCTIONS).
@@ -48,7 +50,9 @@ const require = createRequire(import.meta.url);
* person's program itself with `args`. Signed in? `auth` asks the program (its words say); without it, a session is
* opened and closed (acpSignedIn). `login` is its own sign-in, run in Terminal (none: the program itself, which asks
* for one on its first run; null: signed in in the program or its maker's app, never from here, so one found is
- * connected). `authenticate`: the ACP auth method that takes up the program's own sign-in.
+ * connected). `logout`: its own sign-out, run here with no window (signOutAgent), so Switch account can sign in to
+ * another account; none for an agent that has no such command, or one that asks which account (OpenCode).
+ * `authenticate`: the ACP auth method that takes up the program's own sign-in.
* `approve`: it asks permission for what the app lets every agent do (see the chat's AGENT_FORCED_PREFS), so the app
* answers yes itself. The others are told the app's INSTRUCTIONS in the first message of a session (`systemPrompt`:
* how Claude Code and Codex are told them instead).
@@ -60,6 +64,7 @@ export const AGENTS = Object.freeze({
env: (path) => ({ CLAUDE_CODE_EXECUTABLE: path }),
auth: ['auth', 'status'],
login: ['auth', 'login'],
+ logout: ['auth', 'logout'],
/* of the shell only its PATH, proxies, config folder and locale, as 0.1.5 had it: a key or
gateway set there (ANTHROPIC_*) would take the place of the person's Claude subscription */
fromShell: shellSubset,
@@ -77,7 +82,7 @@ export const AGENTS = Object.freeze({
systemPrompt: true,
},
copilot: { label: AGENT_DEFINITIONS.copilot.name, args: ['--acp', '--allow-all'], login: ['login'], approve: true },
- cursor: { label: AGENT_DEFINITIONS.cursor.name, args: ['--force', 'acp'], auth: ['status'], login: ['login'], authenticate: 'cursor_login', approve: true },
+ cursor: { label: AGENT_DEFINITIONS.cursor.name, args: ['--force', 'acp'], auth: ['status'], login: ['login'], logout: ['logout'], authenticate: 'cursor_login', approve: true },
opencode: { label: AGENT_DEFINITIONS.opencode.name, args: ['acp'], login: ['auth', 'login'], approve: true },
/* CodeBuddy is the China edition unless the person's shell says otherwise: the program itself defaults to the
international site (www.codebuddy.ai) whichever site it was signed in on, out of reach from China */
@@ -85,7 +90,7 @@ export const AGENTS = Object.freeze({
defaults: { CODEBUDDY_INTERNET_ENVIRONMENT: 'internal' } },
qwen: { label: AGENT_DEFINITIONS.qwen.name, args: ['--acp', '--approval-mode', 'yolo'], login: [], approve: true },
kimi: { label: AGENT_DEFINITIONS.kimi.name, args: ['acp'], login: ['login'], approve: true },
- minimax: { label: AGENT_DEFINITIONS.minimax.name, args: ['acp'], login: ['login'], approve: true },
+ minimax: { label: AGENT_DEFINITIONS.minimax.name, args: ['acp'], login: ['login'], logout: ['logout'], approve: true },
/* DeepSeek Harness (`dsh`) speaks ACP as its `acp` profile. It has no sign-in command: the person signs in to their
DeepSeek account in its desktop app, or sets DEEPSEEK_API_KEY, so one found is connected. It reports every tool
as kind `other`, titled by its name: `toolKinds` gives each the kind it is (see withToolKind) */
@@ -406,7 +411,9 @@ export function readAgentStatus(id, stdout, out) {
if (/\bnot logged in\b/i.test(out)) return { signedIn: false, account: null };
if (/\blogged in\b/i.test(out)) {
const method = /chatgpt/i.test(out) ? 'chatgpt' : /api key/i.test(out) ? 'api-key' : 'other';
- return { signedIn: true, account: { method } };
+ /* Cursor: "✓ Logged in as [email protected]" */
+ const email = /\blogged in as\s+([^\s@]+@[^\s@]+\.[^\s@]+)/i.exec(out)?.[1];
+ return { signedIn: true, account: { method, ...(email ? { email } : {}) } };
}
return { signedIn: null, account: null };
}
@@ -633,6 +640,23 @@ export async function openAgentSignIn(id, { track = false } = {}) {
} : {}) };
}
+/**
+ * Sign out of an agent with its own command (`logout`), run here with no window: Switch account signs out, then opens
+ * the agent's sign-in (openAgentSignIn). What it said is the error when it fails. Whether it is signed in is asked
+ * afresh from then on.
+ */
+export async function signOutAgent(id) {
+ const spec = AGENTS[id];
+ if (!spec?.logout) return { ok: false, error: `${spec?.label ?? id} has no sign-out command: switch accounts in ${spec?.label ?? id} itself.` };
+ const cli = resolveAgentCli(id, { pathDirs: (await loginShellEnvironment()).PATH.split(PATH_SEP) });
+ if (!cli) return { ok: false, error: `${spec.label} is not installed on this computer.` };
+ const shell = agentShell(id, await loginShellVariables());
+ const how = starting(cli.path, spec.logout);
+ const r = await run(how.cmd, how.args, 30_000, { cwd: probeFolder(), env: childEnvironment({ shell, extra: { ...agentDefaults(id, shell), ...how.env } }), options: how.options });
+ asked.delete(id);
+ return r.ok ? { ok: true } : { ok: false, error: `${spec.label} did not sign out. ${r.out.trim().slice(0, 500)}`.trim() };
+}
+
/**
* Install an agent with its maker's official installer (installCommand), in a window the person sees: Terminal on a
* Mac, PowerShell on Windows. The person agreed to that exact command in Settings → Agents first. Whether it worked is
@@ -688,6 +712,8 @@ async function agentOnComputer(id, pathDirs, { fresh = false } = {}) {
cli: cli ? { path: cli.path, source: cli.source } : null,
chosen: chosenPaths[id] ?? null,
...(cli ? ownSignIn(AGENTS[id], await agentStatus(id, cli.path, { fresh })) : { signedIn: null, account: null }),
+ /* it signs out with its own command: Switch account signs in to another account from Settings */
+ ...(cli && AGENTS[id].logout ? { signOut: true } : {}),
install,
setupRequired: claudeApp ? 'code-tab' : null,
...(cli ? {} : { app: claudeApp ? null : app, installer: installCommand(id) }),
diff --git a/apps/desktop/src/agents.test.mjs b/apps/desktop/src/agents.test.mjs
index 759b731..46644f4 100644
--- a/apps/desktop/src/agents.test.mjs
+++ b/apps/desktop/src/agents.test.mjs
@@ -2,7 +2,7 @@ import { test } from 'node:test';
import assert from 'node:assert/strict';
import { AgentSession, CLIENT_CAPABILITIES, agentDefaults, closeEverySession, planProblem, probeFolder, CODEX_UTF8_CMD, agentShell, allowOption, codexDeveloperInstructions, codexLaunchEnv, distinctOptions, errorCause, legacyOptions, optionsForModel, powerShellScript, powerShellLine, powerShellWindowLaunch, terminalScript, checkAgentProgram, readAgentStatus, setChosenPaths, signInScript, turnError, signInError, codexTooOld, AGENTS, ownSignIn, codexServiceError, codexRefusal, codexNotice, explainFailure, stderrReason, withToolKind, OWN_GROUP, stopTree, winArg } from './agents.mjs';
import { spawn } from 'node:child_process';
-import { acpSignedIn } from './agents.mjs';
+import { acpSignedIn, signOutAgent } from './agents.mjs';
test('a fresh sign-in check bypasses a cached signed-out result and shares the pending probe', async () => {
const { mkdtempSync, readFileSync, writeFileSync, rmSync } = await import('node:fs');
@@ -132,6 +132,17 @@ test('whose sign-in it is, as each program says it, never a key', () => {
assert.deepEqual(read, { signedIn: true, account: { method: 'api-key' } });
assert.ok(!JSON.stringify(read).includes('sk-'), 'no part of a key');
assert.deepEqual(readAgentStatus('codex', 'Not logged in\n', 'Not logged in\n'), { signedIn: false, account: null });
+ const cursor = '\n✓ Logged in as [email protected]\n';
+ assert.deepEqual(readAgentStatus('cursor', cursor, cursor), { signedIn: true, account: { method: 'other', email: '[email protected]' } });
+});
+
+test('the agents that sign out with a command of their own, run with no window, can switch account here', () => {
+ const logouts = Object.fromEntries(Object.entries(AGENTS).map(([id, spec]) => [id, spec.logout ?? null]));
+ assert.deepEqual(logouts, {
+ claude: ['auth', 'logout'], cursor: ['logout'], minimax: ['logout'],
+ /* Codex signs in in Codex (its app shares the sign-in); OpenCode's asks which account; the others have none */
+ codex: null, copilot: null, opencode: null, codebuddy: null, qwen: null, kimi: null, deepseek: null,
+ });
});
test('settings Codex cannot read: it cannot say whether it is signed in, and says why', () => {
@@ -640,3 +651,51 @@ test("a word for cmd.exe keeps its % as it is: no variable's value is put in its
const r = spawnSync(process.env.ComSpec || 'cmd.exe', ['/d', '/s', '/c', `"${[shim, ...words].map(winArg).join(' ')}"`], { encoding: 'utf8', windowsVerbatimArguments: true, windowsHide: true });
assert.deepEqual(JSON.parse(r.stdout.trim()), words);
});
+
+test("signing out runs the agent's own sign-out with no window, says what it said when it fails, and asks afresh after", async () => {
+ const { mkdtempSync, readFileSync, writeFileSync, existsSync, rmSync } = await import('node:fs');
+ const { tmpdir } = await import('node:os');
+ const { join } = await import('node:path');
+ const dir = mkdtempSync(join(tmpdir(), 'of-sign-out-'));
+ const signedIn = join(dir, 'signed-in');
+ const ran = join(dir, 'ran');
+ /* MiniMax Code as a fake: \`logout\` forgets its sign-in (or fails, told to); \`acp\` opens a session only signed in */
+ const program = join(dir, 'mcode.mjs');
+ writeFileSync(program, `
+ import { createInterface } from 'node:readline';
+ import { appendFileSync, existsSync, rmSync } from 'node:fs';
+ const args = process.argv.slice(2);
+ appendFileSync(${JSON.stringify(ran)}, args.join(' ') + '\\n');
+ if (args[0] === 'logout') {
+ if (existsSync(${JSON.stringify(join(dir, 'fail'))})) { process.stderr.write('Keychain is locked'); process.exit(1); }
+ rmSync(${JSON.stringify(signedIn)}, { force: true });
+ process.exit(0);
+ }
+ const send = (message) => process.stdout.write(JSON.stringify(message) + '\\n');
+ createInterface({ input: process.stdin }).on('line', (line) => {
+ const request = JSON.parse(line);
+ if (request.method === 'initialize') send({ jsonrpc: '2.0', id: request.id, result: { protocolVersion: 1, agentCapabilities: {}, authMethods: [] } });
+ if (request.method === 'session/new') send({ jsonrpc: '2.0', id: request.id, ...(existsSync(${JSON.stringify(signedIn)})
+ ? { result: { sessionId: 'sign-out-test' } } : { error: { code: -32000, message: 'Authentication required' } }) });
+ });
+ `);
+ writeFileSync(signedIn, 'yes');
+ setChosenPaths({ minimax: program });
+ try {
+ assert.equal(await acpSignedIn('minimax'), true);
+ writeFileSync(join(dir, 'fail'), '');
+ const failed = await signOutAgent('minimax');
+ assert.equal(failed.ok, false);
+ assert.match(failed.error, /^MiniMax Code did not sign out\. .*Keychain is locked/);
+ assert.ok(existsSync(signedIn), 'still signed in as it was');
+ rmSync(join(dir, 'fail'));
+ assert.deepEqual(await signOutAgent('minimax'), { ok: true });
+ assert.ok(!existsSync(signedIn));
+ assert.equal(await acpSignedIn('minimax'), false, 'the signed-in answer kept for ten minutes is forgotten');
+ assert.deepEqual(readFileSync(ran, 'utf8').trim().split('\n').filter((l) => l === 'logout'), ['logout', 'logout']);
+ /* one with no sign-out command is never run */
+ const none = await signOutAgent('qwen');
+ assert.equal(none.ok, false);
+ assert.match(none.error, /Qwen Code has no sign-out command/);
+ } finally { setChosenPaths({}); closeEverySession(); rmSync(dir, { recursive: true, force: true }); }
+});
diff --git a/apps/desktop/src/main.mjs b/apps/desktop/src/main.mjs
index 79f1fbd..a0b5e65 100644
--- a/apps/desktop/src/main.mjs
+++ b/apps/desktop/src/main.mjs
@@ -27,7 +27,7 @@ import { registerLocalAgentIpc } from './local-agents-ipc.mjs';
import { readPreferences, registerChatIpc } from './chat-ipc.mjs';
import { registerSkillsIpc } from './skills-ipc.mjs';
import { createRoster } from './agent-roster.mjs';
-import { checkAgentProgram, closeEverySession, diagnoseAgent, listAgents, localAgent, openAgentInstaller, openAgentSignIn, setChosenPaths } from './agents.mjs';
+import { checkAgentProgram, closeEverySession, diagnoseAgent, listAgents, localAgent, openAgentInstaller, openAgentSignIn, setChosenPaths, signOutAgent } from './agents.mjs';
import { agentUsage, forgetAgentUsage } from './agent-usage.mjs';
import { installOpenfilmCommand } from './openfilm-command.mjs';
import { startUpdates } from './updates.mjs';
@@ -616,9 +616,12 @@ async function start() {
localAgents: listAgents,
localAgent,
openSignIn: (id) => openAgentSignIn(id, { track: true }),
+ /* Switch account: its own sign-out, with no window, before its sign-in */
+ signOut: signOutAgent,
/* an agent's official installer, in a terminal window, once the person agreed to it in Settings → Agents */
openInstaller: openAgentInstaller,
- /* sessions closed on connecting and disconnecting: the next look at its usage is for whichever account is used now */
+ /* sessions closed on connecting, disconnecting and switching account: the next look at its usage is for whichever
+ account is used now */
closeSessions: (id) => { forgetAgentUsage(id); localAgents?.closeAgent(id); },
seal,
unseal,
@@ -640,6 +643,7 @@ async function start() {
agentHandle('desktop:agents:connect', ({ id }) => roster.connect(String(id)));
agentHandle('desktop:agents:cancel-sign-in', ({ id }) => { roster.cancelSignIn(String(id)); return { ok: true }; });
agentHandle('desktop:agents:disconnect', ({ id }) => { roster.disconnect(String(id)); return { ok: true }; });
+ agentHandle('desktop:agents:switch-account', ({ id }) => roster.switchAccount(String(id)));
/* what is left of Claude Code's and Codex's plan, on OpenFilm's sign-in (agent-usage.mjs); null when it can't say */
agentHandle('desktop:agents:usage', ({ id, fresh }) => agentUsage(String(id), { fresh: fresh === true }));
agentHandle('desktop:agents:locate', ({ id, words }) => roster.locate(String(id), words));
diff --git a/apps/desktop/src/preload.cjs b/apps/desktop/src/preload.cjs
index 975f38b..f4d85fe 100644
--- a/apps/desktop/src/preload.cjs
+++ b/apps/desktop/src/preload.cjs
@@ -48,6 +48,8 @@ contextBridge.exposeInMainWorld('openfilmNative', {
connect: (id) => ipcRenderer.invoke('desktop:agents:connect', { id }),
cancelSignIn: (id) => ipcRenderer.invoke('desktop:agents:cancel-sign-in', { id }),
disconnect: (id) => ipcRenderer.invoke('desktop:agents:disconnect', { id }),
+ /* signed out with its own command, then its sign-in opened (agent-roster.mjs switchAccount) */
+ switchAccount: (id) => ipcRenderer.invoke('desktop:agents:switch-account', { id }),
usage: (id, fresh) => ipcRenderer.invoke('desktop:agents:usage', { id, fresh: fresh === true }),
setShown: (id, shown) => ipcRenderer.invoke('desktop:agents:shown', { id, shown: shown === true }),
locate: (id, words) => ipcRenderer.invoke('desktop:agents:locate', { id, words }),
diff --git a/packages/openfilm/studio/ui/src/components/settings/AgentsSection.tsx b/packages/openfilm/studio/ui/src/components/settings/AgentsSection.tsx
index 620a63e..1f9a135 100644
--- a/packages/openfilm/studio/ui/src/components/settings/AgentsSection.tsx
+++ b/packages/openfilm/studio/ui/src/components/settings/AgentsSection.tsx
@@ -4,8 +4,10 @@
*
* Codex, Claude Code and the others are the person's own programs, on the account signed in on the computer:
* connecting opens their own sign-in only when they are signed out (the app waits for it), disconnecting only stops
- * the app using them, and connecting again uses the account signed in then (switched in the agent itself).
- * Claude Code's and Codex's rows say whose account it is, and Codex's what is left of its plan. Codex and Claude Code
+ * the app using them, and connecting again uses the account signed in then. Switch account signs one out with its own
+ * command and opens its sign-in (the person agrees first); one without such a command says where it switches (its
+ * maker's app, or the agent itself), and Done reconnects it. A row says whose account it is when the agent tells it,
+ * and Codex's what is left of its plan. Codex and Claude Code
* are always listed under the person's agents, with the person's own key; the others there once switched on (connecting
* one does), else under "More agents", with where to get them when they are not installed. The person's own key is on a service of theirs, with a model that reads pictures (the agent looks at its own frames).
*
@@ -23,7 +25,7 @@ import { Check, Copy, Download, KeyRound, Loader2, Plus, X } from 'lucide-react'
import { useLanguage, useT } from '@/i18n';
import { BYOK_EFFORTS, studioHost, type HostAgent, type HostAgentDiagnosis, type HostAgentId, type HostAgentUsage, type HostByokEffort, type HostByokEffortLevel, type HostByokFormat, type HostOwnModel } from '@/lib/host';
import { parseContextLength } from '@/lib/context-length';
-import { accountOrg, missingActions, ownModelError } from '@/lib/agent-row';
+import { accountOrg, missingActions, ownModelError, switchOffer } from '@/lib/agent-row';
/** What is left of the plan: what Codex can say (the app's agent-usage.mjs; Claude Code's own report is wrong for Team accounts). */
const PLAN_AGENTS: readonly HostAgentId[] = ['codex'];
@@ -119,7 +121,10 @@ export function AgentsSection() {
const [diagnosis, setDiagnosis] = React.useState<{ id: HostAgentId; report: HostAgentDiagnosis | null; copied?: boolean } | null>(null);
/* the agent whose installer the person is asked about */
const [confirming, setConfirming] = React.useState<HostAgentId | null>(null);
+ /* the agent whose account the person is switching: asked first, or told where it switches */
+ const [switching, setSwitching] = React.useState<HostAgentId | null>(null);
if (!host) return null;
+ const offerSwitch = (agent: HostAgent) => switchOffer(agent, { switchAccount: Boolean(host.switchAccount) });
const act = (id: HostAgentId, run: () => Promise<{ ok?: boolean; error?: string } | unknown>) => {
setBusy(id);
@@ -199,10 +204,17 @@ export function AgentsSection() {
const working = busy === agent.id;
if (agent.status === 'ready' && chosen) {
return (
- <SettingsButton variant="quiet" disabled={working} title={agent.id === 'byok' ? undefined : t('settings.agents.disconnectHint').replaceAll('{name}', agent.name)}
- onClick={() => act(agent.id, () => host.disconnect(agent.id))}>
- {t('settings.agents.disconnect')}
- </SettingsButton>
+ <>
+ {offerSwitch(agent) ? (
+ <SettingsButton variant="quiet" disabled={working || switching === agent.id} onClick={() => setSwitching(agent.id)}>
+ {t('settings.agents.switchAccount')}
+ </SettingsButton>
+ ) : null}
+ <SettingsButton variant="quiet" disabled={working} title={agent.id === 'byok' ? undefined : t('settings.agents.disconnectHint').replaceAll('{name}', agent.name)}
+ onClick={() => act(agent.id, () => host.disconnect(agent.id))}>
+ {t('settings.agents.disconnect')}
+ </SettingsButton>
+ </>
);
}
if (agent.status === 'missing') {
@@ -265,6 +277,10 @@ export function AgentsSection() {
const meter = chosen && agent.status === 'ready' && PLAN_AGENTS.includes(agent.id) && Boolean(host.usage) && (plan === undefined || Boolean(plan?.windows.length));
const hint = diag?.report ? hintOf(diag.report) : null;
const asking = confirming === agent.id && agent.status === 'missing' && agent.installer && host.install ? agent.installer : null;
+ /* Switch account: here, once the person agrees to the sign-out; elsewhere, where (in its maker's app or itself) */
+ const switchHow = chosen && switching === agent.id ? offerSwitch(agent) : null;
+ const whereKey = `settings.agents.switchWhere.${agent.id}`;
+ const where = t(whereKey) === whereKey ? agent.name : t(whereKey);
return (
<SettingsItem
key={agent.id}
@@ -292,7 +308,7 @@ export function AgentsSection() {
</>
)}
>
- {agent.status === 'waiting' || open || said || agent.chosen || lost || meter || asking || (chosen && agent.status === 'ready' && (host.mcp || host.skills)) ? (
+ {agent.status === 'waiting' || open || said || agent.chosen || lost || meter || asking || switchHow || (chosen && agent.status === 'ready' && (host.mcp || host.skills)) ? (
<div className="flex flex-col gap-1.5 pl-[34px]">
{meter ? (
<div className="flex flex-col gap-1.5" aria-label={t('settings.agents.usage')}>
@@ -321,6 +337,24 @@ export function AgentsSection() {
</div>
</SettingsInset>
) : null}
+ {switchHow ? (
+ <SettingsInset>
+ <p className="text-[14px] leading-relaxed text-[var(--text)]">
+ {switchHow === 'here'
+ ? t('settings.agents.switchConfirm').replaceAll('{name}', agent.name)
+ : t('settings.agents.switchElsewhere').replaceAll('{name}', agent.name).replace('{where}', where)}
+ </p>
+ <div className="flex justify-end gap-1.5">
+ <SettingsButton variant="quiet" onClick={() => setSwitching(null)}>{t('settings.agents.cancel')}</SettingsButton>
+ <SettingsButton variant="primary" onClick={() => {
+ setSwitching(null);
+ act(agent.id, () => (switchHow === 'here' ? host.switchAccount!(agent.id) : host.connect(agent.id)));
+ }}>
+ {switchHow === 'here' ? t('settings.agents.switchRun') : t('settings.agents.switchDone')}
+ </SettingsButton>
+ </div>
+ </SettingsInset>
+ ) : null}
{lost && !diag ? (
<p className="text-[13.5px] leading-relaxed text-[var(--text-muted)]">
<button type="button" onClick={() => diagnose(agent)} className="underline underline-offset-2 hover:text-[var(--text)]">{t('settings.agents.whyMissing')}</button>
diff --git a/packages/openfilm/studio/ui/src/i18n/en.ts b/packages/openfilm/studio/ui/src/i18n/en.ts
index ff97c74..bd6a48d 100644
--- a/packages/openfilm/studio/ui/src/i18n/en.ts
+++ b/packages/openfilm/studio/ui/src/i18n/en.ts
@@ -1622,7 +1622,7 @@ export const en = {
partCodex: 'Codex’s own warnings and errors around its problems',
},
agents: {
- intro: 'The agents the chat can use. Codex, Claude Code and the others under Your agents are your own, on the account signed in on this computer: to use another account, switch accounts in the agent itself, then disconnect and connect it again here. Your own key runs on models you set up yourself, each on its own service.',
+ intro: 'The agents the chat can use. Codex, Claude Code and the others under Your agents are your own, on the account each one is signed in to on this computer: Switch account changes it. Your own key runs on models you set up yourself, each on its own service.',
byokName: 'Your own key',
groupYours: 'Your agents',
groupMore: 'More agents you can use',
@@ -1668,7 +1668,21 @@ export const en = {
checking: 'Checking…',
connect: 'Connect',
disconnect: 'Disconnect',
- disconnectHint: 'Stops OpenFilm using it; its sign-in stays. To use another account, switch accounts in {name}, then connect it again.',
+ disconnectHint: 'Stops OpenFilm using it; its sign-in stays.',
+ switchAccount: 'Switch account',
+ switchConfirm: '{name} signs out on this computer (in your terminal too), then its sign-in opens so you can choose another account. Chats with it carry on with the new account.',
+ switchRun: 'Sign out and switch',
+ switchElsewhere: '{name} switches accounts in {where}. Switch there, then choose Done: OpenFilm reconnects it with the account signed in then.',
+ switchDone: 'Done',
+ switchWhere: {
+ codex: 'the Codex app, or with codex login in a terminal',
+ copilot: 'Copilot itself: run copilot in a terminal and use /user',
+ opencode: 'the OpenCode app, or with opencode auth switch in a terminal',
+ codebuddy: 'CodeBuddy itself: run codebuddy in a terminal',
+ qwen: 'Qwen Code itself: run qwen in a terminal and use /auth',
+ kimi: 'Kimi itself: run kimi login in a terminal',
+ deepseek: 'the DeepSeek Harness app',
+ },
accountChatgpt: 'ChatGPT account',
accountApiKey: 'API key',
accountConsole: 'Anthropic Console',
diff --git a/packages/openfilm/studio/ui/src/i18n/es.ts b/packages/openfilm/studio/ui/src/i18n/es.ts
index dfe545d..da260cb 100644
--- a/packages/openfilm/studio/ui/src/i18n/es.ts
+++ b/packages/openfilm/studio/ui/src/i18n/es.ts
@@ -1621,7 +1621,7 @@ export const es: Words = {
partCodex: 'Los avisos y errores del propio Codex en torno a sus problemas',
},
agents: {
- intro: 'Los agentes que puede usar el chat. Codex, Claude Code y los demás de Tus agentes son tuyos, con la cuenta iniciada en este equipo: para usar otra cuenta, cámbiala en el propio agente y luego desconéctalo y vuelve a conectarlo aquí. Tu propia clave usa modelos que configuras tú, cada uno con su propio servicio.',
+ intro: 'Los agentes que puede usar el chat. Codex, Claude Code y los demás de Tus agentes son tuyos, cada uno con la cuenta con la que inició sesión en este equipo: Cambiar de cuenta la cambia. Tu propia clave usa modelos que configuras tú, cada uno con su propio servicio.',
byokName: 'Tu propia clave',
groupYours: 'Tus agentes',
groupMore: 'Otros agentes que puedes usar',
@@ -1667,7 +1667,21 @@ export const es: Words = {
checking: 'Comprobando…',
connect: 'Conectar',
disconnect: 'Desconectar',
- disconnectHint: 'Deja de usarlo en OpenFilm; su sesión se mantiene. Para usar otra cuenta, cambia de cuenta en {name} y vuelve a conectarlo.',
+ disconnectHint: 'Deja de usarlo en OpenFilm; su sesión se mantiene.',
+ switchAccount: 'Cambiar de cuenta',
+ switchConfirm: '{name} cierra sesión en este equipo (también en tu terminal) y después abre su inicio de sesión para que elijas otra cuenta. Los chats con {name} siguen con la cuenta nueva.',
+ switchRun: 'Cerrar sesión y cambiar',
+ switchElsewhere: '{name} cambia de cuenta en {where}. Cámbiala allí y elige Listo: OpenFilm lo vuelve a conectar con la cuenta iniciada entonces.',
+ switchDone: 'Listo',
+ switchWhere: {
+ codex: 'la app de Codex, o con codex login en una terminal',
+ copilot: 'el propio Copilot: ejecuta copilot en una terminal y usa /user',
+ opencode: 'la app de OpenCode, o con opencode auth switch en una terminal',
+ codebuddy: 'el propio CodeBuddy: ejecuta codebuddy en una terminal',
+ qwen: 'el propio Qwen Code: ejecuta qwen en una terminal y usa /auth',
+ kimi: 'el propio Kimi: ejecuta kimi login en una terminal',
+ deepseek: 'la app de DeepSeek Harness',
+ },
accountChatgpt: 'Cuenta de ChatGPT',
accountApiKey: 'Clave de API',
accountConsole: 'Anthropic Console',
diff --git a/packages/openfilm/studio/ui/src/i18n/ja.ts b/packages/openfilm/studio/ui/src/i18n/ja.ts
index fa1be1b..277ab71 100644
--- a/packages/openfilm/studio/ui/src/i18n/ja.ts
+++ b/packages/openfilm/studio/ui/src/i18n/ja.ts
@@ -1621,7 +1621,7 @@ export const ja: Words = {
partCodex: '問題の前後に Codex 自身が出した警告とエラー',
},
agents: {
- intro: '会話で使えるエージェントです。Codex、Claude Code など「あなたのエージェント」はあなた自身のもので、このコンピュータでサインインしているアカウントを使います。アカウントを変えるには、エージェント側で切り替えてから、ここで接続を解除して再接続してください。自分のキーは自分で設定したモデルで動き、モデルごとに別のサービスを使えます。',
+ intro: '会話で使えるエージェントです。Codex、Claude Code など「あなたのエージェント」はあなた自身のもので、それぞれがこのコンピュータでサインインしているアカウントを使います。「アカウントを切り替え」で変更できます。自分のキーは自分で設定したモデルで動き、モデルごとに別のサービスを使えます。',
byokName: '自分のキー',
groupYours: 'あなたのエージェント',
groupMore: 'ほかに使えるエージェント',
@@ -1667,7 +1667,21 @@ export const ja: Words = {
checking: '確認中…',
connect: '接続',
disconnect: '接続を解除',
- disconnectHint: 'OpenFilm での利用を止めます。サインインはそのままです。別のアカウントを使うには、{name} でアカウントを切り替えてからもう一度接続してください。',
+ disconnectHint: 'OpenFilm での利用を止めます。サインインはそのままです。',
+ switchAccount: 'アカウントを切り替え',
+ switchConfirm: '{name} をこのコンピュータでサインアウトし(ターミナルでも同様です)、別のアカウントを選べるようにサインインを開きます。{name} との会話は新しいアカウントで続きます。',
+ switchRun: 'サインアウトして切り替え',
+ switchElsewhere: '{name} のアカウントはここで切り替えます:{where}。切り替えたら「完了」を選んでください。OpenFilm がそのときサインインしているアカウントで再接続します。',
+ switchDone: '完了',
+ switchWhere: {
+ codex: 'Codex アプリ、またはターミナルの codex login',
+ copilot: 'Copilot 自体(ターミナルで copilot を起動して /user)',
+ opencode: 'OpenCode アプリ、またはターミナルの opencode auth switch',
+ codebuddy: 'CodeBuddy 自体(ターミナルで codebuddy を起動)',
+ qwen: 'Qwen Code 自体(ターミナルで qwen を起動して /auth)',
+ kimi: 'Kimi 自体(ターミナルで kimi login)',
+ deepseek: 'DeepSeek Harness アプリ',
+ },
accountChatgpt: 'ChatGPT アカウント',
accountApiKey: 'API キー',
accountConsole: 'Anthropic Console',
diff --git a/packages/openfilm/studio/ui/src/i18n/ko.ts b/packages/openfilm/studio/ui/src/i18n/ko.ts
index fbf62d0..07bb099 100644
--- a/packages/openfilm/studio/ui/src/i18n/ko.ts
+++ b/packages/openfilm/studio/ui/src/i18n/ko.ts
@@ -1617,7 +1617,7 @@ export const ko: Words = {
partCodex: '문제 전후로 Codex가 직접 남긴 경고와 오류',
},
agents: {
- intro: '채팅에서 쓸 수 있는 에이전트입니다. Codex, Claude Code 등 「내 에이전트」는 나의 것이며 이 컴퓨터에 로그인된 계정을 사용합니다. 다른 계정을 쓰려면 에이전트에서 계정을 바꾼 뒤 여기서 연결을 끊고 다시 연결하세요. 내 키는 직접 설정한 모델로 실행되며, 모델마다 다른 서비스를 쓸 수 있습니다.',
+ intro: '채팅에서 쓸 수 있는 에이전트입니다. Codex, Claude Code 등 「내 에이전트」는 나의 것이며 각각 이 컴퓨터에서 로그인된 계정을 사용합니다. 「계정 전환」으로 바꿀 수 있습니다. 내 키는 직접 설정한 모델로 실행되며, 모델마다 다른 서비스를 쓸 수 있습니다.',
byokName: '내 키',
groupYours: '내 에이전트',
groupMore: '그 밖에 쓸 수 있는 에이전트',
@@ -1663,7 +1663,21 @@ export const ko: Words = {
checking: '확인 중…',
connect: '연결',
disconnect: '연결 해제',
- disconnectHint: 'OpenFilm에서 사용을 멈춥니다. 로그인은 그대로입니다. 다른 계정을 쓰려면 {name}에서 계정을 바꾼 뒤 다시 연결하세요.',
+ disconnectHint: 'OpenFilm에서 사용을 멈춥니다. 로그인은 그대로입니다.',
+ switchAccount: '계정 전환',
+ switchConfirm: '이 컴퓨터에서 {name}을(를) 로그아웃하고(터미널에서도 마찬가지입니다) 다른 계정을 고를 수 있도록 로그인을 엽니다. {name}과의 채팅은 새 계정으로 이어집니다.',
+ switchRun: '로그아웃하고 전환',
+ switchElsewhere: '{name}의 계정은 여기에서 바꿉니다: {where}. 바꾼 뒤 「완료」를 누르면 OpenFilm이 그때 로그인된 계정으로 다시 연결합니다.',
+ switchDone: '완료',
+ switchWhere: {
+ codex: 'Codex 앱 또는 터미널의 codex login',
+ copilot: 'Copilot 자체(터미널에서 copilot 실행 후 /user)',
+ opencode: 'OpenCode 앱 또는 터미널의 opencode auth switch',
+ codebuddy: 'CodeBuddy 자체(터미널에서 codebuddy 실행)',
+ qwen: 'Qwen Code 자체(터미널에서 qwen 실행 후 /auth)',
+ kimi: 'Kimi 자체(터미널에서 kimi login)',
+ deepseek: 'DeepSeek Harness 앱',
+ },
accountChatgpt: 'ChatGPT 계정',
accountApiKey: 'API 키',
accountConsole: 'Anthropic Console',
diff --git a/packages/openfilm/studio/ui/src/i18n/zh-CN.ts b/packages/openfilm/studio/ui/src/i18n/zh-CN.ts
index 77950a3..bc55471 100644
--- a/packages/openfilm/studio/ui/src/i18n/zh-CN.ts
+++ b/packages/openfilm/studio/ui/src/i18n/zh-CN.ts
@@ -1622,7 +1622,7 @@ export const zhCN: Words = {
partCodex: 'Codex 自己在出问题前后的警告和报错',
},
agents: {
- intro: '对话可以使用的智能体。Codex、Claude Code 等「你的智能体」是你自己的,使用这台电脑上已登录的账号:想换账号,就在智能体里切换,再回到这里断开后重新连接。自有密钥使用你自己配置的模型,每个模型可以接不同的服务。',
+ intro: '对话可以使用的智能体。Codex、Claude Code 等「你的智能体」是你自己的,各自使用它在这台电脑上登录的账号:点「切换账号」即可更换。自有密钥使用你自己配置的模型,每个模型可以接不同的服务。',
byokName: '自有密钥',
groupYours: '你的智能体',
groupMore: '还可以接入的智能体',
@@ -1668,7 +1668,21 @@ export const zhCN: Words = {
checking: '正在检查…',
connect: '连接',
disconnect: '断开连接',
- disconnectHint: '停止在 OpenFilm 中使用,它的登录保持不变。想用别的账号,先在 {name} 里切换账号,再回来重新连接。',
+ disconnectHint: '停止在 OpenFilm 中使用,它的登录保持不变。',
+ switchAccount: '切换账号',
+ switchConfirm: '{name} 会在这台电脑上退出登录(终端里也一样),然后打开它的登录,让你选择另一个账号。和它的对话会接着用新账号。',
+ switchRun: '退出并切换',
+ switchElsewhere: '{name} 的账号在这里切换:{where}。切换好后点「完成」,OpenFilm 会用那时登录的账号重新连接。',
+ switchDone: '完成',
+ switchWhere: {
+ codex: 'Codex 应用,或在终端运行 codex login',
+ copilot: 'Copilot 本身:在终端运行 copilot,然后用 /user',
+ opencode: 'OpenCode 应用,或在终端运行 opencode auth switch',
+ codebuddy: 'CodeBuddy 本身:在终端运行 codebuddy',
+ qwen: 'Qwen Code 本身:在终端运行 qwen,然后用 /auth',
+ kimi: 'Kimi 本身:在终端运行 kimi login',
+ deepseek: 'DeepSeek Harness 应用',
+ },
accountChatgpt: 'ChatGPT 账号',
accountApiKey: 'API 密钥',
accountConsole: 'Anthropic Console',
diff --git a/packages/openfilm/studio/ui/src/lib/agent-row.test.ts b/packages/openfilm/studio/ui/src/lib/agent-row.test.ts
index 6d70731..b557a29 100644
--- a/packages/openfilm/studio/ui/src/lib/agent-row.test.ts
+++ b/packages/openfilm/studio/ui/src/lib/agent-row.test.ts
@@ -1,6 +1,6 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
-import { accountOrg, missingActions, ownModelError } from './agent-row.ts';
+import { accountOrg, missingActions, ownModelError, switchOffer } from './agent-row.ts';
import { zhCN } from '../i18n/zh-CN.ts';
test('an agent not found offers Locate and its installer, or its install page', () => {
@@ -29,3 +29,12 @@ test("an own model not saved is said in the person's language, with the address,
assert.equal(ownModelError({ error: 'Unknown parameter: max_output_tokens' }, t), 'Unknown parameter: max_output_tokens');
assert.equal(ownModelError({ error: 'from a newer app', code: 'something-new' }, t), 'from a newer app');
});
+
+test('a connected agent switches account here when it signs out with its own command; else the row says where', () => {
+ const host = { switchAccount: true };
+ assert.equal(switchOffer({ id: 'claude', status: 'ready', signOut: true }, host), 'here');
+ assert.equal(switchOffer({ id: 'deepseek', status: 'ready' }, host), 'elsewhere');
+ assert.equal(switchOffer({ id: 'claude', status: 'ready', signOut: true }, { switchAccount: false }), 'elsewhere', 'an older app');
+ assert.equal(switchOffer({ id: 'claude', status: 'off', signOut: true }, host), null);
+ assert.equal(switchOffer({ id: 'byok', status: 'ready' }, host), null);
+});
diff --git a/packages/openfilm/studio/ui/src/lib/agent-row.ts b/packages/openfilm/studio/ui/src/lib/agent-row.ts
index f85a1e8..8956741 100644
--- a/packages/openfilm/studio/ui/src/lib/agent-row.ts
+++ b/packages/openfilm/studio/ui/src/lib/agent-row.ts
@@ -11,6 +11,16 @@ export function missingActions(agent: Pick<HostAgent, 'setupRequired' | 'install
return { locate: host.locate, install };
}
+/**
+ * How a connected agent switches account: `here`, one that signs out with its own command (the app signs it out and
+ * opens its sign-in); `elsewhere`, in the agent itself or its maker's app, as the row then says. Null for the own key
+ * and for one not connected.
+ */
+export function switchOffer(agent: Pick<HostAgent, 'id' | 'status' | 'signOut'>, host: { switchAccount: boolean }): 'here' | 'elsewhere' | null {
+ if (agent.id === 'byok' || agent.status !== 'ready') return null;
+ return agent.signOut && host.switchAccount ? 'here' : 'elsewhere';
+}
+
/**
* The organization an account's line names, unless it only says the email again: a personal Claude account's
* organization is "<email>'s Organization".
diff --git a/packages/openfilm/studio/ui/src/lib/host.ts b/packages/openfilm/studio/ui/src/lib/host.ts
index 3d22c39..d417d68 100644
--- a/packages/openfilm/studio/ui/src/lib/host.ts
+++ b/packages/openfilm/studio/ui/src/lib/host.ts
@@ -94,6 +94,8 @@ export interface StudioHost {
/** Stop waiting for terminal sign-in without disconnecting the agent or changing its own sign-in. */
cancelSignIn?: (id: HostAgentId) => Promise<unknown>;
disconnect: (id: HostAgentId) => Promise<unknown>;
+ /** Another account, for one that signs out with its own command (`HostAgent.signOut`): signed out, then its sign-in opened. An older app has none. */
+ switchAccount?: (id: HostAgentId) => Promise<{ ok: boolean; error?: string }>;
/** Codex: what is left of its plan, as it says for the account signed in (null: it can't say; other agents, null) */
usage?: (id: HostAgentId, fresh?: boolean) => Promise<HostAgentUsage | null>;
setShown: (id: HostAgentId, shown: boolean) => Promise<unknown>;
@@ -250,6 +252,8 @@ export interface HostAgent {
/** Found, but it cannot read its own settings (Codex's config file), as it says: no session starts until fixed. */
problem?: string;
account?: HostAgentAccount;
+ /** It signs out with its own command, so the app can switch its account (`agents.switchAccount`); else that is done in the agent itself. */
+ signOut?: boolean;
/** The own key's models, each set up on its own; the first is the one a conversation starts on. */
byok?: { models: HostOwnModel[] };
}