Skip to content

improve empty repository onboarding#2250

Open
somewherelostt wants to merge 3 commits into
mainfrom
fix/issue-2182-git-init-recovery
Open

improve empty repository onboarding#2250
somewherelostt wants to merge 3 commits into
mainfrom
fix/issue-2182-git-init-recovery

Conversation

@somewherelostt

@somewherelostt somewherelostt commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #2182 .

This turns the empty-folder / unborn Git repository case into an onboarding flow instead of a generic validation failure.

Changes

  • Distinguish non-Git folders from Git repositories with no commits using stable backend error codes.
  • Add a narrow project repository initialization API that runs Git setup only after explicit user action.
  • Let the project-add UI recover from NOT_A_GIT_REPO and PROJECT_UNBORN with a clear setup card.
  • Add a one-click action that initializes Git when needed, creates an empty initial commit, then retries project creation automatically.
  • Keep manual setup available behind the info icon.
  • Add backend and renderer coverage for the recovery paths.

Validation

  • go test ./internal/service/project ./internal/httpd/controllers ./internal/httpd/apispec
  • npm test -- Sidebar.test.tsx
  • npm run typecheck
image image

light theme
image
image

@somewherelostt somewherelostt requested a review from whoisasx June 28, 2026 01:08
@somewherelostt

somewherelostt commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator Author

can u test it out
@codebanditssss on Linux

@whoisasx on mac?

@somewherelostt somewherelostt changed the title [codex] improve empty repository onboarding improve empty repository onboarding Jun 28, 2026
@somewherelostt somewherelostt marked this pull request as ready for review June 28, 2026 01:36
@codebanditssss

Copy link
Copy Markdown
Collaborator

working fine on linux
image

@neversettle17-101

Copy link
Copy Markdown
Collaborator

Tested on mac LGTM

}

if _, err := gitOutput(ctx, path, "-c", "user.name=Agent Orchestrator", "-c", "user.email=ao@example.com", "commit", "--allow-empty", "-m", "initial commit"); err != nil {
return InitializeRepositoryResult{}, apierr.Invalid("INITIAL_COMMIT_FAILED", "Could not create the initial commit.", map[string]any{"error": err.Error()})

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there's an error in any of these steps what are we showing the user? can we show the steps that they can follow manually?

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review notes on the Git initialization recovery path.

return InitializeRepositoryResult{}, apierr.Conflict("PROJECT_ALREADY_INITIALIZED", "This repository already has commits.", map[string]any{"path": path})
}

if _, err := gitOutput(ctx, path, "-c", "user.name=Agent Orchestrator", "-c", "user.email=ao@example.com", "commit", "--allow-empty", "-m", "initial commit"); err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This creates a valid HEAD, so git worktree add can succeed, but it does not stage any of the user's existing files. AO worktrees are checked out from the committed tree, so a selected folder with source files can register and spawn while the agent's worktree contains none of those files. Is the empty commit intentional? If not, this recovery should probably git add -A before the initial commit, and the test should assert that an existing file like notes.txt is present in HEAD after recovery.

m.addMu.Lock()
defer m.addMu.Unlock()

if !isGitRepo(path) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!isGitRepo(path) is broader than "plain folder". It also includes subdirectories inside an existing repository and bare/unsupported Git layouts. Running git init here can create a nested repo under a selected subdirectory, or mutate a bare repo into a different shape. Since this endpoint mutates the user's filesystem, can we classify the path before init: real plain folder => initialize; subdirectory of an existing repo => ask the user to select the repo root; bare/unsupported repo => reject clearly; normal unborn repo => create the first commit only?

@whoisasx

whoisasx commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Tested this branch on macOS with the Electron app.

The non-git project recovery flow is working fine on Mac: selecting a non-git folder opens the Project agents dialog and correctly shows the “Set up Git to continue” recovery panel.

Screenshot 2026-06-29 at 14 38 41

I noticed two UI alignment issues:

  1. The entire “Project agents” modal box initially appears slightly up-left from the center, then snaps into the center after the opening animation finishes. The modal should be centered from the first frame.

@somewherelostt we had discussed this first problem before as well. Can you please fix it in this PR?

Likely place to check:

frontend/src/renderer/styles.css:363

The modal-in keyframes currently set transform: translate(-50%, -50%) scale(...) at styles.css:366 and styles.css:370, while the dialog content already has the centering classes:

left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2

So the open animation should not cause the whole modal box to render off-center before settling.

  1. The 1, 2, 3 step numbers in the “Set up Git to continue” panel are not visually centered inside their circular badges.

Line to check:

frontend/src/renderer/components/CreateProjectAgentSheet.tsx:168

Current span:

<span className="grid size-4 shrink-0 place-items-center rounded-full bg-background text-[10px] text-passive">

@somewherelostt can you please fix this alignment issue too?

@somewherelostt

Copy link
Copy Markdown
Collaborator Author

@whoisasx will do it maybe tomorrow.

@whoisasx whoisasx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this branch on macOS with the Electron app. The non-git project recovery flow works: selecting a non-git folder opens the Project agents dialog and shows the "Set up Git to continue" recovery panel.

Requesting changes for two UI alignment issues before this merges: the whole Project agents modal initially appears slightly up-left before snapping to center, and the 1/2/3 recovery step badges are not visually centered.

<Dialog.Portal>
<Dialog.Overlay className="fixed inset-0 z-50 bg-black/55 data-[state=open]:animate-overlay-in" />
<Dialog.Content className="fixed left-1/2 top-1/2 z-50 w-[min(420px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-border bg-popover p-0 text-popover-foreground shadow-xl data-[state=open]:animate-modal-in">
<Dialog.Content className="fixed left-1/2 top-1/2 z-50 w-[min(460px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-border bg-popover p-0 text-popover-foreground shadow-xl data-[state=open]:animate-modal-in">

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entire Project agents modal initially appears slightly up-left from center, then snaps into the center after the opening animation finishes. We had discussed this problem before as well.

This line applies data-[state=open]:animate-modal-in while the content is already centered with left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2. Please adjust the modal animation so it does not re-apply or override the centering transform; the modal should be centered from the first frame. The likely root is frontend/src/renderer/styles.css:363, where modal-in sets transform: translate(-50%, -50%) scale(...).

<div className="grid gap-1.5 text-[11px] text-muted-foreground">
{recovery.steps.map((step, index) => (
<div key={step} className="flex items-center gap-2">
<span className="grid size-4 shrink-0 place-items-center rounded-full bg-background text-[10px] text-passive">

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 1, 2, 3 step numbers in the recovery panel are not visually centered inside these circular badges. Please fix the badge alignment here as well; adding an explicit line-height such as leading-none / leading-[1] should center the numbers better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add git init recovery for non-git project folders

5 participants