Skip to content

An open-source, faster Devin alternative

TypeScript

feat(agents): complete guided repository activation

Igor Zalutskic17066b491df
diff --git a/docs/agent-sessions/agents.mdx b/docs/agent-sessions/agents.mdx
index 1b30136d..c2b21ab1 100644
--- a/docs/agent-sessions/agents.mdx
+++ b/docs/agent-sessions/agents.mdx
@@ -78,6 +78,14 @@ Choose **Agents → Create agent → Import from GitHub**, install the OpenCompu
Review and import are intentionally separate. Import rechecks the exact source plan; if the repository changed in between, nothing is created and the dashboard asks you to review again. A successful import returns the new agent and its first deployment immediately, then opens guided setup instead of making you wait on a log screen. Connect Slack while the deployment continues in the background; its compact phases and expandable log remain available. When both are ready, setup changes to **Open Slack** without a refresh and invites you to send the first message. Manually configured agents use the same setup journey.
+The repository picker marks roots already used by another agent before review.
+An exact linked root cannot be reviewed again: open its owning agent, choose a
+different monorepo root, or unlink it in place after confirming that
+deploy-on-push will stop. Unlinking preserves the existing agent, active
+revision, deployment history, and sessions. Guided setup remains available from
+the agent page; after the first Slack message creates a session, it shows the
+first conversation and links to the complete session view.
+
## Session-pinned config
For a built-in runtime, creating a session **freezes** the agent's active [revision](/agent-sessions/revisions), including its `prompt`, `model`, `runtime`, and `skills`. It also pins the resolved credential. A one-off [`model`](/agent-sessions/sessions#model) override is pinned in the same way. Editing the named agent does not change a running or resumed session: existing sessions keep what they started with, while new sessions pick up the change. Rotating a credential's **key value** is the exception, so a compromised key can be replaced; see [credentials](/agent-sessions/credentials).
diff --git a/docs/agent-sessions/api-reference.mdx b/docs/agent-sessions/api-reference.mdx
index 825fdc2a..c49c8009 100644
--- a/docs/agent-sessions/api-reference.mdx
+++ b/docs/agent-sessions/api-reference.mdx
@@ -306,6 +306,11 @@ the [Deployments & revisions guide](/agent-sessions/revisions).
Review resolves the moving production branch to one exact commit and interprets bounded metadata
without executing repository code. Repository-first import currently accepts the exact Flue result.
+`GET /github/deploy-app` returns the installed OpenComputer GitHub App and its pickable repositories.
+Each repository includes `linked_sources[]` with the owner-scoped `path`, `production_ref`, `status`,
+and owning agent `{ id, name }`. Clients should block review when the selected normalized root has a
+claim. This is an early user-facing check; import repeats the uniqueness check transactionally.
+
<CodeGroup>
```ts TypeScript SDK
@@ -651,6 +656,8 @@ A skill is a folder with a `SKILL.md`; PUT/DELETE are **deployments** (versioned
</Tabs>
Linking deploys the current production HEAD immediately (unless `deploy_now: false` / `--no-deploy`).
+The link is unique by owner, repository, and normalized root. Unlinking stops deploy-on-push but does
+not delete the agent, revisions, deployment history, or sessions.
For built-in runtimes, a push to the production branch activates while other branches stage. For
Flue, only the production branch deploys. **Scopes:** `deploy_now: false` needs `agents:link`; the
default (with an initial deploy) needs `agents:link` + `agents:deploy`, plus `agents:activate` when
diff --git a/docs/agent-sessions/flue.mdx b/docs/agent-sessions/flue.mdx
index 04a0918e..40b7dcca 100644
--- a/docs/agent-sessions/flue.mdx
+++ b/docs/agent-sessions/flue.mdx
@@ -84,6 +84,13 @@ The shortest path for an existing Flue app is the dashboard:
5. Review the detected Flue entrypoint and model. Give the OpenComputer agent a human-readable name; it may differ from the `agent.toml` Flue entrypoint.
6. Choose **Deploy agent**. A guided setup page opens immediately and keeps the deployment running in the background. It shows compact **Prepare**, **Build**, and **Deploy** progress; expand the build log only when you need it.
7. Choose **Connect Slack** as the next step. Slack authorization returns to setup, which changes to **Open Slack** as soon as both the agent and connection are ready and prompts you to send your first message.
+8. Send the message in Slack. Setup detects the real managed-Slack session, previews the first exchange, and links to the full session in OpenComputer. If you leave early, use **Continue setup** from the agent page.
+
+If the chosen repository root is already a deployment source for another agent,
+the picker marks it before review and disables the review action. Open the
+owning agent, choose another monorepo root, or confirm an inline unlink. The
+unlink stops future push deployments for the old agent; it does not delete the
+agent, active revision, deployment history, or sessions.
The selected root is its own build context and must contain `agent.toml`, `package.json`, and a
committed `package-lock.json`. The package must declare a Node engine compatible with the exact
diff --git a/docs/agent-sessions/repos.mdx b/docs/agent-sessions/repos.mdx
index 5a273070..17d23520 100644
--- a/docs/agent-sessions/repos.mdx
+++ b/docs/agent-sessions/repos.mdx
@@ -133,7 +133,16 @@ The dashboard uses the OpenComputer App to:
After import, the dashboard opens guided setup rather than making the deployment log the next task.
Choose **Connect Slack** while the deployment runs in the background. Compact phases remain visible,
the build log expands on demand, and setup promotes **Open Slack** plus the first-message prompt when
-both resources are ready.
+both resources are ready. It then watches ordinary session history: before the first message it says
+that it is waiting, and after managed Slack creates the session it previews the user message and
+agent response with links to the full session and all sessions for that agent. Until then, the agent
+page keeps **Continue setup** available.
+
+The picker also shows existing deployment-source claims before it inspects repository content. The
+uniqueness boundary is one OpenComputer agent per repository root, not one per whole repository, so a
+linked `agents/support` does not block `agents/sales`. Selecting the exact linked root disables review,
+names and links the owning agent, and offers an inline confirmed unlink. Unlinking stops deploy-on-push
+for the old agent but preserves that agent, its active revision, deployment history, and sessions.
Recognition is deterministic. A root-level `agent.toml` is authoritative: if it is malformed or
unsupported, the result is a fixable error rather than a guess. Without a manifest, a root-level
@@ -144,7 +153,8 @@ If the selected root is unrecognized, the review can scan the same bounded tree
entries and return up to 20 candidate roots no more than six folders deep. Results follow fixed
marker precedence, then shallower depth, then repository-relative byte order. Candidates are
suggestions, never an automatic selection; choose one and review it separately. When the result is
-truncated, select a narrower root.
+truncated, select a narrower root. Candidate roots that are already linked are marked and cannot be
+selected until opened or unlinked.
The Git box writes a bounded, digest-checked source archive to object storage and is destroyed.
A different sandbox receives that archive without `.git` or GitHub auth, runs the fixed install and
diff --git a/docs/agent-sessions/slack.mdx b/docs/agent-sessions/slack.mdx
index e4db3231..d3dbabd1 100644
--- a/docs/agent-sessions/slack.mdx
+++ b/docs/agent-sessions/slack.mdx
@@ -21,7 +21,11 @@ connection remains in place if that deployment fails, but the app cannot run a
message until the agent has a ready deployment. A message sent too early gets a
short deploying response and is not queued. Setup follows deployment progress
without a manual refresh. Wait for it to show **Send your first message** and
-**Open Slack**, then send the message again.
+**Open Slack**, then send the message again. While setup is unfinished, the
+agent page keeps **Continue setup** visible. After Slack creates the first real
+session, setup changes automatically from “waiting for a message” to a compact
+conversation preview with links to the full session and the agent's session
+history.
<Warning>
Anyone in the connected Slack workspace who can message the app can use this
diff --git a/web/src/api/client.ts b/web/src/api/client.ts
index 17dd4307..ceae07ff 100644
--- a/web/src/api/client.ts
+++ b/web/src/api/client.ts
@@ -901,6 +901,7 @@ export const getSessions = (
params: {
agent?: string
status?: string
+ after?: string
limit?: number
cursor?: string
} = {},
@@ -908,6 +909,7 @@ export const getSessions = (
const q = new URLSearchParams()
if (params.agent) q.set('agent', params.agent)
if (params.status) q.set('status', params.status)
+ if (params.after) q.set('after', params.after)
if (params.limit) q.set('limit', String(params.limit))
if (params.cursor) q.set('cursor', params.cursor)
const qs = q.toString()
diff --git a/web/src/api/deployment-schemas.test.ts b/web/src/api/deployment-schemas.test.ts
index eb7f8842..5f5893c5 100644
--- a/web/src/api/deployment-schemas.test.ts
+++ b/web/src/api/deployment-schemas.test.ts
@@ -182,6 +182,7 @@ describe('repository deployment API schemas', () => {
full_name: 'example/pending-registration',
default_branch: 'main',
private: true,
+ linked_sources: [],
},
],
})
@@ -189,6 +190,35 @@ describe('repository deployment API schemas', () => {
expect(parsed.repositories[0]?.id).toBeNull()
})
+ it('parses owner-scoped linked repository roots for early conflict UX', () => {
+ const parsed = DeployAppSchema.parse({
+ installed: true,
+ repositories: [
+ {
+ id: 'repo_0123456789abcdef01234567',
+ full_name: 'example/flue-agent',
+ default_branch: 'main',
+ private: false,
+ linked_sources: [
+ {
+ path: '',
+ production_ref: 'main',
+ status: 'active',
+ agent: {
+ id: 'agt_0123456789abcdef01234567',
+ name: 'Support triage',
+ },
+ },
+ ],
+ },
+ ],
+ })
+
+ expect(parsed.repositories[0]?.linked_sources[0]?.agent.name).toBe(
+ 'Support triage',
+ )
+ })
+
it('fails closed when deployment identity or canonical state is absent', () => {
const withoutState = { ...deployment } as Partial<typeof deployment>
delete withoutState.state
diff --git a/web/src/api/schemas.ts b/web/src/api/schemas.ts
index 3ad5213b..ea670cb4 100644
--- a/web/src/api/schemas.ts
+++ b/web/src/api/schemas.ts
@@ -616,6 +616,16 @@ export const DeployAppRepoSchema = z.object({
full_name: z.string(),
default_branch: z.string().nullish(),
private: z.boolean().nullish(),
+ linked_sources: z
+ .array(
+ z.object({
+ path: z.string(),
+ production_ref: z.string(),
+ status: z.string(),
+ agent: z.object({ id: z.string(), name: z.string() }),
+ }),
+ )
+ .default([]),
})
export const DeployAppSchema = z.object({
installed: z.boolean(),
diff --git a/web/src/lib/agent-setup-presentation.test.ts b/web/src/lib/agent-setup-presentation.test.ts
index 8c553f4c..8e2453f1 100644
--- a/web/src/lib/agent-setup-presentation.test.ts
+++ b/web/src/lib/agent-setup-presentation.test.ts
@@ -43,6 +43,21 @@ describe('agentSetupPresentation', () => {
expect(view.label).toBe('Open Slack')
})
+ it('hands a real first Slack session into continued conversation', () => {
+ const view = agentSetupPresentation({
+ agentName: 'Support triage',
+ stage: 'ready',
+ managedStatus: 'active',
+ openUrl: 'https://slack.com/app_redirect?app=A1&team=T1',
+ connecting: false,
+ activated: true,
+ })
+
+ expect(view.title).toBe('Support triage is live in Slack')
+ expect(view.action).toBe('open')
+ expect(view.label).toBe('Continue in Slack')
+ })
+
it('makes deployment recovery primary after a failure', () => {
const view = agentSetupPresentation({
agentName: 'Support triage',
diff --git a/web/src/lib/agent-setup-presentation.ts b/web/src/lib/agent-setup-presentation.ts
index 49af17c7..43c74217 100644
--- a/web/src/lib/agent-setup-presentation.ts
+++ b/web/src/lib/agent-setup-presentation.ts
@@ -17,6 +17,7 @@ export function agentSetupPresentation(input: {
managedStatus: ManagedSlackStatus
openUrl?: string | null
connecting: boolean
+ activated?: boolean
}): AgentSetupPresentation {
const slack = deploymentSlackPresentation({
deploymentState: input.stage === 'ready' ? 'ready' : input.stage,
@@ -39,6 +40,17 @@ export function agentSetupPresentation(input: {
if (input.managedStatus === 'active') {
if (input.stage === 'ready' && input.openUrl) {
+ if (input.activated) {
+ return {
+ ...slack,
+ label: 'Continue in Slack',
+ announcement:
+ 'Your first Slack message created an OpenComputer session.',
+ title: `${input.agentName} is live in Slack`,
+ description:
+ 'Your first message created a durable session. Keep chatting in Slack or open the full conversation in OpenComputer.',
+ }
+ }
return {
...slack,
title: 'Send your first message',
diff --git a/web/src/lib/managed-slack-session.test.ts b/web/src/lib/managed-slack-session.test.ts
new file mode 100644
index 00000000..3e09520a
--- /dev/null
+++ b/web/src/lib/managed-slack-session.test.ts
@@ -0,0 +1,54 @@
+import { describe, expect, it } from 'vitest'
+import type { Session } from '@/api/client'
+import {
+ isManagedSlackSession,
+ latestManagedSlackSession,
+} from '@/lib/managed-slack-session'
+
+function session(
+ id: string,
+ createdAt: string,
+ mode: 'managed' | 'byo' | null,
+): Session {
+ return {
+ id,
+ status: 'idle',
+ created_at: createdAt,
+ metadata: mode ? { slack: { mode } } : null,
+ }
+}
+
+describe('managed Slack activation sessions', () => {
+ it('uses the durable session origin and current connection boundary', () => {
+ expect(
+ isManagedSlackSession(
+ session('ses_managed', '2026-07-17T10:00:01Z', 'managed'),
+ '2026-07-17T10:00:00Z',
+ ),
+ ).toBe(true)
+ expect(
+ isManagedSlackSession(
+ session('ses_old', '2026-07-17T09:59:59Z', 'managed'),
+ '2026-07-17T10:00:00Z',
+ ),
+ ).toBe(false)
+ expect(
+ isManagedSlackSession(
+ session('ses_byo', '2026-07-17T10:00:01Z', 'byo'),
+ '2026-07-17T10:00:00Z',
+ ),
+ ).toBe(false)
+ })
+
+ it('finds the latest matching conversation without claiming dashboard sessions', () => {
+ const sessions = [
+ session('ses_dashboard', '2026-07-17T10:03:00Z', null),
+ session('ses_first', '2026-07-17T10:01:00Z', 'managed'),
+ session('ses_latest', '2026-07-17T10:02:00Z', 'managed'),
+ ]
+
+ expect(
+ latestManagedSlackSession(sessions, '2026-07-17T10:00:00Z')?.id,
+ ).toBe('ses_latest')
+ })
+})
diff --git a/web/src/lib/managed-slack-session.ts b/web/src/lib/managed-slack-session.ts
new file mode 100644
index 00000000..7977dfe7
--- /dev/null
+++ b/web/src/lib/managed-slack-session.ts
@@ -0,0 +1,42 @@
+import type { Session } from '@/api/client'
+
+function record(value: unknown): Record<string, unknown> {
+ return value && typeof value === 'object' && !Array.isArray(value)
+ ? (value as Record<string, unknown>)
+ : {}
+}
+
+/**
+ * Managed Slack ingress records its origin on the ordinary durable session.
+ * Keep onboarding discovery on that public session truth instead of inventing
+ * a second activation state machine in the dashboard.
+ */
+export function isManagedSlackSession(
+ session: Session,
+ connectedAt?: string | null,
+): boolean {
+ const slack = record(record(session.metadata).slack)
+ if (slack.mode !== 'managed') return false
+
+ if (!connectedAt) return true
+ const connectedTime = Date.parse(connectedAt)
+ const sessionTime = Date.parse(session.created_at)
+ return (
+ Number.isFinite(connectedTime) &&
+ Number.isFinite(sessionTime) &&
+ sessionTime >= connectedTime
+ )
+}
+
+export function latestManagedSlackSession(
+ sessions: Session[],
+ connectedAt?: string | null,
+): Session | undefined {
+ return sessions
+ .filter((session) => isManagedSlackSession(session, connectedAt))
+ .sort(
+ (a, b) =>
+ Date.parse(b.created_at) - Date.parse(a.created_at) ||
+ b.id.localeCompare(a.id),
+ )[0]
+}
diff --git a/web/src/lib/repository-onboarding.test.ts b/web/src/lib/repository-onboarding.test.ts
index 95ec722e..bf0f58c6 100644
--- a/web/src/lib/repository-onboarding.test.ts
+++ b/web/src/lib/repository-onboarding.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest'
import { ApiError, type RepositorySourceInspection } from '@/api/client'
import {
+ normalizeRepositoryRoot,
repositoryReviewPresentation,
repositorySeedFromState,
sourceChangedRequiresReview,
@@ -24,6 +25,13 @@ const common = {
}
describe('repository onboarding presentation', () => {
+ it('matches linked roots after harmless path formatting differences', () => {
+ expect(normalizeRepositoryRoot(' agents//support/ ')).toBe(
+ 'agents/support',
+ )
+ expect(normalizeRepositoryRoot('')).toBe('')
+ })
+
it('keeps invalid Flue authoritative and recoverable by re-review', () => {
const presentation = repositoryReviewPresentation({
...common,
diff --git a/web/src/lib/repository-onboarding.ts b/web/src/lib/repository-onboarding.ts
index d6fe60ee..9e7d4a06 100644
--- a/web/src/lib/repository-onboarding.ts
+++ b/web/src/lib/repository-onboarding.ts
@@ -26,6 +26,12 @@ export function isValidRepositoryRoot(root: string): boolean {
.some((part) => part === '.' || part === '..')
}
+/** Mirrors the server's repository-root canonicalization for local conflict
+ * presentation only. Review/import still re-normalize and enforce it. */
+export function normalizeRepositoryRoot(root: string): string {
+ return root.trim().split('/').filter(Boolean).join('/')
+}
+
/** Read the bounded same-origin handoff used after a confirmed source unlink. */
export function repositorySeedFromState(
value: unknown,
diff --git a/web/src/pages/AgentDetail.tsx b/web/src/pages/AgentDetail.tsx
index 2b784e11..760e0b71 100644
--- a/web/src/pages/AgentDetail.tsx
+++ b/web/src/pages/AgentDetail.tsx
@@ -1,7 +1,13 @@
import { useState } from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { Link, useLocation, useNavigate, useParams } from 'react-router-dom'
-import { ArrowLeft, MessagesSquare, Send, GitBranch } from 'lucide-react'
+import {
+ ArrowLeft,
+ MessageSquare,
+ MessagesSquare,
+ Send,
+ GitBranch,
+} from 'lucide-react'
import { notifyError } from '@/lib/errors'
import {
getAgent,
@@ -11,6 +17,7 @@ import {
getCredentials,
createCredential,
getDeploymentSource,
+ getManagedSlackConnection,
type Agent,
} from '@/api/client'
import type { Session } from '@/api/schemas'
@@ -49,6 +56,7 @@ import {
withModelGroups,
} from '@/lib/runtimes'
import { cn } from '@/lib/utils'
+import { latestManagedSlackSession } from '@/lib/managed-slack-session'
const DOCS = 'https://docs.opencomputer.dev/agent-sessions'
@@ -128,10 +136,28 @@ export default function AgentDetail() {
enabled: !!agentId,
})
- // This agent's sessions — filtered server-side.
+ const managedSlackQuery = useQuery({
+ queryKey: ['slack', 'managed', agentId],
+ queryFn: () => getManagedSlackConnection(agentId),
+ enabled: !!agentId,
+ refetchOnWindowFocus: 'always',
+ })
+
+ // This agent's sessions — filtered server-side. While first-run Slack setup
+ // is incomplete, refresh just long enough for the real managed session to
+ // turn the persistent setup affordance from primary into secondary.
const { data: sessions = [], isLoading: loadingSessions } = useQuery({
queryKey: ['sessions', { agent: agentId }],
queryFn: () => getSessions({ agent: agentId }),
+ refetchInterval: (query) =>
+ managedSlackQuery.data?.status === 'active' &&
+ !latestManagedSlackSession(
+ query.state.data ?? [],
+ managedSlackQuery.data.connected_at,
+ )
+ ? 2000
+ : false,
+ refetchOnWindowFocus: 'always',
})
// The deployment-source link (shared cache key with the GitHub card). null = not linked.
@@ -336,6 +362,21 @@ export default function AgentDetail() {
const latestDeploymentId = agent.deployment_status?.deployment_id
const deploymentStatus = agentDeploymentDisplayStatus(agent)
const canStartNewSession = agentCanStartNewSession(agent)
+ const setupHref = `${base}/setup${
+ latestDeploymentId
+ ? `?deployment=${encodeURIComponent(latestDeploymentId)}`
+ : ''
+ }`
+ const managedSlackSession = latestManagedSlackSession(
+ sessions,
+ managedSlackQuery.data?.connected_at,
+ )
+ const setupComplete =
+ canStartNewSession &&
+ managedSlackQuery.isSuccess &&
+ managedSlackQuery.data?.status === 'active' &&
+ !loadingSessions &&
+ !!managedSlackSession
return (
<div className="mx-auto max-w-5xl">
@@ -366,23 +407,35 @@ export default function AgentDetail() {
<SourceChip source={source ?? null} />
</div>
</div>
- {canStartNewSession ? (
- <Button asChild size="sm">
- <Link to={`${base}/sessions`}>
- <Send className="size-4" />
- New session
- </Link>
- </Button>
- ) : (
- <Button
- size="sm"
- disabled
- title="A verified deployment is required before starting a session"
- >
- <Send className="size-4" />
- New session
- </Button>
- )}
+ <div className="flex flex-wrap items-center gap-2">
+ {setupComplete ? (
+ <Button asChild size="sm" variant="ghost">
+ <Link to={setupHref}>Setup</Link>
+ </Button>
+ ) : canStartNewSession ? (
+ <Button asChild size="sm" variant="outline">
+ <Link to={`${base}/sessions`}>
+ <Send className="size-4" />
+ New session
+ </Link>
+ </Button>
+ ) : null}
+ {setupComplete ? (
+ <Button asChild size="sm">
+ <Link to={`${base}/sessions`}>
+ <Send className="size-4" />
+ New session
+ </Link>
+ </Button>
+ ) : (
+ <Button asChild size="sm">
+ <Link to={setupHref}>
+ <MessageSquare className="size-4" />
+ Continue setup
+ </Link>
+ </Button>
+ )}
+ </div>
</div>
<nav className="-mb-px flex gap-1 overflow-x-auto" aria-label="Agent">
<TabLink to={base} label="Overview" current={active === 'overview'} />
diff --git a/web/src/pages/AgentNew.tsx b/web/src/pages/AgentNew.tsx
index 6be583e3..7fdaf675 100644
--- a/web/src/pages/AgentNew.tsx
+++ b/web/src/pages/AgentNew.tsx
@@ -16,15 +16,18 @@ import {
KeyRound,
Loader2,
Search,
+ Unplug,
} from 'lucide-react'
import {
ApiError,
getDeployApp,
importAgentFromGithub,
reviewRepositoryAgent,
+ unlinkDeploymentSource,
type DeployApp,
type RepositorySourceInspection,
} from '@/api/client'
+import { ConfirmDialog } from '@/components/confirm-dialog'
import { Field, FieldError, Input } from '@/components/form'
import { GithubMark } from '@/components/github-mark'
import { ManualAgentForm } from '@/components/manual-agent-form'
@@ -45,11 +48,13 @@ import {
} from '@/lib/agent-creation-mode'
import {
isValidRepositoryRoot,
+ normalizeRepositoryRoot,
repositoryReviewPresentation,
repositorySeedFromState,
sourceChangedRequiresReview,
type RepositorySeed,
} from '@/lib/repository-onboarding'
+import { notifyError, notifySuccess } from '@/lib/errors'
import { cn } from '@/lib/utils'
const STARTER_URL = 'https://github.com/diggerhq/oc-flue-starter'
@@ -58,6 +63,7 @@ const IMPORT_COMMAND_STORAGE = 'oc.repository-import-command.v1'
type ImportBody = Parameters<typeof importAgentFromGithub>[0]
type ImportCommand = { fingerprint: string; key: string }
+type LinkedSource = DeployApp['repositories'][number]['linked_sources'][number]
function existingAgentFromError(
error: unknown,
): { id: string; name: string; conflict: 'name' | 'source' } | null {
@@ -190,6 +196,9 @@ function GithubImport({
)
const [root, setRoot] = useState(initialRepo ? initialSource?.path || '' : '')
const [name, setName] = useState('')
+ const [unlinkingSource, setUnlinkingSource] = useState<LinkedSource | null>(
+ null,
+ )
const repositories = useMemo(() => {
const needle = repoSearch.trim().toLowerCase()
@@ -242,6 +251,41 @@ function GithubImport({
`/agents/${agent.id}/setup?deployment=${encodeURIComponent(deployment.id)}`,
)
},
+ onError: (error) => {
+ if (existingAgentFromError(error)?.conflict === 'source') {
+ void queryClient.invalidateQueries({ queryKey: ['deploy-app'] })
+ }
+ },
+ })
+ const unlinkMutation = useMutation({
+ mutationFn: (source: LinkedSource) =>
+ unlinkDeploymentSource(source.agent.id),
+ onSuccess: (_result, source) => {
+ queryClient.setQueryData<DeployApp>(['deploy-app'], (current) =>
+ current
+ ? {
+ ...current,
+ repositories: current.repositories.map((repo) => ({
+ ...repo,
+ linked_sources: repo.linked_sources.filter(
+ (claim) => claim.agent.id !== source.agent.id,
+ ),
+ })),
+ }
+ : current,
+ )
+ void queryClient.invalidateQueries({ queryKey: ['deploy-app'] })
+ void queryClient.invalidateQueries({ queryKey: ['agents'] })
+ void queryClient.invalidateQueries({
+ queryKey: ['agent-deploy-source', source.agent.id],
+ })
+ setUnlinkingSource(null)
+ notifySuccess(
+ `Repository unlinked from ${source.agent.name}.`,
+ 'The agent, active revision, deployments, and sessions are unchanged.',
+ )
+ },
+ onError: (error) => notifyError("Couldn't unlink the repository.", error),
})
const clearInspection = () => {
@@ -274,15 +318,22 @@ function GithubImport({
inspection?.interpretation.disposition === 'exact' && inspection.profile
? inspection
: null
+ const linkedSourceFor = (path: string) =>
+ selectedRepo?.linked_sources.find(
+ (source) => source.path === normalizeRepositoryRoot(path),
+ )
+ const selectedLinkedSource = linkedSourceFor(root)
const canInspect =
!!selectedRepo &&
!!productionRef.trim() &&
rootValid &&
+ !selectedLinkedSource &&
!inspectMutation.isPending
const canImport =
!!exactInspection &&
!!name.trim() &&
!sourceChanged &&
+ !selectedLinkedSource &&
!importMutation.isPending &&
!inspectMutation.isPending
@@ -427,39 +478,51 @@ function GithubImport({
className="max-h-60 overflow-y-auto rounded-md border"
>
{repositories.length ? (
- repositories.map((repo, index) => (
- <button
- key={repo.id}
- type="button"
- aria-pressed={repo.id === repoId}
- onClick={() => selectRepo(repo.id)}
- className={cn(
- 'focus-visible:ring-ring/50 flex w-full items-center gap-3 px-3 py-2.5 text-left outline-none focus-visible:ring-3 focus-visible:ring-inset',
- index > 0 && 'border-t',
- repo.id === repoId
- ? 'bg-row-selected'
- : 'hover:bg-row-hover',
- )}
- >
- <GithubMark className="size-4 shrink-0" />
- <span className="min-w-0 flex-1 truncate text-sm font-medium">
- {repo.full_name}
- </span>
- <span className="text-muted-foreground flex shrink-0 items-center gap-2 text-xs">
- {repo.private == null
- ? null
- : repo.private
- ? 'Private'
- : 'Public'}
- {repo.default_branch ? (
- <span className="hidden items-center gap-1 sm:flex">
- <GitBranch className="size-3" />
- {repo.default_branch}
+ repositories.map((repo, index) => {
+ const rootClaim = repo.linked_sources.find(
+ (source) => source.path === '',
+ )
+ return (
+ <button
+ key={repo.id}
+ type="button"
+ aria-pressed={repo.id === repoId}
+ onClick={() => selectRepo(repo.id)}
+ className={cn(
+ 'focus-visible:ring-ring/50 flex w-full items-center gap-3 px-3 py-2.5 text-left outline-none focus-visible:ring-3 focus-visible:ring-inset',
+ index > 0 && 'border-t',
+ repo.id === repoId
+ ? 'bg-row-selected'
+ : 'hover:bg-row-hover',
+ )}
+ >
+ <GithubMark className="size-4 shrink-0" />
+ <span className="min-w-0 flex-1 truncate text-sm font-medium">
+ {repo.full_name}
+ </span>
+ {repo.linked_sources.length ? (
+ <span className="bg-muted text-foreground max-w-44 shrink-0 truncate rounded-sm px-1.5 py-0.5 text-xs">
+ {rootClaim
+ ? `Linked to ${rootClaim.agent.name}`
+ : `${repo.linked_sources.length} linked ${repo.linked_sources.length === 1 ? 'root' : 'roots'}`}
</span>
) : null}
- </span>
- </button>
- ))
+ <span className="text-muted-foreground hidden shrink-0 items-center gap-2 text-xs md:flex">
+ {repo.private == null
+ ? null
+ : repo.private
+ ? 'Private'
+ : 'Public'}
+ {repo.default_branch ? (
+ <span className="flex items-center gap-1">
+ <GitBranch className="size-3" />
+ {repo.default_branch}
+ </span>
+ ) : null}
+ </span>
+ </button>
+ )
+ })
) : (
<p className="text-muted-foreground px-4 py-8 text-center text-sm">
{app.repositories.length === 0
@@ -514,6 +577,41 @@ function GithubImport({
</div>
) : null}
+ {selectedRepo && selectedLinkedSource ? (
+ <Alert>
+ <AlertTitle>Repository root already linked</AlertTitle>
+ <AlertDescription>
+ {normalizeRepositoryRoot(root)
+ ? `${selectedRepo.full_name}/${normalizeRepositoryRoot(root)}`
+ : selectedRepo.full_name}{' '}
+ is linked to{' '}
+ <Link
+ className="font-medium underline underline-offset-4"
+ to={`/agents/${selectedLinkedSource.agent.id}`}
+ >
+ {selectedLinkedSource.agent.name}
+ </Link>
+ . One agent can own this repository root for deploy-on-push.
+ </AlertDescription>
+ <div className="mt-3 flex flex-wrap gap-2">
+ <Button size="sm" variant="outline" asChild>
+ <Link to={`/agents/${selectedLinkedSource.agent.id}`}>
+ Open agent
+ </Link>
+ </Button>
+ <Button
+ size="sm"
+ variant="ghost"
+ disabled={unlinkMutation.isPending}
+ onClick={() => setUnlinkingSource(selectedLinkedSource)}
+ >
+ <Unplug className="size-4" />
+ Unlink repository
+ </Button>
+ </div>
+ </Alert>
+ ) : null}
+
{inspectMutation.isError ? (
<FieldError>{agentReviewError(inspectMutation.error)}</FieldError>
) : null}
@@ -580,6 +678,37 @@ function GithubImport({
<AlertDescription>{warning.message}</AlertDescription>
</Alert>
))}
+ {selectedLinkedSource ? (
+ <Alert>
+ <AlertTitle>Repository root already linked</AlertTitle>
+ <AlertDescription>
+ This reviewed root is now linked to{' '}
+ <Link
+ className="font-medium underline underline-offset-4"
+ to={`/agents/${selectedLinkedSource.agent.id}`}
+ >
+ {selectedLinkedSource.agent.name}
+ </Link>
+ . Unlink it before creating another agent from this root.
+ </AlertDescription>
+ <div className="mt-3 flex flex-wrap gap-2">
+ <Button size="sm" variant="outline" asChild>
+ <Link to={`/agents/${selectedLinkedSource.agent.id}`}>
+ Open agent
+ </Link>
+ </Button>
+ <Button
+ size="sm"
+ variant="ghost"
+ disabled={unlinkMutation.isPending}
+ onClick={() => setUnlinkingSource(selectedLinkedSource)}
+ >
+ <Unplug className="size-4" />
+ Unlink repository
+ </Button>
+ </div>
+ </Alert>
+ ) : null}
{importMutation.isError ? (
<Alert
variant={
@@ -699,34 +828,57 @@ function GithubImport({
className="divide-y overflow-hidden rounded-md border"
aria-label="Candidate agent folders"
>
- {inspection.candidate_roots.map((candidate) => (
- <div
- key={`${candidate.path}:${candidate.marker ?? ''}`}
- className="flex flex-col gap-3 px-3 py-3 sm:flex-row sm:items-center sm:justify-between"
- >
- <div className="min-w-0">
- <p className="truncate font-mono text-sm">
- {candidate.path || 'Repository root'}
- </p>
- <p className="text-muted-foreground mt-0.5 text-xs">
- {candidate.summary}
- </p>
- </div>
- <Button
- size="sm"
- variant="outline"
- disabled={inspectMutation.isPending}
- onClick={() => chooseCandidate(candidate)}
+ {inspection.candidate_roots.map((candidate) => {
+ const linkedSource = linkedSourceFor(candidate.path)
+ return (
+ <div
+ key={`${candidate.path}:${candidate.marker ?? ''}`}
+ className="flex flex-col gap-3 px-3 py-3 sm:flex-row sm:items-center sm:justify-between"
>
- {inspectMutation.isPending ? (
- <Loader2 className="size-4 animate-spin motion-reduce:animate-none" />
+ <div className="min-w-0">
+ <p className="truncate font-mono text-sm">
+ {candidate.path || 'Repository root'}
+ </p>
+ <p className="text-muted-foreground mt-0.5 text-xs">
+ {linkedSource
+ ? `Already linked to ${linkedSource.agent.name}`
+ : candidate.summary}
+ </p>
+ </div>
+ {linkedSource ? (
+ <div className="flex shrink-0 flex-wrap gap-1">
+ <Button size="sm" variant="outline" asChild>
+ <Link to={`/agents/${linkedSource.agent.id}`}>
+ Open agent
+ </Link>
+ </Button>
+ <Button
+ size="sm"
+ variant="ghost"
+ disabled={unlinkMutation.isPending}
+ onClick={() => setUnlinkingSource(linkedSource)}
+ >
+ Unlink
+ </Button>
+ </div>
) : (
- <FolderSearch className="size-4" />
+ <Button
+ size="sm"
+ variant="outline"
+ disabled={inspectMutation.isPending}
+ onClick={() => chooseCandidate(candidate)}
+ >
+ {inspectMutation.isPending ? (
+ <Loader2 className="size-4 animate-spin motion-reduce:animate-none" />
+ ) : (
+ <FolderSearch className="size-4" />
+ )}
+ Choose folder
+ </Button>
)}
- Choose folder
- </Button>
- </div>
- ))}
+ </div>
+ )
+ })}
</div>
) : null}
{inspection.candidate_roots_truncated ? (
@@ -755,6 +907,20 @@ function GithubImport({
</PanelContent>
</Panel>
) : null}
+ <ConfirmDialog
+ open={unlinkingSource != null}
+ onOpenChange={(open) => {
+ if (!open) setUnlinkingSource(null)
+ }}
+ title={`Unlink repository from ${unlinkingSource?.agent.name ?? 'this agent'}?`}
+ description="Deploy-on-push from this repository root will stop. The existing agent, active revision, deployment history, and sessions will remain available. You can then import this root into the new agent."
+ confirmLabel="Unlink repository"
+ destructive
+ pending={unlinkMutation.isPending}
+ onConfirm={() => {
+ if (unlinkingSource) unlinkMutation.mutate(unlinkingSource)
+ }}
+ />
</div>
)
}
diff --git a/web/src/pages/AgentSetup.tsx b/web/src/pages/AgentSetup.tsx
index 7ed87e8f..ef8551c0 100644
--- a/web/src/pages/AgentSetup.tsx
+++ b/web/src/pages/AgentSetup.tsx
@@ -15,6 +15,10 @@ import {
getAgent,
getAgentDeployment,
getManagedSlackConnection,
+ getSession,
+ getSessionEvents,
+ getSessions,
+ type SessionEvent,
} from '@/api/client'
import {
DeploymentLog,
@@ -28,6 +32,7 @@ import {
PanelTitle,
} from '@/components/panel'
import { StatusBadge } from '@/components/status-badge'
+import { MessageBubble } from '@/components/session-conversation'
import {
Alert,
AlertAction,
@@ -49,6 +54,12 @@ import {
import { deploymentStage } from '@/lib/deployment-slack-cta'
import { notifyError } from '@/lib/errors'
import { managedSlackNotice } from '@/lib/managed-slack-notice'
+import { latestManagedSlackSession } from '@/lib/managed-slack-session'
+import {
+ bodyText,
+ isTerminalSessionStatus,
+ isTurnInput,
+} from '@/lib/session-turns'
import { cn } from '@/lib/utils'
function setupStage(input: {
@@ -81,6 +92,19 @@ function setupStage(input: {
return stage === 'running' ? 'preparing' : stage
}
+function previewText(text: string | null, max = 360): string | null {
+ if (!text || text.length <= max) return text
+ return `${text.slice(0, max).trimEnd()}…`
+}
+
+function conversationSettled(events: SessionEvent[] | undefined): boolean {
+ return !!events?.some(
+ (event) =>
+ event.type === 'agent.message' ||
+ event.type.toLowerCase().includes('error'),
+ )
+}
+
export default function AgentSetup() {
const { agentId = '' } = useParams()
const [searchParams, setSearchParams] = useSearchParams()
@@ -128,6 +152,72 @@ export default function AgentSetup() {
queryFn: () => getAgent(sameOwnerConnectedAgentId!),
enabled: !!sameOwnerConnectedAgentId,
})
+ const stage = setupStage({
+ hasDeployment: !!deploymentId,
+ state: deploymentQuery.data?.state,
+ terminal: deploymentQuery.data?.terminal,
+ loadFailed: deploymentQuery.isError,
+ agentReady: agentQuery.data
+ ? agentCanStartNewSession(agentQuery.data)
+ : false,
+ agentDeploymentState: agentQuery.data
+ ? agentDeploymentDisplayStatus(agentQuery.data)
+ : undefined,
+ })
+ const activationReady =
+ stage === 'ready' && managedSlackQuery.data?.status === 'active'
+ const activationConnectedAt = managedSlackQuery.data?.connected_at ?? null
+ const activationSessionsQuery = useQuery({
+ queryKey: [
+ 'agent-setup',
+ 'managed-slack-sessions',
+ agentId,
+ activationConnectedAt,
+ ],
+ queryFn: () =>
+ getSessions({
+ agent: agentId,
+ after: activationConnectedAt ?? undefined,
+ limit: 100,
+ }),
+ enabled: !!agentId && activationReady,
+ refetchInterval: (query) =>
+ latestManagedSlackSession(query.state.data ?? [], activationConnectedAt)
+ ? false
+ : 1500,
+ refetchOnWindowFocus: 'always',
+ })
+ const activationSession = latestManagedSlackSession(
+ activationSessionsQuery.data ?? [],
+ activationConnectedAt,
+ )
+ const activationEventsQuery = useQuery({
+ queryKey: ['session-events', activationSession?.id],
+ queryFn: () => getSessionEvents(activationSession!.id),
+ enabled: !!activationSession,
+ refetchInterval: (query) =>
+ conversationSettled(query.state.data) ? false : 1000,
+ refetchOnWindowFocus: 'always',
+ })
+ const activationEvents = activationEventsQuery.data ?? []
+ const activationInput = activationEvents.find(isTurnInput)
+ const activationReply = activationEvents.find(
+ (event) => event.type === 'agent.message',
+ )
+ const activationError = activationEvents.find((event) =>
+ event.type.toLowerCase().includes('error'),
+ )
+ const activationSessionQuery = useQuery({
+ queryKey: ['session', activationSession?.id],
+ queryFn: () => getSession(activationSession!.id),
+ enabled: !!activationSession,
+ refetchInterval: (query) =>
+ conversationSettled(activationEvents) ||
+ isTerminalSessionStatus(query.state.data?.status)
+ ? false
+ : 1500,
+ refetchOnWindowFocus: 'always',
+ })
const logsQuery = useAgentDeploymentLogs({
agentId,
deploymentId,
@@ -177,14 +267,6 @@ export default function AgentSetup() {
const agent = agentQuery.data
const deployment = deploymentQuery.data
- const stage = setupStage({
- hasDeployment: !!deploymentId,
- state: deployment?.state,
- terminal: deployment?.terminal,
- loadFailed: deploymentQuery.isError,
- agentReady: agentCanStartNewSession(agent),
- agentDeploymentState: agentDeploymentDisplayStatus(agent),
- })
const managedSlack = managedSlackQuery.data
const managedSlackStatus = managedSlackQuery.isSuccess
? (managedSlack?.status ?? null)
@@ -195,6 +277,7 @@ export default function AgentSetup() {
managedStatus: managedSlackStatus,
openUrl: managedSlack?.open_url,
connecting: authorizeManagedSlackMutation.isPending,
+ activated: !!activationSession,
})
const managedWorkspace =
managedSlack?.workspace?.name ?? managedSlack?.workspace?.id
@@ -229,16 +312,16 @@ export default function AgentSetup() {
: null
return (
- <div className="mx-auto max-w-3xl space-y-5">
+ <div className="mx-auto max-w-3xl space-y-4">
<header className="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
- <div>
- <p className="text-muted-foreground text-xs font-medium tracking-wide uppercase">
- Agent setup
- </p>
- <h1 className="mt-1 text-xl font-semibold tracking-tight">
+ <div className="space-y-1">
+ <h1 className="text-lg font-semibold tracking-tight">
Set up {agent.name}
</h1>
- <div className="mt-2 flex flex-wrap items-center gap-2">
+ <p className="text-muted-foreground text-sm">
+ Deploy the agent, connect Slack, and start the first conversation.
+ </p>
+ <div className="flex flex-wrap items-center gap-2 pt-1.5">
<StatusBadge
status={
stage === 'preparing' ? (deployment?.state ?? 'pending') : stage
@@ -291,11 +374,11 @@ export default function AgentSetup() {
) : null}
<Panel>
- <PanelContent className="px-6 py-7 sm:px-8 sm:py-9">
- <div className="max-w-2xl">
+ <PanelContent className="px-5 py-5 sm:px-6 sm:py-6">
+ <div className="flex max-w-2xl items-start gap-3">
<div
className={cn(
- 'mb-5 flex size-10 items-center justify-center rounded-md',
+ 'flex size-9 shrink-0 items-center justify-center rounded-md',
stage === 'failed'
? 'bg-status-error-bg text-status-error'
: presentation.action === 'open'
@@ -314,94 +397,226 @@ export default function AgentSetup() {
<span className="sr-only" aria-live="polite" aria-atomic="true">
{presentation.announcement}
</span>
- <h2 className="text-2xl font-semibold tracking-tight">
- {presentation.title}
- </h2>
- <p className="text-muted-foreground mt-2 max-w-xl text-sm leading-relaxed">
- {presentation.description}
- </p>
+ <div className="min-w-0 flex-1">
+ <h2 className="text-lg font-semibold tracking-tight">
+ {presentation.title}
+ </h2>
+ <p className="text-muted-foreground mt-1.5 max-w-xl text-sm leading-relaxed">
+ {presentation.description}
+ </p>
- <div className="mt-6 flex flex-wrap items-center gap-3">
- {presentation.action === 'open' && managedSlack?.open_url ? (
- <Button size="lg" className="h-10 px-5" asChild>
- <a
- href={managedSlack.open_url}
- target="_blank"
- rel="noreferrer"
+ <div className="mt-4 flex flex-wrap items-center gap-3">
+ {presentation.action === 'open' && managedSlack?.open_url ? (
+ <Button asChild>
+ <a
+ href={managedSlack.open_url}
+ target="_blank"
+ rel="noreferrer"
+ >
+ {presentation.label}
+ <ExternalLink className="size-4" />
+ </a>
+ </Button>
+ ) : presentation.action === 'connect' ||
+ presentation.action === 'reconnect' ||
+ presentation.action === 'connecting' ? (
+ <Button
+ disabled={authorizeManagedSlackMutation.isPending}
+ onClick={() => authorizeManagedSlackMutation.mutate()}
>
- Open Slack
- <ExternalLink className="size-4" />
- </a>
- </Button>
- ) : presentation.action === 'connect' ||
- presentation.action === 'reconnect' ||
- presentation.action === 'connecting' ? (
- <Button
- size="lg"
- className="h-10 px-5"
- disabled={authorizeManagedSlackMutation.isPending}
- onClick={() => authorizeManagedSlackMutation.mutate()}
- >
- {authorizeManagedSlackMutation.isPending ? (
+ {authorizeManagedSlackMutation.isPending ? (
+ <Loader2
+ className="size-4 animate-spin motion-reduce:animate-none"
+ aria-hidden
+ />
+ ) : null}
+ {presentation.label}
+ </Button>
+ ) : stage === 'failed' && deploymentHref ? (
+ <Button asChild>
+ <Link to={deploymentHref}>
+ Review deployment
+ <ChevronRight className="size-4" />
+ </Link>
+ </Button>
+ ) : managedSlackStatus === 'active' && stage === 'preparing' ? (
+ <span className="text-muted-foreground inline-flex items-center gap-2 text-sm">
<Loader2
className="size-4 animate-spin motion-reduce:animate-none"
aria-hidden
/>
- ) : null}
- {presentation.label}
- </Button>
- ) : stage === 'failed' && deploymentHref ? (
- <Button size="lg" className="h-10 px-5" asChild>
- <Link to={deploymentHref}>
- Review deployment
- <ChevronRight className="size-4" />
- </Link>
- </Button>
- ) : managedSlackStatus === 'active' && stage === 'preparing' ? (
- <span className="text-muted-foreground inline-flex items-center gap-2 text-sm">
- <Loader2
- className="size-4 animate-spin motion-reduce:animate-none"
- aria-hidden
- />
- Finishing deployment…
- </span>
- ) : null}
- {presentation.action === 'connect' && presentation.disclosure ? (
- <div className="max-w-sm text-xs leading-relaxed">
- <span className="text-muted-foreground">
- Anyone in this workspace who can message the app can use
- this agent.{' '}
+ Finishing deployment…
</span>
- <Link
- to={`/agents/${agentId}?connect=slack`}
- className="text-foreground underline underline-offset-4"
+ ) : null}
+ {presentation.action === 'connect' &&
+ presentation.disclosure ? (
+ <div className="max-w-sm text-xs leading-relaxed">
+ <span className="text-muted-foreground">
+ Anyone in this workspace who can message the app can use
+ this agent.{' '}
+ </span>
+ <Link
+ to={`/agents/${agentId}?connect=slack`}
+ className="text-foreground underline underline-offset-4"
+ >
+ Use your own Slack app
+ </Link>
+ </div>
+ ) : null}
+ </div>
+
+ {managedSlackQuery.isError && stage !== 'failed' ? (
+ <div className="mt-3 flex items-center gap-2 text-xs">
+ <span className="text-status-error">
+ Slack status is unavailable.
+ </span>
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => void managedSlackQuery.refetch()}
>
- Use your own Slack app
- </Link>
+ Retry
+ </Button>
</div>
+ ) : presentation.status ? (
+ <p className="text-muted-foreground mt-3 text-xs">
+ {presentation.status}
+ </p>
+ ) : null}
+ </div>
+ </div>
+ </PanelContent>
+ {activationReady ? (
+ <div
+ className="border-t px-5 py-4 sm:px-6"
+ aria-live="polite"
+ aria-atomic="false"
+ >
+ <div className="flex flex-wrap items-start justify-between gap-2">
+ <div>
+ <p className="text-sm font-semibold">
+ First Slack conversation
+ </p>
+ <p className="text-muted-foreground mt-0.5 text-xs">
+ This page follows the same durable session shown elsewhere in
+ OpenComputer.
+ </p>
+ </div>
+ {activationSession ? (
+ <StatusBadge
+ status={
+ activationSessionQuery.data?.status ??
+ activationSession.status
+ }
+ />
) : null}
</div>
- {managedSlackQuery.isError && stage !== 'failed' ? (
- <div className="mt-4 flex items-center gap-2 text-xs">
+ {activationSessionsQuery.isError ? (
+ <div className="mt-4 flex flex-wrap items-center gap-2 text-sm">
<span className="text-status-error">
- Slack status is unavailable.
+ We couldn&apos;t check for your Slack message.
</span>
<Button
- variant="ghost"
size="sm"
- onClick={() => void managedSlackQuery.refetch()}
+ variant="outline"
+ onClick={() => void activationSessionsQuery.refetch()}
>
Retry
</Button>
</div>
- ) : presentation.status ? (
- <p className="text-muted-foreground mt-4 text-xs">
- {presentation.status}
- </p>
- ) : null}
+ ) : !activationSession ? (
+ <div className="mt-4 flex items-start gap-3" role="status">
+ <Loader2
+ className="text-muted-foreground mt-0.5 size-4 shrink-0 animate-spin motion-reduce:animate-none"
+ aria-hidden
+ />
+ <div>
+ <p className="text-sm font-medium">
+ Waiting for your first Slack message
+ </p>
+ <p className="text-muted-foreground mt-0.5 text-xs">
+ Send a message to OpenComputer in Slack. The session and
+ reply will appear here automatically.
+ </p>
+ </div>
+ </div>
+ ) : (
+ <div className="mt-4">
+ {activationEventsQuery.isError ? (
+ <div className="flex flex-wrap items-center gap-2 text-sm">
+ <span className="text-status-error">
+ The session was created, but its messages could not be
+ loaded.
+ </span>
+ <Button
+ size="sm"
+ variant="outline"
+ onClick={() => void activationEventsQuery.refetch()}
+ >
+ Retry
+ </Button>
+ </div>
+ ) : activationEventsQuery.isLoading ? (
+ <div className="space-y-3">
+ <Skeleton className="h-12 w-full" />
+ <Skeleton className="h-12 w-4/5" />
+ </div>
+ ) : (
+ <div className="space-y-4">
+ {activationInput ? (
+ <MessageBubble
+ label="You"
+ text={
+ previewText(bodyText(activationInput)) ??
+ 'Message received'
+ }
+ />
+ ) : null}
+ {activationReply ? (
+ <MessageBubble
+ label="Agent"
+ text={
+ previewText(bodyText(activationReply)) ??
+ 'Reply available in the full session'
+ }
+ />
+ ) : activationError ? (
+ <div className="bg-status-error-bg/40 text-status-error rounded-md px-3 py-2 text-xs">
+ {bodyText(activationError) ??
+ 'The first turn needs attention. Open the session for details.'}
+ </div>
+ ) : (
+ <div
+ className="text-muted-foreground flex items-center gap-2 text-xs"
+ role="status"
+ >
+ <Loader2
+ className="size-3.5 animate-spin motion-reduce:animate-none"
+ aria-hidden
+ />
+ Agent is replying…
+ </div>
+ )}
+ </div>
+ )}
+ <div className="mt-4 flex flex-wrap items-center gap-2">
+ <Button size="sm" variant="outline" asChild>
+ <Link to={`/sessions/${activationSession.id}`}>
+ Open session
+ <ChevronRight className="size-4" />
+ </Link>
+ </Button>
+ <Button size="sm" variant="ghost" asChild>
+ <Link to={`/agents/${agentId}/sessions`}>
+ All agent sessions
+ </Link>
+ </Button>
+ </div>
+ </div>
+ )}
</div>
- </PanelContent>
+ ) : null}
</Panel>
{deployment ? (
diff --git a/web/src/pages/agent-new-linked-repository.test.tsx b/web/src/pages/agent-new-linked-repository.test.tsx
new file mode 100644
index 00000000..13ea451a
--- /dev/null
+++ b/web/src/pages/agent-new-linked-repository.test.tsx
@@ -0,0 +1,76 @@
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
+import { renderToStaticMarkup } from 'react-dom/server'
+import { MemoryRouter, Route, Routes } from 'react-router-dom'
+import { describe, expect, it } from 'vitest'
+import type { DeployApp } from '@/api/client'
+import AgentNew from './AgentNew'
+
+const repoId = 'repo_0123456789abcdef01234567'
+const agentId = 'agt_0123456789abcdef01234567'
+
+function renderLinkedRepository() {
+ const app: DeployApp = {
+ installed: true,
+ install_url: null,
+ configure_url: 'https://github.com/settings/installations/1',
+ account: 'example',
+ repository_selection: 'selected',
+ repositories: [
+ {
+ id: repoId,
+ full_name: 'example/flue-starter',
+ default_branch: 'main',
+ private: false,
+ linked_sources: [
+ {
+ path: '',
+ production_ref: 'main',
+ status: 'active',
+ agent: { id: agentId, name: 'Support triage' },
+ },
+ ],
+ },
+ ],
+ }
+ const queryClient = new QueryClient({
+ defaultOptions: { queries: { retry: false, staleTime: Infinity } },
+ })
+ queryClient.setQueryData(['deploy-app'], app)
+
+ return renderToStaticMarkup(
+ <QueryClientProvider client={queryClient}>
+ <MemoryRouter
+ initialEntries={[
+ {
+ pathname: '/agents/new',
+ state: {
+ repositoryImport: {
+ repo: repoId,
+ path: '',
+ productionRef: 'main',
+ },
+ },
+ },
+ ]}
+ >
+ <Routes>
+ <Route path="/agents/new" element={<AgentNew />} />
+ </Routes>
+ </MemoryRouter>
+ </QueryClientProvider>,
+ )
+}
+
+describe('repository import conflict discovery', () => {
+ it('marks a linked root before review and offers open or confirmed unlink', () => {
+ const markup = renderLinkedRepository()
+
+ expect(markup).toContain('Linked to Support triage')
+ expect(markup).toContain('Repository root already linked')
+ expect(markup).toContain(`href="/agents/${agentId}"`)
+ expect(markup).toContain('Unlink repository')
+ expect(markup).toMatch(
+ /<button[^>]*disabled=""[^>]*>Review agent<\/button>/,
+ )
+ })
+})
diff --git a/web/src/pages/agent-setup.test.tsx b/web/src/pages/agent-setup.test.tsx
index 75112bfe..403536fc 100644
--- a/web/src/pages/agent-setup.test.tsx
+++ b/web/src/pages/agent-setup.test.tsx
@@ -2,7 +2,7 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { renderToStaticMarkup } from 'react-dom/server'
import { MemoryRouter, Route, Routes } from 'react-router-dom'
import { describe, expect, it } from 'vitest'
-import type { AgentDeployment } from '@/api/client'
+import type { AgentDeployment, Session, SessionEvent } from '@/api/client'
import AgentSetup from './AgentSetup'
const agentId = 'agt_aaaaaaaaaaaaaaaaaaaaaaaa'
@@ -74,6 +74,8 @@ function renderSetup(input: {
managed?: Record<string, unknown> | null
search?: string
agent?: Record<string, unknown>
+ sessions?: Session[]
+ events?: { sessionId: string; data: SessionEvent[] }
}) {
const queryClient = new QueryClient({
defaultOptions: { queries: { retry: false, staleTime: Infinity } },
@@ -97,6 +99,23 @@ function renderSetup(input: {
if ('managed' in input) {
queryClient.setQueryData(['slack', 'managed', agentId], input.managed)
}
+ if (input.sessions) {
+ queryClient.setQueryData(
+ [
+ 'agent-setup',
+ 'managed-slack-sessions',
+ agentId,
+ input.managed?.connected_at ?? null,
+ ],
+ input.sessions,
+ )
+ }
+ if (input.events) {
+ queryClient.setQueryData(
+ ['session-events', input.events.sessionId],
+ input.events.data,
+ )
+ }
return renderToStaticMarkup(
<QueryClientProvider client={queryClient}>
@@ -150,11 +169,64 @@ describe('agent setup', () => {
})
expect(ready).toContain('Send your first message')
expect(ready).toContain('>Open Slack<')
+ expect(ready).toContain('Waiting for your first Slack message')
expect(ready).toContain(
'href="https://slack.com/app_redirect?app=A1&amp;team=T1"',
)
})
+ it('turns a real managed Slack session into a conversation preview', () => {
+ const sessionId = 'ses_aaaaaaaaaaaaaaaaaaaaaaaa'
+ const readyDeployment: AgentDeployment = {
+ ...buildingDeployment,
+ state: 'ready',
+ phase: 'verify',
+ terminal: true,
+ active: true,
+ allowed_actions: ['open_agent', 'start_session'],
+ }
+ const session: Session = {
+ id: sessionId,
+ status: 'running',
+ agent_id: agentId,
+ metadata: { slack: { mode: 'managed', team_id: 'T1' } },
+ created_at: '2026-07-16T18:00:01Z',
+ }
+ const events: SessionEvent[] = [
+ {
+ id: 'evt_input',
+ seq: 1,
+ type: 'user.message',
+ level: 'user',
+ body: { text: 'Hello from Slack' },
+ source: 'client',
+ },
+ {
+ id: 'evt_reply',
+ seq: 2,
+ type: 'agent.message',
+ level: 'user',
+ body: { text: 'Hello! Your agent is ready.' },
+ source: 'runtime',
+ },
+ ]
+
+ const markup = renderSetup({
+ deployment: readyDeployment,
+ managed: activeSlack,
+ sessions: [session],
+ events: { sessionId, data: events },
+ search: `?deployment=${deploymentId}`,
+ })
+
+ expect(markup).toContain('Support triage is live in Slack')
+ expect(markup).toContain('Continue in Slack')
+ expect(markup).toContain('Hello from Slack')
+ expect(markup).toContain('Hello! Your agent is ready.')
+ expect(markup).toContain(`href="/sessions/${sessionId}"`)
+ expect(markup).toContain(`href="/agents/${agentId}/sessions"`)
+ })
+
it('uses the same activation flow for a manually created agent', () => {
const markup = renderSetup({ managed: null })