Skip to content

feat: site create modal add root directory location browse option - #5

Merged
wpexpertinbd merged 5 commits into
wpexpertinbd:masterfrom
plusemon:feat/site-create-modal-browse-option
Aug 5, 2026
Merged

feat: site create modal add root directory location browse option#5
wpexpertinbd merged 5 commits into
wpexpertinbd:masterfrom
plusemon:feat/site-create-modal-browse-option

Conversation

@plusemon

Copy link
Copy Markdown
Contributor

Adds folder browse options to site creation modals across Linux and Windows UI apps, aligning directory location input directly below web server selection.

@plusemon
plusemon force-pushed the feat/site-create-modal-browse-option branch from 8664dda to c8133ce Compare July 29, 2026 08:53
@plusemon

plusemon commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

@wpexpertinbd kindly merge this and update, it is necessary for most of the website when serve sites from diferent dir's.

@wpexpertinbd wpexpertinbd left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for this — the folder pickers are a genuinely nice UX win, and I ran a full supply-chain pass over the diff (new network calls, downloads, eval/base64, new dependencies, process launches): completely clean. Much appreciated.

Requesting changes on three blockers, all straightforward:

1. macOS won't compile. macos/Sources/BHServe/AppState.swift (~line 618) became:

if type is "php" or "laravel" or "wordpress" {

That's the C# 9 pattern match you (correctly) wrote in windows/src/BHServe.Core/Engine.cs, pasted into the Swift file. Swift's is needs a type on the right, and there's no or operator — so swift build fails outright. Please use:

if type == "php" || type == "laravel" || type == "wordpress" {

and run cd macos && swift build before re-requesting review. No CI job builds Swift, so this would ship silently and surface at the next macOS release.

2. Linux GUI: "Add app" is dead on the Node and Python pages. In linux/app/bhserve/window.py, _app_dialog loses name = Gtk.Entry(placeholder_text="app name"), but both consumers survive — rows = [(name, "Name"), ...] and nm, fd = name.get_text().... Result is a NameError; PyGObject swallows it to stderr, so the button just silently does nothing. Please restore the entry (with hexpand=True to match the new row loop) and open both dialogs once to confirm.

3. Laravel sites 404 out of the box. site_add sets vhost_root="$root/public" but only runs mkdir -p "$root", and the branded landing index.php is written to $root — one level above the document root. Windows is the same (Engine.cs). Needs mkdir -p "$vhost_root" (plus Directory.CreateDirectory(vhostRoot)) with the index written there.

Two smaller ones:

  • Please keep nginx -s reload as the primary path and use restart only as a fallback — details in my comment on #6.
  • linux/app/bhserve/pages.py changes "Open config" from _open_editor(...) to _open(...), which loses the code/codium/cursor/subl/gedit chain (_open_editor already falls back to _open, so it's a strict superset). The neighbouring "Open in editor" still uses _open_editor, so the two now behave differently. Could you revert that line?

Note that #6 contains these same commits, so whichever you'd prefer to fix in, let me know — happy to re-review quickly once these land. Thanks again for continuing to contribute!

wpexpertinbd added a commit that referenced this pull request Aug 5, 2026
…no longer break every site)

A site whose document root contains a space rendered as a bare `root /srv/My Site;`,
which nginx rejects with "invalid number of arguments in "root" directive" — a fatal
config error that stops nginx for EVERY site, the same outage class fixed in 1.0.68.
The readers made it worse: `awk '{print $2}'` silently truncated such a root to
`/srv/My`, which was then re-rendered on the next site php/secure — and one call site
feeds that value to rm -rf under `site rm --purge`.

Pre-existing bug, but a folder picker (community PR #5/#6) makes spaced paths likely,
so fix it at the source:

- Writers now quote: `root "$root";` in all three nginx templates (php vhost,
  apache-front, OLS-front) and both Windows C# templates. Apache's DocumentRoot was
  already quoted — that was the model.
- New vhost_root_read() (bash) / VhostRoot() (C#) replaces all 11 bash and 2 C#
  readers. Accepts both the new quoted form and the legacy unquoted form still on
  disk in every existing install, plus an optional trailing comment.
- New valid_site_root() / ValidateSiteRoot() on site add and site root reject ; " { }
  $ \ and newlines — the characters that inject into or break the vhost. Spaces are
  explicitly allowed; that is the point of the quoting.

Verified in WSL (17/17): a spaced root renders quoted, nginx stays valid and the site
serves, a re-render round-trips the full path, the api reports it intact, legacy
unquoted vhosts still parse, and every injection payload is refused with nginx
untouched. C# compiles clean. macOS inherits via the shared engine.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
wpexpertinbd added a commit that referenced this pull request Aug 5, 2026
Adds the missing build CI. BHServe ships three front-ends (Swift/macOS, C#/Windows, Python/Linux) over one shared bash engine and nothing ever compiled the other platforms.

- macOS:   swift build
- Windows: dotnet build BHServe.sln
- Linux:   compileall + ruff F821/F822 (undefined names) + bash -n over the engine and every shipped .sh

Verified by injecting the two real bugs found in community PR #5/#6 and confirming the gate goes red with precise file:line messages (AppState.swift:618 'expected type after is'; window.py:441 'Undefined name name'), then green again on revert. Windows stayed green throughout, confirming per-platform isolation.
@plusemon

plusemon commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

All 5 review points are fixed and pushed. The branch was also merged with the latest master (was CONFLICTING, now CLEAN) — this picked up the quoted-document-root and root-validation changes too, so those coexist cleanly with the new laravel type.

  • macOS compile — AppState.swift now uses type == "php" || type == "laravel" || type == "wordpress"
  • Linux "Add app" — restored the missing name entry in _app_dialog
  • Laravel 404site_add creates the document root and writes the landing index there ($root/public for Laravel); same in Engine.cs
  • nginx reload-s reload is primary, full restart only as a fallback (engine, platform-linux.sh, Nginx.cs)
  • "Open config" — reverted to _open_editor

All 3 CI checks (swift build, dotnet build, python+bash) pass. Ready for re-review 🙏

@wpexpertinbd wpexpertinbd left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Re-reviewed — all 5 points verified fixed in the diff (not just taken on trust), and merging. Thank you for the fast, precise turnaround.

Verified:

  • macOStype == "php" || type == "laravel" || type == "wordpress", and the C# files correctly keep C# pattern syntax. The new CI's swift build job confirms it compiles.
  • Add appname entry restored (with hexpand=True); ruff F821 is clean.
  • Laravelmkdir -p "$vhost_root" creates public/ and the landing index lands in the document root. Live-tested: vhost points at …/lartest/public, the directory is created, and the site serves.
  • nginx-s reload is primary with restart only as the fallback, in both engines and Nginx.cs; you kept the good half (dropping the [ -t 1 ] tty gate so GUI changes actually apply). I A/B'd the reload path against master: identical behaviour, no regression.
  • Open config — back to _open_editor.

Also checked: your master merge preserved all four of the new document-root guards (valid_site_root, vhost_root_check, vhost_root_read, quoted root "$root";) — laravel + quoting compose correctly, including a spaced root rendering as root "/…/My Lara App/public"; and serving. Supply-chain pass is clean: no new network, download, eval/base64, exec surface or dependencies.

Nice work — this is a genuinely useful feature set.

@wpexpertinbd
wpexpertinbd merged commit e58afb9 into wpexpertinbd:master Aug 5, 2026
3 checks passed
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.

2 participants