Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/10-desktop-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions docs/37-quit-confirm.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion docs/ai/code-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 3 additions & 1 deletion docs/ai/requirements-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

---

Expand Down
2 changes: 2 additions & 0 deletions docs/manual-test-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <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.
Expand Down
6 changes: 3 additions & 3 deletions docs/tauri-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down Expand Up @@ -148,11 +148,11 @@ This generates `allow-<cmd>` / `deny-<cmd>` 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

Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'",
Expand All @@ -45,19 +45,19 @@
"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: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:clean": "node -e \"require('node:fs').rmSync('src-tauri/target',{recursive:true,force:true})\"",
"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"
},
Expand Down
Loading