Skip to content

An open-source, faster Devin alternative

TypeScript

feat(web): add repository-first agent onboarding

Igor Zalutski659fd579f2ac
diff --git a/web/src/api/client.ts b/web/src/api/client.ts
index cb5ac765..d5bf4dc9 100644
--- a/web/src/api/client.ts
+++ b/web/src/api/client.ts
@@ -35,7 +35,7 @@ export type {
AgentDeployment,
AgentDeploymentLog,
DeployApp,
- FlueSourceInspection,
+ RepositorySourceInspection,
Session,
AgentSnapshot,
SessionEvent,
@@ -659,7 +659,7 @@ export const deleteAgentSkills = (agentId: string) =>
export const getDeployApp = () =>
apiFetch('/v3/github/deploy-app', {}, S.DeployAppSchema)
-export const inspectFlueRepository = (body: {
+export const reviewRepositoryAgent = (body: {
repo: string
path: string
production_ref: string
@@ -667,7 +667,7 @@ export const inspectFlueRepository = (body: {
apiFetch(
'/v3/github/deploy-app/inspect',
{ method: 'POST', body: JSON.stringify(body) },
- S.FlueSourceInspectionSchema,
+ S.RepositorySourceInspectionSchema,
)
export const importAgentFromGithub = (
@@ -679,6 +679,11 @@ export const importAgentFromGithub = (
path: string
production_ref: string
}
+ review: {
+ sha: string
+ source_profile: 'flue-app-v1'
+ fingerprint: string
+ }
credential: 'managed'
},
idempotencyKey: string,
diff --git a/web/src/api/deploy-app-client.test.ts b/web/src/api/deploy-app-client.test.ts
index 73ff861c..a8f84bf4 100644
--- a/web/src/api/deploy-app-client.test.ts
+++ b/web/src/api/deploy-app-client.test.ts
@@ -1,5 +1,5 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
-import { getDeployApp } from './client'
+import { getDeployApp, importAgentFromGithub } from './client'
const deployAppResponse = {
installed: false,
@@ -23,4 +23,66 @@ describe('deploy app client', () => {
await expect(getDeployApp()).resolves.toEqual(deployAppResponse)
})
+
+ it('submits the exact review receipt and preserves source-change recovery', async () => {
+ let captured: RequestInit | undefined
+ const fetchMock = vi.fn(
+ (_input: string | URL | Request, init?: RequestInit) => {
+ captured = init
+ return Promise.resolve(
+ Response.json(
+ {
+ error: {
+ type: 'source_changed_re_review',
+ message: 'repository source changed since review',
+ },
+ },
+ { status: 409 },
+ ),
+ )
+ },
+ )
+ vi.stubGlobal('fetch', fetchMock)
+
+ await expect(
+ importAgentFromGithub(
+ {
+ name: 'Support triage',
+ credential: 'managed',
+ source: {
+ type: 'github',
+ repo: 'repo_0123456789abcdef01234567',
+ path: 'agents/support',
+ production_ref: 'main',
+ },
+ review: {
+ sha: 'a'.repeat(40),
+ source_profile: 'flue-app-v1',
+ fingerprint: 'sha256:reviewed',
+ },
+ },
+ 'import-command-1',
+ ),
+ ).rejects.toMatchObject({
+ status: 409,
+ type: 'source_changed_re_review',
+ })
+
+ expect(captured?.method).toBe('POST')
+ expect(new Headers(captured?.headers).get('Idempotency-Key')).toBe(
+ 'import-command-1',
+ )
+ const requestBody = captured?.body
+ if (typeof requestBody !== 'string') {
+ throw new Error('import request body must be JSON')
+ }
+ const parsedBody = JSON.parse(requestBody) as unknown
+ expect(parsedBody).toMatchObject({
+ review: {
+ sha: 'a'.repeat(40),
+ source_profile: 'flue-app-v1',
+ fingerprint: 'sha256:reviewed',
+ },
+ })
+ })
})
diff --git a/web/src/api/mock.ts b/web/src/api/mock.ts
index 06769622..eb3769c0 100644
--- a/web/src/api/mock.ts
+++ b/web/src/api/mock.ts
@@ -549,23 +549,42 @@ const flueInspection = {
root: '',
production_ref: 'main',
sha: 'cbb8766d972199b01d03389d2680970dc29d1d34',
- manifest: {
- schema_version: 1 as const,
- entrypoint: 'support-triage',
- model: 'anthropic/claude-haiku-4-5',
- runtime: { family: 'flue' as const, type: 'default' },
- vars: { SUPPORT_QUEUE: 'priority' },
- },
- package: {
- name: 'oc-flue-starter',
- node_engine: '>=22.19 <23',
- flue_cli: '0.1.0',
- },
- lockfile: { version: 3 },
- builder: { node: '22.19.0' },
- source: { files: 28, bytes: 164_208 },
- variable_names: ['SUPPORT_QUEUE'],
- warnings: [],
+ interpretation: {
+ disposition: 'exact' as const,
+ source_profile: 'flue-app-v1' as const,
+ source_profile_version: 1 as const,
+ summary: 'Flue agent detected',
+ reason_code: 'flue_detected',
+ assumptions: [],
+ agent: {
+ runtime: 'flue' as const,
+ model: 'anthropic/claude-haiku-4-5',
+ },
+ },
+ profile: {
+ source_profile: 'flue-app-v1' as const,
+ source_profile_version: 1 as const,
+ manifest: {
+ schema_version: 1 as const,
+ entrypoint: 'support-triage',
+ model: 'anthropic/claude-haiku-4-5',
+ runtime: { family: 'flue' as const, type: 'default' },
+ vars: { SUPPORT_QUEUE: 'priority' },
+ },
+ package: {
+ name: 'oc-flue-starter',
+ node_engine: '>=22.19 <23',
+ flue_cli: '0.1.0',
+ },
+ lockfile: { version: 3 },
+ builder: { node: '22.19.0' },
+ source: { files: 28, bytes: 164_208 },
+ variable_names: ['SUPPORT_QUEUE'],
+ warnings: [],
+ },
+ review_fingerprint: 'sha256:mock-flue-review',
+ candidate_roots: [],
+ candidate_roots_truncated: false,
}
const importedAgent = {
@@ -601,6 +620,9 @@ const importedSource = {
latest_seen_sha: flueInspection.sha,
active_deployed_sha: null,
full_name: flueInspection.repository.full_name,
+ source_profile: 'flue-app-v1',
+ source_profile_version: 1,
+ review_fingerprint: flueInspection.review_fingerprint,
}
const flueDeployment = {
diff --git a/web/src/api/repository-inspection-schemas.test.ts b/web/src/api/repository-inspection-schemas.test.ts
new file mode 100644
index 00000000..7793a4bd
--- /dev/null
+++ b/web/src/api/repository-inspection-schemas.test.ts
@@ -0,0 +1,138 @@
+import { describe, expect, it } from 'vitest'
+import { RepositorySourceInspectionSchema } from './schemas'
+
+const common = {
+ repository: {
+ id: 'repo_0123456789abcdef01234567',
+ full_name: 'example/agent',
+ default_branch: 'main',
+ },
+ root: '',
+ production_ref: 'main',
+ sha: 'a'.repeat(40),
+ review_fingerprint: 'sha256:review',
+ candidate_roots: [],
+ candidate_roots_truncated: false,
+}
+
+describe('repository source inspection schema', () => {
+ it('accepts the sole launch profile without losing its Flue review projection', () => {
+ const parsed = RepositorySourceInspectionSchema.parse({
+ ...common,
+ interpretation: {
+ disposition: 'exact',
+ source_profile: 'flue-app-v1',
+ source_profile_version: 1,
+ summary: 'Flue agent detected',
+ reason_code: 'flue_detected',
+ assumptions: [],
+ agent: { runtime: 'flue', model: 'anthropic/claude-haiku-4-5' },
+ },
+ profile: {
+ source_profile: 'flue-app-v1',
+ source_profile_version: 1,
+ manifest: {
+ schema_version: 1,
+ entrypoint: 'support-triage',
+ model: 'anthropic/claude-haiku-4-5',
+ runtime: { family: 'flue', type: 'default' },
+ vars: {},
+ },
+ package: {
+ name: 'support-agent',
+ node_engine: '>=22.19 <23',
+ flue_cli: '^1.0.0',
+ },
+ lockfile: { version: 3 },
+ builder: { node: '22.19.0' },
+ source: { files: 12, bytes: 4096 },
+ variable_names: [],
+ warnings: [],
+ },
+ })
+
+ expect(parsed.profile?.manifest.entrypoint).toBe('support-triage')
+ expect(parsed.review_fingerprint).toBe('sha256:review')
+ })
+
+ it('treats broken Flue and unrecognized source as review results', () => {
+ const invalid = RepositorySourceInspectionSchema.parse({
+ ...common,
+ interpretation: {
+ disposition: 'invalid',
+ source_profile: 'flue-app-v1',
+ source_profile_version: 1,
+ summary: 'Flue manifest missing',
+ reason_code: 'flue_manifest_missing',
+ issues: [
+ {
+ code: 'flue_manifest_missing',
+ message: 'Add agent.toml to this Flue root.',
+ },
+ ],
+ },
+ profile: null,
+ })
+ const unrecognized = RepositorySourceInspectionSchema.parse({
+ ...common,
+ interpretation: {
+ disposition: 'unrecognized',
+ source_profile: null,
+ source_profile_version: null,
+ summary: "We couldn't find an agent definition in this folder",
+ reason_code: 'unrecognized_source',
+ },
+ profile: null,
+ candidate_roots: [
+ {
+ path: 'agents/support',
+ source_profile: null,
+ summary: 'Agent manifest found',
+ marker: 'agent.toml',
+ },
+ {
+ path: 'apps/triage',
+ source_profile: 'flue-app-v1',
+ summary: 'Flue configuration found',
+ marker: 'flue.config.ts',
+ },
+ ],
+ candidate_roots_truncated: true,
+ })
+
+ expect(invalid.interpretation.disposition).toBe('invalid')
+ expect(unrecognized.candidate_roots).toHaveLength(2)
+ expect(unrecognized.candidate_roots_truncated).toBe(true)
+ })
+
+ it('rejects speculative profiles and fallback dispositions', () => {
+ expect(() =>
+ RepositorySourceInspectionSchema.parse({
+ ...common,
+ interpretation: {
+ disposition: 'exact',
+ source_profile: 'oc-soft-agent-v1',
+ source_profile_version: 1,
+ summary: 'Soft agent detected',
+ reason_code: 'soft_agent_detected',
+ assumptions: [],
+ agent: { runtime: 'pi', model: 'openai/gpt-5' },
+ },
+ profile: null,
+ }),
+ ).toThrow()
+ expect(() =>
+ RepositorySourceInspectionSchema.parse({
+ ...common,
+ interpretation: {
+ disposition: 'fallback',
+ source_profile: null,
+ source_profile_version: null,
+ summary: 'Generated defaults',
+ reason_code: 'fallback',
+ },
+ profile: null,
+ }),
+ ).toThrow()
+ })
+})
diff --git a/web/src/api/schemas.ts b/web/src/api/schemas.ts
index a77c5cdb..6f9d7eb1 100644
--- a/web/src/api/schemas.ts
+++ b/web/src/api/schemas.ts
@@ -595,10 +595,13 @@ export const DeploymentSourceSchema = z.object({
repo_id: z.string(),
path: z.string(),
production_ref: z.string(),
- status: z.string(), // active | path_missing | ref_missing | auth_required | repo_not_selected | app_suspended | error
+ status: z.string(), // active | source_profile_changed | path_missing | ref_missing | auth_required | repo_not_selected | app_suspended | error
latest_seen_sha: z.string().nullish(),
active_deployed_sha: z.string().nullish(),
full_name: z.string().nullish(), // "owner/repo" (joined from the repo row)
+ source_profile: z.literal('flue-app-v1').nullish(),
+ source_profile_version: z.literal(1).nullish(),
+ review_fingerprint: z.string().nullish(),
})
export const DeploymentSourceResponseSchema = z.object({
source: DeploymentSourceSchema,
@@ -628,15 +631,28 @@ export const LinkResultSchema = z.object({
deploy_error: z.object({ type: z.string(), message: z.string() }).nullish(),
})
-export const FlueSourceInspectionSchema = z.object({
- repository: z.object({
- id: z.string(),
- full_name: z.string(),
- default_branch: z.string().nullish(),
- }),
- root: z.string(),
- production_ref: z.string(),
- sha: z.string(),
+export const RepositoryReviewIssueSchema = z.object({
+ code: z.string(),
+ message: z.string(),
+ path: z.string().optional(),
+})
+
+export const RepositoryCandidateRootSchema = z.object({
+ path: z.string(),
+ source_profile: z.literal('flue-app-v1').nullable(),
+ summary: z.string(),
+ marker: z.enum([
+ 'agent.toml',
+ 'flue.config.ts',
+ 'flue.config.js',
+ 'flue.config.mjs',
+ 'flue.config.cjs',
+ ]),
+})
+
+export const FlueSourceProfileSchema = z.object({
+ source_profile: z.literal('flue-app-v1'),
+ source_profile_version: z.literal(1),
manifest: z.object({
schema_version: z.literal(1),
entrypoint: z.string(),
@@ -656,10 +672,70 @@ export const FlueSourceInspectionSchema = z.object({
builder: z.object({ node: z.string() }),
source: z.object({ files: z.number(), bytes: z.number() }),
variable_names: z.array(z.string()).default([]),
- warnings: z
- .array(z.object({ code: z.string(), message: z.string() }))
- .default([]),
-})
+ warnings: z.array(RepositoryReviewIssueSchema).default([]),
+})
+
+export const RepositorySourceInterpretationSchema = z.discriminatedUnion(
+ 'disposition',
+ [
+ z.object({
+ disposition: z.literal('exact'),
+ source_profile: z.literal('flue-app-v1'),
+ source_profile_version: z.literal(1),
+ summary: z.string(),
+ reason_code: z.string(),
+ assumptions: z.array(z.string()).default([]),
+ agent: z.object({
+ runtime: z.literal('flue'),
+ model: z.string(),
+ }),
+ }),
+ z.object({
+ disposition: z.literal('invalid'),
+ source_profile: z.literal('flue-app-v1').nullable(),
+ source_profile_version: z.literal(1).nullable(),
+ summary: z.string(),
+ reason_code: z.string(),
+ issues: z.array(RepositoryReviewIssueSchema).default([]),
+ }),
+ z.object({
+ disposition: z.literal('unrecognized'),
+ source_profile: z.null(),
+ source_profile_version: z.null(),
+ summary: z.string(),
+ reason_code: z.literal('unrecognized_source'),
+ }),
+ ],
+)
+
+export const RepositorySourceInspectionSchema = z
+ .object({
+ repository: z.object({
+ id: z.string(),
+ full_name: z.string(),
+ default_branch: z.string().nullish(),
+ }),
+ root: z.string(),
+ production_ref: z.string(),
+ sha: z.string(),
+ interpretation: RepositorySourceInterpretationSchema,
+ profile: FlueSourceProfileSchema.nullable(),
+ review_fingerprint: z.string(),
+ candidate_roots: z.array(RepositoryCandidateRootSchema).max(20).default([]),
+ candidate_roots_truncated: z.boolean(),
+ })
+ .superRefine((review, context) => {
+ const exact = review.interpretation.disposition === 'exact'
+ if (exact !== (review.profile !== null)) {
+ context.addIssue({
+ code: 'custom',
+ path: ['profile'],
+ message: exact
+ ? 'an exact source interpretation requires its profile projection'
+ : 'a non-exact source interpretation cannot include a deployable profile',
+ })
+ }
+ })
export const ImportAgentResponseSchema = z.object({
agent: AgentSchema,
@@ -832,8 +908,11 @@ export type SkillItem = z.infer<typeof SkillItemSchema>
export type AgentDeploy = z.infer<typeof AgentDeploySchema>
export type AgentDeployment = z.infer<typeof AgentDeploymentSchema>
export type AgentDeploymentLog = z.infer<typeof AgentDeploymentLogSchema>
+export type DeploymentSource = z.infer<typeof DeploymentSourceSchema>
export type DeployApp = z.infer<typeof DeployAppSchema>
-export type FlueSourceInspection = z.infer<typeof FlueSourceInspectionSchema>
+export type RepositorySourceInspection = z.infer<
+ typeof RepositorySourceInspectionSchema
+>
export type Credential = z.infer<typeof CredentialSchema>
export type SlackConnection = z.infer<typeof SlackConnectionSchema>
export type SlackManifestResponse = z.infer<typeof SlackManifestResponseSchema>
diff --git a/web/src/components/agent-deploy-source.tsx b/web/src/components/agent-deploy-source.tsx
index 8abf8ace..f6068b33 100644
--- a/web/src/components/agent-deploy-source.tsx
+++ b/web/src/components/agent-deploy-source.tsx
@@ -5,6 +5,7 @@ import {
useQueryClient,
type QueryClient,
} from '@tanstack/react-query'
+import { useNavigate } from 'react-router-dom'
import { Unplug, ExternalLink, RotateCw } from 'lucide-react'
import { notifyError, notifySuccess } from '@/lib/errors'
import {
@@ -18,21 +19,33 @@ import { Panel, PanelContent } from '@/components/panel'
import { Button } from '@/components/ui/button'
import { Input, Select } from '@/components/form'
import { GithubMark } from '@/components/github-mark'
+import { SourceProfileChangedRecovery } from '@/components/source-profile-changed-recovery'
+import type { RepositorySeed } from '@/lib/repository-onboarding'
// A connect / redeploy kicks off a GitHub deploy that runs ASYNC — the new revision (prompt +
// skills) isn't live until it activates. Poll the source until the deploy lands
// (active_deployed_sha caught up to latest_seen_sha), keeping the card in step, then refresh the
// dependent views so the Overview + Skills update without a manual page reload. Bounded (~60s).
-async function pollDeployUntilActive(agentId: string, queryClient: QueryClient) {
+async function pollDeployUntilActive(
+ agentId: string,
+ queryClient: QueryClient,
+) {
for (let i = 0; i < 24; i++) {
await new Promise((r) => setTimeout(r, 2500))
try {
const src = (await getDeploymentSource(agentId)).source
queryClient.setQueryData(['agent-deploy-source', agentId], src)
- if (src?.active_deployed_sha && src.active_deployed_sha === src.latest_seen_sha) {
+ if (
+ src?.active_deployed_sha &&
+ src.active_deployed_sha === src.latest_seen_sha
+ ) {
void queryClient.invalidateQueries({ queryKey: ['agent', agentId] })
- void queryClient.invalidateQueries({ queryKey: ['agent-skills', agentId] })
- void queryClient.invalidateQueries({ queryKey: ['agent-revisions', agentId] })
+ void queryClient.invalidateQueries({
+ queryKey: ['agent-skills', agentId],
+ })
+ void queryClient.invalidateQueries({
+ queryKey: ['agent-revisions', agentId],
+ })
return
}
} catch {
@@ -55,6 +68,7 @@ export function AgentDeploySource({
agentId: string
autoFocusPicker?: boolean
}) {
+ const navigate = useNavigate()
const queryClient = useQueryClient()
const pickerRef = useRef<HTMLDivElement>(null)
const [repo, setRepo] = useState('')
@@ -65,6 +79,9 @@ export function AgentDeploySource({
// fresh load of an already-installed agent, and cleared on Disconnect — so the "pick a repo"
// nudge never lingers on unlinked/inline-only agents or reappears after an explicit disconnect.
const [justConnected, setJustConnected] = useState(false)
+ const [unlinkedImport, setUnlinkedImport] = useState<RepositorySeed | null>(
+ null,
+ )
const { data: app, isLoading: appLoading } = useQuery({
queryKey: ['deploy-app'],
@@ -150,8 +167,18 @@ export function AgentDeploySource({
onError: (e) => notifyError("Couldn't connect the repo.", e),
})
const unlink = useMutation({
- mutationFn: () => unlinkDeploymentSource(agentId),
- onSuccess: () => {
+ mutationFn: (options?: { prepareReimport?: boolean }) => {
+ void options
+ return unlinkDeploymentSource(agentId)
+ },
+ onSuccess: (_result, options) => {
+ if (options?.prepareReimport && source) {
+ setUnlinkedImport({
+ repo: source.repo_id,
+ path: source.path,
+ productionRef: source.production_ref,
+ })
+ }
invalidate()
hydratedRef.current = false
setJustConnected(false) // an explicit disconnect is not an onboarding moment
@@ -201,21 +228,58 @@ export function AgentDeploySource({
return (
<Panel className="overflow-hidden">
<PanelContent className="space-y-3">
- {srcLoading || appLoading ? (
+ {unlinkedImport ? (
+ <div className="space-y-3">
+ <p className="text-sm font-medium">Repository source unlinked</p>
+ <p className="text-muted-foreground text-xs">
+ Push-to-deploy stopped. The existing agent, active revision, and
+ sessions are unchanged.
+ </p>
+ <Button
+ size="sm"
+ onClick={() =>
+ void navigate('/agents/new', {
+ state: { repositoryImport: unlinkedImport },
+ })
+ }
+ >
+ Import as new agent
+ </Button>
+ </div>
+ ) : srcLoading || appLoading ? (
<p className="text-muted-foreground text-xs">Loading…</p>
) : srcError ? (
<div className="space-y-2">
<p className="text-xs text-red-600 dark:text-red-500">
Couldn’t load the repo connection.
</p>
- <Button size="sm" variant="outline" onClick={() => void refetchSource()}>
+ <Button
+ size="sm"
+ variant="outline"
+ onClick={() => void refetchSource()}
+ >
Retry
</Button>
</div>
+ ) : source?.status === 'source_profile_changed' ? (
+ <SourceProfileChangedRecovery
+ source={source}
+ pending={unlink.isPending}
+ onUnlink={() => unlink.mutate({ prepareReimport: true })}
+ />
) : !app?.installed ? (
<div className="space-y-3">
- <Button size="sm" variant="outline" disabled={!app?.install_url} asChild>
- <a href={app?.install_url ?? '#'} target="_blank" rel="noreferrer">
+ <Button
+ size="sm"
+ variant="outline"
+ disabled={!app?.install_url}
+ asChild
+ >
+ <a
+ href={app?.install_url ?? '#'}
+ target="_blank"
+ rel="noreferrer"
+ >
<GithubMark className="size-4" />
Connect repository
</a>
@@ -287,7 +351,7 @@ export function AgentDeploySource({
size="sm"
className="text-muted-foreground hover:text-foreground"
disabled={unlink.isPending}
- onClick={() => unlink.mutate()}
+ onClick={() => unlink.mutate({ prepareReimport: false })}
>
<Unplug className="size-4" />
Disconnect
@@ -306,8 +370,7 @@ export function AgentDeploySource({
</a>
) : null}
<p className="text-muted-foreground text-xs">
- Or use the CLI:{' '}
- <code className="font-mono">oc agent deploy</code>
+ Or use the CLI: <code className="font-mono">oc agent deploy</code>
</p>
</div>
)}
diff --git a/web/src/components/source-profile-changed-recovery.test.ts b/web/src/components/source-profile-changed-recovery.test.ts
new file mode 100644
index 00000000..1d8c6225
--- /dev/null
+++ b/web/src/components/source-profile-changed-recovery.test.ts
@@ -0,0 +1,27 @@
+import { describe, expect, it } from 'vitest'
+import { sourceChangesUrl } from '@/lib/source-profile-recovery'
+
+describe('source profile change recovery', () => {
+ it('links only a bounded GitHub repository and exact commit', () => {
+ expect(
+ sourceChangesUrl({
+ full_name: 'example/support agent',
+ latest_seen_sha: 'a'.repeat(40),
+ }),
+ ).toBe(
+ `https://github.com/example/support%20agent/commit/${'a'.repeat(40)}`,
+ )
+ expect(
+ sourceChangesUrl({
+ full_name: 'not/a/repository',
+ latest_seen_sha: 'a'.repeat(40),
+ }),
+ ).toBeUndefined()
+ expect(
+ sourceChangesUrl({
+ full_name: 'example/support',
+ latest_seen_sha: 'branch-name',
+ }),
+ ).toBe('https://github.com/example/support')
+ })
+})
diff --git a/web/src/components/source-profile-changed-recovery.tsx b/web/src/components/source-profile-changed-recovery.tsx
new file mode 100644
index 00000000..bbeb4522
--- /dev/null
+++ b/web/src/components/source-profile-changed-recovery.tsx
@@ -0,0 +1,69 @@
+import { useState } from 'react'
+import { ExternalLink, Unplug } from 'lucide-react'
+import type { DeploymentSource } from '@/api/schemas'
+import { ConfirmDialog } from '@/components/confirm-dialog'
+import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
+import { Button } from '@/components/ui/button'
+import { sourceChangesUrl } from '@/lib/source-profile-recovery'
+
+/**
+ * Recovery for a pinned repository whose current source is no longer the
+ * profile it was imported as. Unlinking stops push-to-deploy; it does not
+ * convert or delete the agent, its active revision, or its sessions.
+ */
+export function SourceProfileChangedRecovery({
+ source,
+ pending,
+ onUnlink,
+}: {
+ source: DeploymentSource
+ pending: boolean
+ onUnlink: () => void
+}) {
+ const [confirming, setConfirming] = useState(false)
+ const changesUrl = sourceChangesUrl(source)
+
+ return (
+ <>
+ <Alert variant="destructive">
+ <AlertTitle>
+ This repository no longer matches the agent type it was imported as
+ </AlertTitle>
+ <AlertDescription>
+ Restore the Flue agent definition, or unlink this source and import
+ the repository as a new agent. Unlinking does not convert or delete
+ this agent; its current active revision and sessions remain available.
+ </AlertDescription>
+ <div className="mt-3 flex flex-wrap gap-2">
+ {changesUrl ? (
+ <Button size="sm" variant="outline" asChild>
+ <a href={changesUrl} target="_blank" rel="noreferrer">
+ View source changes
+ <ExternalLink className="size-3.5" />
+ </a>
+ </Button>
+ ) : null}
+ <Button
+ size="sm"
+ variant="outline"
+ disabled={pending}
+ onClick={() => setConfirming(true)}
+ >
+ <Unplug className="size-4" />
+ Unlink source
+ </Button>
+ </div>
+ </Alert>
+ <ConfirmDialog
+ open={confirming}
+ onOpenChange={setConfirming}
+ title="Unlink this repository?"
+ description="Push-to-deploy will stop. The existing agent, its active revision, and its sessions will remain available."
+ confirmLabel="Unlink source"
+ destructive
+ pending={pending}
+ onConfirm={onUnlink}
+ />
+ </>
+ )
+}
diff --git a/web/src/lib/repository-onboarding.test.ts b/web/src/lib/repository-onboarding.test.ts
new file mode 100644
index 00000000..bdd77a72
--- /dev/null
+++ b/web/src/lib/repository-onboarding.test.ts
@@ -0,0 +1,127 @@
+import { describe, expect, it } from 'vitest'
+import { ApiError, type RepositorySourceInspection } from '@/api/client'
+import {
+ repositoryReviewPresentation,
+ repositorySeedFromState,
+ sourceChangedRequiresReview,
+} from './repository-onboarding'
+
+const common = {
+ repository: {
+ id: 'repo_0123456789abcdef01234567',
+ full_name: 'example/agent',
+ default_branch: 'main',
+ },
+ root: '',
+ production_ref: 'main',
+ sha: 'a'.repeat(40),
+ profile: null,
+ review_fingerprint: 'sha256:review',
+ candidate_roots: [],
+ candidate_roots_truncated: false,
+} satisfies Omit<RepositorySourceInspection, 'interpretation' | 'profile'> & {
+ profile: null
+}
+
+describe('repository onboarding presentation', () => {
+ it('keeps invalid Flue authoritative and recoverable by re-review', () => {
+ const presentation = repositoryReviewPresentation({
+ ...common,
+ interpretation: {
+ disposition: 'invalid',
+ source_profile: 'flue-app-v1',
+ source_profile_version: 1,
+ summary: 'Flue manifest is missing',
+ reason_code: 'flue_manifest_missing',
+ issues: [
+ {
+ code: 'flue_manifest_missing',
+ message: 'Add agent.toml to this Flue root.',
+ },
+ ],
+ },
+ })
+
+ expect(presentation).toMatchObject({
+ heading: 'This Flue agent needs a fix',
+ primaryAction: 'review_again',
+ })
+ })
+
+ it('offers explicit candidate selection without auto-selecting a root', () => {
+ const presentation = repositoryReviewPresentation({
+ ...common,
+ interpretation: {
+ disposition: 'unrecognized',
+ source_profile: null,
+ source_profile_version: null,
+ summary: "We couldn't find an agent definition in this folder",
+ reason_code: 'unrecognized_source',
+ },
+ candidate_roots: [
+ {
+ path: 'agents/support',
+ source_profile: null,
+ summary: 'Agent manifest found',
+ marker: 'agent.toml',
+ },
+ ],
+ })
+
+ expect(presentation).toEqual({
+ heading: 'Agent definitions found in other folders',
+ explanation:
+ 'Choose a repository root to review. OpenComputer will never select one for you.',
+ primaryAction: 'choose_folder',
+ })
+ })
+
+ it('is honest when prompt/skills-only source is unrecognized', () => {
+ const presentation = repositoryReviewPresentation({
+ ...common,
+ interpretation: {
+ disposition: 'unrecognized',
+ source_profile: null,
+ source_profile_version: null,
+ summary: "We couldn't find an agent definition in this folder",
+ reason_code: 'unrecognized_source',
+ },
+ })
+
+ expect(presentation.explanation).toContain(
+ 'Prompts or skills alone are not converted automatically',
+ )
+ })
+
+ it('requires a fresh review for the typed source-change conflict', () => {
+ expect(
+ sourceChangedRequiresReview(
+ new ApiError('Repository changed', 409, 'source_changed_re_review'),
+ ),
+ ).toBe(true)
+ expect(
+ sourceChangedRequiresReview(
+ new ApiError('Conflict', 409, 'name_conflict'),
+ ),
+ ).toBe(false)
+ })
+
+ it('accepts only a bounded same-origin source handoff', () => {
+ const seed = {
+ repo: 'repo_0123456789abcdef01234567',
+ path: 'agents/support',
+ productionRef: 'main',
+ }
+ expect(repositorySeedFromState({ repositoryImport: seed })).toEqual(seed)
+ expect(
+ repositorySeedFromState({
+ repositoryImport: { ...seed, path: '../other-agent' },
+ }),
+ ).toBeUndefined()
+ expect(
+ repositorySeedFromState({
+ repositoryImport: { ...seed, repo: 'example/support' },
+ }),
+ ).toBeUndefined()
+ })
+})
diff --git a/web/src/lib/repository-onboarding.ts b/web/src/lib/repository-onboarding.ts
new file mode 100644
index 00000000..d6fe60ee
--- /dev/null
+++ b/web/src/lib/repository-onboarding.ts
@@ -0,0 +1,92 @@
+import { ApiError, type RepositorySourceInspection } from '@/api/client'
+
+export type RepositoryReviewPresentation = {
+ heading: string
+ explanation: string
+ primaryAction: 'deploy' | 'review_again' | 'choose_folder'
+}
+
+export type RepositorySeed = {
+ repo: string
+ path: string
+ productionRef: string
+}
+
+export function isValidRepositoryRoot(root: string): boolean {
+ if (
+ root.length > 1024 ||
+ root.includes('\0') ||
+ root.includes('\\') ||
+ root.startsWith('/')
+ )
+ return false
+ return !root
+ .split('/')
+ .filter(Boolean)
+ .some((part) => part === '.' || part === '..')
+}
+
+/** Read the bounded same-origin handoff used after a confirmed source unlink. */
+export function repositorySeedFromState(
+ value: unknown,
+): RepositorySeed | undefined {
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return
+ const seed = (value as { repositoryImport?: unknown }).repositoryImport
+ if (!seed || typeof seed !== 'object' || Array.isArray(seed)) return
+ const candidate = seed as Record<string, unknown>
+ if (
+ typeof candidate.repo !== 'string' ||
+ !/^repo_[a-z0-9]{24}$/.test(candidate.repo) ||
+ typeof candidate.path !== 'string' ||
+ !isValidRepositoryRoot(candidate.path) ||
+ typeof candidate.productionRef !== 'string' ||
+ !candidate.productionRef.trim() ||
+ candidate.productionRef.length > 255
+ ) {
+ return
+ }
+ return {
+ repo: candidate.repo,
+ path: candidate.path,
+ productionRef: candidate.productionRef,
+ }
+}
+
+/** Canonical user-facing state for the server's repository interpretation. */
+export function repositoryReviewPresentation(
+ inspection: RepositorySourceInspection,
+): RepositoryReviewPresentation {
+ switch (inspection.interpretation.disposition) {
+ case 'exact':
+ return {
+ heading: 'Flue agent detected',
+ explanation: 'Review the detected entrypoint, model, and agent name.',
+ primaryAction: 'deploy',
+ }
+ case 'invalid':
+ return {
+ heading: 'This Flue agent needs a fix',
+ explanation:
+ 'OpenComputer found a Flue definition, but it is not deployable yet. It was not treated as another agent type.',
+ primaryAction: 'review_again',
+ }
+ case 'unrecognized':
+ return inspection.candidate_roots.length
+ ? {
+ heading: 'Agent definitions found in other folders',
+ explanation:
+ 'Choose a repository root to review. OpenComputer will never select one for you.',
+ primaryAction: 'choose_folder',
+ }
+ : {
+ heading: "We couldn't find an agent definition in this folder",
+ explanation:
+ 'OpenComputer looked for an agent manifest and strong Flue markers. Prompts or skills alone are not converted automatically.',
+ primaryAction: 'choose_folder',
+ }
+ }
+}
+
+export function sourceChangedRequiresReview(error: unknown): boolean {
+ return error instanceof ApiError && error.type === 'source_changed_re_review'
+}
diff --git a/web/src/lib/source-profile-recovery.ts b/web/src/lib/source-profile-recovery.ts
new file mode 100644
index 00000000..8bc8e19d
--- /dev/null
+++ b/web/src/lib/source-profile-recovery.ts
@@ -0,0 +1,13 @@
+import type { DeploymentSource } from '@/api/schemas'
+
+export function sourceChangesUrl(
+ source: Pick<DeploymentSource, 'full_name' | 'latest_seen_sha'>,
+): string | undefined {
+ const parts = source.full_name?.split('/') ?? []
+ if (parts.length !== 2 || parts.some((part) => !part)) return
+ const repositoryUrl = `https://github.com/${parts.map(encodeURIComponent).join('/')}`
+ return source.latest_seen_sha &&
+ /^[0-9a-f]{40}$/i.test(source.latest_seen_sha)
+ ? `${repositoryUrl}/commit/${source.latest_seen_sha}`
+ : repositoryUrl
+}
diff --git a/web/src/pages/AgentNew.tsx b/web/src/pages/AgentNew.tsx
index b78ba302..6dd01c70 100644
--- a/web/src/pages/AgentNew.tsx
+++ b/web/src/pages/AgentNew.tsx
@@ -1,11 +1,17 @@
import { useMemo, useRef, useState } from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
-import { Link, useNavigate, useSearchParams } from 'react-router-dom'
+import {
+ Link,
+ useLocation,
+ useNavigate,
+ useSearchParams,
+} from 'react-router-dom'
import {
ArrowLeft,
ArrowRight,
Bot,
ExternalLink,
+ FolderSearch,
GitBranch,
KeyRound,
Loader2,
@@ -15,8 +21,9 @@ import {
ApiError,
getDeployApp,
importAgentFromGithub,
- inspectFlueRepository,
+ reviewRepositoryAgent,
type DeployApp,
+ type RepositorySourceInspection,
} from '@/api/client'
import { Field, FieldError, Input } from '@/components/form'
import { GithubMark } from '@/components/github-mark'
@@ -36,6 +43,13 @@ import {
resolveAgentCreationMode,
type AgentCreationMode,
} from '@/lib/agent-creation-mode'
+import {
+ isValidRepositoryRoot,
+ repositoryReviewPresentation,
+ repositorySeedFromState,
+ sourceChangedRequiresReview,
+ type RepositorySeed,
+} from '@/lib/repository-onboarding'
import { cn } from '@/lib/utils'
const STARTER_URL = 'https://github.com/diggerhq/oc-flue-starter'
@@ -44,7 +58,6 @@ const IMPORT_COMMAND_STORAGE = 'oc.flue-import-command.v1'
type ImportBody = Parameters<typeof importAgentFromGithub>[0]
type ImportCommand = { fingerprint: string; key: string }
-
function existingAgentFromError(
error: unknown,
): { id: string; name: string; conflict: 'name' | 'source' } | null {
@@ -67,15 +80,6 @@ function existingAgentFromError(
: null
}
-function isValidRoot(root: string): boolean {
- if (root.includes('\0') || root.includes('\\') || root.startsWith('/'))
- return false
- return !root
- .split('/')
- .filter(Boolean)
- .some((part) => part === '.' || part === '..')
-}
-
function newCommandKey(): string {
return (
globalThis.crypto?.randomUUID?.() ??
@@ -162,15 +166,29 @@ function ModeButton({
)
}
-function GithubImport({ app }: { app: DeployApp }) {
+function GithubImport({
+ app,
+ initialSource,
+}: {
+ app: DeployApp
+ initialSource?: RepositorySeed
+}) {
const navigate = useNavigate()
const queryClient = useQueryClient()
const importCommand = useRef<ImportCommand | null>(null)
const nameInput = useRef<HTMLInputElement>(null)
+ const rootInput = useRef<HTMLInputElement>(null)
const [repoSearch, setRepoSearch] = useState('')
- const [repoId, setRepoId] = useState('')
- const [productionRef, setProductionRef] = useState('')
- const [root, setRoot] = useState('')
+ const initialRepo = app.repositories.find(
+ (repo) => repo.id === initialSource?.repo,
+ )
+ const [repoId, setRepoId] = useState(initialRepo?.id ?? '')
+ const [productionRef, setProductionRef] = useState(
+ initialRepo
+ ? initialSource?.productionRef || initialRepo.default_branch || 'main'
+ : '',
+ )
+ const [root, setRoot] = useState(initialRepo ? initialSource?.path || '' : '')
const [name, setName] = useState('')
const repositories = useMemo(() => {
@@ -186,18 +204,24 @@ function GithubImport({ app }: { app: DeployApp }) {
}, [app.repositories, repoSearch])
const selectedRepo = app.repositories.find((repo) => repo.id === repoId)
- const rootValid = isValidRoot(root.trim())
+ const rootValid = isValidRepositoryRoot(root.trim())
const inspectMutation = useMutation({
- mutationFn: () =>
- inspectFlueRepository({
- repo: repoId,
- path: root.trim(),
- production_ref: productionRef.trim(),
+ mutationFn: (source?: RepositorySeed) =>
+ reviewRepositoryAgent({
+ repo: source?.repo ?? repoId,
+ path: (source?.path ?? root).trim(),
+ production_ref: (source?.productionRef ?? productionRef).trim(),
}),
onSuccess: (inspection) => {
- setName(inspection.manifest.entrypoint)
- globalThis.requestAnimationFrame?.(() => nameInput.current?.focus())
+ setRoot(inspection.root)
+ if (
+ inspection.interpretation.disposition === 'exact' &&
+ inspection.profile
+ ) {
+ setName((current) => current || inspection.profile!.manifest.entrypoint)
+ globalThis.requestAnimationFrame?.(() => nameInput.current?.focus())
+ }
},
})
@@ -223,6 +247,12 @@ function GithubImport({ app }: { app: DeployApp }) {
importMutation.reset()
}
+ const changeSource = () => {
+ setName('')
+ clearInspection()
+ globalThis.requestAnimationFrame?.(() => rootInput.current?.focus())
+ }
+
const selectRepo = (id: string) => {
const repo = app.repositories.find((candidate) => candidate.id === id)
setRepoId(id)
@@ -234,31 +264,69 @@ function GithubImport({ app }: { app: DeployApp }) {
const inspection = inspectMutation.data
const existingAgent = existingAgentFromError(importMutation.error)
+ const sourceChanged = sourceChangedRequiresReview(importMutation.error)
+ const reviewPresentation = inspection
+ ? repositoryReviewPresentation(inspection)
+ : null
+ const exactInspection =
+ inspection?.interpretation.disposition === 'exact' && inspection.profile
+ ? inspection
+ : null
const canInspect =
!!selectedRepo &&
!!productionRef.trim() &&
rootValid &&
!inspectMutation.isPending
const canImport =
- !!inspection &&
+ !!exactInspection &&
!!name.trim() &&
+ !sourceChanged &&
!importMutation.isPending &&
!inspectMutation.isPending
const deployAgent = () => {
- if (!inspection || !canImport) return
+ if (
+ !exactInspection ||
+ exactInspection.interpretation.disposition !== 'exact' ||
+ !canImport
+ )
+ return
importMutation.mutate({
name: name.trim(),
source: {
type: 'github',
- repo: inspection.repository.id,
- path: inspection.root,
- production_ref: inspection.production_ref,
+ repo: exactInspection.repository.id,
+ path: exactInspection.root,
+ production_ref: exactInspection.production_ref,
+ },
+ review: {
+ sha: exactInspection.sha,
+ source_profile: exactInspection.interpretation.source_profile,
+ fingerprint: exactInspection.review_fingerprint,
},
credential: 'managed',
})
}
+ const reviewAgain = () => {
+ importMutation.reset()
+ inspectMutation.mutate(undefined)
+ }
+
+ const chooseCandidate = (
+ candidate: RepositorySourceInspection['candidate_roots'][number],
+ ) => {
+ const next = {
+ repo: repoId,
+ path: candidate.path,
+ productionRef,
+ }
+ setRoot(candidate.path)
+ setName('')
+ clearInspection()
+ inspectMutation.mutate(next)
+ }
+
if (!app.installed) {
return (
<Panel>
@@ -324,7 +392,7 @@ function GithubImport({ app }: { app: DeployApp }) {
</div>
)}
{inspection ? (
- <Button variant="ghost" size="sm" onClick={clearInspection}>
+ <Button variant="ghost" size="sm" onClick={changeSource}>
Change source
</Button>
) : app.configure_url ? (
@@ -424,15 +492,17 @@ function GithubImport({ app }: { app: DeployApp }) {
error={
rootValid
? undefined
- : 'Use a repository-relative path without . or .. segments.'
+ : 'Use a repository-relative path of at most 1,024 characters without . or .. segments.'
}
- description="Leave empty when agent.toml is at repository root."
+ description="Leave empty to review the repository root."
>
<Input
+ ref={rootInput}
id="import-root"
value={root}
onChange={(event) => {
setRoot(event.target.value)
+ setName('')
clearInspection()
}}
placeholder="agents/support"
@@ -451,7 +521,7 @@ function GithubImport({ app }: { app: DeployApp }) {
type="button"
variant="outline"
disabled={!canInspect}
- onClick={() => inspectMutation.mutate()}
+ onClick={() => inspectMutation.mutate(undefined)}
>
{inspectMutation.isPending ? (
<Loader2 className="size-4 animate-spin motion-reduce:animate-none" />
@@ -467,15 +537,18 @@ function GithubImport({ app }: { app: DeployApp }) {
) : null}
</Panel>
- {inspection ? (
+ {inspection?.interpretation.disposition === 'exact' &&
+ inspection.profile ? (
<Panel>
<PanelHeader>
<div>
- <PanelTitle>Review agent</PanelTitle>
+ <PanelTitle>{reviewPresentation?.heading}</PanelTitle>
<PanelDescription className="mt-1">
- {inspection.manifest.entrypoint}
+ {inspection.profile.manifest.entrypoint}
{' · '}
- <span className="font-mono">{inspection.manifest.model}</span>
+ <span className="font-mono">
+ {inspection.profile.manifest.model}
+ </span>
</PanelDescription>
</div>
</PanelHeader>
@@ -500,31 +573,52 @@ function GithubImport({ app }: { app: DeployApp }) {
<KeyRound className="size-3.5 shrink-0" aria-hidden />
Model access is managed by OpenComputer.
</p>
- {inspection.warnings.map((warning) => (
+ {inspection.profile.warnings.map((warning) => (
<Alert key={`${warning.code}:${warning.message}`}>
<AlertTitle>Compatibility warning</AlertTitle>
<AlertDescription>{warning.message}</AlertDescription>
</Alert>
))}
{importMutation.isError ? (
- <Alert variant={existingAgent ? 'default' : 'destructive'}>
+ <Alert
+ variant={
+ existingAgent || sourceChanged ? 'default' : 'destructive'
+ }
+ >
<AlertTitle>
- {existingAgent?.conflict === 'source'
- ? 'Repository already linked'
- : existingAgent
- ? 'Agent name already in use'
- : 'Agent could not be created'}
+ {sourceChanged
+ ? 'Repository changed since review'
+ : existingAgent?.conflict === 'source'
+ ? 'Repository already linked'
+ : existingAgent
+ ? 'Agent name already in use'
+ : 'Agent could not be created'}
</AlertTitle>
<AlertDescription>
- {existingAgent?.conflict === 'source'
- ? `This repository path is already linked to ${existingAgent.name}. Open the existing agent to deploy its latest commit.`
- : existingAgent
- ? `Another agent is already named ${existingAgent.name}. Choose a different name or open the existing agent.`
- : importMutation.error instanceof Error
- ? importMutation.error.message
- : 'The import request failed. You can retry without creating a duplicate.'}
+ {sourceChanged
+ ? 'Nothing was created. Review the current commit before deploying it.'
+ : existingAgent?.conflict === 'source'
+ ? `This repository path is already linked to ${existingAgent.name}. Open the existing agent to deploy its latest commit.`
+ : existingAgent
+ ? `Another agent is already named ${existingAgent.name}. Choose a different name or open the existing agent.`
+ : importMutation.error instanceof Error
+ ? importMutation.error.message
+ : 'The import request failed. You can retry without creating a duplicate.'}
</AlertDescription>
- {existingAgent ? (
+ {sourceChanged ? (
+ <div className="mt-3">
+ <Button
+ size="sm"
+ onClick={reviewAgain}
+ disabled={inspectMutation.isPending}
+ >
+ {inspectMutation.isPending ? (
+ <Loader2 className="size-4 animate-spin motion-reduce:animate-none" />
+ ) : null}
+ Review agent again
+ </Button>
+ </div>
+ ) : existingAgent ? (
<div className="mt-3">
<Button size="sm" asChild>
<Link to={`/agents/${existingAgent.id}`}>Open agent</Link>
@@ -547,6 +641,116 @@ function GithubImport({ app }: { app: DeployApp }) {
</Button>
</PanelFooter>
</Panel>
+ ) : inspection?.interpretation.disposition === 'invalid' ? (
+ <Panel>
+ <PanelHeader>
+ <div>
+ <PanelTitle>{reviewPresentation?.heading}</PanelTitle>
+ <PanelDescription className="mt-1">
+ {reviewPresentation?.explanation}
+ </PanelDescription>
+ </div>
+ </PanelHeader>
+ <PanelContent className="space-y-3">
+ {inspection.interpretation.issues.map((issue) => (
+ <Alert
+ key={`${issue.code}:${issue.path ?? ''}:${issue.message}`}
+ variant="destructive"
+ >
+ <AlertTitle>{issue.path || issue.code}</AlertTitle>
+ <AlertDescription>{issue.message}</AlertDescription>
+ </Alert>
+ ))}
+ {inspection.interpretation.issues.length === 0 ? (
+ <Alert variant="destructive">
+ <AlertTitle>{inspection.interpretation.reason_code}</AlertTitle>
+ <AlertDescription>
+ {inspection.interpretation.summary}
+ </AlertDescription>
+ </Alert>
+ ) : null}
+ </PanelContent>
+ <PanelFooter className="justify-between gap-2">
+ <Button variant="ghost" onClick={changeSource}>
+ Choose another folder
+ </Button>
+ <Button onClick={reviewAgain} disabled={inspectMutation.isPending}>
+ {inspectMutation.isPending ? (
+ <Loader2 className="size-4 animate-spin motion-reduce:animate-none" />
+ ) : null}
+ Review agent again
+ </Button>
+ </PanelFooter>
+ </Panel>
+ ) : inspection?.interpretation.disposition === 'unrecognized' ? (
+ <Panel>
+ <PanelHeader>
+ <div>
+ <PanelTitle>{reviewPresentation?.heading}</PanelTitle>
+ <PanelDescription className="mt-1">
+ {reviewPresentation?.explanation}
+ </PanelDescription>
+ </div>
+ </PanelHeader>
+ <PanelContent className="space-y-4">
+ {inspection.candidate_roots.length ? (
+ <div
+ 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)}
+ >
+ {inspectMutation.isPending ? (
+ <Loader2 className="size-4 animate-spin motion-reduce:animate-none" />
+ ) : (
+ <FolderSearch className="size-4" />
+ )}
+ Choose folder
+ </Button>
+ </div>
+ ))}
+ </div>
+ ) : null}
+ {inspection.candidate_roots_truncated ? (
+ <Alert>
+ <AlertTitle>More folders may match</AlertTitle>
+ <AlertDescription>
+ The bounded search was truncated. Choose a narrower root and
+ review again.
+ </AlertDescription>
+ </Alert>
+ ) : null}
+ <div className="flex flex-wrap gap-2">
+ <Button onClick={changeSource}>Choose another folder</Button>
+ <Button variant="outline" asChild>
+ <a href={STARTER_FORK_URL} target="_blank" rel="noreferrer">
+ Fork the Flue starter
+ <ExternalLink className="size-3.5" />
+ </a>
+ </Button>
+ <Button variant="ghost" asChild>
+ <Link to="/agents/new?mode=manual">Configure manually</Link>
+ </Button>
+ </div>
+ </PanelContent>
+ </Panel>
) : null}
</div>
)
@@ -554,6 +758,7 @@ function GithubImport({ app }: { app: DeployApp }) {
export default function AgentNew() {
const [searchParams, setSearchParams] = useSearchParams()
+ const location = useLocation()
const deployAppQuery = useQuery({
queryKey: ['deploy-app'],
queryFn: getDeployApp,
@@ -578,7 +783,7 @@ export default function AgentNew() {
<div className="mb-6">
<h1 className="text-xl font-semibold tracking-tight">Create agent</h1>
<p className="text-muted-foreground mt-1 text-sm">
- Deploy an existing Flue repository or configure an agent manually.
+ Deploy an agent from an existing repository or configure one manually.
</p>
</div>
@@ -588,7 +793,7 @@ export default function AgentNew() {
onClick={() => setMode('github')}
icon={GithubMark}
title="Import from GitHub"
- description="Build and deploy an existing Flue agent."
+ description="Review and deploy an agent from code."
/>
<ModeButton
active={mode === 'manual'}
@@ -637,7 +842,10 @@ export default function AgentNew() {
</div>
</Alert>
) : deployAppQuery.data ? (
- <GithubImport app={deployAppQuery.data} />
+ <GithubImport
+ app={deployAppQuery.data}
+ initialSource={repositorySeedFromState(location.state)}
+ />
) : null
) : (
<Panel>