From ed00611dcbe7d63304755dc4789ee5a06e79e054 Mon Sep 17 00:00:00 2001 From: brennermusgraveKPB <155494017+brennermusgraveKPB@users.noreply.github.com> Date: Wed, 16 Sep 2026 09:01:10 -0800 Subject: [PATCH 1/4] =?UTF-8?q?HS-1=20=E2=80=94=20Windows:=20welcome/loadi?= =?UTF-8?q?ng=20screen=20window=20can=20never=20be=20closed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Investigated GitHub issue #68 ("Hot Sheet not working on Windows" — Open Folder unresponsive, window won't close, only Minimize works). Root cause of the reported symptoms was HS-9738 (already fixed on main/beta, not yet in a stable release): the shipped v0.20.0 Windows installer hard-coded tauri://localhost for the welcome-screen navigate, which WebView2 never resolves (it only serves http://tauri.localhost), so the webview stayed on about:blank with no JS ever loaded. Confirmed against this machine's own ~/.hotsheet/startup.log + shutdown.log from the failed run (12 unanswered CloseRequested events, no confirm_quit). Found a second, still-live bug along the way: the global CloseRequested handler in lib.rs always calls prevent_close() and waits for JS to invoke the confirm_quit command, but neither loading/welcome.html nor loading/index.html (the two pre-project screens) ever listened for the quit-confirm-requested event Rust emits — so even after the URL-scheme fix, a user sitting on either screen (most commonly: first launch, before opening any folder) could still never close the window from the UI, only via Task Manager. Both pages now listen for quit-confirm-requested and invoke confirm_quit immediately — no confirmation dialog needed, since neither screen can ever have a project or terminal running to protect. Co-Authored-By: Claude Sonnet 5 --- docs/10-desktop-app.md | 1 + docs/37-quit-confirm.md | 8 ++++++++ docs/ai/requirements-summary.md | 4 +++- docs/manual-test-plan.md | 2 ++ src-tauri/loading/index.html | 13 +++++++++++++ src-tauri/loading/welcome.html | 14 ++++++++++++++ 6 files changed, 41 insertions(+), 1 deletion(-) diff --git a/docs/10-desktop-app.md b/docs/10-desktop-app.md index c0da5b41..a6a7535d 100644 --- a/docs/10-desktop-app.md +++ b/docs/10-desktop-app.md @@ -39,6 +39,7 @@ anything outside the static `extraSearchDirs` undiscoverable. - If launched without `--data-dir` (e.g., double-clicking the app icon), the app first checks `~/.hotsheet/projects.json` for previously opened projects and restores the most recent one. - If no previous projects exist, a welcome/setup screen is shown instead of the main UI. - The welcome screen navigates to the bundled `welcome.html` via the platform's Tauri asset scheme — `tauri://localhost` on macOS/Linux, `http://tauri.localhost` on Windows (built by `app_asset_url()` in `src-tauri/src/lib.rs`). The screen shall load on every supported platform: a hard-coded `tauri://` URL aborts on Windows (WebView2 can't register a real custom scheme) and left the 0.20.0 .exe/.msi installs on an empty window (HS-9738 — Windows desktop app opened blank with no project; the same bug as Glassbox GitHub #57). +- Both `welcome.html` and the `loading/index.html` boot splash acknowledge the `quit-confirm-requested` event (§37.11) by invoking `confirm_quit` immediately — neither page can ever have a project/terminal running, so there's nothing for the main app's confirm dialog to protect. Without this, the global `CloseRequested` handler's `prevent_close()` is never followed by a `confirm_quit` call and the window can only be killed via Task Manager / Force Quit (HS-1). ### 10.4 Window Title diff --git a/docs/37-quit-confirm.md b/docs/37-quit-confirm.md index 84a767e2..e501652d 100644 --- a/docs/37-quit-confirm.md +++ b/docs/37-quit-confirm.md @@ -156,6 +156,14 @@ See [manual-test-plan.md §12](manual-test-plan.md#12-embedded-terminal) — get 9. Cancel — app stays running, no PTYs killed. 10. Quit Anyway — every PTY torn down via destroyAllTerminals's existing SIGHUP path (HS-7528). +## 37.11 Pre-project screens (welcome / loading splash) + +**HS-1 fix.** The `CloseRequested` handler in `lib.rs` is global — it fires (and calls `prevent_close()` + emits `quit-confirm-requested`) no matter which page the main window currently shows, including the two pre-project pages served from `frontendDist` (`loading/index.html`, the "Starting Hot Sheet…" splash shown while a project's sidecar boots, and `loading/welcome.html`, shown when there's no previous project to restore). Neither page is part of the main client bundle, so neither had ever wired up a listener for that event — meaning a user who tried to close the window while on either screen got the close silently swallowed forever (no dialog ever appears, `confirm_quit` never gets invoked, `QuitConfirmed` never flips). The window could only be killed via Task Manager (Windows) / Force Quit (macOS). Reproduced against a real Windows installer run: `~/.hotsheet/shutdown.log` showed a dozen unanswered `WindowEvent::CloseRequested (confirmed=false)` lines with no corresponding `confirm_quit invoked`. + +Fix: both pages now call `window.__TAURI__.event.listen('quit-confirm-requested', …)` and immediately invoke the `confirm_quit` command — no confirmation dialog, unlike the main app's flow, because neither pre-project screen can ever have a running project/terminal to protect (`confirm_quit`'s no-sidecar branch already just calls `app.exit(0)`; mid-boot on the loading splash it tears down the half-started sidecar via the same taskkill/SIGTERM path `confirm_quit` always uses). + +This was found alongside (but is independent of) HS-9738 (§10.3's welcome-screen URL-scheme bug, which left the webview on `about:blank` with NO js at all on Windows 0.20.0 installs) — that bug also explains an unresponsive/unclosable window, but even after it's fixed, the gap this section describes remains: the pre-project screens' JS was simply never taught to answer the quit-confirm event. + ## 37.9 Cross-references - [22-terminal.md](22-terminal.md) §22.7 — base PTY lifecycle. The quit-confirm is a new gate IN FRONT OF the existing `destroyAllTerminals` shutdown flow (HS-7528 SIGHUP path). diff --git a/docs/ai/requirements-summary.md b/docs/ai/requirements-summary.md index cbc546e7..4594bbc8 100644 --- a/docs/ai/requirements-summary.md +++ b/docs/ai/requirements-summary.md @@ -411,7 +411,9 @@ HS-7591 (req-change spec) + HS-7596 (implementation). macOS Terminal.app-style " **HS-8604 (2026-05-25) — extended to project-tab close (§37.10).** Closing a project tab previously DELETEd immediately: it (a) **orphaned the project's PTYs** — `DELETE /api/projects/:secret` only cleared the project maps, leaving every terminal's process running unreachable until app exit, and `destroyProjectTerminals` was both uncalled AND latently broken (deleted `sessions` entries without `teardownPty`); (b) showed **no confirmation**, silently killing the very processes §37 guards. Fix: the DELETE route now calls (the now-correctly-tearing-down) `destroyProjectTerminals(secret)` before `unregisterProject`; the client's `removeProject` / `removeOtherProjects` / `removeProjectsInDirection` gate on a new `confirmCloseProjects(secrets)` (`quitConfirm.tsx`) that reuses the same per-project setting + `evaluateQuitDecision` scoped to the closing tab(s) and shows the lightweight `confirmDialog` (idle tabs never prompt; fetch failure proceeds since the server now kills PTYs cleanly). Tests: registry kill-PTYs-on-destroy, `projects.test.ts` DELETE-invokes-destroy, `buildCloseConfirmMessage`, new `quitConfirmCloseProjects.test.ts` decision matrix. -**Status:** Shipped (HS-7596; project-tab close added HS-8604). Cross-refs: §22 (base PTY lifecycle — quit-confirm gates IN FRONT OF destroyAllTerminals's existing SIGHUP path), §10 (Tauri shell hosts CloseRequested), §8 (CLI flags). +**HS-1 (2026-09-16, §37.11) — pre-project screens (welcome / loading splash) couldn't be closed.** The global `CloseRequested` handler always prevents the first close + waits for JS to invoke `confirm_quit`, but neither `loading/welcome.html` nor `loading/index.html` (shown before any project is open) ever listened for the `quit-confirm-requested` event — so a user on either screen could never close the window from the UI (Task Manager only). Fix: both pages now acknowledge the event by invoking `confirm_quit` immediately (no dialog — nothing to protect pre-project). + +**Status:** Shipped (HS-7596; project-tab close added HS-8604; pre-project-screen close fixed HS-1). Cross-refs: §22 (base PTY lifecycle — quit-confirm gates IN FRONT OF destroyAllTerminals's existing SIGHUP path), §10 (Tauri shell hosts CloseRequested), §8 (CLI flags). --- diff --git a/docs/manual-test-plan.md b/docs/manual-test-plan.md index f67592ea..b9462521 100644 --- a/docs/manual-test-plan.md +++ b/docs/manual-test-plan.md @@ -490,6 +490,8 @@ GPU-dependent **visual-quality** checks (crispness, no blur, no raster artifacts - [ ] **"Quit Anyway" actually quits (HS-8828, Tauri desktop — the reported regression).** With a non-exempt process running (so the dialog fires), ⌘Q → "Quit Anyway" → the app must actually close. This regressed under Tauri 2.11: app commands (`confirm_quit`) called from the remote `http://localhost` origin were ACL-rejected (`confirm_quit not allowed. Plugin not found` in the console), so `app.exit(0)` never ran and the window stayed open while the app remained fully functional. Verify via DevTools console too: `await window.__TAURI__.core.invoke('confirm_quit')` must NOT throw `not allowed. Plugin not found` (it should quit the app). Covered by the `build.rs` `AppManifest` command list + `capabilities/remote-localhost.json` grants; `cargo check` validates the permission identifiers but the *runtime* remote-origin grant needs a real desktop build. **Also re-test Quick Look (HS-8826)** — same root cause: `quicklook` was ACL-rejected → select an attachment, press Space → native Quick Look (no broken-image overlay, no "not allowed" error). - [ ] **Dev quit actually kills the Node server (HS-8828, Tauri dev only).** Run `npm run tauri:dev`. In another terminal note the `node … src/cli.ts` PID (`pgrep -f 'src/cli.ts'`). Quit the app (red traffic-light / ⌘Q → Quit Anyway). Within a few seconds the `cli.ts` process is GONE (`pgrep` empty) and port 4174 is free (`lsof -i:4174` empty). Pre-fix the server was orphaned (the SIGTERM hit the `npx` wrapper, not the server) and "the app never actually quit." Check `~/.hotsheet/shutdown.log`: it should show `CloseRequested` → `confirm_quit` → `RunEvent::Exit — SIGTERM server pid ` with `kill(pid)=0`, and the Node side's `[cli] SIGTERM received` + `[lifecycle] step "…" done` trail. **Also test terminal Ctrl+C** in the `npm run tauri:dev` terminal — the server must still shut down gracefully (it's not in a separate process group, so it still receives the terminal SIGINT). +- [ ] **Welcome/loading screen closes (HS-1, §37.11, Tauri desktop).** Launch the desktop app with no project registered (fresh `~/.hotsheet/projects.json`, or delete it) so it lands on the welcome screen — click the window's close button (red traffic-light / X / Alt+F4). The window must actually close (no dialog, no hang). Repeat by closing the window WHILE the "Starting Hot Sheet…" loading splash is showing (kill/rename `~/.hotsheet/projects.json`'s target dir so the restore hangs, or just be fast). Pre-fix, neither page ever answered the `quit-confirm-requested` event, so the window could only be killed via Task Manager — this was indistinguishable from (and contributed to) the "Windows app won't close" reports in GitHub issue #68. + #### Closing a project tab (HS-8604, §37.10) - [ ] **PTY actually dies (no orphan)** — open a project, start `claude` (or a long-running `node`/dev server) in a drawer terminal, note its PID (`ps`). Close the project's tab (X / right-click → Close Tab). After confirming, the process is GONE (`ps` shows it killed). Pre-fix it kept running, unreachable, until the whole app quit. - [ ] **Tab-close confirm fires for a running non-exempt process** — with `claude` running and the project's Quit-confirmation set to its default ("only with non-exempt processes"), closing the tab shows the lightweight confirm dialog listing `claude`. Cancel: tab stays open, claude continues. Close tab: claude is killed and the tab closes. diff --git a/src-tauri/loading/index.html b/src-tauri/loading/index.html index 2bde78ef..3d62bede 100644 --- a/src-tauri/loading/index.html +++ b/src-tauri/loading/index.html @@ -73,6 +73,19 @@ } } window.addEventListener('app:open-folder', function() { openFolder(); }); + + // HS-1 — same fix as welcome.html: acknowledge the Rust-side + // quit-confirm-requested event immediately so the window can actually + // close while this splash is showing (no project is open yet on this + // screen either, so there is nothing for a confirm dialog to protect). + // Without this, the CloseRequested handler's prevent_close() is never + // followed by a confirm_quit call and the window can only be killed via + // Task Manager. + if (window.__TAURI__.event) { + window.__TAURI__.event.listen('quit-confirm-requested', function() { + window.__TAURI__.core.invoke('confirm_quit').catch(function() {}); + }); + } diff --git a/src-tauri/loading/welcome.html b/src-tauri/loading/welcome.html index 6722a70e..ce43f2d5 100644 --- a/src-tauri/loading/welcome.html +++ b/src-tauri/loading/welcome.html @@ -382,6 +382,20 @@

Settings

openFolder(); }); + // HS-1 — the Rust-side CloseRequested handler always calls + // `prevent_close()` on the first close attempt and waits for the JS side to + // invoke the `confirm_quit` command (see §37 quit-confirm in the main app). + // This welcome screen has no project open and nothing running, so there is + // nothing to confirm — but without a listener here, that wait never ends + // and the window can never be closed (Windows: only Minimize keeps working, + // the X button does nothing; verified via ~/.hotsheet/shutdown.log showing + // repeated unanswered CloseRequested events). Acknowledge immediately. + if (window.__TAURI__.event) { + window.__TAURI__.event.listen('quit-confirm-requested', () => { + invoke('confirm_quit').catch(() => {}); + }); + } + // --- Preferences dialog --- function closePrefs() { document.getElementById('prefs-overlay').style.display = 'none'; From ed30035d38d3b54966c11b54a582f751968140c5 Mon Sep 17 00:00:00 2001 From: brennermusgraveKPB <155494017+brennermusgraveKPB@users.noreply.github.com> Date: Wed, 16 Sep 2026 09:01:27 -0800 Subject: [PATCH 2/4] =?UTF-8?q?HS-3=20=E2=80=94=20fix=20POSIX-only=20npm?= =?UTF-8?q?=20scripts=20that=20break=20under=20cmd.exe=20on=20Windows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While verifying this machine's local Windows dev setup, npm run dev/dev:server failed: npm has no script-shell configured, so on native Windows it runs package.json scripts through cmd.exe by default regardless of which shell npm itself was launched from. build:plugins used a bash `for d in plugins/*/; do ... done` loop with no explicit bash prefix, which cmd.exe can't parse at all ("d was unexpected at this time."). Same class of bug HS-8714 already fixed for build:client — ported the same way: scripts/build-plugins.mjs (Node fs + esbuild JS API) replaces the shell loop. Also fixed clean and tauri:clean (rm -rf -> inline node -e + fs.rmSync) and analyze:freeze (dropped the >/dev/null redirect, not a valid Windows path). Verified npm run dev:server now builds both plugins correctly and boots the server on Windows; tsc --noEmit and lint stay clean. Not fixed here (filed as a follow-up, HS-2): test:fast / test:e2e:fast pass a single-quoted --grep-invert pattern that cmd.exe doesn't group as one argument the way a POSIX shell does. tauri:build:local's bash-only syntax is left alone — it's a maintainer-only local release-signing helper. Co-Authored-By: Claude Sonnet 5 --- docs/ai/code-summary.md | 2 +- package.json | 8 ++++---- scripts/build-plugins.mjs | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 scripts/build-plugins.mjs diff --git a/docs/ai/code-summary.md b/docs/ai/code-summary.md index a5d017b6..eb62e908 100644 --- a/docs/ai/code-summary.md +++ b/docs/ai/code-summary.md @@ -803,7 +803,7 @@ From `tsup.config.ts` + `package.json` scripts: - **HS-8706 — zod is EXTERNAL for `channel.js`.** Bundling zod crashed `channel.js` on boot: `@modelcontextprotocol/sdk@1.29.0`'s `types.js` runs top-level `z.custom()` schemas at module-load, and esbuild's lazy ESM init ran the SDK module before zod's, so `ZodCustom` was undefined → `TypeError: Class2 is not a constructor` → the installed app's MCP server couldn't start ("won't connect"). `tsx` dev never reproduced it (Node's real loader orders zod first). Keeping zod external (`tsup.config.ts` channel entry `external: ['zod']`) makes the bundle resolve the real, fully-initialized module at runtime. `build-sidecar.sh` ships `node_modules/zod` (REQUIRED_DEPS) so the runtime import resolves. Guarded by `src/channelBundle.test.ts` (config contract) + `src/bundleBoot.test.ts` (actually builds + boots both server bundles — `channel.js` via an MCP `initialize`/`tools/list` handshake, `cli.js` via `--help` load-smoke — the ONLY tests that exercise the shipped artifacts; dev/e2e both run via `tsx`). - **HS-9442 — `channel.js` also needs the `createRequire` BANNER** (the cli.js block has had one since HS-9032). esbuild rewrites a bundled **CJS** dependency's `require(…)` into its `__require` shim, which throws `Dynamic require of X is not supported` unless a real `require` exists in ESM scope. HS-9388 added `codexDaemonTransport.ts` → **`ws`** (CJS, `require('events')`), reachable from `channel.ts` via `skills.ts` → `mcpHooksAgents.ts` → `codexAppServer.ts`, so the SHIPPED MCP server crashed at load in packaged installs (npm global / Tauri sidecar — `getChannelServerPath()` prefers `dist/channel.js` when it exists) while `tsx` dev was fine. The banner fixes the class, not just `ws`: any future CJS edge into the channel bundle resolves. **Lesson: a dependency edge added anywhere in `src/` can break the channel bundle only, so `bundleBoot.test.ts` (it spawns the real artifacts) is the test that matters after touching imports reachable from `channel.ts`.** Pinned by `channelBundle.test.ts` alongside the zod-external contract. - `npm run build:client` — client bundle + SCSS + assets only (used by `dev`). Also appends xterm.css to styles.css. **HS-8714 — this is now a cross-platform Node script (`scripts/build-client.mjs`, esbuild + sass JS APIs) instead of the old Unix-shell one-liner (`mkdir -p`/`cp`/`cat`/`${VAR:-default}`), so it runs under Windows `cmd.exe` too. Same output on macOS/Linux.** **HS-9352 — e2e server model is now scope-dependent (`playwright.config.ts` + `e2e/coverage-fixture.ts`): the `no-terminal` scope spawns a PER-WORKER ISOLATED server (workers=2 on CI) — the `workerServer` fixture runs `node --import tsx src/cli.ts --port 0` (OS-assigned ephemeral port, read from the "Hot Sheet running at" banner; `src/server.ts::tryServe` reports the real bound port), with `baseURL` overridden per worker; `e2e/globalSetup.ts` builds the client once up front. This killed the shared-server load-flakiness (each worker's server handles ~half the sweep) + is ~40% faster. The `terminal` scope KEEPS the single shared `webServer` via `scripts/e2e-server.mjs` (isolates HOME/USERPROFILE, temp data dir, builds the client, `node --import tsx`) — it's PTY-timing-sensitive and gains nothing from isolation at workers=1. The coverage path (`NO_WEB_SERVER`, `scripts/test-all.sh`) runs its own single external server on 4190; the fixture targets 4190 for both terminal + coverage. CI `retries` is 3 (backstop for the residual rotating flake tail — HS-9353). E2E runs on Windows (HS-8714).** -- `npm run build:plugins` — loops `plugins/*` and emits into `dist/plugins/*` with `manifest.json` copied. +- `npm run build:plugins` — loops `plugins/*` and emits into `dist/plugins/*` with `manifest.json` copied. **HS-3 — same HS-8714 treatment: `scripts/build-plugins.mjs` (Node fs + esbuild JS API) replaces the old bash `for d in plugins/*/; do … done` one-liner, which failed under Windows `cmd.exe` (npm has no `script-shell` configured, so it runs package.json scripts via `cmd.exe` by default regardless of the invoking shell). `clean` / `tauri:clean` were rewritten the same way (inline `node -e` + `fs.rmSync`, replacing `rm -rf`); `analyze:freeze` dropped its `>/dev/null` redirect (not a valid Windows path). Not yet fixed: `test:fast` / `test:e2e:fast`'s single-quoted `--grep-invert` pattern isn't grouped as one argument by `cmd.exe` the way a POSIX shell does — tracked as a follow-up (HS-2).** - `npm run dev` — `build:client` + `build:plugins` + `tsx src/cli.ts`. - `npm run tauri:dev` / `npm run tauri:build` — Tauri dev window / release package. diff --git a/package.json b/package.json index 1dc3a804..3b0c4628 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "dev:test": "npm run dev -- --test", "build": "tsup", "build:client": "node scripts/build-client.mjs", - "build:plugins": "for d in plugins/*/; do if [ -f \"$d/manifest.json\" ]; then name=$(basename $d); mkdir -p dist/plugins/$name && npx esbuild $d/src/index.ts --bundle --format=esm --outfile=dist/plugins/$name/index.js --platform=node --target=node20 && cp $d/manifest.json dist/plugins/$name/; fi; done", + "build:plugins": "node scripts/build-plugins.mjs", "test": "vitest run --coverage", "test:watch": "vitest", "test:fast": "vitest run && playwright test --grep-invert 'live integration|GitHub credentials|GITHUB_PLUGIN|hasGithubCreds|ATTACHMENT_REPO|PLUGINS_ENABLED'", @@ -45,16 +45,16 @@ "test:rust": "node scripts/ensure-sidecar-placeholder.mjs && cargo test --manifest-path src-tauri/Cargo.toml", "validate:mtls": "bash scripts/validate-mtls.sh", "lint": "eslint src/ plugins/ e2e/ eslint-rules/ eslint.config.mjs", - "analyze:freeze": "npm run build >/dev/null && node scripts/analyze-freeze-log.mjs", + "analyze:freeze": "npm run build && node scripts/analyze-freeze-log.mjs", "capture-demos": "tsx scripts/capture-demos.ts", - "clean": "rm -rf dist node_modules/.cache", + "clean": "node -e \"const fs=require('node:fs');for(const p of ['dist','node_modules/.cache'])fs.rmSync(p,{recursive:true,force:true})\"", "release": "bash scripts/release.sh", "release:beta": "bash scripts/release.sh --beta", "release:beta:auto": "bash scripts/release-beta-auto.sh", "prepublishOnly": "npm run build", "dev:server": "npm run build:client && npm run build:plugins && tsx --tsconfig tsconfig.json src/cli.ts --no-open --strict-port", "tauri": "tauri", - "tauri:clean": "rm -rf src-tauri/target", + "tauri:clean": "node -e \"require('node:fs').rmSync('src-tauri/target',{recursive:true,force:true})\"", "tauri:dev": "bash scripts/ensure-sidecar-stub.sh && tauri dev --no-watch", "tauri:dev:test": "bash scripts/ensure-sidecar-stub.sh && tauri dev --no-watch -- -- --test", "tauri:dev:watch": "bash scripts/ensure-sidecar-stub.sh && tauri dev", diff --git a/scripts/build-plugins.mjs b/scripts/build-plugins.mjs new file mode 100644 index 00000000..0af03064 --- /dev/null +++ b/scripts/build-plugins.mjs @@ -0,0 +1,38 @@ +// Cross-platform replacement for the old `build:plugins` npm script, which +// used a bash `for d in plugins/*/; do ... done` loop plus `mkdir -p` / `cp` — +// Unix-only shell syntax that fails under cmd.exe (npm's default script-shell +// on Windows), the same class of bug `build-client.mjs` (HS-8714) fixed for +// `build:client`. Bundles each plugin under `plugins//` that has a +// `manifest.json` into `dist/plugins//index.js` + a copied manifest. +import { cpSync, existsSync, mkdirSync, readdirSync } from 'node:fs'; +import { dirname, join } from 'node:path'; +import { fileURLToPath } from 'node:url'; + +import * as esbuild from 'esbuild'; + +const root = join(dirname(fileURLToPath(import.meta.url)), '..'); +const pluginsDir = join(root, 'plugins'); + +const names = existsSync(pluginsDir) + ? readdirSync(pluginsDir, { withFileTypes: true }).filter(e => e.isDirectory()).map(e => e.name) + : []; + +for (const name of names) { + const dir = join(pluginsDir, name); + const manifest = join(dir, 'manifest.json'); + if (!existsSync(manifest)) continue; + + const outDir = join(root, 'dist', 'plugins', name); + mkdirSync(outDir, { recursive: true }); + await esbuild.build({ + entryPoints: [join(dir, 'src', 'index.ts')], + bundle: true, + format: 'esm', + outfile: join(outDir, 'index.js'), + platform: 'node', + target: 'node20', + }); + cpSync(manifest, join(outDir, 'manifest.json')); +} + +console.log('build:plugins done'); From caf7fe03e995d401586aa25d68652f9f276daa8a Mon Sep 17 00:00:00 2001 From: brennermusgraveKPB <155494017+brennermusgraveKPB@users.noreply.github.com> Date: Wed, 16 Sep 2026 09:08:30 -0800 Subject: [PATCH 3/4] =?UTF-8?q?HS-3=20=E2=80=94=20fix=20npm=20run=20tauri:?= =?UTF-8?q?dev=20/=20cargo=20check=20on=20Windows:=20wrong=20sidecar=20stu?= =?UTF-8?q?b=20filename?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While verifying this machine could build/run the Tauri desktop shell (part of getting local Windows dependencies working end-to-end), `cargo check --manifest-path src-tauri/Cargo.toml` panicked: "resource path binaries\hotsheet-node-x86_64-pc-windows-msvc.exe doesn't exist". Same failure hits `npm run tauri:dev` / `tauri:dev:test` / `tauri:dev:watch` on any Windows checkout, since they all go through the same build.rs resource-existence check. Root cause: two separate scripts created the dev-mode sidecar placeholder. `scripts/ensure-sidecar-placeholder.mjs` (used by test:rust) correctly adds `.exe` on Windows. `scripts/ensure-sidecar-stub.sh` (used by tauri:dev*) built the stub path as `hotsheet-node-` unconditionally, with no extension — so on Windows it wrote a file Tauri's build script doesn't recognize, and the existence check still fails even after running it. Fix: point tauri:dev / tauri:dev:test / tauri:dev:watch at the already-correct ensure-sidecar-placeholder.mjs (it also covers the server/**/* resources glob check the bash script never handled) and delete the redundant, broken ensure-sidecar-stub.sh. Verified: cargo check now succeeds on this machine. Co-Authored-By: Claude Sonnet 5 --- docs/tauri-architecture.md | 6 +++--- package.json | 6 +++--- scripts/ensure-sidecar-placeholder.mjs | 27 ++++++++++++++++++-------- scripts/ensure-sidecar-stub.sh | 14 ------------- 4 files changed, 25 insertions(+), 28 deletions(-) delete mode 100755 scripts/ensure-sidecar-stub.sh diff --git a/docs/tauri-architecture.md b/docs/tauri-architecture.md index 28172a08..b22dc037 100644 --- a/docs/tauri-architecture.md +++ b/docs/tauri-architecture.md @@ -37,7 +37,7 @@ src-tauri/ ``` scripts/ ├── build-sidecar.sh # Downloads Node.js + bundles server for production -├── ensure-sidecar-stub.sh # Creates placeholder binary for dev mode +├── ensure-sidecar-placeholder.mjs # Creates placeholder binary + server/ resource for dev mode / cargo test ├── verify-bundle.mjs # Post-build check: produced bundle has a real sidecar + bootable server (HS-8868) └── release.sh # npm + Tauri version bumping + publish ``` @@ -148,11 +148,11 @@ This generates `allow-` / `deny-` permissions (kebab-case: `confirm_qu |---|---|---| | Node server | Runs via `npm run dev:server` (tsx, separate process) | Bundled sidecar (downloaded Node.js binary) | | Frontend | Loaded from `http://localhost:4174` (dev URL) | Loaded from `loading/index.html`, then navigated | -| Sidecar binary | Stub placeholder (from `ensure-sidecar-stub.sh`) | Real Node.js binary (from `build-sidecar.sh`) | +| Sidecar binary | Stub placeholder (from `ensure-sidecar-placeholder.mjs`) | Real Node.js binary (from `build-sidecar.sh`) | | Server code | Source TypeScript via tsx | Bundled `cli.js` in `server/` resource dir | | Release-only code | Skipped (`#[cfg(not(debug_assertions))]`) | Active (sidecar spawn, welcome screen, updater) | -In dev mode, Tauri's `beforeDevCommand` starts the Node server, and the webview connects to `devUrl`. The sidecar binary is never used — `ensure-sidecar-stub.sh` creates a no-op placeholder so Tauri's build system doesn't complain about a missing binary. +In dev mode, Tauri's `beforeDevCommand` starts the Node server, and the webview connects to `devUrl`. The sidecar binary is never used — `ensure-sidecar-placeholder.mjs` creates a no-op placeholder (and a `server/` resource-dir placeholder file, for the `server/**/*` resources glob check) so Tauri's build system doesn't complain about either missing on-disk requirement. Originally two separate scripts existed for this (a `cargo test`-only `.mjs` version and a `tauri:dev`-only bash version); the bash one (`ensure-sidecar-stub.sh`, now removed) never appended `.exe` on Windows, so it wrote a placeholder Tauri's build script didn't recognize and `cargo check` / `npm run tauri:dev` failed there with `resource path binaries\hotsheet-node-x86_64-pc-windows-msvc.exe doesn't exist` — the `.mjs` version already handled the extension correctly, so `tauri:dev`/`tauri:dev:test`/`tauri:dev:watch` now call it too. ## Build pipeline diff --git a/package.json b/package.json index 3b0c4628..9166de31 100644 --- a/package.json +++ b/package.json @@ -55,9 +55,9 @@ "dev:server": "npm run build:client && npm run build:plugins && tsx --tsconfig tsconfig.json src/cli.ts --no-open --strict-port", "tauri": "tauri", "tauri:clean": "node -e \"require('node:fs').rmSync('src-tauri/target',{recursive:true,force:true})\"", - "tauri:dev": "bash scripts/ensure-sidecar-stub.sh && tauri dev --no-watch", - "tauri:dev:test": "bash scripts/ensure-sidecar-stub.sh && tauri dev --no-watch -- -- --test", - "tauri:dev:watch": "bash scripts/ensure-sidecar-stub.sh && tauri dev", + "tauri:dev": "node scripts/ensure-sidecar-placeholder.mjs && tauri dev --no-watch", + "tauri:dev:test": "node scripts/ensure-sidecar-placeholder.mjs && tauri dev --no-watch -- -- --test", + "tauri:dev:watch": "node scripts/ensure-sidecar-placeholder.mjs && tauri dev", "tauri:build": "bash scripts/build-sidecar.sh && tauri build", "tauri:build:local": "read -rsp \"Password: \" MYPASS && echo && TAURI_SIGNING_PRIVATE_KEY_PASSWORD=$MYPASS TAURI_SIGNING_PRIVATE_KEY=$(cat ~/.tauri/hotsheet.key) npm run tauri:build" }, diff --git a/scripts/ensure-sidecar-placeholder.mjs b/scripts/ensure-sidecar-placeholder.mjs index f517407f..80858e6f 100644 --- a/scripts/ensure-sidecar-placeholder.mjs +++ b/scripts/ensure-sidecar-placeholder.mjs @@ -1,6 +1,8 @@ -// Ensure the Tauri build-time resource checks pass for `cargo test` (test:rust). +// Ensure the Tauri build-time resource checks pass without a real sidecar +// build. Used by `test:rust` (`cargo test`) AND by `tauri:dev` / `tauri:dev:test` +// / `tauri:dev:watch` (HS-3 — see below). // -// `cargo test` compiles the Tauri crate, whose build.rs calls +// Compiling the Tauri crate runs its build.rs, which calls // `tauri_build::try_build(...)`. Since the Tauri 2.11 bump (HS-8828) that build // step VALIDATES that the `externalBin` and `resources` declared in // tauri.conf.json actually exist on disk for the build target, and panics when @@ -11,9 +13,18 @@ // path not found or didn't match any files" // Both the Node sidecar binary and the `server/` bundle are large artifacts // produced by `scripts/build-sidecar.sh`, only needed for an actual `tauri -// build`; the Rust unit tests never use them. The CI `rust` job and the release -// workflows' fail-fast `test:rust` (which runs BEFORE build-sidecar.sh) have -// neither yet, so we drop minimal placeholders to satisfy the existence checks. +// build`; neither `cargo test` nor `tauri dev` (which runs the server via +// `beforeDevCommand`/tsx instead) ever uses them. So we drop minimal +// placeholders to satisfy the existence checks. +// +// HS-3 — `tauri:dev*` used to call a separate bash script +// (`ensure-sidecar-stub.sh`, now removed) that built the stub path as +// `hotsheet-node-` unconditionally, with no `.exe` on Windows. Tauri's +// check looks for the target's real executable name, so on Windows that stub +// was silently the wrong filename and `cargo check` / `npm run tauri:dev` +// failed with the "resource path ...exe doesn't exist" panic above. This +// script already handled the extension correctly (below), so the `tauri:dev*` +// scripts now call this one instead. // // Placeholders are created ONLY when the real artifact is absent, so a dev // machine / a post-build-sidecar checkout is never touched. They never reach a @@ -46,7 +57,7 @@ if (existsSync(sidecar)) { mkdirSync(binDir, { recursive: true }); writeFileSync(sidecar, ''); if (ext === '') chmodSync(sidecar, 0o755); - console.log(`sidecar placeholder: created empty ${sidecar} for cargo test`); + console.log(`sidecar placeholder: created empty ${sidecar}`); } // 2. resources — the `server/**/*` glob needs at least one matching file. @@ -56,6 +67,6 @@ if (hasServerFiles) { console.log(`server resources: ${serverDir} already populated — leaving it`); } else { mkdirSync(serverDir, { recursive: true }); - writeFileSync(join(serverDir, 'placeholder'), 'Placeholder so the tauri `server/**/*` resources glob matches during cargo test. Replaced by scripts/build-sidecar.sh for a real bundle.\n'); - console.log(`server resources: created placeholder in ${serverDir} for cargo test`); + writeFileSync(join(serverDir, 'placeholder'), 'Placeholder so the tauri `server/**/*` resources glob matches during cargo test / tauri dev. Replaced by scripts/build-sidecar.sh for a real bundle.\n'); + console.log(`server resources: created placeholder in ${serverDir}`); } diff --git a/scripts/ensure-sidecar-stub.sh b/scripts/ensure-sidecar-stub.sh deleted file mode 100755 index 96454c19..00000000 --- a/scripts/ensure-sidecar-stub.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# Creates a placeholder sidecar binary for Tauri dev mode. -# In dev mode, the Node server runs via beforeDevCommand (not the sidecar), -# but Tauri's build script still requires the externalBin path to exist. -set -e - -TARGET="$(rustc --print host-tuple 2>/dev/null || echo "aarch64-apple-darwin")" -STUB="src-tauri/binaries/hotsheet-node-${TARGET}" - -if [ ! -f "$STUB" ]; then - mkdir -p src-tauri/binaries - printf '#!/bin/sh\necho "This is a dev-mode stub. The real Node binary is downloaded by scripts/build-sidecar.sh"\nexit 1\n' > "$STUB" - chmod +x "$STUB" -fi From 8f08ec0d1f5aae46bfe1bc55e8dc70dd7c32a119 Mon Sep 17 00:00:00 2001 From: brennermusgraveKPB <155494017+brennermusgraveKPB@users.noreply.github.com> Date: Wed, 16 Sep 2026 09:09:53 -0800 Subject: [PATCH 4/4] =?UTF-8?q?HS-4=20=E2=80=94=20correct=20ticket-number?= =?UTF-8?q?=20references=20in=20the=20previous=20commit=20(was=20HS-3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The prior commit (sidecar stub filename fix) accidentally reused HS-3's number in its comments/message -- HS-3 was already the number for the separate npm-script-portability fix earlier in this session. Filed the proper ticket after the fact (HS-4) and correcting the two stray HS-3 references here to point at it. Co-Authored-By: Claude Sonnet 5 --- scripts/ensure-sidecar-placeholder.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ensure-sidecar-placeholder.mjs b/scripts/ensure-sidecar-placeholder.mjs index 80858e6f..f116dc22 100644 --- a/scripts/ensure-sidecar-placeholder.mjs +++ b/scripts/ensure-sidecar-placeholder.mjs @@ -1,6 +1,6 @@ // Ensure the Tauri build-time resource checks pass without a real sidecar // build. Used by `test:rust` (`cargo test`) AND by `tauri:dev` / `tauri:dev:test` -// / `tauri:dev:watch` (HS-3 — see below). +// / `tauri:dev:watch` (HS-4 — see below). // // Compiling the Tauri crate runs its build.rs, which calls // `tauri_build::try_build(...)`. Since the Tauri 2.11 bump (HS-8828) that build @@ -17,7 +17,7 @@ // `beforeDevCommand`/tsx instead) ever uses them. So we drop minimal // placeholders to satisfy the existence checks. // -// HS-3 — `tauri:dev*` used to call a separate bash script +// HS-4 — `tauri:dev*` used to call a separate bash script // (`ensure-sidecar-stub.sh`, now removed) that built the stub path as // `hotsheet-node-` unconditionally, with no `.exe` on Windows. Tauri's // check looks for the target's real executable name, so on Windows that stub