Skip to content

Create a new project from the Add a project dialog - #229

Merged
yansfil merged 3 commits into
mainfrom
feat/create-new-project
Sep 28, 2026
Merged

yansfil merged 3 commits into
mainfrom
feat/create-new-project

Conversation

@yansfil

@yansfil yansfil commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Related: follows #223 (Add a project dialog). Clone from URL lands separately in the same "Other ways to add" group.

Summary

Add a project could only register a folder that already exists.
Now, on this Mac, an "Other ways to add" group sits under Browse folder, and Create new project names a folder, shows where it goes, and makes it with its own Git repository before registering it, in one step.
hided answers a new project_target probe on the same $HOME line the create is checked on, so a taken name, a folder outside home, or an invalid name shows inline before anything is sent.
The core's existing creation worker makes the folder and runs git init off the runtime lock; a failed create keeps its folder, and a retry continues into it.

Create a new project view: name field, location row with the full path, Create project

The location row names the parent as ~ spells it; the full path under it follows the name as it is typed (the long path here is the e2e fixture's temporary home).

Review

  • Judge: a target that is an empty folder, or holds only .git and .DS_Store, counts as a leftover of a failed create and is continued into instead of refused as existing. This is how behavior 5 (retry converges, nothing deleted) and "existing target refused" were reconciled; the view says "An empty folder by this name is already there; the project is made in it."
  • Judge: copy - title "Create a new project", description "Name it, and Hide makes the folder with its own Git repository and adds it.", row detail "A new folder with its own Git repository".
  • Files to watch:
    • hided/src/boundary.rs, hided/src/server.rs - the $HOME boundary: resolve_new_project allows home itself as the parent (the new folder is still strictly under it) and never follows a symlink at the target.
    • herdr-core/src/live.rs - failure path: the folder is made at the literal checked path before registration() canonicalizes it (a review finding fixed in the second commit).
    • contracts/hided-ws.schema.json - WS contract: new project_target frame, projectTarget/projectTargetResult defs, already_exists reason, new_folder on create_workspace.
    • web/src/registration.tsx - the send/answer logic Browse folder used is extracted here and shared by both views; D3 will want it too.

Evidence

  • Confirmed:
    • Desktop e2e desktop/e2e/add-project.spec.ts against an isolated Herdr and a dev Electron app, 2/2 passing: the new test opens the view (name focused, default ~), picks ~/projects through the stubbed picker, sees already_exists for a folder with a file, the name problem for a/b, creates fresh with Enter, then asserts the dialog closes, the project row appears, fresh/.git is a directory, the taken folder is untouched, a reopen defaults beside fresh and refuses the same name as already_registered, and Back returns focus to the row.
    • The existing Browse folder, cancel, outside_home, already_registered and device-field flows still pass in the same spec.
    • Core unit test: folder made as its own repository inside another repository's tree; a retry, an empty folder and a .DS_Store-only folder are continued into; a folder with contents, a file, and a symlink at the name are refused and left untouched.
    • hided test: probe answers parent label, full path, leftover and each refusal (already_exists, invalid_path, not_found, outside_home) and makes nothing; new_folder creates are forwarded as the canonical path or refused with the path as sent.
    • Core runtime test: a new_folder create naming an SSH device is refused.
    • verify-cargo.sh lint, verify-web.sh (web 443 tests, desktop 44, typecheck, lint, build), check-design-contract.mjs: pass.
    • Two native review passes; findings fixed: a symlink race at the leaf (core canonicalized before creating) and .DS_Store breaking retry convergence.
  • Not confirmed:
    • Under load (six parallel builds, load average about 10) one full herdr-core run failed 3 unrelated deadline tests (github::tests gh timeouts, live::tests::a_hung_hcoord_link...); they pass on rerun and passed in the earlier full run.
    • A real git init failure (git missing) was not exercised live; its message path is covered only by reading.
    • Not observed against the installed app; QA used the dev app from this branch only.
More evidence

Add a project with the Other ways to add group

The first view: Browse folder keeps the keyboard; Create new project sits under "Other ways to add", on this Mac only.

AI tooling: mostly AI tools; the diff, the boundary checks, and the e2e screenshots were read by hand.

The dialog gains an Other ways to add group under Browse folder; Create new
project names a folder, shows where it goes, and makes it with its own Git
repository before registering it. hided judges the parent on the $HOME line
and answers a project_target probe so problems show before anything is sent;
the core's creation worker makes the folder and runs git init off the lock.
A leftover empty folder from a failed attempt is continued into, never
deleted.
The creation worker canonicalized the path before making the folder, so a
symlink planted at the name after hided's check would have been followed.
The folder is now made at the literal path first. A Finder .DS_Store no
longer turns a leftover folder into one a retry refuses.
@yansfil
yansfil merged commit c7abe77 into main Sep 28, 2026
11 of 13 checks passed
@yansfil
yansfil deleted the feat/create-new-project branch September 28, 2026 07:10
yansfil added a commit that referenced this pull request Sep 28, 2026
## Summary

Add a project could only register a folder that already exists.
Under `Browse folder` there is now an "Other ways to add" group with
`Clone from URL`: paste a Git URL, pick a parent folder under home, and
the repository is cloned in the background with visible progress and a
Cancel, then registered through the existing `create_workspace` path;
the dialog closes when the project appears.
The clone is one core job (`repository_clone` snapshot slot) run by a
worker off the lock; `hide_host::clone` runs `git clone` in its own
process group with no prompts, into a hidden staging folder renamed into
place only on success, so a cancel, a stall (120 s with no output) or a
failure leaves nothing under the target's name.
Local host only; a device's Host shows no such option.

![Clone from URL while cloning a large public repository: Git's stage
and percent, a progress bar, and
Cancel](https://github.com/yansfil/pr-assets/blob/main/hide/clone-from-url/7c9a815/live-clone-progress-crop.png?raw=true)

## Review

- **Judge**: the look of the sub-view and the "Other ways to add" row
(built from hide's Dialog, Input, Button, Status and tokens after the
reference); the copy of the failure lines, for example "Authentication
failed: this repository needs credentials Git could not find...".
- **Judge**: `file://` is accepted as a clone source next to https and
ssh. The e2e and tests need it, and it only reads what the operator's
account can already read; say if it should be test-only.
- **Judge**: closing the dialog leaves a running clone running (it
registers when done); reopening Add a project shows it. The alternative
is to cancel on close.
- **Files to watch**:
- `hide-host/src/clone.rs` - failure path and process ownership: process
group kill on every exit, staging cleanup, `RENAME_EXCL` move, stderr
classification, credential redaction.
- `herdr-core/src/runtime/clone.rs` - runtime mutex: the worker locks
only to write progress and the result; one slot, a repeated request
joins the running clone.
- `hided/src/boundary.rs`, `hided/src/server.rs` - the `$HOME` line for
`clone_repository` (a taken name is `already_exists`, the code Create
new project uses, but a clone accepts no leftover folder) and a
`clone_target` probe answered beside #229's `project_target`.
- `contracts/hided-ws.schema.json`, `herdr-core/src/model.rs` - snapshot
wire: new `clone_target` frame, `repository_clone` rest field.
- `web/src/AddProjectDialog.tsx`, `web/src/CloneFromUrl.tsx` - merged
with #229: Clone from URL is a second row of its `OTHER_WAYS` list, and
the registration a finished clone makes is read through its
`useRegistration`.

## Evidence

- **Confirmed**:
- Live, in a dev app I launched against an isolated Herdr and HOME:
cloning `microsoft/TypeScript` showed Receiving objects with percent,
and Cancel left the parent folder empty. A missing `github.com`
repository failed with the authentication line, leaving nothing on disk.
`octocat/Hello-World` cloned, registered, and closed the dialog.
- `hide-host` clone tests (5, real `git`): a `file://` bare repository
clones with progress; a cancel partway leaves no folder; a server that
accepts and never answers ends as stalled after the limit, leaving
nothing; a taken name is refused before Git runs; a missing repository
reads as not found. Plus 6 unit tests for URL parsing, progress lines,
failure classification and redaction.
- Core (4): a finished clone reaches `create_workspace`; the same clone
sent twice runs once with one registration and another clone is refused
as busy; a cancel leaves no folder and registers nothing; a mismatched
name or an `ext::` URL is refused before anything runs.
- hided (2): the `$HOME` line accepts `~` and folders under it, refuses
taken names (dangling symlinks too), `..`, outside home and missing
parents; `clone_target` is answered without reaching the core.
- Desktop e2e `add-project.spec.ts` (new case): invalid URL inline,
`target_exists` inline, picker-chosen parent, clone and registration,
parent defaulting beside the new project, Back. The whole desktop e2e
suite passed locally (18 passed, 1 skipped as on main).
- `cargo test --workspace` 1394 passed, clippy and fmt clean, web
typecheck/lint/444 unit tests, desktop typecheck/lint, structural
checks, design contract.
- Two review passes (code, security and fidelity). Fixed: a registration
failure after a finished clone now shows the reason and the folder on
disk instead of waiting forever; `::` transport-helper URLs are refused
by both parsers; a panicking clone worker still settles the slot.
- After merging main (#229): `cargo test --workspace` 1397 passed,
clippy and fmt clean, web 452 unit tests, and all three
`add-project.spec.ts` cases (Browse folder, Create new project, Clone
from URL) passed locally.
- **Not confirmed**:
- An ssh (`git@host:path`) clone was not run live; its flags are covered
only by code reading.
- A GUI credential helper configured by the operator could still show
its own window; the stall limit bounds the wait.
- A daemon killed mid-clone leaves its hidden `.<name>.hide-clone-<pid>`
staging folder behind (documented).
- The parent is checked by path in hided and used by path in the core,
like `create_workspace` today; a process that can already write inside
home could swap an ancestor between the check and the clone (follow-up:
pin the parent by handle).
  - `design/hide-screens.pen` does not draw the sub-view yet.

<details><summary>More evidence</summary>

Add a project on this Mac with the new "Other ways to add" group.

![Add a project with Browse folder and Other ways to add: Clone from
URL](https://github.com/yansfil/pr-assets/blob/main/hide/clone-from-url/7c9a815/live-add-dialog-crop.png?raw=true)

A repository that needs sign-in (or does not exist), with no prompt and
nothing kept.

![Clone from URL showing the authentication failure line with Clone
enabled
again](https://github.com/yansfil/pr-assets/blob/main/hide/clone-from-url/7c9a815/live-clone-failed-crop.png?raw=true)

</details>

**AI tooling**: mostly AI tools; I read the process, cleanup and
boundary code paths and watched the live clone, cancel and failure in
the dev app.
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