An open-source, faster Devin alternative
TypeScript
Connections: the organization's Slack app and GitHub, nothing else
Slack U06H7D98X4099df8a3b0f52
diff --git a/web/src/api/mock.ts b/web/src/api/mock.tsindex d8b0ce57..ac5affa7 100644--- a/web/src/api/mock.ts+++ b/web/src/api/mock.ts@@ -1364,6 +1364,25 @@ const ROUTES: Array<[RegExp, Handler]> = [/^\/managed-agents\/computer\/sessions$/,() => ({ sessions: previewComputerSessions() }),],+ [+ /^\/managed-agents\/github$/,+ () => ({+ // The same accounts the computer reports, with none before setup.+ connections: previewComputer().github.installations.map(+ (installation, index) => ({+ id: `ghc_preview_${installation.id}`,+ githubInstallationId: 1000 + Number(installation.id),+ accountLogin: installation.accountLogin,+ accountType: 'Organization',+ repositorySelection: index === 0 ? 'all' : 'selected',+ state: 'active',+ createdAt: new Date(BASE).toISOString(),+ updatedAt: new Date(BASE).toISOString(),+ }),+ ),+ app: { slug: 'opencomputerdev' },+ }),+ ],[/^\/managed-agents\/account\/runtime-profile$/,() => ({ customized: false, displayName: 'OpenComputer default' }),diff --git a/web/src/components/slack-mark.tsx b/web/src/components/slack-mark.tsxnew file mode 100644index 00000000..67753317--- /dev/null+++ b/web/src/components/slack-mark.tsx@@ -0,0 +1,14 @@+// Slack's mark as one path. Inherits color via `currentColor`; size via+// className (e.g. `size-4`), like GithubMark.+export function SlackMark({ className }: { className?: string }) {+ return (+ <svg+ viewBox="0 0 24 24"+ fill="currentColor"+ className={className}+ aria-hidden="true"+ >+ <path d="M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zM6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313zM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zM8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312zM18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834zM17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312zM15.165 18.956a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zM15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z" />+ </svg>+ )+}diff --git a/web/src/managed-agents/Computer.tsx b/web/src/managed-agents/Computer.tsxindex 692dee3a..589cfce9 100644--- a/web/src/managed-agents/Computer.tsx+++ b/web/src/managed-agents/Computer.tsx@@ -25,13 +25,11 @@ import {Route,ShieldCheck,Terminal,- Send,TriangleAlert,Unplug,UsersRound,X,} from 'lucide-react'-import { ConfirmDialog } from '@/components/confirm-dialog'import { EmptyState } from '@/components/empty-state'import { GithubMark } from '@/components/github-mark'import { CopyRow } from '@/components/copy-row'@@ -58,14 +56,13 @@ import { PixelScene } from './pixel-scene'import { AuthContext } from '@/hooks/useAuth'import { addManagedGitHubConnection } from './api'import { launchAuthorizationWindow } from './authorization-window'+import { SlackInstallButton, UnlinkSlackDialog } from './computer-slack'import {computerQueryKey,computerSessionsQueryKey,createComputer,getComputer,getComputerSessions,- startComputerSlackInstall,- unlinkComputerSlack,type ComputerSession,type ComputerStatus,} from './computer-api'@@ -1080,22 +1077,7 @@ function ConnectionsMenu({status: ComputerStatusmanage?: boolean}) {- const queryClient = useQueryClient()const [confirmUnlink, setConfirmUnlink] = useState(false)- const unlink = useMutation({- mutationFn: unlinkComputerSlack,- onSuccess: async () => {- setConfirmUnlink(false)- await queryClient.invalidateQueries({ queryKey: computerQueryKey })- notifySuccess(- 'Slack workspace unlinked.',- 'Remove the app in Slack to uninstall it there too.',- )- },- onError: (error) => notifyError("Couldn't unlink Slack.", error),- })-- const teamName = status.slack.teamName ?? 'this Slack workspace'return (<><DropdownMenu>@@ -1127,52 +1109,15 @@ function ConnectionsMenu({</DropdownMenuItem></DropdownMenuContent></DropdownMenu>- <ConfirmDialog+ <UnlinkSlackDialog+ teamName={status.slack.teamName}open={confirmUnlink}onOpenChange={setConfirmUnlink}- title={`Unlink ${teamName}?`}- description="Your computer stops answering in this workspace. The app stays installed in Slack until you remove it there, and you can link a workspace again at any time."- confirmLabel="Unlink Slack"- destructive- pending={unlink.isPending}- onConfirm={() => unlink.mutate()}/></>)}-function SlackInstallButton({- variant = 'default',- size = 'default',- label = 'Install Slack app',-}: {- variant?: 'default' | 'outline'- size?: 'default' | 'lg'- label?: string-}) {- const install = useMutation({- mutationFn: startComputerSlackInstall,- onSuccess: (url) => window.location.assign(url),- onError: (error) => notifyError("Couldn't start the Slack install.", error),- })- return (- <Button- variant={variant}- size={size}- // Stays pending through the navigation to Slack.- disabled={install.isPending || install.isSuccess}- onClick={() => install.mutate()}- >- {install.isPending || install.isSuccess ? (- <Loader2 className="size-4 animate-spin" aria-hidden />- ) : (- <Send className="size-4" aria-hidden />- )}- {label}- </Button>- )-}-function GitHubAction({ size = 'default' }: { size?: 'default' | 'lg' }) {const [starting, setStarting] = useState(false)return (diff --git a/web/src/managed-agents/Connections.test.tsx b/web/src/managed-agents/Connections.test.tsxnew file mode 100644index 00000000..aa92651c--- /dev/null+++ b/web/src/managed-agents/Connections.test.tsx@@ -0,0 +1,151 @@+// @vitest-environment happy-dom++import { act } from 'react'+import { createRoot, type Root } from 'react-dom/client'+import { QueryClient, QueryClientProvider } from '@tanstack/react-query'+import { MemoryRouter } from 'react-router-dom'+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'++const computerApi = vi.hoisted(() => ({+ getComputer: vi.fn(),+ startComputerSlackInstall: vi.fn(),+ unlinkComputerSlack: vi.fn(),+}))+vi.mock('./computer-api', async (importOriginal) => ({+ ...(await importOriginal<typeof import('./computer-api')>()),+ ...computerApi,+}))+const api = vi.hoisted(() => ({+ displayManagedAgentName: (agent: { id: string }) => agent.id,+ addManagedGitHubConnection: vi.fn(),+ claimManagedAgentChannelIdentity: vi.fn(),+ disconnectManagedAgentConnection: vi.fn(),+ getManagedAgentConnections: vi.fn(),+ getManagedGitHubConnections: vi.fn(),+ getManagedAgents: vi.fn(),+ linkManagedAgentConnection: vi.fn(),+ refreshManagedAgentConnection: vi.fn(),+}))+vi.mock('./api', () => api)++const { default: ConnectionsPage } = await import('./Connections')+const { AuthContext } = await import('@/hooks/useAuth')+const auth = {+ user: {+ id: 'u1',+ email: '[email protected]',+ orgId: 'org_1',+ durableSessionsEnabled: false,+ infrastructureEnabled: false,+ computerEnabled: true,+ },+ loading: false,+ error: null,+ switchOrg: async () => {},+ refreshUser: async () => {},+} as const++const installation = {+ id: 'ghc_1',+ githubInstallationId: 7,+ accountLogin: 'acme',+ accountType: 'Organization',+ repositorySelection: 'all' as const,+ state: 'active' as const,+ createdAt: '2026-10-11T10:00:00.000Z',+ updatedAt: '2026-10-11T10:00:00.000Z',+}++let root: Root | undefined+let container: HTMLDivElement++async function render() {+ const client = new QueryClient({+ defaultOptions: { queries: { retry: false } },+ })+ container = document.createElement('div')+ document.body.append(container)+ root = createRoot(container)+ act(() => {+ root?.render(+ <AuthContext.Provider value={auth}>+ <QueryClientProvider client={client}>+ <MemoryRouter initialEntries={['/managed-agents/connections']}>+ <ConnectionsPage />+ </MemoryRouter>+ </QueryClientProvider>+ </AuthContext.Provider>,+ )+ })+ // Queries resolve, then the ones they enable (agent names) do.+ for (let tick = 0; tick < 3; tick++) {+ await act(async () => {+ await new Promise((resolve) => setTimeout(resolve, 0))+ })+ }+}++beforeEach(() => {+ ;(+ globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }+ ).IS_REACT_ACT_ENVIRONMENT = true+ computerApi.getComputer.mockResolvedValue({+ computer: null,+ slack: { installed: true, teamId: 'T1', teamName: 'Acme' },+ github: { connected: true, installations: [] },+ plan: 'free',+ })+ api.getManagedGitHubConnections.mockResolvedValue({+ connections: [installation],+ app: { slug: 'opencomputerdev' },+ })+ api.getManagedAgentConnections.mockResolvedValue([])+ api.getManagedAgents.mockResolvedValue([])+})++afterEach(() => {+ act(() => root?.unmount())+ container.remove()+ vi.clearAllMocks()+})++describe('Connections', () => {+ it('shows the organization Slack app and GitHub accounts, with nothing to add beyond them', async () => {+ await render()+ const text = container.textContent ?? ''+ expect(text).toContain('Installed in Acme')+ expect(text).toContain('acme')+ expect(text).toContain('All repositories')+ expect(text).not.toContain('Add connection')+ expect(text).not.toContain('Personal accounts')+ const configure = container.querySelector<HTMLAnchorElement>(+ 'a[href*="/settings/installations/"]',+ )+ expect(configure?.href).toBe(+ 'https://github.com/organizations/acme/settings/installations/7',+ )+ })++ it('lists personal accounts agents already connected, without repeating the name', async () => {+ api.getManagedAgentConnections.mockResolvedValue([+ {+ id: 'conn_1',+ kind: 'tool',+ provider: 'google',+ label: 'gmail',+ agentId: '',+ alias: 'gmail',+ displayName: 'Gmail',+ scopes: ['https://www.googleapis.com/auth/gmail.readonly'],+ status: 'connected',+ createdAt: '2026-10-11T10:00:00.000Z',+ },+ ])+ await render()+ expect(container.textContent).toContain('Personal accounts')+ expect(container.textContent).not.toContain('Gmail · Gmail')+ expect(+ container.querySelector('[aria-label="Remove gmail connection"]'),+ ).not.toBeNull()+ })+})diff --git a/web/src/managed-agents/Connections.tsx b/web/src/managed-agents/Connections.tsxindex 40193888..e8547eac 100644--- a/web/src/managed-agents/Connections.tsx+++ b/web/src/managed-agents/Connections.tsx@@ -1,30 +1,32 @@-import { useEffect, useRef, useState } from 'react'+import { useContext, useEffect, useRef, useState, type ReactNode } from 'react'import { useQuery } from '@tanstack/react-query'-import { Loader2, Plug, Plus, Trash2 } from 'lucide-react'+import {+ Ellipsis,+ ExternalLink,+ Loader2,+ Plus,+ RefreshCw,+ Trash2,+ Unplug,+} from 'lucide-react'import { useSearchParams } from 'react-router-dom'import { ConfirmDialog } from '@/components/confirm-dialog'import { GithubMark } from '@/components/github-mark'import { PageHeader } from '@/components/page-header'+import { Panel } from '@/components/panel'import { ServiceLogo } from '@/components/service-logo'-import {- Panel,- PanelContent,- PanelDescription,- PanelHeader,- PanelTitle,-} from '@/components/panel'+import { SlackMark } from '@/components/slack-mark'import { StatusBadge } from '@/components/status-badge'import { Button } from '@/components/ui/button'import {- Dialog,- DialogContent,- DialogDescription,- DialogFooter,- DialogHeader,- DialogTitle,-} from '@/components/ui/dialog'-import { Input } from '@/components/ui/input'-import { Label } from '@/components/ui/label'+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuTrigger,+} from '@/components/ui/dropdown-menu'+import { Skeleton } from '@/components/ui/skeleton'+import { AuthContext } from '@/hooks/useAuth'+import { notifyError } from '@/lib/errors'import {displayManagedAgentName,addManagedGitHubConnection,@@ -37,10 +39,15 @@ import {refreshManagedAgentConnection,type ManagedAgentConnection,} from './api'-import {- navigateAuthorizationWindow,- openAuthorizationWindow,-} from './authorization-window'+import { launchAuthorizationWindow } from './authorization-window'+import { computerQueryKey, getComputer } from './computer-api'+import { SlackInstallButton, UnlinkSlackDialog } from './computer-slack'+import { slackLinks } from './computer-state'++// The organization's connections: the Slack app the computer answers in and+// the GitHub accounts it works in. Personal accounts (Google, Linear) are+// only listed when an agent already connected one; agents start new ones+// with a link to this page (`?connect=1&service=…`), so there is no picker.function displayResourceName(value: string) {return value@@ -82,6 +89,25 @@ function connectionServiceId(return googleServiceFor(connection.scopes)?.id}+function connectionTitle(connection: ManagedAgentConnection) {+ return displayResourceName(connection.label || connection.provider)+}++/** Service, account and agent, leaving out whatever just repeats the title. */+function connectionDetail(+ connection: ManagedAgentConnection,+ agentName: string | undefined,+) {+ const seen = new Set([connectionTitle(connection).toLowerCase()])+ return [connectionService(connection), connection.displayName, agentName]+ .filter((part): part is string => {+ if (!part || seen.has(part.toLowerCase())) return false+ seen.add(part.toLowerCase())+ return true+ })+ .join(' · ')+}+async function loadManagedAgentConnections() {const current = await getManagedAgentConnections()const pending = current.filter(@@ -102,7 +128,20 @@ async function loadManagedAgentConnections() {return getManagedAgentConnections()}+/** GitHub's settings page for one installation, where repositories are chosen. */+function githubInstallationSettingsUrl(installation: {+ githubInstallationId: number+ accountLogin: string+ accountType: string+}) {+ return installation.accountType === 'Organization'+ ? `https://github.com/organizations/${encodeURIComponent(installation.accountLogin)}/settings/installations/${installation.githubInstallationId}`+ : `https://github.com/settings/installations/${installation.githubInstallationId}`+}+export default function ManagedAgentConnections() {+ const computerEnabled =+ useContext(AuthContext)?.user?.computerEnabled ?? falseconst [searchParams, setSearchParams] = useSearchParams()const channelLinkStarted = useRef(false)const connectionStarted = useRef(false)@@ -112,38 +151,12 @@ export default function ManagedAgentConnections() {const [connectionRequestState, setConnectionRequestState] = useState<'idle' | 'connecting' | 'connected' | 'failed'>('idle')- const [newService, setNewService] = useState('gmail')- const [newAlias, setNewAlias] = useState('gmail')- const [addConnectionOpen, setAddConnectionOpen] = useState(false)- const [addConnectionError, setAddConnectionError] = useState<string>()- const [addingGitHubConnection, setAddingGitHubConnection] = useState(false)- const [syncingGitHubConnections, setSyncingGitHubConnections] =- useState(false)- const [githubConnectionError, setGithubConnectionError] = useState<string>()- const [removeConnectionError, setRemoveConnectionError] = useState<string>()- const [connectionToRemove, setConnectionToRemove] =- useState<ManagedAgentConnection>()- const [removingConnection, setRemovingConnection] = useState(false)const requestedService = searchParams.get('service')const requestedAlias = searchParams.get('alias') || 'default'const connections = useQuery({queryKey: ['managed-agent-connections'],queryFn: loadManagedAgentConnections,})- const githubConnections = useQuery({- queryKey: ['managed-github-connections'],- queryFn: getManagedGitHubConnections,- })- const agents = useQuery({- queryKey: ['managed-agents'],- queryFn: getManagedAgents,- })- const agentNames = new Map(- (agents.data ?? []).map((agent) => [- agent.id,- displayManagedAgentName(agent),- ]),- )useEffect(() => {const token = searchParams.get('channel_link')@@ -196,44 +209,30 @@ export default function ManagedAgentConnections() {])return (- <div>+ <div className="max-w-3xl"><PageHeadertitle="Connections"- description="Manage services and GitHub organizations available to your agents."- actions={- <Button- onClick={() => {- setConnectionRequestState('idle')- setAddConnectionError(undefined)- setAddConnectionOpen(true)- }}- >- <Plus className="size-4" aria-hidden />- Add connection- </Button>- }+ description="Where OpenComputer works for your organization."/>- {channelLinkState !== 'idle' && (- <Panel className="mb-4">- <PanelContent className="text-sm">+ <div className="space-y-4">+ {channelLinkState !== 'idle' && (+ <Notice>{channelLinkState === 'linking' && 'Linking your channel identity…'}{channelLinkState === 'linked' &&'Channel identity linked. This agent can now use your connections when you message it.'}{channelLinkState === 'failed' &&'This channel link is invalid or expired. Ask the agent for a new link.'}- </PanelContent>- </Panel>- )}+ </Notice>+ )}- {requestedService && (- <Panel className="mb-4">- <PanelContent>- <p className="text-sm font-medium">+ {requestedService && (+ <Notice>+ <p className="font-medium">Connect {displayResourceName(requestedService)} as “{requestedAlias}”</p>- <p className="text-muted-foreground mt-1 text-sm">+ <p className="text-muted-foreground mt-0.5">{connectionRequestState === 'connecting'? 'Opening secure authorization…': connectionRequestState === 'connected'@@ -242,422 +241,433 @@ export default function ManagedAgentConnections() {? 'The connection could not be started. Reload this link to try again.': 'Continue to securely authorize this account.'}</p>- </PanelContent>- </Panel>- )}+ </Notice>+ )}- <Panel className="mb-4">- <PanelHeader className="items-center">- <div className="flex min-w-0 items-center gap-3">- <div className="bg-muted text-muted-foreground flex size-9 shrink-0 items-center justify-center rounded-md">- <GithubMark className="size-4" />- </div>- <div>- <PanelTitle>Managed GitHub</PanelTitle>- <PanelDescription className="mt-1">- Install OpenComputer for the GitHub organizations your agents- can work in.- </PanelDescription>+ {computerEnabled ? <SlackConnection /> : null}+ <GitHubConnection />+ <PersonalAccounts query={connections} />+ </div>+ </div>+ )+}++function Notice({ children }: { children: ReactNode }) {+ return (+ <div className="bg-muted/50 rounded-lg border px-4 py-3 text-sm">+ {children}+ </div>+ )+}++/** One service: its mark, what it does here, and its actions; rows below. */+function ServiceCard({+ icon,+ title,+ summary,+ actions,+ children,+}: {+ icon: ReactNode+ title: string+ summary: ReactNode+ actions?: ReactNode+ children?: ReactNode+}) {+ return (+ <Panel>+ <section aria-label={title}>+ <div className="flex items-center gap-4 px-5 py-4">+ <div className="bg-muted text-foreground flex size-9 shrink-0 items-center justify-center rounded-md">+ {icon}+ </div>+ <div className="min-w-0 flex-1">+ <h2 className="text-sm font-semibold">{title}</h2>+ <div className="text-muted-foreground mt-0.5 truncate text-sm">+ {summary}</div></div>- <div className="flex items-center gap-2">- <Button- type="button"- variant="ghost"- disabled={addingGitHubConnection || syncingGitHubConnections}- onClick={() => {- setGithubConnectionError(undefined)- let authorizationWindow: Window- try {- authorizationWindow = openAuthorizationWindow()- } catch (error) {- setGithubConnectionError(- error instanceof Error- ? error.message- : 'GitHub sync could not be started.',- )- return- }- setSyncingGitHubConnections(true)- void addManagedGitHubConnection('existing')- .then((authorizationUrl) =>- navigateAuthorizationWindow(- authorizationWindow,- authorizationUrl,- ),- )- .catch((error: unknown) => {- authorizationWindow.close()- setGithubConnectionError(- error instanceof Error- ? error.message- : 'GitHub sync could not be started.',- )- })- .finally(() => setSyncingGitHubConnections(false))- }}- >- {syncingGitHubConnections ? (- <Loader2 className="size-4 animate-spin" aria-hidden />- ) : null}- Sync installations- </Button>+ {actions ? (+ <div className="flex shrink-0 items-center gap-1">{actions}</div>+ ) : null}+ </div>+ {children ? <div className="border-t">{children}</div> : null}+ </section>+ </Panel>+ )+}++function ServiceRow({+ title,+ detail,+ trailing,+}: {+ title: ReactNode+ detail?: ReactNode+ trailing?: ReactNode+}) {+ return (+ <div className="flex min-h-12 items-center gap-3 py-2.5 pr-3 pl-[4.25rem]">+ <div className="min-w-0 flex-1">+ <p className="truncate text-sm font-medium">{title}</p>+ {detail ? (+ <p className="text-muted-foreground truncate text-xs">{detail}</p>+ ) : null}+ </div>+ {trailing ? (+ <div className="flex shrink-0 items-center gap-1">{trailing}</div>+ ) : null}+ </div>+ )+}++function OverflowMenu({+ label,+ children,+}: {+ label: string+ children: ReactNode+}) {+ return (+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button+ variant="ghost"+ size="icon-sm"+ className="text-muted-foreground"+ aria-label={label}+ >+ <Ellipsis className="size-4" aria-hidden />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end" className="min-w-56">+ {children}+ </DropdownMenuContent>+ </DropdownMenu>+ )+}++function SlackConnection() {+ const status = useQuery({+ queryKey: computerQueryKey,+ queryFn: getComputer,+ })+ const [confirmUnlink, setConfirmUnlink] = useState(false)+ const slack = status.data?.slack++ return (+ <ServiceCard+ icon={<SlackMark className="size-4" />}+ title="Slack"+ summary={+ status.isLoading ? (+ <Skeleton className="mt-1 h-3.5 w-40" />+ ) : status.isError ? (+ 'Slack status is temporarily unavailable.'+ ) : slack?.installed ? (+ <>+ Installed in{' '}+ <span className="text-foreground">+ {slack.teamName ?? 'your workspace'}+ </span>+ </>+ ) : (+ 'Add OpenComputer to your workspace to work with it in Slack.'+ )+ }+ actions={+ status.isError ? (+ <Button+ variant="outline"+ size="sm"+ onClick={() => void status.refetch()}+ >+ Try again+ </Button>+ ) : slack?.installed ? (+ <>+ {slackLinks(slack).web ? (+ <Button variant="ghost" size="sm" asChild>+ <a+ href={slackLinks(slack).web ?? undefined}+ target="_blank"+ rel="noreferrer"+ >+ Open Slack+ <ExternalLink className="size-3.5" aria-hidden />+ </a>+ </Button>+ ) : null}+ <OverflowMenu label="Slack options">+ <DropdownMenuItem+ variant="destructive"+ onSelect={() => setConfirmUnlink(true)}+ >+ <Unplug aria-hidden />+ Unlink Slack workspace+ </DropdownMenuItem>+ </OverflowMenu>+ <UnlinkSlackDialog+ teamName={slack.teamName}+ open={confirmUnlink}+ onOpenChange={setConfirmUnlink}+ />+ </>+ ) : status.isSuccess ? (+ <SlackInstallButton+ variant="outline"+ size="sm"+ label="Add to Slack"+ />+ ) : null+ }+ />+ )+}++function GitHubConnection() {+ const installations = useQuery({+ queryKey: ['managed-github-connections'],+ queryFn: getManagedGitHubConnections,+ })+ const [starting, setStarting] = useState<'install' | 'existing'>()+ const start = (mode: 'install' | 'existing') => {+ setStarting(mode)+ void launchAuthorizationWindow(() => addManagedGitHubConnection(mode))+ .catch((error: unknown) =>+ notifyError(+ mode === 'install'+ ? "Couldn't start the GitHub installation."+ : "Couldn't start the GitHub sync.",+ error,+ ),+ )+ .finally(() => setStarting(undefined))+ }+ const accounts = installations.data?.connections ?? []++ return (+ <ServiceCard+ icon={<GithubMark className="size-4" />}+ title="GitHub"+ summary={+ installations.isError+ ? 'GitHub installations are temporarily unavailable.'+ : 'Accounts and repositories OpenComputer can work in.'+ }+ actions={+ installations.isError ? (+ <Button+ variant="outline"+ size="sm"+ onClick={() => void installations.refetch()}+ >+ Try again+ </Button>+ ) : (+ <><Button- type="button"variant="outline"- disabled={addingGitHubConnection || syncingGitHubConnections}- onClick={() => {- setGithubConnectionError(undefined)- let authorizationWindow: Window- try {- authorizationWindow = openAuthorizationWindow()- } catch (error) {- setGithubConnectionError(- error instanceof Error- ? error.message- : 'GitHub setup could not be started.',- )- return- }- setAddingGitHubConnection(true)- void addManagedGitHubConnection('install')- .then((authorizationUrl) =>- navigateAuthorizationWindow(- authorizationWindow,- authorizationUrl,- ),- )- .catch((error: unknown) => {- authorizationWindow.close()- setGithubConnectionError(- error instanceof Error- ? error.message- : 'GitHub setup could not be started.',- )- })- .finally(() => setAddingGitHubConnection(false))- }}+ size="sm"+ disabled={Boolean(starting)}+ onClick={() => start('install')}>- {addingGitHubConnection ? (- <Loader2 className="size-4 animate-spin" aria-hidden />+ {starting === 'install' ? (+ <Loader2 className="size-3.5 animate-spin" aria-hidden />) : (- <Plus className="size-4" aria-hidden />+ <Plus className="size-3.5" aria-hidden />)}- Add organization+ Add account</Button>- </div>- </PanelHeader>- <PanelContent>- {githubConnections.isLoading ? (- <div className="flex min-h-20 items-center justify-center">- <Loader2 className="text-muted-foreground size-5 animate-spin" />- </div>- ) : githubConnections.isError ? (- <div className="flex min-h-20 items-center justify-between gap-4">- <p className="text-muted-foreground text-sm">- GitHub installations are temporarily unavailable.- </p>- <Button- variant="outline"- onClick={() => void githubConnections.refetch()}+ <OverflowMenu label="GitHub options">+ <DropdownMenuItem+ disabled={Boolean(starting)}+ onSelect={() => start('existing')}>- Try again- </Button>- </div>- ) : githubConnections.data?.connections.length ? (- <div className="grid gap-3 md:grid-cols-2">- {githubConnections.data.connections.map((connection) => (- <div- key={connection.id}- className="flex items-center gap-3 rounded-md border px-4 py-3"- >- <GithubMark className="text-muted-foreground size-4 shrink-0" />- <div className="min-w-0 flex-1">- <p className="truncate text-sm font-medium">- {connection.accountLogin}- </p>- <p className="text-muted-foreground truncate text-xs">- {connection.repositorySelection === 'all'- ? 'All repositories'- : 'Selected repositories'}- </p>- </div>- <StatusBadge- status={- connection.state === 'active' ? 'connected' : 'stopped'- }- />- </div>- ))}- </div>- ) : (- <div className="py-4 text-center">- <p className="text-sm font-medium">No organizations added</p>- <p className="text-muted-foreground mt-1 text-sm">- Add a GitHub user or organization account, then choose which- repositories OpenComputer can access.- </p>- </div>- )}- {githubConnectionError ? (- <p className="text-destructive mt-3 text-sm">- {githubConnectionError}- </p>- ) : null}- </PanelContent>- </Panel>-- {connections.isLoading ? (- <div className="flex min-h-48 items-center justify-center">- <Loader2 className="text-muted-foreground size-5 animate-spin" />+ <RefreshCw aria-hidden />+ Sync existing installations+ </DropdownMenuItem>+ </OverflowMenu>+ </>+ )+ }+ >+ {installations.isLoading ? (+ <div className="divide-y">+ <ServiceRow title={<Skeleton className="h-4 w-28" />} /></div>- ) : connections.isError ? (- <Panel>- <PanelContent className="flex min-h-40 flex-col items-center justify-center gap-4 text-center">- <div>- <p className="text-sm font-medium">- Connections are temporarily unavailable- </p>- <p className="text-muted-foreground mt-1 text-sm">- Try loading this page again.- </p>- </div>- <Button- variant="outline"- onClick={() => void connections.refetch()}- >- Try again- </Button>- </PanelContent>- </Panel>- ) : connections.data?.length ? (- <div className="grid gap-3 md:grid-cols-2">- {connections.data.map((connection) => {- const agentName = agentNames.get(connection.agentId)- const service = connectionServiceId(connection)- return (- <Panel key={connection.id}>- <PanelContent className="flex items-center gap-3">- <div className="bg-muted text-muted-foreground flex size-9 shrink-0 items-center justify-center rounded-md">- {service === 'github' ? (- <GithubMark className="size-4" />- ) : (- <ServiceLogo service={service} className="size-4" />- )}- </div>- <div className="min-w-0 flex-1">- <p className="truncate text-sm font-medium">- {displayResourceName(- connection.label || connection.provider,- )}- </p>- <p className="text-muted-foreground truncate text-xs">- {connectionService(connection)}- {connection.displayName- ? ` · ${connection.displayName}`- : ''}- {agentName ? ` · ${agentName}` : ''}- </p>- </div>- <StatusBadge status={connection.status} />- {service ? (- <Button- type="button"- variant="ghost"- size="icon"- aria-label={`Remove ${connection.label} connection`}- onClick={() => setConnectionToRemove(connection)}+ ) : accounts.length ? (+ <div className="divide-y">+ {accounts.map((installation) => (+ <ServiceRow+ key={installation.id}+ title={installation.accountLogin}+ detail={+ installation.repositorySelection === 'all'+ ? 'All repositories'+ : 'Selected repositories'+ }+ trailing={+ <>+ {installation.state === 'active' ? null : (+ <StatusBadge+ status="stopped"+ label={+ installation.state === 'suspended'+ ? 'Suspended'+ : 'Removed'+ }+ />+ )}+ <Button+ variant="ghost"+ size="sm"+ className="text-muted-foreground"+ asChild+ >+ <a+ href={githubInstallationSettingsUrl(installation)}+ target="_blank"+ rel="noreferrer">- <Trash2 className="size-4" aria-hidden />- </Button>- ) : null}- </PanelContent>- </Panel>- )- })}+ Configure+ <ExternalLink className="size-3.5" aria-hidden />+ </a>+ </Button>+ </>+ }+ />+ ))}</div>- ) : (- <Panel>- <PanelContent className="flex min-h-40 flex-col items-center justify-center text-center">- <div className="bg-muted text-muted-foreground mb-3 flex size-10 items-center justify-center rounded-full">- <Plug className="size-4" aria-hidden />- </div>- <p className="text-sm font-medium">No connections yet</p>- <p className="text-muted-foreground mt-1 max-w-sm text-sm">- Add Google, GitHub, or Linear accounts for your agents.- </p>- <Button- className="mt-4"- variant="outline"- onClick={() => setAddConnectionOpen(true)}- >- <Plus className="size-4" aria-hidden />- Add connection- </Button>- </PanelContent>- </Panel>- )}+ ) : installations.isSuccess ? (+ <p className="text-muted-foreground py-3 pr-5 pl-[4.25rem] text-sm">+ No accounts yet. Add a GitHub organization or user, then choose its+ repositories.+ </p>+ ) : null}+ </ServiceCard>+ )+}- <Dialog- open={addConnectionOpen}- onOpenChange={(open) => {- if (connectionRequestState === 'connecting') return- setAddConnectionOpen(open)- if (!open) setAddConnectionError(undefined)- }}- >- <DialogContent>- <DialogHeader>- <DialogTitle>Add connection</DialogTitle>- <DialogDescription>- Choose a service and a memorable alias for this account.- </DialogDescription>- </DialogHeader>- <form- className="grid gap-4"- onSubmit={(event) => {- event.preventDefault()- const alias = newAlias.trim()- if (!alias || connectionRequestState === 'connecting') return- setAddConnectionError(undefined)- setConnectionRequestState('connecting')- let authorizationWindow: Window- try {- authorizationWindow = openAuthorizationWindow()- } catch (error) {- setConnectionRequestState('failed')- setAddConnectionError(- error instanceof Error- ? error.message- : 'The connection could not be started.',- )- return- }- void linkManagedAgentConnection(newService, alias)- .then((result) => {- if (result.authorizationUrl) {- navigateAuthorizationWindow(- authorizationWindow,- result.authorizationUrl,- )- return- }- authorizationWindow.close()- setConnectionRequestState('connected')- setAddConnectionOpen(false)- void connections.refetch()- })- .catch((error: unknown) => {- authorizationWindow.close()- setConnectionRequestState('failed')- setAddConnectionError(- error instanceof Error- ? error.message- : 'The connection could not be started.',- )- })- }}- >- <div className="grid gap-2">- <Label htmlFor="connection-service">Service</Label>- <select- id="connection-service"- value={newService}- onChange={(event) => {- const service = event.target.value- setNewService(service)- setNewAlias(service === 'calendar' ? 'calendar' : service)- }}- className="border-input bg-background ring-offset-background focus-visible:ring-ring h-9 w-full rounded-md border px-3 text-sm focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none"- >- <option value="gmail">Gmail</option>- <option value="calendar">Google Calendar</option>- <option value="drive">Google Drive</option>- <option value="sheets">Google Sheets</option>- <option value="linear">Linear</option>- </select>- </div>- <div className="grid gap-2">- <Label htmlFor="connection-alias">Account alias</Label>- <Input- id="connection-alias"- value={newAlias}- onChange={(event) => setNewAlias(event.target.value)}- pattern="[A-Za-z0-9._-]+"- placeholder="work-gmail"- required- />- <p className="text-muted-foreground text-xs">- Agents use this alias to select the account in callService().- </p>- </div>- {addConnectionError ? (- <p className="text-destructive text-sm">{addConnectionError}</p>- ) : null}- <DialogFooter>- <Button- type="button"- variant="outline"- disabled={connectionRequestState === 'connecting'}- onClick={() => setAddConnectionOpen(false)}- >- Cancel- </Button>- <Button- type="submit"- disabled={- !newAlias.trim() || connectionRequestState === 'connecting'- }- >- {connectionRequestState === 'connecting' ? (- <Loader2 className="size-4 animate-spin" aria-hidden />- ) : null}- Continue- </Button>- </DialogFooter>- </form>- </DialogContent>- </Dialog>+/**+ * Accounts an agent connected on someone's behalf (serverless agents). Shown+ * only while there are some, so they can still be removed.+ */+function PersonalAccounts({+ query,+}: {+ query: {+ data?: ManagedAgentConnection[]+ refetch: () => Promise<unknown>+ }+}) {+ const accounts = query.data ?? []+ const agents = useQuery({+ queryKey: ['managed-agents'],+ queryFn: getManagedAgents,+ enabled: accounts.length > 0,+ })+ const agentNames = new Map(+ (agents.data ?? []).map((agent) => [+ agent.id,+ displayManagedAgentName(agent),+ ]),+ )+ const [toRemove, setToRemove] = useState<ManagedAgentConnection>()+ const [removing, setRemoving] = useState(false)+ const [removeError, setRemoveError] = useState<string>()+ if (!accounts.length) return null++ return (+ <section aria-label="Personal accounts" className="pt-4">+ <h2 className="text-sm font-semibold">Personal accounts</h2>+ <p className="text-muted-foreground mt-0.5 text-sm">+ Accounts your agents connected on your behalf.+ </p>+ <Panel className="mt-3 divide-y">+ {accounts.map((connection) => {+ const service = connectionServiceId(connection)+ const agentName = agentNames.get(connection.agentId)+ return (+ <div+ key={connection.id}+ className="flex min-h-12 items-center gap-3 px-5 py-2.5"+ >+ {service === 'github' ? (+ <GithubMark className="text-muted-foreground size-4 shrink-0" />+ ) : (+ <ServiceLogo service={service} className="size-4 shrink-0" />+ )}+ <div className="min-w-0 flex-1">+ <p className="truncate text-sm font-medium">+ {connectionTitle(connection)}+ </p>+ <p className="text-muted-foreground truncate text-xs">+ {connectionDetail(connection, agentName)}+ </p>+ </div>+ {connection.status === 'connected' ? null : (+ <StatusBadge status={connection.status} />+ )}+ {service ? (+ <Button+ type="button"+ variant="ghost"+ size="icon-sm"+ className="text-muted-foreground"+ aria-label={`Remove ${connection.label} connection`}+ onClick={() => {+ setRemoveError(undefined)+ setToRemove(connection)+ }}+ >+ <Trash2 className="size-4" aria-hidden />+ </Button>+ ) : null}+ </div>+ )+ })}+ </Panel><ConfirmDialog- open={Boolean(connectionToRemove)}+ open={Boolean(toRemove)}onOpenChange={(open) => {- if (!open) setConnectionToRemove(undefined)+ if (!open) setToRemove(undefined)}}title="Remove connection?"description={- connectionToRemove- ? removeConnectionError- ? `The connection could not be removed: ${removeConnectionError}`- : `Agents will no longer be able to use the “${connectionToRemove.label}” account. You can reconnect it later.`+ toRemove+ ? removeError+ ? `The connection could not be removed: ${removeError}`+ : `Agents will no longer be able to use the “${toRemove.label}” account. You can reconnect it later.`: undefined}confirmLabel="Remove connection"destructive- pending={removingConnection}+ pending={removing}onConfirm={() => {- if (!connectionToRemove) return- const service = connectionServiceId(connectionToRemove)+ if (!toRemove) return+ const service = connectionServiceId(toRemove)if (!service) return- setRemovingConnection(true)- setRemoveConnectionError(undefined)+ setRemoving(true)+ setRemoveError(undefined)void disconnectManagedAgentConnection(service === 'github' || service === 'linear' ? service : 'google',service,- connectionToRemove.id,+ toRemove.id,)- .then(() => connections.refetch())- .then(() => setConnectionToRemove(undefined))+ .then(() => query.refetch())+ .then(() => setToRemove(undefined)).catch((error: unknown) => {- setRemoveConnectionError(+ setRemoveError(error instanceof Error? error.message: 'The connection could not be removed.',)})- .finally(() => setRemovingConnection(false))+ .finally(() => setRemoving(false))}}/>- </div>+ </section>)}diff --git a/web/src/managed-agents/computer-slack.tsx b/web/src/managed-agents/computer-slack.tsxnew file mode 100644index 00000000..9f5bbf34--- /dev/null+++ b/web/src/managed-agents/computer-slack.tsx@@ -0,0 +1,80 @@+import { useMutation, useQueryClient } from '@tanstack/react-query'+import { Loader2, Send } from 'lucide-react'+import { ConfirmDialog } from '@/components/confirm-dialog'+import { Button } from '@/components/ui/button'+import { notifyError, notifySuccess } from '@/lib/errors'+import {+ computerQueryKey,+ startComputerSlackInstall,+ unlinkComputerSlack,+} from './computer-api'++// The organization's Slack app, shared by the computer page and Connections.++export function SlackInstallButton({+ variant = 'default',+ size = 'default',+ label = 'Install Slack app',+}: {+ variant?: 'default' | 'outline'+ size?: 'default' | 'sm' | 'lg'+ label?: string+}) {+ const install = useMutation({+ mutationFn: startComputerSlackInstall,+ onSuccess: (url) => window.location.assign(url),+ onError: (error) => notifyError("Couldn't start the Slack install.", error),+ })+ return (+ <Button+ variant={variant}+ size={size}+ // Stays pending through the navigation to Slack.+ disabled={install.isPending || install.isSuccess}+ onClick={() => install.mutate()}+ >+ {install.isPending || install.isSuccess ? (+ <Loader2 className="size-4 animate-spin" aria-hidden />+ ) : (+ <Send className="size-4" aria-hidden />+ )}+ {label}+ </Button>+ )+}++export function UnlinkSlackDialog({+ teamName,+ open,+ onOpenChange,+}: {+ teamName?: string+ open: boolean+ onOpenChange: (open: boolean) => void+}) {+ const queryClient = useQueryClient()+ const unlink = useMutation({+ mutationFn: unlinkComputerSlack,+ onSuccess: async () => {+ onOpenChange(false)+ await queryClient.invalidateQueries({ queryKey: computerQueryKey })+ notifySuccess(+ 'Slack workspace unlinked.',+ 'Remove the app in Slack to uninstall it there too.',+ )+ },+ onError: (error) => notifyError("Couldn't unlink Slack.", error),+ })+ return (+ <ConfirmDialog+ open={open}+ onOpenChange={onOpenChange}+ title={`Unlink ${teamName ?? 'this Slack workspace'}?`}+ description="Your computer stops answering in this workspace. The app stays installed in Slack until you remove it there, and you can link a workspace again at any time."+ confirmLabel="Unlink Slack"+ destructive+ pending={unlink.isPending}+ onConfirm={() => unlink.mutate()}+ />+ )+}