feat: site create modal add root directory location browse option - #5
Conversation
8664dda to
c8133ce
Compare
|
@wpexpertinbd kindly merge this and update, it is necessary for most of the website when serve sites from diferent dir's. |
wpexpertinbd
left a comment
There was a problem hiding this comment.
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 reloadas the primary path and use restart only as a fallback — details in my comment on #6. linux/app/bhserve/pages.pychanges "Open config" from_open_editor(...)to_open(...), which loses the code/codium/cursor/subl/gedit chain (_open_editoralready 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!
…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>
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.
…dal-browse-option # Conflicts: # engine/bhserve
|
All 5 review points are fixed and pushed. The branch was also merged with the latest
All 3 CI checks (swift build, dotnet build, python+bash) pass. Ready for re-review 🙏 |
wpexpertinbd
left a comment
There was a problem hiding this comment.
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:
- macOS —
type == "php" || type == "laravel" || type == "wordpress", and the C# files correctly keep C# pattern syntax. The new CI'sswift buildjob confirms it compiles. - Add app —
nameentry restored (withhexpand=True);ruff F821is clean. - Laravel —
mkdir -p "$vhost_root"createspublic/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 reloadis primary with restart only as the fallback, in both engines andNginx.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.
Adds folder browse options to site creation modals across Linux and Windows UI apps, aligning directory location input directly below web server selection.