Reported in review by ghgoodreau: KaTeX defaults to inline mode, which
rejects display-only TeX. `A["$$x^2\tag{1}$$"]` threw "\tag works only in
display equations", so the resolver returned null and Pele drew the
literal source. mermaid.js passes `displayMode: true`, so this does too.
Display mode also restores mermaid's display sizing: \frac and \sum render
with stacked, full-size limits. The in-page measurement still matches what
the SVG draws: `x^2\tag{1}` measures 86x26 and draws 86x26, `\frac{a+b}{c+d}`
35x30 and 35x30.
The browser-hosted app applies its UI scale as CSS zoom on <html>
(browser-zoom.ts), so getBoundingClientRect on the math probe returns
zoomed pixels while the isolated SVG draws at the unzoomed font size. At
50% an `x^2` label reserved 8 px and drew 16 px, clipping it; at 175% it
reserved 28 px for the same 16. Dividing by the probe's currentCSSZoom
restores the match: within 1 px from 50% to 175%. Electron's zoom factor
scales the whole page, rect included, so it was never affected.
Review follow-ups on the Pele swap:
- The theme atom holds the typed DiagramTheme instead of a JSON string.
The render cache is generic over the theme, so the parse-and-cast
round-trip goes away, along with the '' sentinel that JSON.parse would
have thrown on. The cache still keys on JSON.stringify([theme, code]).
- Each distinct `--dt-*` token is probed once: 7 reads per repaint instead
of 9, since three palette slots share `--dt-muted-foreground`.
- The accessible name reads only the root's own <title>/<desc>. Pele also
writes nested <title>s (journey actors, click tooltips), so a journey
diagram used to be named after its first actor.
- KaTeX runs with strict: 'ignore', as katex-memo does, so non-LaTeX input
doesn't log a warning per label.
- Drops leftovers of the mermaid dependency: the expired mermaid
min-release-age exclusion, and uuid and stylis from the vendor-util chunk
group (neither is in the lockfile any more).
Reported in review by ghgoodreau: mermaid.js typeset `A["$$x^2$$"]` labels,
but Pele 1.6.0 drew them as literal `$$x^2$$`. The render still succeeded,
so the source fallback never ran.
Pele 1.8.0 added a `math` resolver, so this moves to 1.13.0 and connects
KaTeX to it. The app already loads KaTeX for chat markdown, so this adds no
download. The resolver returns MathML, which needs no stylesheet or
webfonts, so it draws inside the isolated <img> SVG and in the PNG copy;
mermaid's output was MathML too. TeX that KaTeX can't parse returns null,
and Pele shows the source.
Pele sizes each label from a measurement taken in the page. The app
stylesheet would skew it: it enlarges KaTeX's `.katex` wrapper by 1.21em,
and its reset changes bare-element layout. So the wrapper is dropped and
the measurement is taken in a shadow root. The reserved size then matches
what the stylesheet-free SVG draws: x^2 measures 16 px wide and draws
16 px, where it measured 19 px before.
1.13.0 is two days old, so .npmrc gets a min-release-age-exclude entry with
a removal date, in the same form as the existing ones.
The hand-rolled listener set around onThemeRepaint duplicated what a
nanostore already gives (apps/desktop/AGENTS.md: shared renderer state
lives in small stores). The resolved theme is now an atom whose onMount
owns the repaint subscription, read through useStore, the same shape as
$routesVersion. It is still resolved once per repaint for all diagrams, and
cleared on unmount so a later mount re-resolves.
Desktop drew ```mermaid fences with mermaid.js 11.17.2: a 2.97 MB (768 KB
gzip) lazy chunk, 1.3 s of main-thread work to draw 15 diagrams even with
the runtime already loaded, and a full re-render of every diagram on each
light/dark flip. Heybinshao proposed Pele in #145052.
Pele (obsidianmd/pele, MIT, by kepano) renders the same Mermaid syntax to
plain SVG, synchronously, with no dependencies. This swaps it in behind the
existing RichCodeBlock `mermaid` entry and keeps the rest of the path:
- `pele/lazy`, so a diagram loads only its own type's chunk (the pattern
from TudeOrangBiasa/brainondesk#98 and Limatura/tessera#148). The
`mermaid` advancedChunks group is gone; a group would merge the types back
into one chunk.
- Still an <img> data: URI, so the SVG stays an isolated document with no
scripts. Links and images are off, as under mermaid's strict mode (as in
7Yearsss/reizo-studio#155).
- Colors: the app's `--dt-*` tokens are resolved to concrete values and
written onto the SVG root as `--pele-*`. A token that does not resolve is
left to Pele's default rather than becoming black. The resolved theme is
the render-cache key, so skins re-color too, not only the mode flip.
- No mermaid fallback (energon and brainondesk keep one). Mermaid's own
syntax docs (492 fences) draw in exactly the same 476 cases with both
renderers; the 16 misses are all zenuml, an external plugin neither ships.
Two follow-ups came from profiling the first Pele version:
- Every diagram re-resolved the palette on mount and on each repaint, one
forced style recalc per token: 246 recalcs per 15-diagram re-render. The
theme is now resolved once per repaint, shared through
useSyncExternalStore, with all probes styled before any is read.
- The palette went in through a DOMParser/XMLSerializer round trip, and
the alt text through another parse. The palette is now a string insert
into Pele's root style, and the alt-text parse runs only when the SVG has
a <title> or <desc>.
xmlWellFormedSvg and normalizeSvgSize only existed to repair mermaid's HTML
serialisation (#133089), so they go, along with their tests. The #133089
case is kept as a test against real Pele output. Pele is pinned to 1.6.0,
the newest release that passes the repo's 14-day min-release-age.
Refs #145052
Standalone hermes serve read agent.daybreak when an agent was built and
then relied on a live-agent scan and a compute-host refresh. A build that
raced a flip could still publish the old value, and the compute-host read
bound only the home, not the profile's secrets and terminal policy.
_prepare_turn_input now reads it once the turn's final agent is selected,
inside the turn's own profile scope (prompt_turn._sync_agent_daybreak).
That one read covers in-process and compute-host turns, so the build-time
read, the live-agent scan and the compute-host refresh are gone.
Desktop: a queued write kept the primary menu's focus-following
requester, so after a focus switch it could reach another connection's
same-named profile. The model menu now binds Daybreak reads and writes to
the clicked surface's own gateway.
OpenAI Daybreak (Trusted Access for Cyber) reduces cyber refusals for
approved accounts. Codex's model picker has a Daybreak toggle; Hermes had
no way to request it.
The signed-in account's Codex /models catalog already lists, per model,
which cyber programs that account may use
(available_access_programs.cyber). Hermes reads that catalog for Fast and
Ultrafast; it now keeps the cyber list from the same fetch.
- agent.daybreak (default false) is one profile-wide switch, like Codex's.
- Desktop shows a Daybreak switch in a model's options submenu, next to
Fast, only when this account's catalog lists daybreak_blue for that
model. Unknown or unreachable catalog: hidden.
- Each Responses request adds access_programs.cyber=daybreak_blue only
when the switch is on AND the request's credential and model are listed.
Checked per request, so a /model switch, credential rotation or expired
catalog never carries it to a model or account without it.
- The gateway re-reads the switch every turn, so a flip applies to the
next turn of a running chat without rebuilding its agent.
- The opt-in codex app-server runtime does not send it, so the switch is
hidden there.
Co-authored-by: FroRaut <79215537+Froraut@users.noreply.github.com>
runGatewayEnsure layered the Desktop process env under the child, so a dev build's `gateway ensure` (and `gateway restart`) handed HERMES_DESKTOP_DEV_SERVER to the per-host gateway it starts. That gateway outlives the dev session and kept trusting the renderer port (Vite's 5174 fallback) for CORS and sockets afterwards. Desktop never needs it there: its HTTP to the local gateway goes through main-process requests with no Origin, and its socket dials have Origin stripped. The variable is now removed from the ensure client env; SSH-spawned serve backends still receive it.
local-gateway.test.ts: the new case reported the inherited value before this change and none after.
A packaged build (no dev server) spawned the remote serve with whatever HERMES_DESKTOP_DEV_SERVER the remote login shell exported, so that backend trusted a dev renderer origin nobody asked for. The Windows helper already clears it. The POSIX spawn script now runs `unset HERMES_DESKTOP_DEV_SERVER` before `exec env`, which sets it again only for a dev build (plain sh, no reliance on `env -u`).
remote-lifecycle-dev-server.test.ts runs the real command with the variable exported to the spawning shell: the packaged case reported the exported value before this change and reports it unset after.
connectWindowsRemote ignored devServer: the spawn payload never asked
windows_ssh_runtime to set HERMES_DESKTOP_DEV_SERVER, the ownership record
did not name a renderer, and reuse did not compare one. A dev build's
renderer sockets through the SSH forward were then refused unless the
Windows host had been configured by hand.
Send devServer in the spawn payload and have the runtime helper set (or
clear) HERMES_DESKTOP_DEV_SERVER from it, record it in both ownership
writes, and decide reuse with the POSIX lockServesConnect predicate.
Records without the field count as no dev server, so packaged builds
reuse as before.
The dev-server condition took connect() to cyclomatic complexity 36,
over its code-health cap of 34. The lockfile checks that decide whether
a published backend serves this connect move into lockServesConnect();
behaviour is unchanged.
The web server trusts a dev renderer's origin only from the
HERMES_DESKTOP_DEV_SERVER it was spawned with. connect() reused any
owned, live backend whose profile, token, runtime path and home matched,
so after the dev-server port changed, or on a switch between packaged
and dev builds, it reused a backend that refuses every renderer socket.
The ownership lockfile now records the dev server a backend was spawned
for, and reuse also requires it to match the current one; otherwise the
owned backend is reaped and respawned. Records without the field count
as no dev server, so packaged builds reuse exactly as before.
The spawn env test passed process.env through to the spawned shell. Run
from a dev shell that exports HERMES_DESKTOP_DEV_SERVER, the packaged
case inherited it and read the runner's value instead of 'unset'. Drop
the variable from the env the test hands the spawn.
remote-lifecycle.test.ts and main.ts are over the code-health size cap
and may only shrink. The real-sh spawn test for the dev renderer origin
now lives in remote-lifecycle-dev-server.test.ts, and waits on a FIFO
the detached serve writes instead of polling for a report file. main.ts
offsets its one added line by joining a two-line comment.
A dev renderer is served from HERMES_DESKTOP_DEV_SERVER, so its sockets carry
that http origin. A backend trusts it only when it inherited the variable
(the locally spawned child does), and the dashboard is about to stop trusting
fixed dev-server ports. Two paths reached a backend without it:
- Attach: a dev build attaches to the host's running backend (a packaged
app's, `hermes dashboard`, another hgui slot). The attach probe now sends the
renderer's Origin, so a backend that would refuse the renderer's sockets is
skipped and the dev build spawns its own, instead of attaching and failing
every renderer socket.
- SSH: the `hermes serve` a dev build starts over SSH now gets
HERMES_DESKTOP_DEV_SERVER in its environment, as a local child inherits it.
Packaged builds (file:// renderer, no dev server) are unchanged.
(cherry picked from commit 57c532175efd9d9747d21869361a7aba9b875683)
/api/status gateway_shared_with is [] on a single-profile gateway: it serves only the profile it
was launched as, which the list does not name. Treating that as {default} switched a window on a
gateway launched as 'work' onto 'default', which that gateway refuses (profile_mismatch). A
non-empty list already names the launch profile, so it is used as-is; [] is unknown, like null.
Re-review P3 (ELOOP divergence in the liveness port): one outer try/catch
made a symlink loop on any marker or on the tombstone path forget the whole
profile, while hermes_constants.named_profile_is_live (os.path predicates on
the shipped Python 3.14) reads that one path as absent and keeps checking.
Review finding (#147718): the boot repair accepted any directory under
profiles/, so a tombstoned or marker-less profile stayed remembered and every
launch still failed. Port hermes_constants.named_profile_is_live (identity
marker, dangling symlinked marker counts, no profiles/.deleted tombstone) into
local-profile-liveness.ts and use it for the check.
Review finding (#147718): an inactive profiles.default={mode:'local',savedSsh}
entry suppressed the remembered-profile repair even though the primary's
effective route was the global remote. Gate on profileHasRemoteConnection
(the same per-profile rungs resolveDesktopRemoteRoute selects), not on the
entry's truthiness.
Keeps main.ts under its FILE_LINES cap after the profile-intent fixes: the
shared-primary descriptor (and its rationale) moves into joinPrimaryBoot, the
dial-claim suffix into primaryDialClaimKey, and the profile preference IPC
handlers into registerDesktopProfilePreferenceIpc. No behaviour change.
Review finding "Installed does not mean served". /api/profiles lists every
INSTALLED profile, parked (gateway.parked) and standalone ones included,
while profiles_to_serve excludes them and a gateway-hosted listener refuses
their session calls with profile_mismatch. A remembered parked profile was
picked by the ladder, and a parked inherited name was kept.
Read the gateway's served set from /api/status gateway_shared_with (the
multiplexer's served_profiles; [] = a single-profile gateway serving only the
host's default) and filter both the inherited name and every ladder rung by
it. The same field and rule back the webapp's served-profile set
(src/lib/browser-served-profiles.ts). Unknown (null: no gateway running, an
older backend, a failed or signed-out read) keeps the installed list, as
before.
Review finding "Windows overwrite saved profile choices". Every window pushed
its whole $lastProfileByConnection copy and main replaced its map wholesale,
but windows never see each other's picks: an older window changing an
unrelated gateway erased newer choices and resurrected an entry
connectionRemoved had just pruned.
Main now owns the map. A window reports only the (connection, profile)
entries it changed (hermes:profile:connections:remember), and imports its
pre-mirror record once (hermes:profile:connections:import: fills only
connections main has no entry for, then latches). Both ignore connections
that are no longer registered.
Review findings "In-flight dials keep stale profiles" and "Retries skip
profile recovery". hermes:connection fills an empty request with the
primary's name before ensureBackend/startHermes see it, so the resolved name
could not tell an inherited caller from one that named a profile:
- a renderer joining a remote boot during its /api/profiles read got the
stale name back, because the route (descriptorProfile) was resolved before
the wait;
- a renderer retry after a failed remote health check reached
startHermes(key) with a truthy requestedProfile, which disabled the
served-profile restore.
Carry the intent (primaryBootRequest.inheritsPrimary) from hermes:connection
and the terminal backend through ensureBackend into startHermes. An inherited
caller re-reads the primary and rebuilds its route after the wait and may be
restored; an explicitly requested profile keeps its name and route.
Inherited and explicit dials of one name no longer share a dial claim.
Electron main pinned a remote primary to the machine-local legacy profile
from active-profile.json, so every legacy-scoped REST call (the update
check included) asked the remote for a profile it does not serve and 404'd,
and the renderer adopted that stale name as the primary's profile.
On a remote primary whose authoritative /api/profiles listing lacks the
inherited name, main now picks with the renderer's startupProfileForConnection
ladder: that connection's own remembered profile when served, else
default, else the first listed. A failed, empty or partial roster read keeps
the old behaviour. The machine-local preference is no longer rewritten for a
remote that lacks it.
Main boots before any window exists, so the renderer mirrors its
per-connection last-profile record to active-profile.json
(connectionProfiles), pruned with the connection. ensureBackend re-reads the
pin after joining an in-flight boot, so a dial made during the roster read
reports the re-pinned profile instead of the stale one.
Also adapts the missing-local-profile check to main, where the old
directoryExists helper no longer exists.
Electron userData (active-profile.json) outlives HERMES_HOME. After a
reinstall that wiped the Hermes home, or a `hermes profile delete` while
the app was closed, Desktop still launched `hermes --profile <name>
gateway ensure`, which refuses a missing profile, so every boot and
every Retry failed with "Profile '<name>' does not exist".
Before the first profile read at startup, apply what an in-app delete
already does: a remembered last-used profile whose directory is absent
from this machine's profiles root falls back to default, and a matching
explicit default route is cleared. Remote, SSH and cloud routes are not
judged by the local disk, and a profile named with --profile at launch
still fails loudly, like `hermes -p`.
makeDashboardReadyFile and recentHermesLog lost their last callers in
9c40ddcfc2 (local launches attach to the canonical gateway); nothing
references either. Removing them also keeps main.ts under its
code-health line cap for the next change.
Review finding "A user click before registry initialization is still
erased": initializeConnectionsRegistry read the user-open revision as its
baseline when it ran, which waits for boot.running=false, while the
connecting overlay lifts at the socket open and config keeps loading. A
sidebar row clicked in that gap bumped the revision before the baseline was
read, so the restore saw it unchanged and closed the chat.
The launch restores now compare against the revision at window start
(LAUNCH_USER_SESSION_OPEN, 0 by construction: module load precedes any
input). Automatic selections still never bump it, so the cold-start route
resume keeps landing as before.
With launch mode "last used" on a gateway other than the one main opens
first, the window paints on This device and the launch restore
(restorePreferredConnection -> restoreConnection(preferredId)) dials the
saved gateway in the background. That restore does not yield (only the
startup profile re-home does, #147711), so a stored chat the person opened
right as the window painted was closed when the restore landed seconds
later and the window jumped to a blank draft on the other gateway.
openSession, the one door every surface opens a chat through, now bumps a
user-open revision (store/session-open-intent). The launch restores carry
the revision captured when boot began and give way once it moves. Route
effects that select a chat on their own (the cold-start route resume,
runtime recovery) never bump it, so those restores still land as on main.
With one backend per SSH machine (#147741), box/gamma's socket is box's default serve, and an
unscoped config.set edits that serve's launch profile: the live E2E saw Tips off land in
Box's default config.yaml, not gamma's. Both writes now carry the profile in the params, the
same way the approval chip already scopes its config.get/set.
Review finding (#147797, display auto-push writes to the new gateway's OLD
profile): the connect-time push runs inside the $gateway notification, which
applyActive fires before it publishes the route's profile. Pairing
activeGatewayConnectionId() with that still-old profile sent config.set
display.in_app_tips to box/default on a local/default -> box/gamma switch.
Read both halves from the registry (activeGatewayRoute).
CI red at tutorial-lifetime.test.tsx:75: display-toggles now routes config.set
through requestGatewayForAgent(activeGatewayConnectionId(), ...), which the
mock did not define. Harness only; assertions unchanged.
setVoiceChatMode (voice-live.ts) and the display-toggle mirror
(display-toggles.ts) sent `config.set` through
requestGatewayForProfile(activeProfile), the same bare-name route the
approval-mode chip used. On a profile served only by a remote or SSH
gateway (`gamma` on Box) that name resolves through this machine's
profile pool: main refuses it (`Profile "gamma" no longer exists`) and
the write is lost, or, when This device has a profile of the same name
(`default`), the write lands in This device's config.yaml instead of the
remote one.
Route both through requestGatewayForActiveRoute, the (connection,
profile) helper the chip uses.
Tests: voice-live.test.ts and display-toggles.test.ts only move the
assertion about which call is made (requestGatewayForProfile ->
requestGatewayForAgent with the active connection); the written key,
value and target profile are asserted unchanged. New
active-route-config-writes.test.ts drives the real gateway store on a
remote-only profile (red on d53e317e30c).
The status-bar approval-mode chip read `approvals.mode` through
requestGatewayForProfile(activeProfile). A bare profile name has no
gateway, so that call resolves through this machine's profile pool: on a
profile served only by a remote or SSH gateway (`marina` on Homelab,
`gamma` on Box) the renderer asked main for the profile-only route and
main tried to start a LOCAL backend for it, refused with
`Profile "gamma" no longer exists` — twice per switch (shared-primary
probe + secondary dial), dozens of lines per session.
Route the chip and the plugin-catalog lookup (same active-route shape)
through the active (connection, profile) pair, and re-read the mode when
the active socket changes, so `default` on Box and `default` on This
device are not treated as one route.
Review finding "Cached fleet failure cancels valid same-gateway profile
repair": the launch-fallback watch in restoreConnection also armed for the
startup profile re-home on the gateway already in front, so a fleet-roster
row still saying reachable:false from an earlier timed-out read abandoned a
repair whose own /api/profiles and /api/status reads had just succeeded, and
the window stayed on a profile that gateway does not serve.
The "target reported down -> the window fell back" rule only means something
for a restore that moves the window to another gateway; a restore onto the
gateway already in front never arms it.
The roster can report the target down after beforeActivate already ran;
the activation then kept dialing and published the target when it
recovered. Abandoning a pick now aborts its activation and points a draft
it already re-homed back at the gateway still in front.
Since #147681 picking a gateway no longer rewrites the saved config, so
the Settings > Gateways connection form edits the primary (startup)
gateway, not "this window". The previous commit seeded the editable form
from the window's gateway, which made Save silently promote that gateway
to primary and blank tokens for other URLs. Drop that seeding (the form
loads and saves the primary exactly as before) and fix the label instead,
in English and all eight overlays.
The page loaded only the saved primary config, so after picking Homelab (or a
last-used launch onto it) it still showed "Local gateway" selected. It now
shows the registered gateway the window is actually on: its kind, URL or SSH
host. The saved token is offered only when the URL matches the one it was
saved for, so Save never carries one gateway's token to another.
With launch mode "last-used" and that gateway down, the window shows This
device while the boot restore keeps dialing (main waits out the remote's
readiness budget). When the gateway came back ~30-50 s later the restore
finished and moved the window there with no user action.
The restore now watches the fleet roster: once it reports the launch target
unreachable, the window has fallen back and the restore gives up its pick.
The kept socket (gateway-persistence) still reconnects the gateway, so its
sessions fill in without moving the window. A reachable but slow target
(connect-on-demand SSH, a cold dial) still lands the launch on it.
Review finding (#147763, Settings soft re-home still publishes new
gateway/old profile): softSwitch recorded box's connection while the
primary profile was still local's alpha, then awaited the ticket and
connect before adopting box's profile, so the request scope named
box|alpha and the version poller asked box for alpha. Boot had the same
shape. Resolve the primary profile before the record and publish the
connection with it as one pair; adoptPrimaryProfile reuses the lookup.
The pair test now drives the production order (connection, then socket).
Review finding (#147797 display auto-push, publication order): applyActive
set $gateway, and so ran its listeners, before the route's profile and
request scope were published. The display-toggle connect push read the new
socket's connection with the previous route's profile and wrote config.set
to box/default on a local/default -> box/gamma switch. Publish socket,
gateway state, request scope and profile in one nanostores batch.