feat(project-import): implement asynchronous GitHub repository import into sandbox#142
Merged
feat(project-import): implement asynchronous GitHub repository import into sandbox#142
Conversation
✅ PR Check Results: PassedBuild Checks
✨ Great work!All checks passed successfully. Your PR is ready for review. Details:
🔗 View Details: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
The
Importflow on/projectspreviously reused theNew Projectpath and only created an empty project. It did not perform a real repository import.This PR implements the minimum viable end-to-end loop: create project metadata first, then asynchronously import repository code into the sandbox.
Scope
In scope
git clone)importProjectFromGitHubreturns immediately)Out of scope
Design
Import state machine
PENDING: waiting for sandbox readinessCLONING: import in progressREADY: import completedFAILED: import failed (project remains usable)Failure policy matches
New Project: do not delete/rollback project on import failure.Implementation
Data model (
prisma/schema.prisma)ProjectImportStatus:PENDING | CLONING | READY | FAILEDProjectfields:importStatusimportErrorimportLockedUntilgithubRepoDefaultBranchServer actions
lib/actions/project.tscreateProjectWithSandbox(...)for both new/import pathsimportProjectFromGitHub(payload):importStatus=PENDINGlib/actions/github.tsdefault_branchin repository metadata returned to UIBackground execution
lib/jobs/project-import/projectImportReconcile.tsPENDING/CLONINGRUNNINGREADYon success,FAILEDwithimportErroron failurelib/repo/project-import.tslib/startup/index.tsEvent-first + polling fallback
lib/events/sandbox/sandboxListener.tsRUNNINGImport command behavior
import/<repo>-<projectId>/(does not overwrite workspace root)Frontend behavior
app/(dashboard)/projects/_components/import-github-dialog.tsximportProjectFromGitHubinstead ofcreateProject/api/projects/:idforimportStatusREADY: success toast + dialog close + list refreshFAILED: fallback toast (“empty project created; import failed”) + close + refreshValidation
pnpm lint✅pnpm build✅Compatibility and risk
New Projectbehavior remains unchanged in core flowinitialize/pushpage behavior is preserved