An open-source, faster Devin alternative
TypeScript
Dashboard: scope-bound cancellation, no manifest retry, frozen name, superseded copy
Igor Zalutskiacf1ca2272b3
diff --git a/cloudflare-workers/api-edge/src/managed_agents.ts b/cloudflare-workers/api-edge/src/managed_agents.tsindex 2cdffa64..1264ae4d 100644--- a/cloudflare-workers/api-edge/src/managed_agents.ts+++ b/cloudflare-workers/api-edge/src/managed_agents.ts@@ -174,7 +174,7 @@ const SLACK_SETUP_ERROR_MESSAGES: Record<string, string> = {slack_enterprise_install_unsupported:"Organization-wide Slack installations are not supported. Install the app into a single workspace.",slack_setup_superseded:- "Another Slack connection change completed first. Check the current connection.",+ "This setup no longer owns the connection. Use Set up manually or start again.",};async function publicErrorResponse(upstream: Response): Promise<Response> {diff --git a/docs/agents/api.mdx b/docs/agents/api.mdxindex b003ffec..c03c147c 100644--- a/docs/agents/api.mdx+++ b/docs/agents/api.mdx@@ -549,14 +549,14 @@ Error codes, as HTTP errors or as `error.code` on the setup:| `slack_setup_busy` | `409` on cancel: the setup is creating or exchanging; wait for it to finish || `slack_setup_cancelled` | Recorded on a setup cancelled after the app was created or its creation was uncertain: the Slack app may still appear in the workspace's app list and can be removed there || `slack_configuration_token_invalid`, `slack_configuration_token_expired` | The token was rejected; generate a new one and submit it with the same key |-| `slack_manifest_rejected` | Slack rejected the generated app configuration; `pointer` names the field |+| `slack_manifest_rejected` | Slack rejected the generated app configuration; `pointer` names the field. Not recoverable in place: fix the declaration, redeploy, cancel the setup and start again || `slack_app_limit_reached` | The workspace cannot hold another app || `slack_rate_limited` | Wait `retryAfterMs` and submit again || `slack_provider_unavailable` | Slack declined with an unexpected error when creating the app, or did not answer during installation; submit or authorize again || `slack_creation_uncertain` | See phase `creation_uncertain` || `slack_exchange_failed`, `slack_exchange_uncertain`, `slack_authorization_denied`, `slack_authorization_expired` | The installation did not complete; authorize again || `slack_app_mismatch`, `slack_workspace_mismatch`, `slack_scope_missing`, `slack_enterprise_install_unsupported` | The installation did not match the created app, its established workspace or its declared scopes; authorize again and approve that app in a single workspace |-| `slack_setup_superseded` | A manual connection or reconnect completed first |+| `slack_setup_superseded` | The setup lost ownership of its connection to a manual connection or reconnect; set up manually or start again |The authorization URL opens Slack's consent page for the created app and isvalid for ten minutes; authorizing again issues a new one. Slack sends thediff --git a/web/src/managed-agents/Slack.test.tsx b/web/src/managed-agents/Slack.test.tsxindex 8b78e750..da8a2d0d 100644--- a/web/src/managed-agents/Slack.test.tsx+++ b/web/src/managed-agents/Slack.test.tsx@@ -48,6 +48,12 @@ const project = {activeDeploymentId: 'dep_coder',updatedAt: '2026-09-17T00:00:00.000Z',},+ {+ name: 'production',+ agentId: 'coder',+ activeDeploymentId: 'dep_coder_production',+ updatedAt: '2026-09-17T00:00:00.000Z',+ },],agents: [{ id: 'coder', name: 'Coder' }],createdAt: '2026-09-17T00:00:00.000Z',@@ -199,12 +205,13 @@ describe('ManagedProjectSlack', () => {function render(path = '/projects/prj_1/connections?environment=development',+ environment: 'development' | 'production' = 'development',) {act(() => {root.render(<QueryClientProvider client={client}><MemoryRouter initialEntries={[path]}>- <ManagedProjectSlack projectId="prj_1" environment="development" />+ <ManagedProjectSlack projectId="prj_1" environment={environment} /><LocationProbe /></MemoryRouter></QueryClientProvider>,@@ -388,6 +395,22 @@ describe('ManagedProjectSlack', () => {offered: ['Try another token', 'Cancel setup'],withheld: ['Authorize in Slack', 'Retry'],},+ {+ setup: setup({+ actions: ['cancel', 'manual'],+ error: {+ code: 'slack_manifest_rejected',+ message: 'Slack rejected the app manifest.',+ recoverable: false,+ pointer: '/oauth_config/scopes/bot',+ at: '2026-09-17T00:00:00.000Z',+ },+ }),+ title: 'Slack rejected the app manifest',+ offered: ['Cancel setup', 'Set up manually'],+ withheld: ['Try another token', 'Create Slack bot', 'Retry'],+ once: ['Set up manually'],+ },{setup: setup({ phase: 'creating', actions: [] }),title: 'Creating the Slack app…',@@ -468,7 +491,7 @@ describe('ManagedProjectSlack', () => {setup: setup({phase: 'app_created',app: { id: 'A1', name: 'Patch' },- actions: ['cancel'],+ actions: ['manual'],error: {code: 'slack_setup_superseded',message: 'superseded',@@ -476,9 +499,15 @@ describe('ManagedProjectSlack', () => {at: '2026-09-17T00:00:00.000Z',},}),- title: 'Another connection change completed first',- offered: ['Cancel setup'],- withheld: ['Authorize again', 'Authorize in Slack'],+ title: 'This setup no longer owns the connection',+ offered: ['Set up manually'],+ withheld: [+ 'Authorize again',+ 'Authorize in Slack',+ 'Cancel setup',+ 'Create Slack bot',+ ],+ once: ['Set up manually'],},{setup: setup({ phase: 'exchanging', actions: [] }),@@ -876,4 +905,140 @@ describe('ManagedProjectSlack', () => {expect(buttons(container)).not.toContain('Authorize in Slack')expect(buttons(container)).not.toContain('Cancel setup')})++ it('drops a cancellation confirmation when the environment changes', async () => {+ api.findManagedSlackSetup.mockImplementation(+ (target: { alias: 'development' | 'production' }) =>+ Promise.resolve(+ setup({+ id: `setup_${target.alias}`,+ alias: target.alias,+ phase: 'app_created',+ app: { id: 'A1', name: 'Patch' },+ actions: ['authorize', 'cancel'],+ }),+ ),+ )+ api.cancelManagedSlackSetup.mockResolvedValue(+ setup({ phase: 'cancelled', actions: [] }),+ )+ // Both environments were visited before: nothing loads in between.+ client.setQueryData(+ ['managed-agent-deployment', 'dep_coder_production'],+ dedicatedDeployment,+ )+ client.setQueryData(+ ['managed-agent-deployment', 'dep_coder'],+ dedicatedDeployment,+ )+ render(undefined, 'development')+ await settle(+ () => buttons(container).includes('Cancel setup'),+ 'development',+ )+ act(() => button(container, 'Cancel setup').click())+ await settle(+ () => document.body.querySelector('[role="alertdialog"]') !== null,+ 'the confirmation',+ )++ // Back navigation to the other environment: same panel, new scope.+ render(undefined, 'production')+ await settle(+ () =>+ api.findManagedSlackSetup.mock.calls.some(+ (call: unknown[]) =>+ (call[0] as { alias: string }).alias === 'production',+ ),+ 'the production lookup',+ )+ await settle(+ () => buttons(container).includes('Cancel setup'),+ 'production',+ )+ const stale = document.body.querySelector('[role="alertdialog"]')+ if (stale) act(() => button(stale as HTMLElement, 'Cancel setup').click())+ await act(async () => {+ await new Promise((resolve) => setTimeout(resolve, 0))+ })+ expect(document.body.querySelector('[role="alertdialog"]')).toBeNull()+ expect(api.cancelManagedSlackSetup).not.toHaveBeenCalled()+ })++ it('freezes the bot name once a request key has been used', async () => {+ render()+ await settle(() => text().includes('Create Slack bot'), 'the slot')+ act(() => button(container, 'Create Slack bot').click())+ await settle(+ () => document.body.querySelector('#managed-slack-setup-token') !== null,+ 'the dialog',+ )+ const tokenInput = document.body.querySelector(+ '#managed-slack-setup-token',+ ) as HTMLInputElement+ const nameInput = document.body.querySelector(+ '#managed-slack-setup-name',+ ) as HTMLInputElement+ const dialog = tokenInput.closest('[role="dialog"]') as HTMLElement+ act(() => typeInto(nameInput, 'Patch'))+ act(() => typeInto(tokenInput, 'xoxe.xoxp-first'))+ const first = deferred<ManagedSlackSetup>()+ api.startManagedSlackSetup.mockReturnValueOnce(first.promise)+ act(() => button(dialog, 'Create Slack bot').click())+ await settle(+ () => api.startManagedSlackSetup.mock.calls.length === 1,+ 'the first submit',+ )+ // The intent is fixed from here on: an edit attempt changes nothing.+ act(() => typeInto(nameInput, 'Patched'))+ expect(nameInput.value).toBe('Patch')+ expect(nameInput.readOnly).toBe(true)++ const firstCall = api.startManagedSlackSetup.mock.calls[0][0] as {+ requestKey: string+ name: string+ }+ await act(async () => {+ first.resolve(+ setup({+ requestKey: firstCall.requestKey,+ name: 'Patch',+ error: {+ code: 'slack_configuration_token_invalid',+ message: 'invalid_auth',+ recoverable: true,+ at: '2026-09-17T00:01:00.000Z',+ },+ }),+ )+ await first.promise+ })+ await settle(+ () =>+ dialog.textContent?.includes(+ 'Slack rejected the configuration token',+ ) ?? false,+ 'the rejection',+ )+ act(() => typeInto(nameInput, 'Other'))+ expect(nameInput.value).toBe('Patch')+ api.startManagedSlackSetup.mockResolvedValueOnce(+ setup({+ requestKey: firstCall.requestKey,+ phase: 'creating',+ actions: [],+ }),+ )+ act(() => typeInto(tokenInput, 'xoxe.xoxp-second'))+ act(() => button(dialog, 'Try another token').click())+ await settle(+ () => api.startManagedSlackSetup.mock.calls.length === 2,+ 'the retry',+ )+ expect(api.startManagedSlackSetup.mock.calls[1][0]).toMatchObject({+ requestKey: firstCall.requestKey,+ name: 'Patch',+ configurationToken: 'xoxe.xoxp-second',+ })+ })})diff --git a/web/src/managed-agents/Slack.tsx b/web/src/managed-agents/Slack.tsxindex be44de69..3fa6d5d6 100644--- a/web/src/managed-agents/Slack.tsx+++ b/web/src/managed-agents/Slack.tsx@@ -216,7 +216,7 @@ export function ManagedProjectSlack({) : (slots.map((slot) => (<SlackSlotRow- key={slot.key}+ key={`${projectId}:${environment}:${slot.key}`}slot={slot}environment={environment}agentNames={agentNames}@@ -339,7 +339,12 @@ function SlackAutomaticSetup({const connection = slot.connectionconst connected = connection?.status === 'connected'const [dialogOpen, setDialogOpen] = useState(false)- const [confirmCancel, setConfirmCancel] = useState(false)+ // The confirmation names the setup it was opened for, in the environment+ // it was opened in; it never cancels whatever is current when confirmed.+ const [cancelTarget, setCancelTarget] = useState<{+ setupId: string+ environment: Environment+ }>()const setupQuery = useQuery({queryKey,@@ -393,7 +398,7 @@ function SlackAutomaticSetup({const cancel = useMutation({mutationFn: (setupId: string) => cancelManagedSlackSetup(setupId),onSuccess: (cancelled) => {- setConfirmCancel(false)+ setCancelTarget(undefined)// The cancelled record stays on screen with the platform's message// until the next lookup, which answers only non-cancelled setups.queryClient.setQueryData(queryKey, cancelled)@@ -548,7 +553,9 @@ function SlackAutomaticSetup({<Buttonsize="sm"variant="ghost"- onClick={() => setConfirmCancel(true)}+ onClick={() =>+ setCancelTarget({ setupId: resumable.id, environment })+ }>Cancel setup</Button>@@ -571,15 +578,21 @@ function SlackAutomaticSetup({) : null}<ConfirmDialog- open={confirmCancel}- onOpenChange={setConfirmCancel}+ open={Boolean(cancelTarget)}+ onOpenChange={(open) => {+ if (!open) setCancelTarget(undefined)+ }}title="Cancel Slack setup?"description="The setup is removed from OpenComputer. If Slack already created the app, it stays in your Slack app list; delete it there if you do not need it."confirmLabel="Cancel setup"cancelLabel="Keep"destructivepending={cancel.isPending}- onConfirm={() => resumable && cancel.mutate(resumable.id)}+ onConfirm={() => {+ if (cancelTarget && cancelTarget.environment === environment) {+ cancel.mutate(cancelTarget.setupId)+ }+ }}/></div>)@@ -610,7 +623,10 @@ function SlackSetupDialog({const [requestKey] = useState(() => setup?.requestKey ?? newSlackSetupRequestKey(),)- const resuming = Boolean(setup)+ // The name the request key was first used with; retries send it (the+ // persisted setup's name once the platform has answered), never an edit.+ const intentName = useRef(setup?.name)+ const [nameFrozen, setNameFrozen] = useState(Boolean(setup))const [name, setName] = useState(defaultName)const [token, setToken] = useState('')const [outcome, setOutcome] = useState<ManagedSlackSetup>()@@ -629,7 +645,7 @@ function SlackSetupDialog({tokenRef.current = ''const result = await startManagedSlackSetup({...target,- name: name.trim(),+ name: intentName.current ?? name.trim(),requestKey,configurationToken,})@@ -642,11 +658,13 @@ function SlackSetupDialog({return result},onSuccess: (result) => {- if (result.phase === 'prepared') {+ intentName.current = result.name+ if (result.phase === 'prepared' && result.error?.recoverable) {// An explicit rejection with no side effect: fix the token, same key.setOutcome(result)return}+ // Anything else is shown by the panel from the platform's record.onClose()},onError: (error) => {@@ -682,8 +700,17 @@ function SlackSetupDialog({const submit = (event: FormEvent) => {event.preventDefault()- if (inFlight.current || !name.trim() || !token.trim()) return+ if (+ inFlight.current ||+ !(intentName.current ?? name).trim() ||+ !token.trim()+ )+ returninFlight.current = true+ if (intentName.current === undefined) {+ intentName.current = name.trim()+ setNameFrozen(true)+ }tokenRef.current = token.trim()setOutcome(undefined)setSubmitError(undefined)@@ -715,8 +742,8 @@ function SlackSetupDialog({label="Bot name"htmlFor="managed-slack-setup-name"description={- resuming- ? 'This setup already has a name. Cancel it to start over with another.'+ nameFrozen+ ? 'The name is fixed once submitted. Cancel the setup to start over with another.': 'What people will see in Slack.'}>@@ -724,8 +751,10 @@ function SlackSetupDialog({id="managed-slack-setup-name"value={name}maxLength={35}- readOnly={resuming}- onChange={(event) => setName(event.target.value)}+ readOnly={nameFrozen}+ onChange={(event) => {+ if (!nameFrozen) setName(event.target.value)+ }}/></Field><Fielddiff --git a/web/src/managed-agents/slack-setup.test.ts b/web/src/managed-agents/slack-setup.test.tsindex 0d7e6d7d..5dfcfcd9 100644--- a/web/src/managed-agents/slack-setup.test.ts+++ b/web/src/managed-agents/slack-setup.test.ts@@ -359,6 +359,44 @@ describe('setup copy', () => {).toBeUndefined()})+ it('does not offer a retry for a rejected manifest, which needs a redeploy and a new setup', () => {+ const view = describeSlackSetup(+ setup({+ actions: ['cancel', 'manual'],+ error: {+ code: 'slack_manifest_rejected',+ message: 'Slack rejected the app manifest.',+ recoverable: false,+ pointer: '/oauth_config/scopes/bot',+ at: '2026-09-18T08:00:00.000Z',+ },+ }),+ )+ expect(view.title).toBe('Slack rejected the app manifest')+ expect(view.description).toContain('redeploy')+ expect(view.description).toContain('Cancel')+ expect(view.primary).toBeUndefined()+ })++ it('reports a setup that lost its connection in any phase', () => {+ for (const phase of ['app_created', 'exchanging', 'prepared'] as const) {+ const view = describeSlackSetup(+ setup({+ phase,+ actions: ['manual'],+ error: {+ code: 'slack_setup_superseded',+ message: 'superseded',+ recoverable: false,+ at: '2026-09-18T08:00:00.000Z',+ },+ }),+ )+ expect(view.title, phase).toBe('This setup no longer owns the connection')+ expect(view.primary, phase).toBeUndefined()+ }+ })+it('shows the platform message on a cancelled setup and offers a fresh start', () => {const message ="This Slack setup was cancelled. The Slack app may still appear in your workspace's app list and can be removed there."diff --git a/web/src/managed-agents/slack-setup.ts b/web/src/managed-agents/slack-setup.tsindex f6868702..013632f0 100644--- a/web/src/managed-agents/slack-setup.ts+++ b/web/src/managed-agents/slack-setup.ts@@ -184,6 +184,14 @@ export function describeSlackSetup(}const name = setup.app?.name ?? setup.nameconst error = setup.error+ if (error?.code === 'slack_setup_superseded') {+ return {+ title: 'This setup no longer owns the connection',+ description:+ 'A manual connection or reconnect replaced it. Use Set up manually, or start again.',+ tone: 'error',+ }+ }switch (setup.phase) {case 'prepared': {if (!error) {@@ -194,7 +202,11 @@ export function describeSlackSetup(primary: { action: 'create', label: 'Create Slack bot' },}}- const retry = { action: 'create', label: 'Try another token' } as const+ // Only an explicit rejection with no side effect is retried with a+ // new token; anything the platform marks unrecoverable is not.+ const retry = error.recoverable+ ? ({ action: 'create', label: 'Try another token' } as const)+ : undefinedswitch (error.code) {case 'slack_configuration_token_invalid':return {@@ -215,9 +227,8 @@ export function describeSlackSetup(case 'slack_manifest_rejected':return {title: 'Slack rejected the app manifest',- description: `${error.message} Check the channel's declared scopes and events, redeploy, then submit a token again.`,+ description: `${error.message} Fix the channel declaration and redeploy, then Cancel this setup and create the bot again, or set it up manually.`,tone: 'error',- primary: retry,}case 'slack_app_limit_reached':return {@@ -339,13 +350,6 @@ export function describeSlackSetup(tone: 'error',primary: authorize,}- case 'slack_setup_superseded':- return {- title: 'Another connection change completed first',- description:- 'A manual connection or reconnect won while this app was being installed. This setup is no longer needed; check the current connection.',- tone: 'error',- }default:return {title: 'The installation did not complete',