Skip to content

An open-source, faster Devin alternative

TypeScript

fix: always expose GitHub agent import

Igor Zalutski11facc6c4151
diff --git a/web/src/api/deploy-app-client.test.ts b/web/src/api/deploy-app-client.test.ts
index f1d22906..73ff861c 100644
--- a/web/src/api/deploy-app-client.test.ts
+++ b/web/src/api/deploy-app-client.test.ts
@@ -15,32 +15,12 @@ afterEach(() => {
})
describe('deploy app client', () => {
- it('preserves an explicit repository-deploy availability grant', async () => {
- vi.stubGlobal(
- 'fetch',
- vi.fn(() =>
- Promise.resolve(
- Response.json({
- ...deployAppResponse,
- repository_deploys_available: true,
- }),
- ),
- ),
- )
-
- await expect(getDeployApp()).resolves.toMatchObject({
- repository_deploys_available: true,
- })
- })
-
- it('fails closed when an older response omits availability', async () => {
+ it('returns GitHub installation state without a separate capability fork', async () => {
vi.stubGlobal(
'fetch',
vi.fn(() => Promise.resolve(Response.json(deployAppResponse))),
)
- await expect(getDeployApp()).resolves.toMatchObject({
- repository_deploys_available: false,
- })
+ await expect(getDeployApp()).resolves.toEqual(deployAppResponse)
})
})
diff --git a/web/src/api/deployment-schemas.test.ts b/web/src/api/deployment-schemas.test.ts
index 44e35b50..eb7f8842 100644
--- a/web/src/api/deployment-schemas.test.ts
+++ b/web/src/api/deployment-schemas.test.ts
@@ -171,7 +171,6 @@ describe('repository deployment API schemas', () => {
it('filters repositories without a registered import coordinate safely', () => {
const parsed = DeployAppSchema.parse({
- repository_deploys_available: true,
installed: true,
install_url: null,
configure_url: null,
@@ -188,20 +187,6 @@ describe('repository deployment API schemas', () => {
})
expect(parsed.repositories[0]?.id).toBeNull()
- expect(parsed.repository_deploys_available).toBe(true)
- })
-
- it('keeps repository deploys unavailable for older API responses', () => {
- const parsed = DeployAppSchema.parse({
- installed: false,
- install_url: null,
- configure_url: null,
- account: null,
- repository_selection: null,
- repositories: [],
- })
-
- expect(parsed.repository_deploys_available).toBe(false)
})
it('fails closed when deployment identity or canonical state is absent', () => {
diff --git a/web/src/api/mock.ts b/web/src/api/mock.ts
index 9513ee52..06769622 100644
--- a/web/src/api/mock.ts
+++ b/web/src/api/mock.ts
@@ -488,7 +488,6 @@ const DEPLOY_PREVIEW = 'installed' as
| 'connected'
const deployAppInstalled = {
- repository_deploys_available: true,
installed: true,
install_url: 'https://github.com/apps/opencomputerdev/installations/new',
configure_url:
@@ -517,7 +516,6 @@ const deployAppInstalled = {
],
}
const deployAppNotInstalled = {
- repository_deploys_available: true,
installed: false,
install_url: 'https://github.com/apps/opencomputerdev/installations/new',
configure_url: null,
diff --git a/web/src/api/schemas.ts b/web/src/api/schemas.ts
index cbb67f2e..a77c5cdb 100644
--- a/web/src/api/schemas.ts
+++ b/web/src/api/schemas.ts
@@ -615,9 +615,6 @@ export const DeployAppRepoSchema = z.object({
private: z.boolean().nullish(),
})
export const DeployAppSchema = z.object({
- // Rollout is owner-gated server-side. Missing stays unavailable so an older
- // API cannot accidentally expose repository deploy controls.
- repository_deploys_available: z.boolean().default(false),
installed: z.boolean(),
install_url: z.string().nullish(),
configure_url: z.string().nullish(),
diff --git a/web/src/lib/agent-creation-mode.test.ts b/web/src/lib/agent-creation-mode.test.ts
index 2cd3898c..893cd014 100644
--- a/web/src/lib/agent-creation-mode.test.ts
+++ b/web/src/lib/agent-creation-mode.test.ts
@@ -2,14 +2,9 @@ import { describe, expect, it } from 'vitest'
import { resolveAgentCreationMode } from './agent-creation-mode'
describe('agent creation mode', () => {
- it('fails a direct GitHub request over to manual until availability is true', () => {
- expect(resolveAgentCreationMode('github', false)).toBe('manual')
- expect(resolveAgentCreationMode(null, false)).toBe('manual')
- })
-
- it('keeps repository-first defaults for an allowed owner', () => {
- expect(resolveAgentCreationMode(null, true)).toBe('github')
- expect(resolveAgentCreationMode('github', true)).toBe('github')
- expect(resolveAgentCreationMode('manual', true)).toBe('manual')
+ it('defaults to repository import and preserves an explicit manual choice', () => {
+ expect(resolveAgentCreationMode(null)).toBe('github')
+ expect(resolveAgentCreationMode('github')).toBe('github')
+ expect(resolveAgentCreationMode('manual')).toBe('manual')
})
})
diff --git a/web/src/lib/agent-creation-mode.ts b/web/src/lib/agent-creation-mode.ts
index 2c72dedd..d1ee1eb8 100644
--- a/web/src/lib/agent-creation-mode.ts
+++ b/web/src/lib/agent-creation-mode.ts
@@ -2,8 +2,6 @@ export type AgentCreationMode = 'github' | 'manual'
export function resolveAgentCreationMode(
requestedMode: string | null,
- repositoryDeploysAvailable: boolean,
): AgentCreationMode {
- if (!repositoryDeploysAvailable) return 'manual'
return requestedMode === 'manual' ? 'manual' : 'github'
}
diff --git a/web/src/pages/AgentNew.tsx b/web/src/pages/AgentNew.tsx
index 095df86b..18c4ad7b 100644
--- a/web/src/pages/AgentNew.tsx
+++ b/web/src/pages/AgentNew.tsx
@@ -602,37 +602,18 @@ function GithubImport({ app }: { app: DeployApp }) {
}
export default function AgentNew() {
- const navigate = useNavigate()
const [searchParams, setSearchParams] = useSearchParams()
const deployAppQuery = useQuery({
queryKey: ['deploy-app'],
queryFn: getDeployApp,
refetchOnWindowFocus: 'always',
})
- const availableDeployApp =
- !deployAppQuery.isError &&
- deployAppQuery.data?.repository_deploys_available === true
- ? deployAppQuery.data
- : null
- const repositoryDeploysAvailable = availableDeployApp !== null
- const mode = resolveAgentCreationMode(
- searchParams.get('mode'),
- repositoryDeploysAvailable,
- )
+ const mode = resolveAgentCreationMode(searchParams.get('mode'))
const setMode = (next: AgentCreationMode) =>
setSearchParams(next === 'github' ? {} : { mode: 'manual' }, {
replace: true,
})
- // A cold request starts in the fully usable manual flow. If someone begins
- // using it before the availability read returns, keep that choice instead
- // of replacing their in-progress form with the repository flow.
- const preserveManualIntent = () => {
- if (!repositoryDeploysAvailable && searchParams.get('mode') !== 'manual') {
- setMode('manual')
- }
- }
-
return (
<div className="mx-auto max-w-4xl">
<Link
@@ -646,97 +627,111 @@ 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">
- {repositoryDeploysAvailable
- ? 'Deploy an existing Flue repository or configure an agent manually.'
- : 'Configure an agent from a prompt, runtime, and model.'}
+ Deploy an existing Flue repository or configure an agent manually.
</p>
</div>
- {deployAppQuery.isLoading ? (
- <div
- className="bg-muted mb-6 rounded-lg p-1"
- role="status"
- aria-label="Checking available creation methods"
- >
- <Skeleton className="h-[58px] w-full rounded-md" />
- </div>
- ) : repositoryDeploysAvailable ? (
- <div className="bg-muted mb-6 flex flex-col gap-1 rounded-lg p-1 sm:flex-row">
- <ModeButton
- active={mode === 'github'}
- onClick={() => setMode('github')}
- icon={GithubMark}
- title="Import from GitHub"
- description="Build and deploy an existing Flue agent."
- />
- <ModeButton
- active={mode === 'manual'}
- onClick={() => setMode('manual')}
- icon={Bot}
- title="Configure manually"
- description="Create a built-in runtime agent from a prompt."
- />
- </div>
- ) : null}
+ <div className="bg-muted mb-6 flex flex-col gap-1 rounded-lg p-1 sm:flex-row">
+ <ModeButton
+ active={mode === 'github'}
+ onClick={() => setMode('github')}
+ icon={GithubMark}
+ title="Import from GitHub"
+ description="Build and deploy an existing Flue agent."
+ />
+ <ModeButton
+ active={mode === 'manual'}
+ onClick={() => setMode('manual')}
+ icon={Bot}
+ title="Configure manually"
+ description="Create a built-in runtime agent from a prompt."
+ />
+ </div>
- {availableDeployApp && mode === 'github' ? (
- <GithubImport app={availableDeployApp} />
- ) : (
- <div onFocusCapture={preserveManualIntent}>
- <Panel>
+ {mode === 'github' ? (
+ deployAppQuery.isLoading ? (
+ <Panel aria-busy="true">
<PanelHeader>
<div>
- <PanelTitle>Configure manually</PanelTitle>
+ <PanelTitle>Connect GitHub</PanelTitle>
<PanelDescription className="mt-1">
- Sessions pin a snapshot of this definition when they are
- created.
+ Loading your GitHub installation and repositories.
</PanelDescription>
</div>
</PanelHeader>
<PanelContent>
- <ManualAgentForm
- onCancel={() => {
- if (repositoryDeploysAvailable) setMode('github')
- else void navigate('/agents')
- }}
- />
+ <Skeleton className="h-10 w-full max-w-sm" />
</PanelContent>
</Panel>
- </div>
- )}
-
- {repositoryDeploysAvailable ? (
- <section
- className="mt-8 border-t pt-6"
- aria-labelledby="starter-heading"
- >
- <div className="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
- <div className="max-w-xl">
- <h2 id="starter-heading" className="text-sm font-semibold">
- Need a starting point?
- </h2>
- <p className="text-muted-foreground mt-1 text-sm">
- Fork the Flue starter, add your agent logic, then return here to
- deploy it.
- </p>
- </div>
- <div className="flex flex-wrap gap-2">
- <Button variant="outline" size="sm" asChild>
- <a href={STARTER_URL} target="_blank" rel="noreferrer">
- View repository
- <ExternalLink className="size-3.5" />
- </a>
- </Button>
- <Button variant="outline" size="sm" asChild>
- <a href={STARTER_FORK_URL} target="_blank" rel="noreferrer">
- Fork on GitHub
- <ExternalLink className="size-3.5" />
- </a>
+ ) : deployAppQuery.isError ? (
+ <Alert variant="destructive">
+ <AlertTitle>GitHub import could not be loaded</AlertTitle>
+ <AlertDescription>
+ {deployAppQuery.error instanceof Error
+ ? deployAppQuery.error.message
+ : 'The GitHub installation request failed.'}
+ </AlertDescription>
+ <div className="mt-3">
+ <Button
+ size="sm"
+ variant="outline"
+ onClick={() => void deployAppQuery.refetch()}
+ disabled={deployAppQuery.isFetching}
+ >
+ {deployAppQuery.isFetching ? (
+ <Loader2 className="size-4 animate-spin motion-reduce:animate-none" />
+ ) : null}
+ Retry
</Button>
</div>
+ </Alert>
+ ) : deployAppQuery.data ? (
+ <GithubImport app={deployAppQuery.data} />
+ ) : null
+ ) : (
+ <Panel>
+ <PanelHeader>
+ <div>
+ <PanelTitle>Configure manually</PanelTitle>
+ <PanelDescription className="mt-1">
+ Sessions pin a snapshot of this definition when they are
+ created.
+ </PanelDescription>
+ </div>
+ </PanelHeader>
+ <PanelContent>
+ <ManualAgentForm onCancel={() => setMode('github')} />
+ </PanelContent>
+ </Panel>
+ )}
+
+ <section className="mt-8 border-t pt-6" aria-labelledby="starter-heading">
+ <div className="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
+ <div className="max-w-xl">
+ <h2 id="starter-heading" className="text-sm font-semibold">
+ Need a starting point?
+ </h2>
+ <p className="text-muted-foreground mt-1 text-sm">
+ Fork the Flue starter, add your agent logic, then return here to
+ deploy it.
+ </p>
</div>
- </section>
- ) : null}
+ <div className="flex flex-wrap gap-2">
+ <Button variant="outline" size="sm" asChild>
+ <a href={STARTER_URL} target="_blank" rel="noreferrer">
+ View repository
+ <ExternalLink className="size-3.5" />
+ </a>
+ </Button>
+ <Button variant="outline" size="sm" asChild>
+ <a href={STARTER_FORK_URL} target="_blank" rel="noreferrer">
+ Fork on GitHub
+ <ExternalLink className="size-3.5" />
+ </a>
+ </Button>
+ </div>
+ </div>
+ </section>
</div>
)
}