Skip to content

An open-source, faster Devin alternative

TypeScript

web: route /new?repository-url= to the template deploy form (#789)

devin-ai-integration[bot]67da7cb1cba4
diff --git a/web/src/App.tsx b/web/src/App.tsx
index afb28971..411b4ed8 100644
--- a/web/src/App.tsx
+++ b/web/src/App.tsx
@@ -1,9 +1,10 @@
import { lazy } from 'react'
-import { Routes, Route, Navigate } from 'react-router-dom'
+import { Routes, Route, Navigate, useSearchParams } from 'react-router-dom'
import { AuthProvider } from './hooks/auth-provider'
import ProtectedRoute from './components/ProtectedRoute'
import AppShell from './components/app-shell'
import { managedAgentsExperimentEnabled } from './managed-agents/feature'
+import { templateDeployPathFromSearch } from './managed-agents/templates'
// Route pages are code-split so the initial bundle stays small; the heaviest
// deps (xterm, in Terminal/LogsPanel) only load on SandboxDetail when opened.
@@ -42,6 +43,13 @@ const ModelAccessCallback = lazy(
() => import('./managed-agents/ModelAccessCallback'),
)
+function NewProject() {
+ const [searchParams] = useSearchParams()
+ const templatePath = templateDeployPathFromSearch(searchParams)
+ if (templatePath) return <Navigate to={templatePath} replace />
+ return <ManagedProjectOnboarding />
+}
+
export default function App() {
return (
<AuthProvider>
@@ -87,7 +95,7 @@ export default function App() {
path="managed-agents/new"
element={<Navigate to="/new" replace />}
/>
- <Route path="new" element={<ManagedProjectOnboarding />} />
+ <Route path="new" element={<NewProject />} />
<Route path="template" element={<ManagedTemplateNew />} />
<Route
path="projects/:projectId"
diff --git a/web/src/managed-agents/templates.test.ts b/web/src/managed-agents/templates.test.ts
index b85f046b..e45f939f 100644
--- a/web/src/managed-agents/templates.test.ts
+++ b/web/src/managed-agents/templates.test.ts
@@ -3,6 +3,7 @@ import {
CURATED_TEMPLATES,
HELLO_WORLD_TEMPLATE_REPOSITORY,
templateDeployPath,
+ templateDeployPathFromSearch,
} from './templates'
describe('project creation templates', () => {
@@ -12,6 +13,19 @@ describe('project creation templates', () => {
)
})
+ it('sends public /new?repository-url links to the template deploy form', () => {
+ expect(
+ templateDeployPathFromSearch(
+ new URLSearchParams(
+ 'repository-url=https%3A%2F%2Fgithub.com%2Fdiggerhq%2Fshipvideo',
+ ),
+ ),
+ ).toBe(
+ '/template?repository-url=https%3A%2F%2Fgithub.com%2Fdiggerhq%2Fshipvideo',
+ )
+ expect(templateDeployPathFromSearch(new URLSearchParams())).toBeNull()
+ })
+
it('includes each documented example once', () => {
expect(CURATED_TEMPLATES.map((template) => template.name)).toEqual([
'Pull Request Reviewer',
diff --git a/web/src/managed-agents/templates.ts b/web/src/managed-agents/templates.ts
index 6c30fe9e..723c7a9a 100644
--- a/web/src/managed-agents/templates.ts
+++ b/web/src/managed-agents/templates.ts
@@ -32,6 +32,13 @@ export const CURATED_TEMPLATES = [
},
] as const
+// Public "Deploy with OpenComputer" links (READMEs, docs) point at
+// `/new?repository-url=...`; the template deploy form lives at `/template`.
+export function templateDeployPathFromSearch(search: URLSearchParams) {
+ if (!search.has('repository-url')) return null
+ return `/template?${search.toString()}`
+}
+
export function templateDeployPath(repositoryUrl: string, quickStart = false) {
const query = new URLSearchParams({ 'repository-url': repositoryUrl })
if (quickStart) query.set('quick-start', '1')