A starting gateway answered its control socket for about 1.7 seconds before it registered the
Webapp's verbs, because the registration ran only after the Webapp's listener and dashboard mount
were up. In that window webapp-status got "unknown verb: 'webapp-status'". Web Access turned that into
"unavailable", and the pane's restart wait, which stops at the first answer that is not pending,
showed a Start that had worked as Unavailable with the protocol error and a Stop button.
The gateway now registers the Webapp's verbs before its control socket starts, and the runtime
reports the Webapp as "starting" until its listener settles on serving, off or unavailable. While
starting, webapp-status answers that state (the pane already keeps waiting on any state other than
serving or unavailable), and webapp-launch and webapp-sign-out refuse with "still starting": a
sign-out must not replace the stored credential while the starting listener may already hold it,
and hermes webapp --sign-out already waits for a starting gateway. hermes webapp --status says the
gateway is still starting instead of printing "Unavailable: None".
When a running chat refused the gateway restart after Start or Stop, the pane raised an error
toast titled "Couldn't change web access" whose body began "Saved." and then pasted the CLI's
refusal, including a POST /api/gateway/restart?interrupt=true line. The title said the change
failed, the body said it was saved, and the detail was meant for a terminal.
The restart answer now carries restart_busy when live sessions refused it (the shared helper adds
it beside its existing text, so other callers are unaffected). The pane shows a warning titled
"Restart needed" that says the change is saved and why the gateway did not restart: a chat is
running, or the restart could not be started. The CLI text stays out of the toast. Every locale
has the two new messages and the old one is gone.
When a saved Web Access change was waiting for the gateway to restart (a running chat had refused
the restart), the pane's "Restart gateway" button ran Start or Stop again. Start registered the
sign-in callback with the Nous Portal once more and rewrote the config just to restart.
A new POST /api/webapp-access/restart restarts the gateway serving the profile onto the saved
config and does nothing else: no Portal registration, no build, no config write. It is limited to
the machine's owner like the other Web Access routes, and Electron routes it to the primary
backend like them. The button calls it in both pending states, and the pane then waits for the
Webapp to come up when the saved config turns it on.
Start only wrote the webapp: config and restarted the gateway. Nothing built
apps/desktop/dist-webapp except hermes webapp, so on an install where that never ran the pane
reported the Webapp running while every page returned a 404 that named a different product.
Start now builds the bundle with prepare_webapp_renderer, the function hermes webapp uses, which
reuses a current bundle. It runs after the request is checked and before anything lasting: a
failed build registers nothing with the Portal, writes no config, restarts nothing, and its error
names hermes webapp --build-only. The pane waits up to 35 minutes for Start, since that build can
wait 30 minutes for another build of it.
The status mapped every enabled Webapp whose host was not a wildcard to the "My own URL" mode.
The documented setup for hermes webapp (webapp.enabled: true on loopback) therefore showed as
"My own URL" with an empty link, and the pane offered no way to tell it apart from a Webapp
published through a tunnel.
The mode now follows the config: webapp.public_url means the user's own URL, a wildcard host means
the network, and any other enabled host means this computer only (mode "local"). For a local
Webapp the pane links to the address the gateway serves, says only this computer can open it, and
hides the network choice until it is stopped.
A loopback Webapp tab opened its host terminal with the session token in the socket URL, where
logs, history and proxies keep it. An authenticated request now mints a one-use ticket named for
one socket: a chat ticket does not open the host terminal, a terminal ticket does not open the
chat socket, and the host terminal opens only with its own ticket. The Webapp's plugin sockets
use their polling fallback, as the signed-in Webapp already did, so no URL carries the token.
hermes webapp --sign-out replaced the token but left open tabs connected until they reconnected.
The gateway tracks every socket the session token opened, closes them with 4401 on sign-out and
revokes media stream links. Native clients and signed-in browsers stay connected.
- The Desktop's canonical adapter replaced the server's open_requests with
entries built from its own prompts, so a warm session.activate dropped a
waiting batch clarify and restore-pending-clarify then cleared it. The
snapshot now keeps the server's entries beside the projected prompts.
- Automatic window requests (terminal/preview reads, preview clicks, the
tour, theme.apply) are asked with replay=False: a reconnecting viewer is
not handed them again, because a second delivery repeats the action.
Requests that wait for a person keep the replay.
- Cmd/Ctrl+Enter (queueDraft) skipped the setup slash check. Every composer
send action now asks one refusedDuringSetup rule first.
- Slash availability lives in the completion source: useSlashCompletions
returns no adapter while setup runs, and both trigger engines (composer and
message edit) open no `/` menu for a source without one. The `off` flag
is gone.
* feat(desktop): sign-in dialog shows who signed in and what moved
The free-tier sign-in dialog now reads "Finish in your browser" with the
device code shown small ("Do not share it.") and an "Open page again"
button. Once the browser approves, the result screen sets the account
email large under "Signed in as", then says what the replaced free
tier's apps did, in the same lines every other sign-in surface prints.
A Reconnect button opens the app that has to be reconnected; a move
still retrying is a small note that updates itself.
- The sign-in poll is a long-poll (`?wait=`): the backend answers once
the session leaves pending, capped at 25 s. The desktop never asks
again sooner than 2 s, so an older backend that answers at once is
not hammered. The onboarding picker uses the same loop, and a Nous
sign-in there that moved apps opens the same result screen.
- The poll reports `handoff_status`: the handoff record as fields plus
its copy (`guest_handoff.wire_status`).
- New `GET /api/providers/oauth/nous/handoff?since=&wait=`
(token-protected, profile-scoped) long-polls the handoff record so a
retrying move is followed until it settles or the dialog closes.
- The copy and failure screens for the retired transfer outcomes
(declined, superseded, retired) are gone.
* test(auth): sign-in copy check builds Completed with its handoff_status
The every-state copy check builds each SignInState from a placeholder
per dataclass field; Completed gained handoff_status in the parent
commit, so give it a real wire_status value.
* fix(desktop): Greptile round 1 on the sign-in result screen
- Onboarding paints above every dialog, so a result from the onboarding
provider list now waits until onboarding leaves the screen.
- The result keeps the profile the sign-in ran for, and Reconnect names
that profile (and connection) in the Connectors link, like a chat's
connector links do.
- A sign-in whose own run attempted no move (another process held the
claim, or the budget ran out) reports the replaced free tier's saved
record instead of no handoff (`guest_handoff.record_status`).
- A failed handoff read retries with backoff (4, 8, 16, 32 s) before the
result stops following the move.
- de, es, fr and zh get the new dialog strings.
Settings › Model › Subagents gains a Routing section for delegation.backend:
Default / Model routes / Profile routes, plus any other plugin's backend by
its own label. Plugin modes stay visible with an Install / Turn on hint while
the Advanced Delegation plugin is absent or off.
Core fails closed, so the page shows the SAVED mode as selected even when it
cannot run, with a "Subagents will not start until …" banner naming the fix
(Install plugin / Turn on / restart) and a Switch to Default button.
Model routes get a list with create/edit/delete, a default route and inline
validation (reusing the provider catalog + ModelSelect picker); Profile routes
are a checkbox list of existing profiles with an optional description and a
default. In any mode but Default the subagent model/provider rows are shown
inert with one line saying why (with no default route, unrouted tasks use the
main agent's model) and a Switch to Default button.
Backend: GET /api/delegation/routing (configured + blocked_reason from core's
backend_status), PUT /api/delegation/backend (core set_global_backend, under
the profile scope + config lock), PUT /api/delegation/backends/{model_map,
profile_routes} — profile-scoped (?profile=), validated (unique route names,
known reasoning effort / service tier, existing profiles); route api_keys are
redacted on read and kept on write.
Comment and docstring edits only (no code or assertion changes): bug
history in module docstrings, narration, cross-refs and test copies of
the handshake comment go; WHY comments on ordering, locking, the launch
profile scope and the old-backend wire constraint stay.
Since the unified gateway (#106742) the Desktop attaches to the shared
gateway instead of spawning its own `hermes serve`. Onboarding, the
welcome-trial claim and free inference decide "is this the Desktop app on
this machine?" from HERMES_DESKTOP and the spawn token in the process
environment, which the gateway never has. So `onboarding.state` answered
eligible:false for every new user, who landed on the provider picker with
no free account.
The answer now comes from the connection:
- The Desktop sends `client.capabilities {desktop_local: true}` first on
every socket, as a call of its own, before the boot's first
`onboarding.state` (the backend reads frames in order). An older backend
refuses only that call and keeps the server_requests answer.
- The gateway counts it only on a native-ticket connection, so a remote or
tunnelled client never gets the trial.
- Requests on that connection run under `serving_local_desktop(True)`, and
a chat it creates records the declaration in its launch policy, so the
chat's later turns run the same way (`local_desktop_turn`).
- A trial-only user has no configured model; a canonical chat freezes its
model at creation, so the chat now freezes the free model
(`_welcome_trial_model`) instead of refusing.
Live: a --fresh-install sandbox launch minted a guest account, opened the
onboarding chat and the free model answered.
Removing the pills left callers-less code behind: reloadMcpFor and
McpReloadDeferred (plus their wrapper-only tests and the
mcpReloadNotInChat string in every locale), addMcpServer /
removeMcpServer, brandGlyphStyle, and getGhAuthStatus. reloadMcp and
announceMcpReload stay; Settings still uses them.
Only the composer recorded its admissions, so an edit, a regenerate or a Quick
Entry send into a messaging session never lit the unread dot. The canonical
client now reports every prompt.submit receipt that starts a turn, whichever
surface sent it. A completion is judged against its delivering socket's profile
(another profile's same-id session no longer decides it) and marks the row's own
id (a compressed conversation's listed segment paints at once). A completion
that arrives before its receipt is held until the receipt lands.
Refs #134889 (RT-18)
Resolves the hermes_cli/cli_tui_mixin.py conflict from #141501 landing: main moved _Panel to
hermes_cli/cli_panel.py and this branch moved the wrap helpers to hermes_cli/cli_tui_wrap.py.
Keep both moves: import _Panel and the wrap helpers, define neither here.
Refs #134889 (N8)
Review on #141492 (client.ts:409-419): the replay-only /undo /retry probe
was answered locally before the attach re-route. A redial forgets the
named launch profile the owner reports in info.profile_name, so the probe
looked under `default`, missed the rewind retained under the named
profile, and answered "nothing". localAnswer now runs after the attach
and the second routeCanonicalParams, so the repeat re-presents the
original request. Cost: one attach for an unattached session, which
deriveAndRewind's session.resume would make anyway.
Refs #134889 (RT-40)
Two gaps in the lost-reply repeat:
1. The retained rewind was reached only after the repeat had derived and
checked a new target from the already-rewound transcript. A /retry
that removed the only user turn answered "nothing to retry", /undo N
with fewer than N turns left answered "nothing to undo", and an older
media turn made a text-only /retry refuse as unsupported, all before
the retained request could be resent. Each /undo and /retry now sends
a replay-only rewind first. The protocol re-presents the retained
request (the owner answers with the original receipt), or, when
nothing is retained, answers 'nothing' locally without a request
(CanonicalDesktopProtocol.localAnswer). Only then does the command
derive and check a fresh target.
2. A reconnect refreshes the transcript, so the rewound rows can already
be gone when the replayed receipt arrives. truncateRewoundMessages
then fell back by position and hid the newest remaining exchange.
A view bound to durable rows that holds none of the rewound rows is
left as is; only unbound live bubbles after the bound history, or a
wholly unbound view, still fall back by position.
Red on the previous head: the four new lost-reply command tests (real
CanonicalDesktopProtocol in front of a receipt-replaying owner) and the
bound-view truncate test.
Refs #134889 (RT-40)
A Desktop viewer of a LOCAL session whose voice chat another viewer (Ink)
turned on, typing a bare "stop": the owner ends that voice chat, admits
nothing and answers {voice_stopped: true}. CanonicalDesktopProtocol's
admissionReceipt threw "Canonical admission receipt destination mismatch",
so the submit errored and showed a failed prompt although the stop worked.
admissionReceipt now passes that variant through as an allowlist (only
voice_stopped, session_id and the submission id, and only when no ref or
admission_id is present). The submit pipeline treats it as settled with no
turn: the optimistic bubble goes (no turn holds it), busy is released, no
pending submission is tracked and no error is shown. Nothing new is rendered,
so no new strings. Other Desktop callers (tiles, bots, rewind, first message)
only read admissions or survivor ids and are unaffected once it stops throwing.
Refs #134889 (TUI-26)
A typed /undo or /retry rewind is retained by operation alone, so the retry
after a lost reply resends the original request. Only revision/generation and
busy refusals dropped it, though. Any other typed refusal (invalid_params when
the target row is gone or was compacted) left the refused request retained,
and every later /undo or /retry resent that same refused request until some
other control retired it. A refusal that carries a reason means the owner
wrote nothing, so the rewind is now forgotten and the next attempt derives
its target again.
Refs #134889 (RT-40)
Refs #134889 only
Desktop derived the rewind target from a fresh snapshot on every attempt and retained the request keyed by that target. After a lost reply the owner had already rewound, so the repeat derived the turn before and sent a second rewind: /undo removed two exchanges, /retry archived the newest question and resent the one before. A derived rewind is now retained by operation, as Ink's mutateCanonical and the classic PreparedMutations do, so the repeat re-sends the original request and the owner replays its receipt; the view is truncated at the receipt's row. Explicit rewinds (edit, regenerate, restore) stay keyed by their target.
(cherry picked from commit c2e041df1a969eec4120fad3f2e5f2dbb712c8c7)
The first-run due check (onboarding.state) and onboarding.start pass
timeout 0 on purpose: a way-out offer bounds the wait, and the shared
JSON-RPC channel arms no timer for 0. HermesGateway's canonical path
computed deadline = now + 0 and remainingRequestBudget threw "Hermes
gateway request timed out" before sending. The due check therefore
failed instantly on every canonical boot, markOnboardingDecided ran, and
the provider-setup overlay (gated only on onboardingSurfaceActive and
configured === null) rendered its header over a configured home until
the readiness probes answered — 5.3 s → 11.4 s on a CPU-idle host,
never on the pre-merge build, which dials legacy and has no wrapper.
A non-positive caller timeout now means no deadline, as in the shared
channel. Live (Electron on Xvnc, configured seeded home): HEAD card shown
3/3 boots (≈5–6 s each); with this change 0/2, onboarding.state is sent.
Test: canonical-deadline.test.ts "a zero timeout is no deadline on the
canonical socket" — red on main (throws before send), green here.
Refs #134889 (T21/F3, T18)
Refs #140337
Desktop's queue panel rendered only Delete for a server-owned (canonical)
queued row. The guard was deliberate: the gateway had no verb that could
steer or edit a queued admission, and composing prompt.cancel with
session.steer or with a resubmit is two writes. The drain can claim the row
between them, so the prompt either runs twice or is lost.
Add two owner verbs that consume the still-queued admission in the owner's
own write transaction:
- prompt.steer_queued {admission_id}: only while the running claim has
adopted its agent (else steer_unavailable, before the row is touched: it
stays queued and runs in FIFO order). The row goes queued -> terminal
'steering' bound to that claim's (owner_epoch, generation), so the drain
can never also claim it, and the text is then handed to the claim's agent
while that execution still runs. The transfer settles in the claim's own
terminal write: 'steered' when the claim completed with the text
delivered, 'interrupted' when it ended any other way (never replayed),
and queued again in its own FIFO place when the text never reached the
agent (the turn ended first). An owner restart settles a transfer left
open as 'interrupted'. Until settled the receipt reads 'started'. The
fence is an in-memory transfer record changed under the session stream
lock; the SQLite writes run outside that lock, so a held writer never
stalls the owner loop (loop-side receipts, attaches and publication take
it).
- prompt.replace_queued {admission_id, submission_id, text, ...}: cancel
the queued row inside the admission write of its successor, which joins
the back of the FIFO under a NEW admission identity. That write also
binds the new identity to the row it retired; the exact-replay path
checks the binding inside the same transaction, so a retry naming the
same old admission answers the same replacement and any other old
admission under that submission_id is admission_conflict. Ordinary
prompt.submit payloads are unchanged.
Refusals: admission_started, session_idle, steer_unavailable,
admission_conflict, queue_full, unsupported_control, not_found.
Each pending row names the queued-row verbs its owner serves (controls:
steer/replace): text-only rows of sessions launched from an interactive
local surface (cli, tui, gui, acp), whose observers settle a steered or
cancelled row. Hosted-room, cron, kanban and a2a producers read a saved
result for any other outcome, so their rows are never offered either verb
and both verbs refuse them (unsupported_control). Desktop shows Steer and
Edit on a canonical row only when the row lists them, so an older gateway
keeps Delete only. Canonical rows never get Next: reordering would break
the owner's one FIFO. Local rows are unchanged.
Edit loads the row into the composer; Save calls prompt.replace_queued and
keeps the edit open until the owner answers. A refusal, or the owner
starting the row mid-edit, keeps the edited text in the composer as an
unsent draft (followed by the draft it interrupted) with a short notice.
The composer holds presentation state only; the owner's FIFO never pauses.
Both verbs are declared in tui_gateway/contracts (generated TS/OpenRPC
regenerated).
Refs #134889 (RT-35)
Refs #140208
Blank-line padding only (eslint --fix), on top of the salvaged #139504.
Root cause #139504 fixes, verified red on main with its vitest: the
canonical snapshotResult projected prompts into pending_approval /
pending_clarify but never open_requests, while
restorePendingClarifyFromSnapshot reads only open_requests. Every
resume/activate therefore read as "no clarify" (authoritativeAbsent) and
cleared the parked card that adoptAttachedSnapshot had just re-delivered.
Approvals survived because restorePendingApproval reads pending_approval.
Refs #139189
Refs #134889 (RT-23)
Refs #140138
pluginSocket read the active profile when it started a dial but never
re-checked it after the connection lookup or the grant mint resolved. A
profile switch during either await still dialed the old profile's URL, and
no dial for the new profile followed. A socket already open when the
profile changed also stayed bound to the old profile's grant: the scope
listener only reset the counters and re-dialed a stopped socket. The
gateway checks the grant's own profile, so consent held, but the plugin
view showed the other profile's stream.
Each dial now carries the generation it was started under. A connection
or profile change bumps the generation, closes an open socket, and dials
for the new scope. A lookup, mint, backoff timer or socket callback from
an older generation is dropped. It neither retries nor counts toward
MAX_REFUSED_PLUGIN_DIALS. Permission refusals still stop at the limit,
connection failures keep the capped retry, and the no-bridge/OAuth,
disposed and null-URL cases are unchanged. The SDK guide says a live
socket follows a profile switch.
Refs #134889 (PLG-1)
Refs #139523
pluginSocket turned a failed or timed-out activeConnection() into null and
returned without scheduling another attempt. That lookup is part of the
restart path: getConnection re-ensures the gateway, which rejects while it
starts or drains, and a stale ticket forgets the cached descriptor before
re-ensuring. The socket then stopped for good, and since it was not marked
stopped, a connection or profile change did not revive it either.
A descriptor failure or timeout is now a connection failure like a dial
that never opened: the next attempt is scheduled with the same capped
backoff (500 ms base, 30 s cap) and does not count toward
MAX_REFUSED_PLUGIN_DIALS. A missing bridge and OAuth connections still stay
on polling, and permission refusals still stop at the limit. The SDK doc
now says the socket keeps retrying while the connection or grant can't be
resolved yet.
Refs #134889 (PLG-1)
Refs #139523
pluginSocket stopped for good after 5 dials in a row that never stayed
open. The browser cannot tell a refused upgrade from a gateway that is
restarting, draining or being re-ensured, and a failed grant mint counted
the same way, so any outage longer than about 7.5 s moved every open
plugin socket (Kanban included) to polling until the view remounted, on
local and token-mode backends alike.
Now the socket stops only on refusals that do not clear by themselves:
- Main names the one refusal it can identify. hermes:plugin:ws-url
answers { refused: 'permission' } (plain data) when the grant mint is
refused for a permission reason: an unsafe control path or a
group-writable profile home (Desktop's own checks or the runtime
bridge's unsafe_control_permissions). Any other failure still rejects.
- The renderer counts those, and a server that accepts and closes at
once. A dial that never opens, a mint that fails or times out keep the
capped retry (30 s cap, as before this PR).
- A connection or profile change resets the count, and a stopped socket
dials again.
Refs #134889 (PLG-1)
Refs #139523
A local Desktop talks to its gateway with authMode "native" and no static
token, so pluginSocket dialed /api/plugins/<id>/... with an empty ?token=.
The canonical WS gate (web_server_chat._ws_auth_reason) refused every such
upgrade: Kanban stayed on its 60 s poll, third-party ctx.socket was dead, and
the reconnect loop re-dialed every <=30 s forever, keeping an idle-exit
gateway awake.
The plugin socket now rides the credential its REST twin already uses on a
local gateway: the one-use native-http grant in X-Hermes-Gateway-Ticket.
- Gateway: GatewayRuntimeAPI stamps the raw socket peer on WebSocket scopes
too. PluginApiWebSocketGate redeems the grant once, ahead of routing
(native_http.redeem_native_ws: the HTTP seam's exact checks - single header,
no Origin, loopback peer, ready/served profiles, native-http purpose and
capability - plus the profile selectors, /api/plugins/ paths only), binds
the grant profile's home and secret scope for the whole connection, and
requires both that profile's and the launch profile's plugin consent before
accept. The route's credential check reads that principal and never
redeems. /api/ws and other core streams keep their purpose-bound credentials.
- Desktop main: hermes:plugin:ws-url mints the grant for the routed profile
and reserves a one-use dial bound to its origin (scheme, host, port) and
path. The path is checked one decoded segment at a time (dot segments, an
encoded slash or backslash, double encoding and bad escapes are refused),
then parsed with the real URL parser and required to stay under
/api/plugins/<id>/, and the dial records that parsed path. The webRequest
hook strips Origin and attaches the header only to an upgrade that matches
that dial, so the grant can't reach another host or another plugin's
path. The grant never enters a renderer URL. The redial/mint/prepare
branch shared by both gateway-socket IPCs moves to
local-gateway.localGatewayDial (main.ts stays under its line cap).
- Renderer: pluginSocket asks main for the URL when authMode is native, with
a deadline (a main process that never answers counts as a refused dial),
and stops after 5 dials in a row that never stay open, including a socket
that opens and closes at once (polling fallback stays).
Refs #134889 (PLG-1)
Refs #139523
A deferred pick can carry `reasoning`. Desktop's confirmation resend rebuilt it as
config.set/slash.exec with model/provider only, so the level was dropped, and the
stored owner token (keyed on the full payload) never matched, so the owner asked
again. The resend now sends the update's whole canonical payload plus its token
as a `session.model` request, which the protocol turns into a retained
`session.mutate` model operation: the same request shape the TUI resends.
Review finding on #139646 (independent review + kshitijk4poor)
When a deferred pick failed at the turn boundary, the gateway removed
it and emitted session.updated with status 'refused'. Desktop read
only that event's revision, which these payloads usually lack. The
user had seen "applies from your next message" and then silently kept
the old model.
Gateway: the refusal now names the refused target_model and the
committed model/provider the UI must show again.
Desktop: a new handleDeferredPickEvent handler:
- refused: shows the named reason under the existing 'Model switch
failed' copy, paints the committed model back on the session state
(and on the composer pill while it still shows the refused pick),
and refreshes the model options.
- confirmation_required: asks through the shared guarded-switch dialog.
The protocol keeps the owner's token from the event, so the confirmed
resend carries it (#139646 Issue 3's client half).
No new strings.
Review finding on #139604 (Greptile); also #139646 Issue 8 (Desktop)
Preparing pick B retires pick A from the retained mutations. If B
committed before A's revision_conflict / stale_generation reply was
handled, the one-shot fence retry re-prepared A at the fences named
in the refusal and overwrote B. That refusal also set the cached
revision and generation backwards.
retryableFence now retries only a request that is still the session's
current retained mutation. failure() adopts refusal fences only when
they move forward.
Review finding on #139646 Issue 6 (Greptile)
The composer pick already travels as the session-scoped canonical
session.mutate (config.set key=model; it never reaches /api/model/set with
scope 'main', which stays Settings > Model's explicit global door). Two
gaps made picks fail silently on a live session:
- A pick on a busy session is now answered status=deferred by the owner
(previous commit). The protocol maps it to the legacy `deferred` answer
and the composer shows "<model> applies from your next message".
- A revision_conflict / stale_generation refusal of a model or reasoning
pick now carries the owner's current fences. The client adopts them and
retries once (a fresh request id), never loops; any other refusal keeps
surfacing by name through the existing failure toast.
Builds on KoNit-K's cherry-picked stale_generation retirement (#138959).
Refs #134889 (RT-12, MP-6)
Fixes#139346Fixes#138790Fixes#138952
On the shared owner, the preview pane's "restart dev server" always failed.
The Desktop canonical adapter refused `preview.restart` by name, and the owner
had no handler for it. The only implementation was the legacy sidecar's
(tui_gateway/methods_prompt.py), which looks the session up in its own
table, where owner sessions never appear.
The owner now serves `preview.restart` beside `/bg` and `/btw` in
gateway/session_tui_side.py: the same admission (session:submit,
subscribed connection, profile match, closed param set), the same detached
side agent on the session's frozen route and owning-profile scope, and the
sidecar's prompt and rules. It is never an admission, a FIFO turn or a parent
transcript row. Like the sidecar it uses terminal+file tools, no
session_db or memory, and it is not closed afterwards, so the server it
starts keeps running. Progress rides `preview.restart.progress` and the answer
`preview.restart.complete {task_id, text}`, both already in the events
contract. Context comes from the session's stored transcript. The AIAgent
construction shared with `/bg` is factored into `_side_agent`.
The Desktop adapter stops refusing the verb.
Test (real owner over a real WebSocket, scripted provider): red on base
(`session not found`), green with the fix.
Refs #134889 (TUI-12)
Refs #139574
On a local Desktop whose primary backend was launched as a named profile
(active-profile.json), picking `default` and starting a new chat created the
session in the named profile. desktopSessionCreateParams already sends
`profile: 'default'`, but the canonical wire adapter (prepareCreate) dropped
it through siblingRoute(), which treated `default` as "the socket's own
profile". The socket's own profile is the launch profile, so the owner
created the chat there.
The create now always carries the picked profile, `default` included. The
gateway side already resolves an explicit `default` to the default home
(session_controls._sibling_for -> profile_matches_home -> get_profile_dir
-> default root), so no gateway change is needed. siblingRoute had no other
caller and is removed.
Live (Desktop core harness, real hermes serve, scripted provider,
active-profile.json = football, default picked, new chat):
base: session.create params {request_id, service_tier, source} ->
row in profiles/football/state.db
fixed: session.create params {profile: "default", ...} -> row in the
default state.db; a second turn lands in the same default row.
Refs #134889 (RT-26)
Refs #139574Fixes#139298
config.set on the owner now serves the keys the clients refused before the wire, each through the
code its slash command runs:
- `reasoning` (show/hide/reset/levels, `scope=global` = `/reasoning --global`): the /reasoning
handler's _apply_reasoning_selection for this session.
- `yolo` with `scope=global` (Desktop's Shift+click zap): approvals.mode off / manual, as main.
- `approvals.mode` / `approval_mode`: /approvals' run_approval_mode_command for the profile.
- `display.message_reactions|in_app_tips|in_app_tours` and `voice.voice_chat_mode`: config.yaml
leaves with main's validation (tui_gateway/server.py::_DISPLAY_TOGGLE_KEYS).
Ink drops its /reasoning (--global, display words) and `/voice tts` refusals: the first goes through
config.set reasoning, the second through slash.exec to the /voice handler (gateway state; recording
and playback stay in the terminal). Desktop's CANONICAL_CONFIG_KEYS opens those keys and the
`reasoning`/`yolo` scope. Contracts regenerated (CanonicalConfigSetParams.scope).
(cherry picked from commit 8f5fe27957d7636b5209692a2d57509381e0527e)
Mechanism: HermesGateway.connect() and close() cleared the replay_epoch -> owner
map (replayProfiles) on every transport replacement, while the shared
JsonRpcGatewayClient keeps the session's lastSeenSeq cursor and replay epoch
across the redial. On open the shared client sends session.events.since with
session_id/last_seen/replay_epoch and no profile; the Desktop override found no
owner for the epoch and threw "Replay owner unavailable" locally. The superclass
swallows that, releases the replay hold and emits no gap, so a viewer that lost
its socket while the owner retained events 3-5 rendered 1, 2, 6: the middle
delta and the tool lifecycle were silently dropped. Main has no canonical
replay-owner routing; this path is new in the PR.
Fix: the epoch owner map now lives exactly as long as the shared client's
retained cursor: connect()/close() drop only the owners whose session no longer
has a cursor (getSeqWatermarks). The owner check is unchanged: an unknown or
mismatched epoch is still refused, never routed to an ambient profile.
Test: apps/desktop/src/api/canonical-reconnect-replay-owner.test.ts (real
HermesGateway over a ws fixture owner that only replays to profile alpha):
observe 1-2, terminate the socket, reconnect, then deliver 6; requires one
session.events.since routed to alpha with last_seen 2, subscriber order
[1..6], one tool.complete. Red on r14-base (received [1, 2], no replay request).
Review: andrexibiza F2 (inline 4243905748)
Mechanism: for an equal stored session ID under several profiles, a frame with an
unrecognised epoch has no route; normalizeCanonicalEvent started the owner resume
probes and the listener wrappers dropped the frame. The probes could succeed and
establish the route, but their snapshots stayed internal, so the original
message.complete (or delta) was never dispatched.
Fix: while a (session, epoch) probe runs, the listener wrappers park that key's
frames, the triggering frame first, and replay them in order through the normal
normalize-and-dispatch path once a probe succeeds (fenced to the connection
generation; cleared on connect/close). If no probe succeeds the frames stay
undeliverable as before and the next frame probes again.
Test: apps/desktop/src/api/canonical-ambiguous-owner-reconcile.test.ts
'the frame that triggered a successful reconciliation is delivered to its owner'
(red on r14-base and on the previous commit: zero deliveries).
Review: andrexibiza 4243963773
Mechanism: reconcileAmbiguousEvent inserted the (session, epoch) key into
reconciledEpochs before either owner resume probe ran and swallowed both
rejections. When every owner was briefly unavailable, each later frame for that
session and epoch was dropped without another probe until the socket reconnected.
Fix: await the probes; if none established an owner, retire the key (fenced to the
connection generation) so the next frame probes again. A successful probe keeps it.
Test: apps/desktop/src/api/canonical-ambiguous-owner-reconcile.test.ts
'a failed owner reconciliation is probed again by the next frame' (red on
r14-base: two resume probes instead of four).
Review: andrexibiza 4243963771
Mechanism: deliverCanonicalPrompt latches deliveredPrompts[id] before handing the
prompt to the renderer. The renderer's fail() (the stopped-session decline) only
marked the wrapper settled and sent nothing to the authority, so the latch stayed:
if the authority still listed the prompt, every later authoritative snapshot
suppressed it as already delivered until reconnect, and the turn stayed blocked.
Fix: fail() retires the prompt's delivery key (fenced to the connection generation),
so only answered or settled prompts stay deduplicated and the next snapshot that
still lists it shows it again. No authority call is added.
Test: apps/desktop/src/api/canonical-ambiguous-owner-reconcile.test.ts
'a prompt declined locally is shown again while the authority still lists it'
(red on r14-base: the second snapshot delivers nothing).
Review: andrexibiza 4243963769
Lift the N91 session.updated revision adoption out of CanonicalDesktopProtocol.event
(CC 21 > 20) into adoptEventRevision, and narrow the N86 fallback seam catch to the
exceptions _profile_home raises (OSError / ValueError). No behaviour change; the N91
and N86 regression tests stay green.
Mechanism (N101): createSessionMutationClient keeps an ambiguous write's
identity per key (destination + payload) and deleted only the sent key on
success. After A:X (lost ACK) -> B:Y (acknowledged, revision 8) -> A:X, the
retained A identity still presented the old expected_revision and could
only conflict. Mechanism (B2-22): the definitive-refusal list omitted
unknown_execution, not_found and mutation_identity_required, so e.g. a
Delete refused with unknown_execution kept its identity; after Discard bumped
runtime_revision the next click replayed it into revision_conflict and only
the third click went through.
Fix: an acknowledged write retires every other retained identity of the same
destination + session (key entries 0-1, as retireSupersededMutations does
for the canonical protocol); the three definitive reasons drop the identity.
Test: session-http-mutation-identity.test.ts (table over the intervening
outcomes, plus a different-session identity that must survive) is red on
r13-base2.
Review: dokterdok N101
Review: ahrazzle B2-22