Commit Graph

81 Commits

Author SHA1 Message Date
BearHuddleston
dbc135f5d0 fix(bundles): let the payload launcher run a named module
A bundle's bin/hermes could only start hermes_cli.main. The store launcher
that source installs publish (.hermes/bin/hermes) also takes
`--run-module <module>`, and services persist that form for the launchd
stderr wrapper (installation_command), so a service could not run through
a bundle's own launcher.

posix_launcher now handles `--run-module` the same way, with the same
interpreter, PYTHONPATH, site dir and outside-the-app bytecode cache as its
main entry. The module name is spliced into the -c source, so anything but a
dotted Python name exits 2 before Python runs. Keeping the name in the
source keeps the stderr wrapper's argv in the shape gateway/status already
matches for runtime_command's bootstrap.

The next commit makes a macOS app's gateway service use this.
2026-11-12 23:36:59 -06:00
BearHuddleston
f3ad28864a fix(bundles): ship the prebuilt Webapp in every desktop bundle
Desktop bundles (MSIX, Store, DMG/ZIP) plant prebuilt TUI and dashboard
products into the agent payload, but not the Webapp renderer, and the
payload drops apps/ and scripts/, so nothing in the app can build one.

desktop.py now compiles the Webapp with scripts/build/webapp.mjs from the
checkout whose apps/desktop dependencies the bundle job already installed,
and hands it to finish_native beside tui and web. The assembler plants it
at hermes-agent/apps/desktop/dist-webapp, where the gateway serves it.

- webapp.mjs gets the --source/--out CLI its sibling builders have.
  Compiling in place tripped its own overlap guard: the workspace's path
  relative to the source is '', which protected the whole checkout.
- The prepared payload's source digest ignores dist-webapp, as it does
  tui_dist and web_dist. Windows assembles the bundled and then the Store
  variant from one preparation; without this the Store pass fails with
  "prepared bytes changed: hermes-agent".

The renderer adds about 45 MB in 1,083 files to the payload, about 18 MB
deflated. It built in 23 s on linux-arm64.
2026-11-12 14:16:57 -06:00
Maciej Lisiewski
6750c484c3 refactor(build): move the node-deps lock and its programs into modules
The checkout lock, the child supervision and the heartbeat, watcher and
relay programs embedded as strings move out of node-deps.mjs:
node-deps-lock.mjs owns who may touch the trees, and the three programs are
real .mjs files (node-deps-heartbeat/-watcher/-relay.mjs) that lint and
navigation can see. node-deps.mjs keeps recovery, install and commit.
No behaviour change; the watcher's empty catches now say why.

The new files ship wherever node-deps.mjs did: the Dockerfile's
dependency layer, nix/webapp.nix, the webapp freshness inputs, the desktop
input-cache key, and the source-build test fixture.
2026-11-09 19:13:41 +01:00
Maciej Lisiewski
dc2c16efdb fix(build): read node-deps inputs once the checkout lock is held
The lockfile, projects and receipt key were read before lockCheckout,
which can wait 10 minutes. A run that waited out an update compared the
new trees with the old files: it reused a stale receipt or rejected a good
install. They are now read and validated after the lock is taken.
2026-11-09 19:13:41 +01:00
Maciej Lisiewski
16236f2166 fix(build): start the node-deps lock watcher before the installer
The relay started pnpm first and the watcher after it, with no error
handler: a watcher spawn failure (a process or descriptor limit) exited the
relay while pnpm went on writing the trees the failed run then restored.
The relay now starts pnpm only once the watcher has spawned, and hands it
the pid on stdin; a watcher that cannot start fails the run before
anything touches the trees.
2026-11-09 19:13:41 +01:00
Maciej Lisiewski
9bd3241914 fix(build): restore the trees and release the lock on Ctrl-C during install
node-deps had no SIGINT/SIGHUP listener, so a Ctrl-C or closed terminal
during pnpm killed it before the restore and the release: the next run
waited out the 30 s stale limit on a dead owner. The run now outlives the
job signals while its child runs (the child gets them too and exits), and
the CLI exits with the child's 128 + n so Ctrl-C still reports 130.
SIGTERM is left out: one aimed at node-deps alone still kills it and the
relay passes it on.
2026-11-09 19:13:41 +01:00
Maciej Lisiewski
70947e2f74 fix(build): end the node-deps lock wait when a dead lock cannot be replaced
A takeover rename that kept failing (EPERM/EBUSY/EACCES) skipped both the
deadline check and the sleep, so the wait spun past its limit. A failed
rename now waits like a live owner.
2026-11-09 19:13:41 +01:00
Maciej Lisiewski
aafb19ff96 docs(build): name the node-deps lock gaps a whole-tree SIGKILL and Windows leave 2026-11-09 19:13:40 +01:00
Maciej Lisiewski
91ad3787bf fix(build): count only retry settings pnpm 12 reads on a source launch
pnpm 12 reads neither npm_config_fetch_retries nor fetch-retries from an npmrc,
so treating them as the user's choice left pnpm's default of 2 retries (~70 s
offline) instead of the user's count or the launch's 1.
2026-11-09 19:13:40 +01:00
Maciej Lisiewski
2a42a58110 fix(build): keep node-deps failures from being masked by the lock
A run that lost its lock during the reuse check failed with a raw ENOENT from
the tree the new owner had moved; it now reports the lost lock. A release that
throws (a leaked guard past the wait bound) no longer replaces the error that
failed the run.
2026-11-09 19:13:40 +01:00
Maciej Lisiewski
d2a041890d fix(build): kill a stopped node-deps run's pnpm once it loses the lock
Ctrl-Z stops the whole job, pnpm included. A run stopped past the stale limit
lost its lock, but no check could run while it blocked in execFileSync, so on
`fg` its pnpm finished writing into the trees the next owner had installed and
certified.

pnpm and Electron's installer now run under a watcher outside the job (its own
session; taskkill /T on Windows) that re-reads the lock every 250 ms and kills
the child's process tree, stopped first so nothing forks meanwhile, once the
lock is no longer its run's. pnpm stays in the job, so Ctrl-C and Ctrl-Z reach
it as before, and a SIGTERM aimed at node-deps alone is now passed on to it.
A run that breaks a lock replaces it in one rename and waits 2 s before it
touches the trees, so the old owner's watcher acts first.
2026-11-09 19:13:40 +01:00
Maciej Lisiewski
3de0089f86 fix(build): keep the user's download retries on a source launch
A launch forced pnpm_config_fetch_retries=1 whenever the env did not set it,
overriding a count in pnpm's config.yaml or pnpm-workspace.yaml, or the user
npmrc's fetch-retries. Lower it only when none of them sets one.
2026-11-09 19:13:40 +01:00
Maciej Lisiewski
57c5f92abd fix(build): bound the node-deps lock guard wait
A leaked guard dated in the future (a network filesystem's clock ahead, or a
clock stepped back) never aged out by its mtime, so underGuard spun forever.
It is now judged like the lock, by staying unchanged on this process's
monotonic clock, and the wait stops at the lock's wait limit.
2026-11-09 19:13:39 +01:00
Maciej Lisiewski
482f48329b fix(build): keep the node-deps heartbeat through transient errors
One EBUSY/ESTALE/EMFILE from utimes stopped the heartbeat for good, so a
waiter broke the lock of an install that was still running and both pnpm
installs ran in one checkout. The heartbeat now stops only on release, when
the lock is gone, or when it holds another run's token.
2026-11-09 19:13:39 +01:00
Maciej Lisiewski
c1a408dba8 fix(build): a node-deps run that lost its lock touches nothing
The heartbeat worker's flag lagged a resumed process by up to a beat, and
restore, discard and the Electron step never consulted it. An owner stopped
past the stale limit could restore its old trees over the new owner's fresh
ones, or write a receipt for a tree another run built. Every recover, move,
restore, discard, receipt write and pnpm start now re-reads the lock file and
compares the token; a run that lost it exits without touching the trees or
the set aside.
2026-11-09 19:13:39 +01:00
Maciej Lisiewski
73ac5478fb fix(build): give up on an unreachable registry sooner when launching
A source launch (`hermes --tui`, the dashboard) that has to install waited ~70 s on
pnpm's default retries before failing offline and falling back to the previous build,
holding the checkout lock the whole time. Launches now retry a download once (~10 s).
Updates and explicit builds keep the defaults. The retry settings are left out of the
reuse receipt, which covers what is installed, not how it was downloaded.
2026-11-09 19:13:39 +01:00
Maciej Lisiewski
74e8848fd9 fix(build): judge the node-deps lock by a heartbeat, and bound the wait
The pid/host/start-time owner check kept a dead run's lock forever when its pid was
reused by another user's process (EPERM), on Windows and macOS (no start time), after a
hostname change, and it took over a live lock from a sibling PID namespace. The wait had
no limit, so `hermes update` and `hermes --tui` could hang with the remedy cut off a
narrow progress line.

The owner now refreshes the lock's mtime from a worker thread; a lock a waiter sees
unchanged for 30 s of its own monotonic clock is broken, whatever it names. Removals run
under a short guard and re-check the content, which also closes the three-way takeover
race. The wait gives up after 10 minutes, with the remedy at the start of the line. A
run suspended past the stale limit certifies nothing.

The moved-set record is written to a temporary file and renamed, so a kill or ENOSPC
mid-write cannot leave a record that breaks every later run, and a previous set that
cannot be deleted after a successful install no longer fails the run: the next run's
recovery removes it.
2026-11-09 19:13:39 +01:00
Maciej Lisiewski
992ecc841f fix(build): delete a node_modules in place when it cannot be moved aside
A node_modules that is a mount point (a container volume) cannot be
renamed (EBUSY), nor moved to a .cache on another filesystem (EXDEV).
moveAside then restored and threw, so no install ran. Such a tree is
emptied in place, as before the move-aside, and only it cannot be
restored. On Windows EBUSY means an open file, and it stays a failure.
2026-11-09 19:13:39 +01:00
Maciej Lisiewski
ba63979246 fix(build): serialise node-deps runs and make the move-aside crash-safe
Every run, --no-install and reuse checks included, restored a set left
in .cache/node-deps-previous without a lock. A launch beside an
install put the old trees back under it, and that install then wrote a
receipt for the new inputs over the old tree. A kill while the set was
being deleted left a partial copy, which the next run restored over
the fresh trees.

node-deps now takes .cache/node-deps.lock (owner pid, host and Linux
start time; a dead owner's lock is taken over) around recovery, the
reuse check, the install and the receipt. The set records its trees
before the first move and is marked complete after the last. A run
after a kill keeps a finished pnpm install (one that wrote
.pnpm-workspace-state-v1.json after the move) instead of restoring
over it, and finishes an interrupted move or restore. The set is
renamed away before it is deleted, and the receipt is written first.
The receipt also requires pnpm's installed lock to hold this
lockfile's importers.
2026-11-09 19:13:38 +01:00
Maciej Lisiewski
14accd54f1 fix(build): keep the previous node_modules until the pnpm install succeeds
node-deps.mjs deleted every installed tree before pnpm fetched anything.
The first pnpm install runs on an empty store, so an unreachable registry
left no node_modules and every later `hermes --tui` failed.

Move the trees under .cache/node-deps-previous instead, put them back if
pnpm or the Electron step fails, and drop them once the install succeeds.
A run killed mid-install gets them back on the next run. Installs still
start from empty trees, because pnpm won't restore gutted packages.

`pnpm fetch` cannot fill the store first in pnpm 12: it takes no filter,
and it rewrites node_modules/.pnpm itself, even when it fails.

Fixes #150031
2026-11-09 19:13:38 +01:00
Maciej Lisiewski
2d70da667f docs(desktop): reword the get-windows degrade comment for a regular dependency 2026-11-07 01:43:58 +01:00
Maciej Lisiewski
3d9dfffb9c docs(desktop): describe get-windows as the build now installs it
The win32 binding comes from the node-pre-gyp run in stage-native-deps, not
a dependency install script, and a skipped optional install is no longer how
get-windows goes missing. The compiler README now says an absent staged copy
is a degraded build.
2026-11-07 01:43:58 +01:00
Ronald Reis
f59eab9f3c fix(desktop): build without get-windows when pnpm skips it
pnpm >= 11.6 infers `os: [win32]` for optional dependencies whose name
contains "windows" (pnpm/pnpm#17774), so the filtered install that
node-deps.mjs runs drops get-windows on macOS. stage-native-deps already
treats that as a degraded tree and ships without read_window_below, but
validateNativeTree in scripts/build/desktop.mjs still required
get-windows/main on darwin, so every macOS `hermes update` failed with
"Prepared get-windows is missing its macOS helper" and re-owed the
desktop build.

Only refuse a staged get-windows that lacks its macOS helper; an absent
package is the documented degraded build.

Refs #149861

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit a9f644c1c3c85b7e8e6808de2cd643fb27e8637f)
2026-11-07 01:43:36 +01:00
Maciej Lisiewski
c338036bf6 fix(pm): name a missing pnpm pin; keep npm's cache query out of the checkout
node-deps.mjs failed with a raw ENOENT/TypeError when pm/lock.json was
missing or pinned no pnpm; it now names the file and the field.
setup_toolchain.py keeps running `npm config get cache` outside the
checkout: a project package.json or .npmrc in cwd can change or fail it,
not only warn. The alignment test whose pnpm assertion went with
devEngines duplicated PM's lock validation and is gone with its type.
2026-11-07 00:45:52 +01:00
Maciej Lisiewski
7eee902ae0 refactor(pm): keep the pnpm pin only in pm/lock.json
The pnpm version lived in pm/lock.json and in root devEngines, kept equal
by a sync writer on every pnpm re-pin. node-deps.mjs, the only reader of
devEngines, now reads pm/lock.json. That drops root devEngines, the sync
writer and its test, and setup_toolchain's workaround for the
EBADDEVENGINES warning npm printed on every command in the checkout.
2026-11-07 00:45:52 +01:00
Maciej Lisiewski
29e78b124e docs: pnpm commands for the JS workspaces
READMEs, contributor guides, AGENTS.md files, skills and the website (with
the zh-Hans translations) give pnpm commands for the workspaces; the
website itself is still an npm project.
2026-11-06 04:08:45 +01:00
Maciej Lisiewski
7062229090 chore(js): switch the workspaces from npm to pnpm
pnpm 12.15.0 (native executable) installs every JS workspace from one
pnpm-lock.yaml, imported from package-lock.json with the same resolved
versions. website/, the WhatsApp bridge and the photon sidecar stay separate
npm projects.

Configuration moves from .npmrc and the root manifest into
pnpm-workspace.yaml: the 14-day minimumReleaseAge and its excludes,
overrides, allowBuilds (the old allowScripts set, with strictDepBuilds
failing any unlisted build script), engineStrict, sideEffectsCache: false
(in-place rebuilds must not write into the store) and
verifyDepsBeforeRun: false (a `pnpm run` never installs).

The pnpm version is pinned in pm/lock.json and in root devEngines.
pmOnFail: ignore keeps that pin out of pnpm-lock.yaml: a leading pin
document makes osv-scanner read zero packages. scripts/build/node-deps.mjs
enforces the exact version instead, and every lock reader refuses a
multi-document lock. A root preinstall refuses `npm install`; devEngines
onFail is warn so npx (MCP servers, the tsc linter) keeps working inside
the checkout.

User-machine installs run --frozen-lockfile --trust-lockfile (release age is
checked when locking, in CI, not per user). node-deps removes npm-era
node_modules trees before the first pnpm install. Nix builds the store with
fetchPnpmDeps and a hash file that CI checks.
2026-11-06 04:08:24 +01:00
Teknium
7a954418ce fix(update): reuse the packaged desktop app when no desktop build input changed
hermes update rebuilt and repackaged the Electron app (6-38 min on Windows)
on every commit move, because _packaged_desktop_current_for_head requires the
app's baked commit to be HEAD before the freshness receipt is consulted.

The receipt already content-hashes every desktop build input (sources,
lockfile, build scripts, prepared icons/native trees, renderer env, Node,
platform, arch) and the output. The baked install stamp is the one input it
cannot see. desktop_build_reuse asks whether a build at HEAD would bake a
stamp that differs in anything but commit provenance (commit, commitDate,
dirty, builtAt), using write-build-stamp.mjs's own resolver, and reuses the
packaged app when the receipt is current and it would not.

The reused app keeps naming the commit it was built from: the stamp is never
rewritten (bundle-swap would relaunch into a "swap" forever), and bundle-skew
counts desktop runtime-path commits since it, which identical inputs rule out.
2026-10-27 07:53:07 -07:00
unsupportedpastels
3f2b1722b1 feat(nix): ship the Webapp in the Nix package
The Nix package had no Webapp bundle, and `hermes webapp` could not build
one in the read-only store. nix/webapp.nix builds it in the npm workspace
the hook prepares (no native rebuild, no Electron), exposed as
`.#webapp`. The agent assembler takes it as a `webapp` frontend: the
wrapper sets HERMES_WEBAPP_DIST to it, as HERMES_WEB_DIST is set for the
dashboard.

hermes_cli/webapp.py serves a HERMES_WEBAPP_DIST bundle as shipped: no
freshness check, no build lock, never rebuilt or marked stale, and
`--force-build` says it cannot rebuild it.
2026-10-27 09:42:22 -04:00
unsupportedpastels
3883e02935 perf(webapp): build the browser bundle without downloading Electron
The Webapp recipe installs Desktop's workspace, and node-deps prepared
Electron's binary for any install that selects apps/desktop. The browser
bundle never runs Electron, so prepareNodeDependencies now takes
`electron: false` and build-webapp.mjs passes it. Desktop builds keep the
default.
2026-10-27 09:42:22 -04:00
unsupportedpastels
0beda3a109 refactor(build): name the stale-bundle marker outputIntact ignores 2026-10-26 21:30:03 -04:00
unsupportedpastels
148f36ea6c fix(webapp): warn when a previous chunk cannot be kept across a rebuild
keepPreviousGeneration skipped a copy that failed for an unexpected reason (a full disk, a permission error) without a word: the build recorded its receipt and published, and tabs still on the previous generation lost that chunk with nothing in the build log saying why.

The build still never fails here, but a failed copy, an unexpected directory error, or a failed cleanup of the partial copy now warns with the path and error code. The expected cases stay quiet: no previous build, a rejected manifest entry, a new file standing where the name or its directory would go (including EEXIST from COPYFILE_EXCL).
2026-10-26 21:30:03 -04:00
dokterdok
f22598136d fix(webapp): keep the previous bundle's lazy chunks across a rebuild
A Webapp tab that was already open crashed the next time it opened a
lazy view such as Settings once `npm run build:webapp`, `hermes webapp`
or `hermes update` had published a new renderer. Publication replaces
apps/desktop/dist-webapp, which the gateway reads per request, so the
old entry's hashed lazy chunks 404 and the rejected import reaches the
app's error boundary until the page is reloaded.

Before the receipt is written, the builder now copies into the new
generation the files the previous generation's Vite manifest names that
the new one lacks: only that generation's own files, so a rebuild keeps
exactly one generation back; only while its bytes still match its
receipt (freshness.mjs gains outputIntact, which ignores the marker a
failed `hermes update` leaves in the bundle: that still forces the
rebuild, but no longer costs open tabs their chunks); only regular
files inside it, never through a symlink and never over a new file. A
bad entry is skipped and never fails the build. The builder names the
manifest itself, so it exists whatever the Vite config says.

Refs #141864, #93508

(cherry picked from commit 096996d1a591917b21c96e104d20e9dc54c5d850)
2026-10-26 21:30:03 -04:00
Bear Huddleston
b5eb5ee7a8 feat(webapp): carry the browser-hosted Desktop's server pieces from #93508
Carried from BearHuddleston's #93508 onto main. The Webapp relay and the
profile-incarnation fence stay out: carried code follows main's
named-profile rule and refuses a missing or deleted profile home.

- Webapp routes: one-use launch tickets, window handoff, and gateway
  WebSocket tickets minted for the signed-in browser
- Browser surface policy and the SPA document policy
- A host terminal for the browser that survives reconnects
- Staged browser uploads and file tickets; file.attach takes a staged upload
- hermes sessions adopt
- Webapp bundle build helpers and the renderer freshness check
- Regenerated gateway contracts

Co-authored-by: emozilla <emozilla@nousresearch.com>
2026-10-25 03:22:14 -07:00
ethernet
8c3734f1d7 fix(desktop): fresh Windows hosts can unpack Electron 40.10.3+ without the VC++ redist
From 40.10.3 on, every Electron line unpacks its binary with
@electron-internal/extract-zip, an MSVC-built binding that imports
VCRUNTIME140.dll. A Windows host that never installed the VC++
Redistributable has no copy, so install.js dies with ERR_DLOPEN_FAILED.
This is the failure that made bb8280b753 roll Electron back to 40.10.2.

Our Python ships vcruntime140.dll. source_build_env() passes its path to
the Node builders as HERMES_VC_RUNTIME, and electron-runtime.mjs copies it
beside the extractor's binding right before it runs install.js. Node
loads bindings with LOAD_WITH_ALTERED_SEARCH_PATH (libuv uv_dlopen), so
Windows finds that copy first. This is the same app-local copy
fdea3e92e0 ships beside ARM64 rg.exe.

Clean Windows Sandbox (ARM64, no redist), Node 26.7.0, electron 44.9.3:
- before: install.js exits 1, "Cannot find native binding", ERR_DLOPEN_FAILED
- after: install.js exits 0, dist/electron.exe --version prints v44.9.3
2026-10-22 16:17:57 -04:00
ahrazzle
a9376424e5 fix(desktop): prepare the locked Electron runtime explicitly before use
Electron 42 dropped the postinstall that unpacked its binary into
node_modules/electron/dist. The binary now appears on the first
require('electron'), so parallel vitest workers race to unpack it
("Text file busy" in #128267's CI), and `hermes desktop --source` finds
no path.txt to launch.

electron-runtime.mjs runs Electron's own install.js once: after npm ci
for the desktop workspace, and in CI before the parallel checks. It first
checks the installed package against the desktop pin and the lockfile,
and does nothing when the runtime is already in place. On the current
40.10.2 pin, whose postinstall still unpacks the binary, it is a no-op.

Salvaged from #137648 (the runtime-preparation subset only).
2026-10-22 16:17:57 -04:00
ethernet
13cb8cca17 ci: pull requests restore the uv and npm caches without saving their own
save-python-cache and save-node-cache now default to false on
pull_request events, like save-tools-cache. Their restore-only steps
read the exact keys the saving steps write on main, so a PR gets main's
uv and npm caches and leaves nothing PR-scoped behind.

Restore-only used to mean an explicit-save flow: run- and job-scoped
keys meant for save-pm-cache or a caller's actions/cache/save to write
later. Nothing calls save-pm-cache, and the last caller restoring from
the npm explicit-save key moved to its own cache, so the flow and its
outputs are deleted.
2026-10-20 15:50:30 -04:00
Teknium
91e27b6c09 fix(desktop-build): npm run builder -- --win --x64 can stage its per-target native deps
`npm run builder` with an arch flag stages native deps into
apps/desktop/build/native-deps-<platform>-<arch>
(scripts/run-electron-builder.mjs). The product guard in
scripts/build/frontend-common.mjs accepted only apps/desktop/build/native-deps
as a generated destination in the tree, so every source build with an
explicit arch died before staging:

  Error: Output must be outside source or in a supported generated
  destination: ...\apps\desktop\build\native-deps-win32-x64

Seen on blacksmith-32vcpu-windows-2025 packaging the Desktop for the W3
attach lane (run 39053936919, `npm run builder -- --dir --publish never
--win --x64`). The guard now also accepts exactly
native-deps-(darwin|linux|win32)-(x64|arm64) under apps/desktop/build.
A nested path below one, or another platform/arch, is still refused.

Red -> green: run-electron-builder.test.mjs "source multiarch ..." now
asserts each per-target --out it hands stage-native-deps.mjs passes
productOutput (red on main: "Output must be outside source ..." for
native-deps-darwin-x64). product-builders.test.mjs gains the accepted and
refused per-target names (10 passed).

Refs #134889 (W3)
Refs #140337
2026-10-17 11:33:15 -07:00
Mikhail Tarasov
c1f19acb7f fix(tui): ship runtime Python helpers with the built product
(cherry picked from commit 699555cebc116c50d8fab0d7d0e0dc604840bca6)
2026-10-16 01:54:58 -07:00
kshitijk4poor
bc0758c393 fix(desktop): a renderer built under other VITE_*/NODE_ENV settings is never reused
Vite inlines every VITE_* variable into the renderer and NODE_ENV selects its mode, but the
desktop receipt recorded only sources and prepared inputs. After `VITE_PERF_PROBE=1 npm run
build`, the next plain build reused (and productCurrent certified) the renderer that still
carries the perf probe; a NODE_ENV change had the same gap.

The desktop build inputs now record the renderer environment (VITE_* plus NODE_ENV, unset
read as vite's production default), so both rendererCurrent and productCurrent require it to
match. Reported by Greptile on #135092.
2026-10-08 15:20:58 -07:00
kshitijk4poor
3fc37481eb refactor(desktop): one receipt reader, one output list, no native double copy on renderer reuse
rendererCurrent and productCurrent share hostReceipt() for the schema/product/host checks. The stamped outputs come from bundleElectronMain's own electronOutputs list, so a renamed or added bundle can never be copied stale from the previous dist. The reuse copy skips node_modules/ and native/, which copyNativeTree recopies from nativeDeps right after, and a --typecheck build never reuses a renderer that skipped tsc.
2026-10-08 15:20:58 -07:00
kshitijk4poor
1a4d7768c5 perf(desktop): reuse the compiled renderer when only the install stamp changed 2026-10-08 15:20:58 -07:00
Austin Pickett
af9c7137c8 fix(web): bound the dashboard build's CPU and heap (#63338)
The dashboard build (Vite 8 + Rolldown + Tailwind v4) saturates every CPU
on small hosts (200%+ top readings, OOMs and frozen SSH sessions on 2–4
vCPU VPS boxes). Rolldown exposes no JS-level worker knob, but its native
binding parallelizes with rayon, which honours RAYON_NUM_THREADS.

Cap both sides of the build, everywhere it runs:

- scripts/build/web.mjs (the npm run build / packaging entry): limit the
  native bundler's rayon pool to half the available cores before vite is
  imported, and re-exec once with a --max-old-space-size cap (sized from
  the cgroup memory limit, 75%, floored at 1 GB, ceiling 4 GB) unless
  the user already set one.
- hermes_cli/web_build_limits.py + build_source_web(): the same caps for
  the install/update/dashboard-triggered source build path.

User env always wins (existing NODE_OPTIONS heap flag or
RAYON_NUM_THREADS is preserved); HERMES_WEB_BUILD_MAX_OLD_SPACE_SIZE /
HERMES_WEB_BUILD_THREADS tailor the caps, and HERMES_WEB_BUILD_LIGHT=1
tightens them (1 thread, 1 GB heap) for hosts that cannot spare full CPU
during the build — the light-build idea from the closed PR #78131.
2026-10-07 17:13:11 -04:00
liuhao1024
1d6b2786e2 fix(build): refuse a completed-install receipt whose packages lost their manifests
The reuse receipt check in node-deps.mjs accepted a tree where every locked
directory existed but package contents had been stripped (partial cleanup or
snapshot restore). npm trusts the hidden lockfile and never repairs such
entries, so every 'hermes update' skipped npm ci, the TUI build died on the
missing esbuild manifest, and the stale receipt kept the loop closed (#128935).
Probe each locked entry's package.json — the same file product builders
resolve tools through — so a gutted tree falls back to a real npm ci.
2026-10-05 22:09:20 -07:00
Brooklyn Nicholson
f0b9649032 fix(build): wait out Windows scanner holds when publishing products
publishDirectory moved a finished product into place with one renameSync.
On Windows an antivirus scanner opens every freshly written file, so the
rename onto build/native-deps (right after hud-modifier-monitor.exe is
compiled) or hermes_cli/web_dist failed EPERM and threw away a build that
took minutes.

retryHeld retries EPERM/EACCES/EBUSY for about 3s and raises every other
code at once. All three publication renames use it, as does the HUD
helper's staging rename. The previous product's backup now sits beside
the output instead of inside withProduct's scratch tree, so a rollback
that also fails no longer has its only copy deleted by scratch cleanup;
the error names where it is.

Co-authored-by: dskwe <6286305+dskwe@users.noreply.github.com>
Co-authored-by: juliorobertoalvarez <39749815+juliorobertoalvarez@users.noreply.github.com>
Co-authored-by: bighamx <10262931+bighamx@users.noreply.github.com>
Co-authored-by: lzmuhioin <1814826+lzmuhioin@users.noreply.github.com>
2026-10-05 17:08:32 -05:00
Brooklyn Nicholson
5690810779 fix(build): await the scratch-dir removal; drop an unused test import 2026-10-01 00:15:05 -05:00
Brooklyn Nicholson
dde4bc7bb7 fix(update): serialize source-completion tails on the shared update lock; skip Windows file-manager metadata in freshness hashing (#123376, #122803)
WIP for the freshness-guard-os-metadata unit: the UpdateLock claim in
complete_source_checkout plus its tests are complete but unrun; the
Thumbs.db/Desktop.ini skip predicate is in but its test rows are not yet
extended, and the rmTree ENOTEMPTY test has not been written yet.
2026-10-01 00:15:05 -05:00
PRATHAMESH75
64eca050ec fix(build): skip macOS Finder metadata in build freshness hashing (#122632)
Opening the checkout in Finder mid-build lets .DS_Store, AppleDouble ._*
sidecars or .localized land inside a hashed input dir (apps/desktop, apps/shared,
assets, scripts/build). treeHash then sees a new input and recordProduct throws
"Build inputs changed during compilation; retry the build", so `hermes update`
rebuilds the desktop app, fails closed, and never prints Update complete.

Finder metadata is never a build input, so skip it as a baseline in treeHash —
covering source, output and prepared trees uniformly rather than only the source
predicate. A real source change is still detected and still names nothing new to
hash, so clean checkouts (CI) hash byte-identically.
2026-10-01 00:15:05 -05:00
Brooklyn Nicholson
4091ef8967 fix(build): absorb Finder's ENOTEMPTY scratch-dir removal race (#122803)
macOS's Finder/Spotlight can drop a fresh .DS_Store (or xattr) into a
directory while we're removing it, making rmSync throw ENOTEMPTY on the
first pass. That file is cosmetic garbage — retry the removal so the
race can't abort an otherwise-clean product build.

Salvaged from #123078 (its freshness.mjs hunk is subsumed by the broader
metadata skip; the unrelated CI-workflow deletions in that PR are not
included).

Co-Authored-By: dlshumway <85191357+dlshumway@users.noreply.github.com>
2026-10-01 00:15:05 -05:00
Halldrix
eec5d2af64 fix(build): record the baked stamp clock, not the live one (#123308)
write-build-stamp.mjs rewrites the stamp's `builtAt` clock on every build, so the
whole-file hash moved under a receipt that had just recorded it. Two builds
overlapping on one tree failed with "Build inputs changed during compilation" for
a difference the build machinery itself made, and the caller turned that into
SystemExit(1).

Hash the stamp's provenance identity instead, key-sorted so a cosmetic
re-serialisation is not a change. The clock is excluded from that comparison but
recorded as `stampClock` — the value the bake actually embedded, captured from
the same read that produces __HERMES_INSTALL_STAMP__ — because packaging copies
the live stamp into the bundle after the receipt is written. Re-reading the stamp
at record time would certify a clock the output never contained, and
productCurrent would then report a bundle current whose packaged clock disagrees
with its baked main, which is exactly what detectBundleSwap must never do.

recordProduct still compares the prepared inputs, so a clock-only restamp cannot
throw. productCurrent additionally requires the recorded clock to match, so a
restamp between bake and packaging is a rebuild rather than a silent divergence.
A receipt predating the field compares by hash alone until the next build
rewrites it; the release packaging path never consults productCurrent.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-10-01 00:15:05 -05:00