Skip to content

feat(stack): bootstrap empty remotes + actionable unreachable-repo UX#1364

Open
TerrifiedBug wants to merge 2 commits intomoghtech:mainfrom
TerrifiedBug:feat/stack-empty-remote-bootstrap
Open

feat(stack): bootstrap empty remotes + actionable unreachable-repo UX#1364
TerrifiedBug wants to merge 2 commits intomoghtech:mainfrom
TerrifiedBug:feat/stack-empty-remote-bootstrap

Conversation

@TerrifiedBug
Copy link
Copy Markdown

@TerrifiedBug TerrifiedBug commented Apr 18, 2026

Summary

Closes the gap where Komodo can't scaffold the first file into an empty or
branch-less git repo from the Stack Info → Initialize File flow. Adds a
cheap git ls-remote probe that classifies remote state into four cases and
routes each to the right action.

Behavior changes

Remote state Before After
Branch exists Pull/clone (unchanged) Pull/clone (unchanged)
Reachable but empty git pull fails with noisy error Local repo is git inited on the configured branch; Initialize File creates the first commit and pushes
Branch missing on a non-empty remote git pull fails Same bootstrap path — Initialize File creates the branch from the first commit
Unreachable (404 / auth / network) Raw multi-line git stderr dumped to the user Concise, actionable error; Initialize File button hidden on this synthetic error row

Files

  • lib/git/src/ls_remote.rs (new) — RemoteState enum + check_remote_state probe
  • lib/git/src/lib.rs — export new module
  • bin/core/src/stack/remote.rs — probe first, then branch on state; bootstrap_local_clone helper
  • bin/core/src/api/write/stack.rs — same state-based branching in the write-file-contents path
  • ui/src/resources/stack/info.tsx — hide Initialize File button on Failed at: … synthetic error paths

Test plan

  • New Stack pointed at an empty GitHub/Gitea/GitLab repo → Initialize File writes compose.yaml on the first commit
  • New Stack pointed at a repo where the configured branch doesn't exist → Initialize File creates the branch from the first commit
  • New Stack pointed at a non-existent repo → concise error, no Initialize File button on the error row
  • Existing Stack with a populated repo → no regression (still pulls)

…e repo

Probe the remote with `git ls-remote` before pull/clone in the Stack
git-mode flows so the Initialize File action can:

  * Bootstrap an empty remote (no refs) by skipping pull and pushing the
    first commit on the configured branch via `push --set-upstream`.
  * Bootstrap a branch that doesn't exist yet on a populated remote,
    listing available branches in the log.
  * Surface an actionable multi-line error when the repo is unreachable
    (doesn't exist, auth failure, token expired) instead of raw git
    output.

Also hide the Initialize File button on synthetic "Failed at: ..." error
rows so users don't accidentally write files to stage-name paths.

Changes:
  * lib/git/src/ls_remote.rs: new `check_remote_state` probe and
    `RemoteState` enum. Token-scrubbed on failure.
  * bin/core/src/stack/remote.rs: `ensure_remote_repo` branches on state.
  * bin/core/src/api/write/stack.rs: `write_stack_file_contents_git`
    rejects Unreachable early and skips pull for Empty/BranchMissing.
  * ui/src/resources/stack/info.tsx: hide button on synthetic paths.

Sync has an identical pattern that was intentionally not changed in this
commit since empty sync repos are a degenerate case in practice.
Condense verbose multi-bullet verification checklist into concise
actionable message. Preserves git stderr (trimmed) as diagnostic
while replacing procedural steps with direct guidance.
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.

1 participant