Skip to content

An open-source, faster Devin alternative

TypeScript

web: join a setup token the terminal wrapped (work 081)

Igor Zalutski via Computerbcde54b68035
diff --git a/web/src/managed-agents/AgentStep.test.tsx b/web/src/managed-agents/AgentStep.test.tsx
index ceb32cad..2f704090 100644
--- a/web/src/managed-agents/AgentStep.test.tsx
+++ b/web/src/managed-agents/AgentStep.test.tsx
@@ -209,6 +209,22 @@ describe('choosing the coding agent', () => {
})
})
+ it('joins a token the terminal wrapped, and says when one is cut off', async () => {
+ await show({ ...empty, agent: fresh }, 'Choose your coding agent')
+ paste('sk-ant-oat01-short')
+ expect(text()).toContain('That token looks cut off.')
+ computerApi.connectClaudeSubscription.mockResolvedValue({
+ agent: { ...fresh, choice: 'claude', subscription: subscription('ok') },
+ verified: true,
+ via: 'pool',
+ })
+ paste(` ${TOKEN.slice(0, 25)}\n ${TOKEN.slice(25)} `)
+ expect(text()).not.toContain('cut off')
+ submit()
+ await settle(() => text().includes('Step 2 of 4'), 'Slack step')
+ expect(computerApi.connectClaudeSubscription).toHaveBeenCalledWith(TOKEN)
+ })
+
it('says a rejected token did not work, and empties the field', async () => {
await show({ ...empty, agent: fresh }, 'Choose your coding agent')
computerApi.connectClaudeSubscription.mockRejectedValue(
diff --git a/web/src/managed-agents/AgentStep.tsx b/web/src/managed-agents/AgentStep.tsx
index 799e83aa..0ec3710f 100644
--- a/web/src/managed-agents/AgentStep.tsx
+++ b/web/src/managed-agents/AgentStep.tsx
@@ -60,6 +60,12 @@ const FORMAT_ERROR = (
</>
)
+const CUT_OFF_ERROR = <>That token looks cut off. Copy all of it again.</>
+
+// The terminal wraps the long token, so a copy can carry the line break and
+// indentation. A setup token has no whitespace of its own.
+const cleanToken = (value: string) => value.replace(/\s+/g, '')
+
const SLACK_INSTRUCTION = (
<>
Connect from Slack: <Cmd>!claude connect</Cmd>
@@ -345,10 +351,14 @@ function ClaudeConnect({
}
}, [pending])
- const trimmed = token.trim()
+ const cleaned = cleanToken(token)
const badFormat =
- formatChecked && trimmed !== '' && !SETUP_TOKEN.test(trimmed)
- const error = badFormat ? FORMAT_ERROR : failure
+ formatChecked && cleaned !== '' && !SETUP_TOKEN.test(cleaned)
+ const error = badFormat
+ ? cleaned.startsWith('sk-ant-oat01-')
+ ? CUT_OFF_ERROR
+ : FORMAT_ERROR
+ : failure
return (
<form
@@ -357,11 +367,11 @@ function ClaudeConnect({
event.preventDefault()
setFormatChecked(true)
if (pending) return
- if (!SETUP_TOKEN.test(trimmed)) {
- if (trimmed !== '') trackAgentFailed('computer_agent_token_format')
+ if (!SETUP_TOKEN.test(cleaned)) {
+ if (cleaned !== '') trackAgentFailed('computer_agent_token_format')
return
}
- sending.current = trimmed
+ sending.current = cleaned
setToken('')
setFormatChecked(false)
setFailure(null)