Skip to content

An open-source, faster Devin alternative

TypeScript

fix: persist Claude selection during Computer onboarding

Igor Zalutski via Computer5cb2aa8de736
diff --git a/web/src/managed-agents/AgentStep.test.tsx b/web/src/managed-agents/AgentStep.test.tsx
index 38231eae..d8721c6d 100644
--- a/web/src/managed-agents/AgentStep.test.tsx
+++ b/web/src/managed-agents/AgentStep.test.tsx
@@ -837,6 +837,41 @@ describe('choosing the coding agent', () => {
expect(computerApi.setAgentChoice).not.toHaveBeenCalled()
})
+ it('persists switching from Codex to Claude before connecting, including after reload', async () => {
+ let savedAgent: ComputerAgent = { ...withCodex, choice: 'codex' }
+ await show({ ...empty, agent: savedAgent }, 'Choose your coding agent')
+ await settle(() => command()?.includes(' codex ') === true, 'codex command')
+ computerApi.setAgentChoice.mockImplementation(async (choice) => {
+ savedAgent = { ...savedAgent, choice }
+ return savedAgent
+ })
+
+ act(() => claudeCard().click())
+ await settle(
+ () =>
+ computerApi.setAgentChoice.mock.calls.length === 1 &&
+ savedAgent.choice === 'claude',
+ 'saved Claude choice',
+ )
+ expect(computerApi.setAgentChoice).toHaveBeenCalledWith('claude')
+ await settle(
+ () => command()?.includes(' claude ') === true,
+ 'claude command',
+ )
+ expect(computerApi.connectClaudeSubscription).not.toHaveBeenCalled()
+
+ // A new root and query cache model a reload, using only the saved response.
+ act(() => root.unmount())
+ client.clear()
+ root = createRoot(container)
+ await show({ ...empty, agent: savedAgent }, 'Choose your coding agent')
+ await settle(
+ () => command()?.includes(' claude ') === true,
+ 'restored Claude command',
+ )
+ expect(computerApi.setAgentChoice).toHaveBeenCalledTimes(1)
+ })
+
describe('where this computer cannot run Codex yet', () => {
it.each([
['an older backend that names none', fresh],
diff --git a/web/src/managed-agents/AgentStep.tsx b/web/src/managed-agents/AgentStep.tsx
index 1ba13552..8777a762 100644
--- a/web/src/managed-agents/AgentStep.tsx
+++ b/web/src/managed-agents/AgentStep.tsx
@@ -236,14 +236,9 @@ export function AgentSetup({
const pick = (choice: AgentCardChoice) => {
if (choice === selected) return
onSelect(choice)
- // Codex is recorded on selection, so the step reopens on it after a
- // reload; so is any card this computer cannot run yet, as the interest
- // is all that card does.
- if (
- (choice === 'codex' || !isHarnessAvailable(agent, choice)) &&
- agent.choice !== choice
- )
- choose.mutate(choice)
+ // Persist either card immediately so a refresh restores what was selected,
+ // even before the person connects their subscription.
+ if (agent.choice !== choice) choose.mutate(choice)
}
const onCredits = !agent.subscription && agent.choice === 'credits'