Skip to content

An open-source, faster Devin alternative

TypeScript

fix(slack): clarify connection lifecycle states

Igor Zalutskia3d6e7817bc5
diff --git a/docs/agent-sessions/slack.mdx b/docs/agent-sessions/slack.mdx
index c544871c..3adfcea5 100644
--- a/docs/agent-sessions/slack.mdx
+++ b/docs/agent-sessions/slack.mdx
@@ -27,6 +27,12 @@ short deploying response and is not queued. Wait for the dashboard to show
with an agent whose tools and spend are appropriately bounded.
</Warning>
+<Note>
+ A workspace can connect the managed app to one agent at a time. Managed Slack
+ accepts text direct messages and mentions in ordinary workspace channels.
+ Files and mentions in Slack Connect channels are not supported yet.
+</Note>
+
The same flow is available over the API:
<CodeGroup>
diff --git a/sdks/typescript/src/agents/agents.test.ts b/sdks/typescript/src/agents/agents.test.ts
index 9331d1b5..624904d9 100644
--- a/sdks/typescript/src/agents/agents.test.ts
+++ b/sdks/typescript/src/agents/agents.test.ts
@@ -1,7 +1,32 @@
import { describe, expect, it, vi } from "vitest";
import { OpenComputer } from "./client.js";
-describe("Agents managed Slack", () => {
+describe("Agents Slack", () => {
+ it("exposes the builder-owned app deep link", async () => {
+ const fetcher = vi.fn(async () =>
+ Response.json({
+ id: "sla_1",
+ agent_id: "agt_1",
+ status: "active",
+ slack_app_id: "A1",
+ team_id: "T1",
+ open_url: "https://slack.com/app_redirect?app=A1&team=T1",
+ }),
+ );
+ const oc = new OpenComputer({
+ apiKey: "test-key",
+ baseUrl: "https://api.example.test/v3",
+ fetch: fetcher as typeof fetch,
+ maxRetries: 0,
+ });
+
+ const result = await oc.agents.getSlack("agt_1");
+
+ expect(result.openUrl).toBe(
+ "https://slack.com/app_redirect?app=A1&team=T1",
+ );
+ });
+
it("starts OAuth with validated deployment return context", async () => {
const fetcher = vi.fn(async (_input: RequestInfo | URL, init?: RequestInit) =>
Response.json({
diff --git a/sdks/typescript/src/agents/agents.ts b/sdks/typescript/src/agents/agents.ts
index 2f7cd7fc..4f8d3bdd 100644
--- a/sdks/typescript/src/agents/agents.ts
+++ b/sdks/typescript/src/agents/agents.ts
@@ -48,6 +48,7 @@ export interface SlackConnection {
slackAppId?: string | null;
teamId?: string | null;
accountLogin?: string | null;
+ openUrl?: string | null;
}
/** The three values pasted back from Slack to finalize a connection. */
diff --git a/web/src/components/slack-connect.render.test.tsx b/web/src/components/slack-connect.render.test.tsx
new file mode 100644
index 00000000..be59e4b9
--- /dev/null
+++ b/web/src/components/slack-connect.render.test.tsx
@@ -0,0 +1,71 @@
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
+import { renderToStaticMarkup } from 'react-dom/server'
+import { MemoryRouter } from 'react-router-dom'
+import { describe, expect, it } from 'vitest'
+import { SlackConnect } from './slack-connect'
+
+const agentId = 'agt_aaaaaaaaaaaaaaaaaaaaaaaa'
+const connectedAgentId = 'agt_bbbbbbbbbbbbbbbbbbbbbbbb'
+
+function renderSlackConnect(
+ managed: Record<string, unknown> | null,
+ url = `/agents/${agentId}`,
+ connectedAgentName?: string,
+) {
+ const queryClient = new QueryClient({
+ defaultOptions: { queries: { retry: false, staleTime: Infinity } },
+ })
+ queryClient.setQueryData(['slack', 'managed', agentId], managed)
+ queryClient.setQueryData(['slack', 'byo', agentId], null)
+ if (connectedAgentName) {
+ queryClient.setQueryData(['agent', connectedAgentId], {
+ id: connectedAgentId,
+ name: connectedAgentName,
+ })
+ }
+
+ return renderToStaticMarkup(
+ <QueryClientProvider client={queryClient}>
+ <MemoryRouter initialEntries={[url]}>
+ <SlackConnect agentId={agentId} agentName="Support triage" />
+ </MemoryRouter>
+ </QueryClientProvider>,
+ )
+}
+
+describe('SlackConnect managed states', () => {
+ it('preserves disconnected lifecycle truth and offers reconnection', () => {
+ const markup = renderSlackConnect({
+ mode: 'managed',
+ status: 'disconnected',
+ workspace: { id: 'T1', name: 'Acme' },
+ app: { id: 'A1', handle: 'OpenComputer' },
+ connected_at: '2026-07-16T18:00:00Z',
+ })
+
+ expect(markup).toContain('no longer receives messages')
+ expect(markup).toContain('Connect Slack again')
+ })
+
+ it('names and links a same-owner workspace conflict', () => {
+ const markup = renderSlackConnect(
+ null,
+ `/agents/${agentId}?slack=workspace_already_connected&connected_agent=${connectedAgentId}`,
+ 'Docs writer',
+ )
+
+ expect(markup).toContain('This workspace sends messages to Docs writer.')
+ expect(markup).toContain(`href="/agents/${connectedAgentId}"`)
+ expect(markup).toContain('Open connected agent')
+ })
+
+ it('keeps a cross-owner workspace conflict anonymous', () => {
+ const markup = renderSlackConnect(
+ null,
+ `/agents/${agentId}?slack=workspace_already_connected`,
+ )
+
+ expect(markup).toContain('Use your own Slack app for this agent.')
+ expect(markup).not.toContain('Open connected agent')
+ })
+})
diff --git a/web/src/components/slack-connect.test.ts b/web/src/components/slack-connect.test.ts
index d33b5e50..6adcc48f 100644
--- a/web/src/components/slack-connect.test.ts
+++ b/web/src/components/slack-connect.test.ts
@@ -24,4 +24,23 @@ describe('managed Slack OAuth notices', () => {
managedSlackNotice('provider_message_here', null, 'Agent'),
).toBeNull()
})
+
+ it('names a same-owner agent in a workspace conflict', () => {
+ expect(
+ managedSlackNotice(
+ 'workspace_already_connected',
+ null,
+ 'Support triage',
+ 'Docs writer',
+ ),
+ ).toMatchObject({
+ description: 'This workspace sends messages to Docs writer.',
+ })
+ })
+
+ it('does not suggest an inaccessible agent for a cross-owner conflict', () => {
+ expect(
+ managedSlackNotice('workspace_already_connected', null, 'Support triage'),
+ ).toMatchObject({ description: 'Use your own Slack app for this agent.' })
+ })
})
diff --git a/web/src/components/slack-connect.tsx b/web/src/components/slack-connect.tsx
index ec9e070f..a3ab0ddf 100644
--- a/web/src/components/slack-connect.tsx
+++ b/web/src/components/slack-connect.tsx
@@ -6,6 +6,7 @@ import { notifyError } from '@/lib/errors'
import {
authorizeManagedSlack,
disconnectManagedSlack,
+ getAgent,
getManagedSlackConnection,
getSlackConnection,
startSlackConnect,
@@ -54,7 +55,11 @@ function WizardSteps({ current }: { current: number }) {
const done = i < current
const active = i === current
return (
- <li key={label} className="flex min-w-0 items-center gap-2">
+ <li
+ key={label}
+ className="flex min-w-0 items-center gap-2"
+ aria-current={active ? 'step' : undefined}
+ >
<span
className={cn(
'flex size-5 shrink-0 items-center justify-center rounded-full text-[11px] font-semibold',
@@ -63,7 +68,7 @@ function WizardSteps({ current }: { current: number }) {
: 'bg-secondary text-muted-foreground',
)}
>
- {done ? <Check className="size-3" /> : i + 1}
+ {done ? <Check className="size-3" aria-hidden /> : i + 1}
</span>
<span
className={cn(
@@ -73,6 +78,7 @@ function WizardSteps({ current }: { current: number }) {
: 'text-muted-foreground',
)}
>
+ {done ? <span className="sr-only">Completed: </span> : null}
{label}
</span>
{i < WIZARD_STEPS.length - 1 ? (
@@ -231,14 +237,34 @@ export function SlackConnect({
const managedActive = managed?.status === 'active'
const managedNeedsReconnect =
managed?.status === 'error' || managed?.status === 'revoked'
+ const managedDisconnected = managed?.status === 'disconnected'
const managedWorkspace = managed?.workspace?.name || managed?.workspace?.id
const oauthResult = searchParams.get('slack')
const connectedAgentId = searchParams.get('connected_agent')
- const notice = managedSlackNotice(oauthResult, managedWorkspace, agentName)
- const connectedAgentHref =
+ const sameOwnerConnectedAgentId =
oauthResult === 'workspace_already_connected' &&
- connectedAgentId?.startsWith('agt_')
- ? `/agents/${encodeURIComponent(connectedAgentId)}`
+ connectedAgentId &&
+ /^agt_[0-9a-f]{24}$/.test(connectedAgentId)
+ ? connectedAgentId
+ : null
+ const connectedAgentQuery = useQuery({
+ queryKey: ['agent', sameOwnerConnectedAgentId],
+ queryFn: () => getAgent(sameOwnerConnectedAgentId!),
+ enabled: !!sameOwnerConnectedAgentId,
+ })
+ const connectedAgentName = connectedAgentQuery.data?.name ?? null
+ const notice =
+ sameOwnerConnectedAgentId && connectedAgentQuery.isLoading
+ ? null
+ : managedSlackNotice(
+ oauthResult,
+ managedWorkspace,
+ agentName,
+ connectedAgentName,
+ )
+ const connectedAgentHref =
+ connectedAgentQuery.data && sameOwnerConnectedAgentId
+ ? `/agents/${encodeURIComponent(sameOwnerConnectedAgentId)}`
: null
const dismissNotice = () => {
const next = new URLSearchParams(searchParams)
@@ -295,7 +321,7 @@ export function SlackConnect({
<h3 id="managed-slack-title" className="text-sm font-medium">
OpenComputer app
</h3>
- {!managedActive ? (
+ {!managedActive && !managedDisconnected ? (
<p className="text-muted-foreground text-xs leading-relaxed">
Connect the shared app to try this agent in Slack.
</p>
@@ -377,6 +403,26 @@ export function SlackConnect({
: 'Reconnect Slack'}
</Button>
</div>
+ ) : managedDisconnected ? (
+ <div className="space-y-3">
+ <p className="text-muted-foreground text-xs leading-relaxed">
+ Disconnected. This agent no longer receives messages from the
+ OpenComputer app.
+ </p>
+ <p className="text-muted-foreground text-xs leading-relaxed">
+ Anyone in this Slack workspace who can message the app can use
+ this agent after you reconnect it.
+ </p>
+ <Button
+ size="sm"
+ onClick={() => authorizeManagedMutation.mutate()}
+ disabled={authorizeManagedMutation.isPending}
+ >
+ {authorizeManagedMutation.isPending
+ ? 'Connecting…'
+ : 'Connect Slack again'}
+ </Button>
+ </div>
) : (
<div className="space-y-3">
<p className="text-muted-foreground text-xs leading-relaxed">
diff --git a/web/src/lib/managed-slack-notice.ts b/web/src/lib/managed-slack-notice.ts
index 6648f22c..8877ae8d 100644
--- a/web/src/lib/managed-slack-notice.ts
+++ b/web/src/lib/managed-slack-notice.ts
@@ -15,6 +15,7 @@ export function managedSlackNotice(
result: string | null,
workspace: string | null | undefined,
agentName: string,
+ connectedAgentName?: string | null,
): { title: string; description?: string; destructive?: boolean } | null {
if (!result || !MANAGED_SLACK_RESULTS.has(result)) return null
switch (result) {
@@ -55,8 +56,9 @@ export function managedSlackNotice(
case 'workspace_already_connected':
return {
title: 'This Slack workspace is already connected',
- description:
- 'Open its connected agent, or use your own Slack app for this one.',
+ description: connectedAgentName
+ ? `This workspace sends messages to ${connectedAgentName}.`
+ : 'Use your own Slack app for this agent.',
destructive: true,
}
case 'oauth_exchange_failed':