fix(remote): satisfy changed-code quality gate for agent sign-in follow-ups

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Neil
2026-11-09 06:38:41 -08:00
co-authored by Claude
parent 87e9cea521
commit cf8809a6b2
6 changed files with 24 additions and 24 deletions
@@ -137,13 +137,7 @@ export function VmBuildAgentSignInRowView({
{t('agentSignIn.openAgain', 'Open again')}
</Button>
) : null}
<Button
type="button"
variant="ghost"
size="xs"
className="text-muted-foreground"
onClick={actions.cancel}
>
<Button type="button" variant="ghost" size="xs" onClick={actions.cancel}>
{t('agentSignIn.cancel', 'Cancel')}
</Button>
</>
@@ -4,10 +4,16 @@ type Report = { checkedAt: number; agents: { agent: string; state: string }[] }
const signedOut: Report = { checkedAt: 0, agents: [{ agent: 'claude', state: 'signedOut' }] }
const signedIn: Report = { checkedAt: 0, agents: [{ agent: 'claude', state: 'signedIn' }] }
const status = vi.hoisted(() => ({
fresh: null as Report | null,
refresh: vi.fn<() => Promise<Report | null>>()
}))
const status = vi.hoisted(() => {
const state: {
fresh: Report | null
refresh: ReturnType<typeof vi.fn<() => Promise<Report | null>>>
} = {
fresh: null,
refresh: vi.fn<() => Promise<Report | null>>()
}
return state
})
vi.mock('@/runtime/provider-accounts/sign-in/host-agent-sign-in-status-client', () => ({
readHostAgentSignInReport: () => status.fresh,
@@ -14,21 +14,21 @@ describe('desktop agent account', () => {
it('uses the selected account, else the System default login', () => {
const accounts = [account('a', 'work@example.com'), account('b', 'home@example.com')]
expect(
selectedAccountEmail('claude', {
selectedAccountEmail({
accounts,
activeAccountId: 'a',
activeAccountIdsByRuntime: { host: 'b', wsl: {} }
})
).toBe('home@example.com')
expect(
selectedAccountEmail('claude', {
selectedAccountEmail({
accounts,
activeAccountId: null,
systemDefaultEmail: 'default@example.com'
})
).toBe('default@example.com')
expect(
selectedAccountEmail('codex', {
selectedAccountEmail({
accounts: [],
activeAccountId: null,
systemDefault: {
@@ -10,7 +10,6 @@ const READ_BUDGET_MS = 1_500
/** The email of the account a launch would use: the selected one, else System default's. */
export function selectedAccountEmail(
agent: HostAgentSignInAgent,
state: ClaudeRateLimitAccountsState | CodexRateLimitAccountsState | null | undefined
): string | null {
if (!state) {
@@ -20,9 +19,10 @@ export function selectedAccountEmail(
if (selectedId) {
return state.accounts.find((account) => account.id === selectedId)?.email ?? null
}
return agent === 'claude'
? ((state as ClaudeRateLimitAccountsState).systemDefaultEmail ?? null)
: ((state as CodexRateLimitAccountsState).systemDefault?.email ?? null)
if ('systemDefaultEmail' in state) {
return state.systemDefaultEmail ?? null
}
return 'systemDefault' in state ? (state.systemDefault?.email ?? null) : null
}
/** The account this computer uses for `agent`; null in the web client, whose accounts live on its host. */
@@ -36,7 +36,7 @@ export async function readDesktopAgentEmail(agent: HostAgentSignInAgent): Promis
accounts?.list().catch(() => null) ?? null,
new Promise<null>((resolve) => setTimeout(() => resolve(null), READ_BUDGET_MS))
])
return selectedAccountEmail(agent, state)
return selectedAccountEmail(state)
}
/** The account this computer uses when the host signed in as a different one; null otherwise. */
@@ -11,8 +11,8 @@ vi.mock('@/lib/workspace/creation/worktree-creation-host-agent-launch', () => ({
const { hostSignInCheck, signedInHostLaunch } = await import('./host-agent-launch-sign-in')
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: only host and agent are read.
const onHost = (hostId: string | null) =>
const onHost = (hostId: string | null): WorktreeCreationRequest =>
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: only host and agent are read.
({ agent: 'claude', executionHostId: hostId }) as WorktreeCreationRequest
describe('host-started agent launch on a new VM', () => {
@@ -77,9 +77,9 @@ async function signInOne(
agent: HostAgentSignInAgent
): Promise<'proceed' | 'cancel'> {
const environmentId = runs.get(creationId)!.environmentId
let lastView: AgentSignInGateView | null = null
const seen: { view: AgentSignInGateView | null } = { view: null }
const unsubscribe = subscribeAgentSignInGates(() => {
lastView = readAgentSignInGate(gateKey)?.view ?? lastView
seen.view = readAgentSignInGate(gateKey)?.view ?? seen.view
})
try {
const held = requireAgentSignIn({
@@ -99,7 +99,7 @@ async function signInOne(
startAgentSignIn(gateKey)
}
const outcome = await held
const signed = lastView as AgentSignInGateView | null
const signed = seen.view
const run = runs.get(creationId)
if (outcome === 'proceed' && signed?.step === 'signed' && run?.gateKey === gateKey) {
update(creationId, gateKey, {