Skip to content

fix(projects): a manual folder-to-Git change proves the folder is the Git root first - #29282

Merged
brennanb2025 merged 11 commits into
mainfrom
brennan/sta-10638-pr-c-prove-git-root
Oct 16, 2026
Merged

brennanb2025 merged 11 commits into
mainfrom
brennan/sta-10638-pr-c-prove-git-root

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​151 $\color{#cf222e}{\Huge{\mathbf{−}}}$​30 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​121
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​285 $\color{#cf222e}{\Huge{\mathbf{−}}}$​61 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​224

ELI5

Before Orca turns a folder project into a Git project, it now checks that the folder really is the top of a Git repository. If it isn't, the change is refused and nothing is written. Until now only the automatic upgrade did this check; changing the type by hand skipped it.

Stacked on #29257 (refuse a folder-to-Git change that would hide folder workspaces). This review covers PR C’s original top commit and its review fixes; PR A and #29265 are separate.

What Changed

The problem. A folder project can become a Git project in two ways. One is automatic: Orca notices a git init. The other is manual: orca project setup-update --kind git, a general repo update, or cloning into an existing folder project. The automatic path does two things first:

  • It confirms the folder is the top folder of a Git repository. Git also answers "yes, this is a repo" for any subfolder, so without this check a project sitting inside another repo would become a Git project whose listings fail.
  • It records how Git spells that top folder. When the folder is reached through a symlink, or spelled differently, Git lists the main checkout under its own spelling. Orca maps that spelling back so the main workspace keeps the same id. Without the mapping, the main workspace gets a new id on the next refresh, and Orca clears the old id's tabs as if the workspace had been deleted.

The manual paths did neither, so they could break a project, or lose the main workspace's tabs, in the same way the user in #29257 lost their other workspaces.

The change. The automatic upgrade's check moved into one shared function, and every manual folder-to-Git change now runs it first:

  • setup-update, on the desktop and on a paired server
  • the general repo update, on the desktop and on a paired server
  • both "clone into an existing folder project" paths

If the folder isn't the top of a Git repository, the change is refused with " isn't the top folder of a Git repository, so this project's type was not changed." Otherwise the recorded root is written with the type change. If the project is removed, moved or already converted while Git is being checked, Orca writes none of the requested changes and says: “The project changed while Orca was checking it, so its type was not changed. Try again.” Clone completion also rereads the current project and folder-workspace metadata after that check.

Intended difference: the automatic upgrade also hides external worktrees when the spelling matches. That stays a choice of the automatic upgrade only, so a manual change keeps the user's own visibility setting.

What you see. Before: setup-update --kind git on a folder inside another repo succeeds and leaves a project whose workspace list fails. On a symlinked folder, the main workspace's tabs disappear after the next refresh. After: the first is refused with the message above, and the second keeps its main workspace and tabs.

Why

Two entry points each made their own copy of one decision, and only one copy was complete. This is the second time that has happened in this mechanism (#20653 added the recorded root to the automatic path only), so the fix is one shared function used by every path, not a third copy.

Where the check runs: on the machine that runs Git for the project. That covers local projects, projects behind a WSL path (Git runs through the existing WSL route), and projects registered on a paired server (checked on that server). Temporary difference: projects on an SSH host keep today's unchecked change, because the SSH connection has no "find the Git root" call yet. Adding one is a wire change for a follow-up.

Linked Issue

Linear STA-10638

Visual Proof

Remote Electron comparison passed on M4Air using signed-in Grok and the approved paired-terminal Playwright CDP route. Pinned main a54236751ec132f0c816eb9a6b598bbc6b22b0eb accepted the nested-folder request and hid its workspace after reload; this head refused and kept the original folder type and name. Main's symlink-parent root lost its visible workspace and tabs after reload (saved tab records remained under the old identity); this head retained the exact workspace ID, Editor/Logs tab IDs, order and active Logs selection. Ordinary-root conversion also retained its workspace and tab.

Main after conversion and full reload This branch after conversion and full reload
Main hides nested and alias workspaces and has no active tabs Branch retains nested folder and alias workspace with original tabs

Before conversion: main, branch. Full QA and review evidence.

Limits: new-worktree setup scripts/default tabs and rendered SSH/WSL execution were not exercised. The existing-folder fixture opened Terminal 1; its config is for new worktree creation. Selected Logs survived reload; keyboard focus did not persist. No conversion regression was established for those observations.

Testing

  • One real-store test with a real git init: a folder project inside the repo (not at its top) is refused and stays a folder project; the project at the top converts and records the root.
  • Four named Windows test files passed 89 tests at b0dcd68. The focused runtime selection passed 20 tests (1,350 skipped) at fa7dbd7. The runtime fixtures now create a real Git root and use the existing path normalizer for the expected stamp.
  • Current head is 1c16fff5baf1d5a6a20d7fd1cdcb3a213678eb3d. Its only change after those passing runs replaces an unchecked property access in a test assertion, fixing CI's TS18046. That assertion-only change has not been rerun remotely.
  • CI is the lint and typecheck gate. The full PR workflow for this head completed successfully: static analysis and typecheck, all five unit-test shards, relay integration, both packaging jobs and selection evidence passed. The aggregate follows its configured skipped success fast path. Mobile verification, repository guards and the line-count check also passed. The fresh ready-for-review run and persistence check also passed on this same head.
  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Review

Two adversarial review rounds, an architecture challenge, a performance review and final source readiness review completed. Two bounded design panels retained the focused root-proof design and required current-state checks at mutation. Review fixes cover SSH host ownership, stale projects and WSL move protection after the asynchronous check, clone registration changes, and ordinary settings updates avoiding unnecessary catalog reads. Runtime clone test fixtures now create an actual temporary Git root.

Deferred concerns, with no demonstrated new user failure: pre-existing setup-ID routing ambiguity, two synchronous setup writes with no identified intermediate observer, and unmeasured filesystem latency on WSL network paths. The required rendered main-versus-branch comparison and full exact-head PR workflow passed. Review status. The product option to keep folder workspaces listed in Git projects is excluded.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

No new saved field, and no change to what the IPC or RPC messages carry. repos:update, projectHostSetups:update and the runtime projectHostSetup.update now resolve asynchronously; their callers already await them. The write-protection check during a WSL move refuses before any Git probe starts and is repeated immediately before mutation after the probe.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred) — full exact-head PR workflow passed; remote QA build passed

Author: @BrennanKB5

…der workspaces (STA-10638)

A folder project's extra workspaces exist only as metadata rows that the folder listing shows. Changing the project to Git switches it to `git worktree list`, so those workspaces drop out of the next refresh and their saved tabs are purged as if they had been deleted. Only the automatic upgrade checked for this; `orca project setup-update --kind git`, repo updates and clone-into-folder did not.

The check now lives in the one repo write every type change goes through, so any caller gets the same refusal and nothing is written. The automatic upgrade and both clone paths use the same check and keep the project as a folder project.
… Git root first (STA-10638)

Only the automatic upgrade checked that a folder project's path is the top of a Git repository and recorded Git's spelling of that root. A manual change (orca project setup-update --kind git, repo updates, clone into a folder project) flipped the type without either, so a project inside another repo became a broken Git project, and a project whose path Git spells differently lost its main workspace's id and tabs on the next refresh. All of them now run the same proof and write the proven root with the type change. SSH projects keep the unverified change because their Git runs on a host this process can't probe.
@brennanb2025

brennanb2025 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author

A folder project could be changed to Git while pointing inside another repository, leaving a project whose workspace list failed. A project reached through a symlinked parent could also lose its main workspace tabs after refresh because manual conversion did not record how Git spells the root.

This PR checks that the selected folder is the Git root before changing its type, then records that spelling to preserve the main workspace identity and tabs. A refusal writes none of the requested changes. If the project changes during the check, Orca says: “The project changed while Orca was checking it, so its type was not changed. Try again.”

Source review and required remote Electron comparison passed on the current head. Reviewed PR C's original top commit and review fixes only, excluding its base #29257 and separate #29265. Current head: 1c16fff5baf1d5a6a20d7fd1cdcb3a213678eb3d. Two adversarial rounds, architecture and performance reviews, two bounded design panels, and final source readiness checks completed.

Fixed during review:

  • Preserve the temporary SSH exception when the authoritative host is SSH without a legacy connection ID; paired runtime proof runs on its owner.
  • Recheck the selected project and WSL move protection after Git returns, immediately before mutation.
  • Reread clone registration and folder-workspace metadata after the await, handle removal through fresh registration, and convert an eligible replacement row using its current identity and settings.
  • Avoid catalog hydration for ordinary settings edits, and give the accurate retry message above.
  • Correct runtime clone fixtures, Windows path expectations, and an unknown-result test assertion caught by CI.

Deferred concerns: pre-existing setup-ID routing ambiguity, two synchronous setup writes without an identified intermediate observer, and unmeasured synchronous filesystem latency on WSL paths. No demonstrated new user failure was established for these concerns. SSH's unchecked conversion remains temporary until a compatible host-side root query is added. The pending product option to keep folder workspaces listed in Git projects is excluded. Production additions remain 246 code lines excluding blanks/comments (285 raw); no further production growth was made.

Verification: Windows passed 89 tests across four named files at b0dcd689762, then 20 focused runtime tests at fa7dbd713179 (1,350 skipped). Current head has one subsequent assertion-only typing correction; it was not rerun remotely. The previous workflow found TS18046 in that assertion; it is fixed and pushed. The full PR workflow for the current head completed successfully: static analysis and typecheck, all five unit-test shards, relay integration, both packaging jobs and selection evidence passed. The aggregate uses the configured skipped success fast path on this head. Mobile verification, repository guards and the line-count check also passed. The fresh ready-for-review run also passed on this same head, and the persistence check passed; the single checks watcher exited successfully.

Remote Electron QA passed on M4Air, comparing pinned main a54236751ec132f0c816eb9a6b598bbc6b22b0eb with this exact head. Signed-in Grok drove named Playwright sessions through the approved paired-terminal CDP route. Test apps used isolated homes and profiles. The coordinator inspected the original whole-window screenshots. Owned apps, drivers, remote checkouts, terminals, scratch branches and redundant remote evidence are cleaned up; real config hashes matched before and after. Original evidence and the final report are archived locally.

  • Folder inside a Git repository: main accepted both Git type and a requested rename, then hid its workspace after reload. This branch refused with the plain root message; after reload, repo, setup and project retained the original folder type/name and no root stamp. Neither requested change was written.
  • Git root reached through a symlinked parent: main accepted conversion without the root mapping, then hid the main workspace and tab bar after reload. Its saved tab records remained under the old identity; deletion from disk was not demonstrated. This branch accepted conversion, recorded the physical Git root and preserved the exact main workspace ID, both full Editor/Logs tab IDs, their order and active Logs tab after full reload.
  • Ordinary Git root: conversion succeeded and its primary workspace and original Terminal 1 tab remained after reload.

Limits: setup scripts and default tabs on newly created worktrees were not exercised. Existing-folder activation showed Terminal 1 despite the fixture's orca.yaml; the config applies to new worktree creation, so this is not evidence of a conversion regression. SSH and WSL were source-reviewed but not rendered in this comparison. Reload cleared the terminal's accessibility focus flag while preserving the selected Logs tab; the ordinary root's branch label appeared after reload. These observations do not change the tab-preservation verdict.

For Brennan's review

The screenshots show both required flows together: nested-folder is the refusal case; root-project is the symlink-parent root with Editor then Logs, Logs active. The ordinary root is the neighboring successful conversion.

Main before conversion Branch before conversion
Main folder projects and original tabs Branch folder projects and original tabs after baseline reload
Main after conversion and full reload Branch after conversion and full reload
Main hidden nested and alias workspaces with no active tabs Branch nested project remains a folder and alias workspace keeps Editor and active Logs

Immediately after the CLI, before reload: main, branch. Both still show the original alias tabs at that point.

Update after #29257 merged: this PR now targets main. Main was merged in and its lockfile restored (c3c523707cb). The PR's own change against main is identical, line for line, to the reviewed and QA'd diff at 1c16fff5baf; only commit hashes differ. The full PR workflow is green on c3c523707cb.

@brennanb2025
brennanb2025 marked this pull request as ready for review October 16, 2026 08:03
@brennanb2025
brennanb2025 changed the base branch from brennan/sta-10638-bug-folder-to-git-conversion-leaves-old-workspaces-orphaned to main October 16, 2026 19:43
# Conflicts:
#	src/main/ipc/repos/repo-clone-lifecycle.ts
#	src/main/persistence-update-repo.test.ts
#	src/main/runtime/runtime-repository-clone-controller.ts
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The change adds shared Git-root proof and repository-state checks for folder-to-Git conversions. Manual repository updates and project-host setup updates use the proof before writing conversion data. Clone completion rechecks the saved repository and workspace state before upgrading it. The affected update paths now await asynchronous operations, and tests cover nested folders, changed or removed repository records, and clone-driven conversions.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to c3c52

Merge Risk: 🟡 Moderate · up to c3c52

A project changed during the Git check can still receive the pending setup conversion. Recheck the setup binding before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 63.64% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 14 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: manual folder-to-Git conversion now proves that the folder is the Git root first.
Description check Passed The description is complete and directly related to the changes. It includes the user impact, implementation details, rationale, linked issue reference, visual proof, testing evidence, known limitatio…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is complete and directly related to the changes. It includes the user impact, implementation details, rationale, linked issue reference, visual proof, testing evidence, known limitations, review notes, and checklist status.

✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 36a74592-ce4e-437e-96c0-b1e0a89ac4a5
📥 Commits

Reviewing files that changed from the base of the PR and between 6a76068 and 1ccadaa.

⛔ Files ignored due to path filters: 1
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing: 14
  • src/main/folder-repo-git-conversion.ts
  • src/main/ipc/folder-repo-git-upgrade.ts
  • src/main/ipc/repos-local-add-and-project-setup.test.ts
  • src/main/ipc/repos-local-clone-lifecycle.test.ts
  • src/main/ipc/repos/project-host-setup-handlers.ts
  • src/main/ipc/repos/repo-clone-lifecycle.ts
  • src/main/ipc/repos/repo-update-handler.ts
  • src/main/persistence-update-repo.test.ts
  • src/main/runtime/orca-runtime-tests/repository-project-operations-part-02.spec.ts
  • src/main/runtime/rpc/methods/project-runtime-rpc-methods.ts
  • src/main/runtime/runtime-project-host-setup-controller.ts
  • src/main/runtime/runtime-project-host-setup-publication.test.ts
  • src/main/runtime/runtime-repository-clone-controller.ts
  • src/main/runtime/runtime-repository-settings-controller.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

Comment thread src/main/folder-repo-git-conversion.ts Resolved
@brennanb2025
brennanb2025 merged commit fa923c6 into main Oct 16, 2026
33 checks passed
@brennanb2025
brennanb2025 deleted the brennan/sta-10638-pr-c-prove-git-root branch October 16, 2026 22:54
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