Commit Graph

1430 Commits

Author SHA1 Message Date
Teknium
669df020d9 fix(cli,tui): a stalled event loop no longer submits a held Enter ahead of a waiting paste chunk
The held trailing Enter decides on a 250 ms timer. When the event loop
stalls past that window with the next paste chunk already in stdin, the
timer ran before the chunk was read and submitted the first line alone:

- Ink: Node runs the timers phase before the poll phase, and
  stdin.readableLength cannot see bytes libuv has not read yet. The flush
  now hops to setImmediate (after this turn's poll) and runs only if no
  read replaced keyParseState in between.
- Classic: a signal handler that interrupts the selector past its deadline
  returns no events (PEP 475), so the due call_later ran before the reader.
  The settle now runs two call_soon hops later, after the next selector
  pass's readers. Text arriving while an Enter is held also keeps the paste
  burst alive however late it is read, so the paste's own trailing Enter
  stays a newline instead of submitting the joined text.
2026-10-28 19:05:57 -07:00
Teknium
7745fa7f92 fix(cli,tui): a paste still arriving keeps its trailing newline
Paste detection expired BURST_END_QUIET_S after the last pasted newline,
not after input went quiet. A non-bracketed paste delivered in reads
100 ms apart, with newlines only in the first and last read, therefore
treated its trailing Enter as a scripted text+Enter and submitted (and
cleared) the multi-line draft. Any input inside the quiet window now
keeps the paste burst alive, in the classic CLI (note_text_change) and
the Ink parser (pasteBurstAt). One-write text+Enter and a lone Enter
still submit.
2026-10-28 19:05:57 -07:00
Teknium
f511fbaba3 fix(tui): keys after a CSI-u Enter in the same read edit the next draft
A kitty Enter (CSI 13 u) is not held by the parser, so text, Enter and the
next keystroke can share one React batch. The key after Enter was applied to
the submitted draft before the parent's submit response rendered: with fast
echo the forced re-sync then dropped it (`hello\e[13ux` left an empty
composer), and on the Ink path it was appended to the submitted text
(`hellox`).

Keys arriving after a submit now queue until an effect declared after the
value sync replays them, so they edit whatever draft the parent settled on:
`x` after a clearing parent, `hellox` after a parent that keeps its value.
2026-10-28 19:05:57 -07:00
Teknium
f4383ac930 fix(tui): text and a CSI-u Enter in one read clear the composer after submit
Terminals with the kitty keyboard protocol send Enter as CSI 13 u, which is no
CR, so the burst hold does not apply: the text and the submit land in one React
batch, the parent value ends where it started and the local draft kept the
submitted text. TextInput re-syncs its draft on every submit (restores the
re-sync this PR's review round reverted).
2026-10-28 19:05:57 -07:00
Teknium
4889361215 fix(cli,tui): keep the draft and split pastes intact in the burst-Enter submit
Review round on the one-write text + Enter submit:

- Classic: the provisional newline goes in at the cursor, so settling restores
  the exact pre-Enter document (text + cursor) instead of dropping the last
  character. A scripted edit inside a draft now submits the whole draft.
- Ink: the decision is kept across stdin reads. A single-line read ending in CR
  emits its text and holds the CR in the parser state; App's flush timer
  releases it as return after BURST_END_QUIET_MS (250 ms) of no input, and any
  read inside the window turns it into paste content. A CR-ending read within
  250 ms of a pasted line break stays content. A paste split across reads (both
  directions) no longer submits itself. The textInput submit re-sync is no
  longer needed (text and return land in separate batches) and is reverted.
- Tests: injected clock (cli_enter_burst.monotonic, also read by
  _tui_on_text_changed); the single-write test proves the delayed callback
  path; new mid-draft and split-read cases.
2026-10-28 19:05:57 -07:00
Teknium
2432e31e2b fix(cli,tui): text + Enter in one write submits instead of inserting a newline
Scripted drivers deliver the text and its Enter in ONE read (`tmux send-keys
'text' Enter`, a PTY write of `text\r`). The classic CLI's #10994 guard treats
every Enter within 50 ms of a buffer change as a pasted newline, so the burst
never submitted; the Ink TUI routed the CR-carrying token through the paste path
and dropped it.

Classic: an Enter with more keys of the same read queued, or the tail Enter of a
burst that already held one, stays a newline (unbracketed multi-line paste is
unchanged). The lone Enter that ends a burst inserts a provisional newline and
submits once input stays quiet for 250 ms; input in that window (a paste split
across reads) keeps the newline. New sibling hermes_cli/cli_enter_burst.py.

Ink: a single-line text token ending in CR peels the CR into its own return key;
multi-line tokens keep it as paste content. TextInput re-syncs its local draft on
every submit, since text + submit in one React batch left the parent value
unchanged and the submitted text stuck in the composer.
2026-10-28 19:05:57 -07:00
Teknium
fde4219745 fix(groups): retry receipts, pre-submit file refusals and TUI missing-method copy
Review follow-ups on #145566:

- Policy checkpoint: turn.deferred receipts (explicit user retries) are bounded on
  their own, so a discussion configured to its full max_rounds no longer stalls when
  a deferred turn is retried while it runs.
- Both routes run a member's file preparation through prepare_before_submit: a file
  the member can never take (over gateway.max_inbound_media_bytes, unbound, expired)
  settles the turn as failed; a transient failure is proven not admitted and is
  requeued with backoff. Neither pauses the room as uncertain execution.
- Ink TUI: the backends' "not available on this Hermes backend" answer is no longer
  read as version skew; it renders a translated methodUnavailable line. The
  invalid-params skew warning and older backends' bare wording are unchanged.

Refs #144648 (WA-20)
2026-10-27 20:24:05 -07:00
rob-maron
384e4bde56 fix(model-picker): no "Free" tag on subscription-billed rows for window plans
Rows the gateway bills to a subscription the account holds (billing_mode:
subscription) keep their free usage level, so a full allowance never dims
them, but the pickers no longer label them "Free": that subscription pays.
The ids ride on plan_usage.subscription_model_ids for Desktop/TUI; CLI and
messaging pickers use usage_tag_levels().
2026-10-27 12:44:44 -07:00
xxxigm
5c6660eaf5 fix(tui): drop the stale context meter when /compress commits
/compress does not call the chat model and publishes no session.usage, so the
bar kept the previous reply's prompt size until the next turn.
2026-10-27 10:33:32 -04:00
xxxigm
0189fb43d3 test(tui): cover the context meter after a committed /compress
The meter still shows the previous reply once /compress reloads the transcript.
2026-10-27 10:33:32 -04:00
unsupportedpastels
690440524b fix(gateway): answer viewer reads on a history mount; name read-only refusals
Addresses maintainer review on #143601.

Refs #143547
2026-10-25 11:39:45 -04:00
unsupportedpastels
8245012d4d fix(tui): restore an open clarify batch form after a reconnect
Review finding F1: the channel re-delivers session.resume's open_requests before the reply resolves, but resumeById / activateLiveSession then reset the screen, so a multi-question clarify form vanished while the owner kept waiting. hydrateSharedPrompts, which both callers run after the reset and before settleAttach, now delivers open_requests again under the same request id, so a held request.cancel still closes it.

Refs #143547
2026-10-25 11:36:11 -04:00
unsupportedpastels
9172b629b0 fix(tui): clear runtime capabilities on reconnect
Addresses maintainer review on #143599.

Refs #143547
2026-10-25 11:36:11 -04:00
unsupportedpastels
a435c8af5f test(tui): cover clarify-batch capability discovery
Addresses Greptile review on #143599.

Refs #143547
2026-10-25 11:36:11 -04:00
unsupportedpastels
163a633265 fix(tui): declare clarify_batch so a multi-question clarify is one form
The gateway advertises clarify-batch-v1 and the Ink TUI declares clarify_batch
on real prompts when the owner advertises it.

Row TUI-29.

Refs #143547

Co-authored-by: Khwan888 <148256154+Khwan888@users.noreply.github.com>
2026-10-25 11:36:11 -04:00
Maciej Lisiewski
05b83f632f Merge pull request #143719 from NousResearch/bulk-update-js
chore(deps): bump npm dependencies to latest minor/patch releases
2026-10-25 12:54:29 +01:00
Teknium
f973257cab fix: show transform_llm_output rewrites in the TUI and desktop app
A plugin that rewrites the final reply with transform_llm_output had its
rewrite stored, but the TUI and desktop app kept showing the raw streamed
reply. A streamed local-viewer turn counts as delivered by the event
stream, so the turn handler returns None and message.complete went out
with text: null next to response_transformed: true. The completion frame
now carries the rewritten final when the stream could not.

The Ink TUI also flushed the raw streamed tail as its own segment before
appending the final, so even with the text present it showed both. A
response_transformed completion now replaces the streamed tail.
2026-10-24 19:45:27 -07:00
Teknium
f5900bf66e fix: a chat whose launch API key changed says so and names /new, not /retry
A local session never sends a different key than it started with (#139615).
When the config.yaml secret on its route changes and the backend restarts,
every turn and model pick on that chat is refused with
launch_credentials_unavailable. That policy is unchanged. The copy was the bug:

- Turn (every surface): the refusal escaped TurnRunner.run_sync as an
  exception into the generic agent-error handler, so the reply read
  "Something went wrong ... launch_credentials_unavailable (...). Use /retry
  to try again" plus a false "Some actions may already have run" notice.
  /retry can never succeed here. run_sync now settles it like the gone-folder
  refusal: a failed, never-run turn (api_calls 0) whose text says the key the
  chat started with changed, that /retry fails the same way, and that /new
  starts a chat on the current key; stamped failure_reason
  launch_credentials_unavailable, failure_retryable false. The generic handler
  path (a refusal raised later in the turn) uses the same copy and stamp.
- agent/error_surface maps the code to the gateway layer (no Switch provider).
- Desktop: an error card for the code (Start new session, no Retry), and the
  model-menu/model-option toast (#143133) shows the card's sentence with a
  Start new session button instead of the raw code.
- TUI: describeRpcError rewrites the bare code (model pick refusal) to the
  same remedy.
- Classic CLI: refusal_text (/compress, /worktree) and a refused /model print
  the remedy instead of the bare code; --api-key on resume that does not match
  now says a session never switches keys and to start a new one.

Copy: gateway.errors.launch_credentials_unavailable in all 17 locales,
userMessages.rpc.launchCredentialsChanged in all TUI catalogs, the Desktop
card in all 9 catalogs carrying error codes. The over-cap de/es/fr/ja/zh
Desktop catalogs move their refusal card rows into <lang>_error_codes.ts
siblings (the ru shape), so each shrinks while gaining the entry.

Refs #143133 (its raw toast; the reporter's trigger without a config change is not root-caused here)
2026-10-24 11:47:35 -07:00
Maciej Lisiewski
458b9dbafd chore(deps): bump react and react-dom to 19.3.0
react+react-dom: 19.2.7 -> 19.3.0 (pins edited: 9; also: {})
2026-10-23 22:00:12 +02:00
Maciej Lisiewski
f4d2041ae8 chore(deps): bump tsx to 4.23.15
tsx: 4.23.1 -> 4.23.15 (pins edited: 2; also: {})
2026-10-23 22:00:12 +02:00
Maciej Lisiewski
e3bbaa7dd3 chore(deps): bump prettier to 3.9.9
prettier: 3.9.5 -> 3.9.9 (pins edited: 2; also: {})
2026-10-23 22:00:12 +02:00
Maciej Lisiewski
7bb5b450ae chore(deps): bump get-east-asian-width to 1.7.0
get-east-asian-width: 1.6.0 -> 1.7.0 (pins edited: 1; also: {})
2026-10-23 22:00:12 +02:00
Maciej Lisiewski
b592209965 chore(deps): bump esbuild to 0.28.2
esbuild: 0.28.1 -> 0.28.2 (pins edited: 3; also: {})
2026-10-23 22:00:12 +02:00
Maciej Lisiewski
0a95f665e2 chore(deps): bump bidi-js to 1.1.0
bidi-js: 1.0.3 -> 1.1.0 (pins edited: 1; also: {})
2026-10-23 22:00:12 +02:00
Maciej Lisiewski
67407d6cf5 chore(deps): bump @types/react to 19.3.0
@types/react: 19.2.17 -> 19.3.0 (pins edited: 4; also: {})
2026-10-23 22:00:12 +02:00
Maciej Lisiewski
e52e39ee20 chore(deps): bump @types/node to 22.20.5
@types/node: 22.20.1 -> 22.20.5 (pins edited: 3; also: {})
2026-10-23 22:00:12 +02:00
Teknium
db1fa153fe fix(tui): inputs queued in the same millisecond on two sessions keep their order
A restored or migrated pending-input queue sorts by createdAt. useQueue made
createdAt strictly increasing only within one session's queue, so an input
queued on the old session and one queued on its successor in the same
millisecond tied, and a resume that merged the two queues ordered them by
their random submission UUIDs (readdir order). That is the intermittent
pendingMigrationRenderer red on CI (waiting / already next swapped).

createdAt now comes from one process-wide monotonic clock, so every queue's
inputs stay strictly ordered across sessions.
2026-10-23 08:26:32 -07:00
Teknium
433e420be4 refactor(browser): drop /browser use, the browser.manage use action and the downgrade notice
browser_exec is the only core browser path, so there is no Browser Use /
built-in tools switch to flip and no silent downgrade to announce.

- classic CLI, Ink TUI and the gateway browser.manage RPC lose the `use`
  action (contract regenerated: BrowserAction, enabled, browser_use);
- /browser status no longer reports a mode; the Chromium-fallback line for
  Lightpanda and the dead "chrome" engine row go with the built-in tools;
- browser_backend_notice leaves the session snapshot, the CLI banner and
  the canonical contract.

TUI locale packs and _keys.tui.json drop the five slashCmd.ops.browser
keys whose only caller was `/browser use`.
2026-10-23 01:41:24 -07:00
Teknium
32fc5b878c Merge origin/main into window-plans
Resolves hermes_cli/auth_model_picker.py against 7a8569baa9 (the picker
takes a title, public as prompt_model_selection): keeps this branch's
description_lines()/menu_title() split, with menu_title(title=...) and the
title= parameter on _prompt_model_selection carried over from main.
2026-10-22 14:43:44 -07:00
Teknium
6341ef3296 fix(usage-window): never retry another chat from the TUI limit card's model switch
Greptile: "Recovery retries another chat". After accepting the limit
card, the user could open another chat while session.mutate was pending;
switchCanonicalModel skipped /model's stale checks, painted the result
into the newly active chat and called /retry, which reads the current
sid and so rewound and resent the other chat's last prompt.

switchCanonicalModel now reuses /model's guards: the mutation is fenced
on the refused chat's sid (stale after the CAS read and after the reply),
and isSupersededControl (now taking the baseline info) drops a reply an
epoch change or newer turn superseded. A stale reply applies nothing and
does not /retry. The legacy config.set path gets the same sid check.
2026-10-22 14:34:55 -07:00
Teknium
e4a1eb7c27 fix(usage-window): switch the TUI limit card's model via session.mutate on canonical connections
Greptile: "TUI model recovery is rejected". On a canonical connection the
owner's busy_config (gateway/session_busy_controls.py) refuses config.set
key=model with use_session_mutation_model, so the usage-limit card's
"switch to <model>" printed an error and never re-sent.

On canonical connections the card now uses the same revision-fenced,
session-scoped session.mutate operation=model path as /model
(switchCanonicalModel in canonicalSessionControls.ts, sharing
applyModelResult and the guarded-target confirmation). /retry runs only
once the switch committed; a refusal, a declined ask or a pick deferred
behind a running turn does not re-send. Standalone backends keep the
legacy config.set call.
2026-10-22 13:50:11 -07:00
Maciej Lisiewski
c82bdd01ae chore(deps): bump vitest to 4.1.12
Latest 4.1.x patch: mocker hardening for manual and redirect mocks
(vitest-dev/vitest#11580 backport to v4). Also bumps @vitest/mocker.

vitest 4.1.12 is 7 days old, below the min-release-age=14d guard, so
.npmrc gains a dated exclude entry (remove when > 2wks old).
2026-10-22 21:20:10 +02:00
rob-maron
cafa03f7f4 PR review comments 2026-10-21 23:05:11 -04:00
rob-maron
0e29e8a25a fix tests 2026-10-20 22:18:49 -04:00
rob-maron
83c5737be2 merge main in 2026-10-20 21:19:31 -04:00
rob-maron
15307dece7 Usage-window plan support 2026-10-20 21:04:30 -04:00
Teknium
b2c269f665 fix: re-admit only a correction the owner marks undelivered
A live agent's 'rejected' can follow delivery: Codex turn/steer returns
False on an ACK timeout even when the server already consumed the steer.
The TUI read every same-generation 'rejected' as "never delivered" and
re-sent the words as prompt.submit, so the correction could run twice.

correct() now marks the no-agent refusal with delivered: False (declared
on CanonicalCorrectionAck, contracts regenerated). The TUI re-admits only
that reply plus the three pre-agent error reasons; a plain 'rejected'
settles as refused with the input retained, as on main. The salvaged
gateway tests are trimmed to the no-agent case plus a live-agent refusal
that must carry no marker.
2026-10-20 03:09:11 -07:00
Teknium
e9530b8757 fix(tui): a busy correction refused undelivered is re-admitted as a prompt
The TUI journal kept a refused session.redirect / session.steer with its
controlMethod and the finished turn's execution_generation, so every
retry was refused again ("queued (N)" forever, never delivered).

A refusal the owner raises before any agent sees the text
(stale_generation, execution_not_ready, unsupported_control) or a
'rejected' reply for that generation now clears the control fields and
re-submits the same row as prompt.submit with its existing submission_id
(queued behind any running turn; the owner's admission dedupes a repeat).
Transport failures stay ambiguous and keep the retain semantics, since a
correction that may already be inside the turn must not be delivered twice.

Fixes #141511
2026-10-20 03:09:11 -07:00
Teknium
de0b2d4a12 fix(tui): a refused MCP reload revision backs off instead of retrying every poll
The TUI's config poll re-sent `reload.mcp` for an unacknowledged revision on every 5 s tick. With
one MCP server parked after a gateway restart the gateway refused each one, so every open TUI
produced a WARNING and a full reconcile every 5 s forever (1,897 lines in 52 min with three TUIs).
The salvaged gateway change answers a reload naming the held revision as success; this is the
client half for the reloads that are still refused: the same revision now retries after a doubling
backoff capped at 5 minutes, and a new revision retries at once.

Refs #141769
2026-10-20 03:08:06 -07:00
yoniebans
737d1d9e81 fix(cli,tui): a refused delete releases its read with a plain detach under the resolved id
The release carried an end_reason (cli_close, tui_close), which made the
owner run its viewer close: the session's async delegations were
interrupted, its route refused new ones until a viewer attached again, and
the session ended at idle. On a messaging chat refused with session_busy
that fenced the live chat. The release is now a plain session.detach keyed
by the id the read resolved to, skipped when this viewer already held it
(the shape #141498 introduced).

Refs #134889 (TUI-19)
2026-10-19 23:04:43 +02:00
Teknium
9db77087cb test(cli,tui): a refused delete detaches by the resolved id and keeps a view the client holds (currently failing)
Carried from #141498 (Teknium), adapted to this branch's clients: the classic
CLI and the Ink picker release the delete's read with a plain detach under
snapshot.session_id, and never release a session this viewer already watches.

Refs #134889 (TUI-19)
2026-10-19 23:04:43 +02:00
yoniebans
048b20eab4 style(tui): the delete hook takes the possibly-missing row, keeping the picker's key handler under its complexity cap 2026-10-19 23:04:43 +02:00
yoniebans
98b951bf9f refactor(tui): the picker's delete lifecycle lives in a useSessionDelete hook 2026-10-19 23:04:43 +02:00
yoniebans
1832807216 fix(tui): hold picker input from the moment a delete starts
The pending-delete guard read React state, which lands on the next render. One
stdin chunk can carry the confirming key and a click on the same row, and the
click then resumed the row the delete was about to hand back. A ref set before
the delete starts now guards keys and clicks.

Refs #134889 (TUI-19)
2026-10-19 23:04:43 +02:00
yoniebans
c06d8b4b5d fix(tui): a history row does not open while its delete is pending
Keys are held while the picker deletes a row, but a click still resumed it. The
resume shares the delete's revision read attachment (one per viewer), so a
refused delete then detached the session the user had just opened. Row clicks
are ignored until the delete settles, as keys are.

Refs #134889 (TUI-19)
2026-10-19 23:04:43 +02:00
yoniebans
9566b51a00 fix(tui,cli): a refused delete hands back the attachment its revision read made
Deleting a stored session reads its revision and generation through
session.resume, which attaches the deleting view. When the owner refused
the delete (stale revision, busy, read-only grant) nothing detached it, so
the closed session sat in the live section until the client exited. Before
the shared gateway the picker deleted with no attach at all.

On a refusal the Ink picker and the classic CLI's gateway session store now
detach the subscription that read made, with the client's close stamp
(tui_close, cli_close). A session the classic CLI was already viewing keeps
its attachment.

Refs #134889 (TUI-19)
2026-10-19 23:04:43 +02:00
yoniebans
c92ca62a76 test(tui,cli): cover a refused delete leaving the closed session attached (currently failing)
A refused session.mutate delete keeps the viewer that session.resume
attached for the revision read, so the closed session returns to the live
list. One test per client: the Ink picker and the classic CLI's gateway
session store. A second classic case pins that a session this CLI is still
viewing keeps its attachment.

Refs #134889 (TUI-19)
2026-10-19 23:04:43 +02:00
Teknium
85188e61c3 Merge origin/main into fix/pkg13-ink-leftovers
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)
2026-10-19 12:55:27 -07:00
Teknium
dfb4ecd911 fix: a stop typed as a busy correction ends the voice chat on the shared gateway
In Ink's interrupt and steer busy modes, text typed during a running turn
goes to session.redirect / session.steer, not prompt.submit. The typed
stop-phrase check only ran in prompt.submit, so a bare "stop" in a LOCAL
voice chat reached the running agent and voice chat stayed on.

The owner's correct() now makes the same _typed_voice_stop decision (attached
submitter, LOCAL session, voice on, bare stop phrase) after authorization and
before the generation fence, and answers {voice_stopped: true}. The canonical
CanonicalCorrectionResult becomes Ack | CanonicalVoiceStopped (generated TS
and OpenRPC regenerated); the dispatch test proves it through the real
contract parse.

Every client settles that reply instead of treating it as a refusal that
re-sends the text as a prompt (which would admit "stop" as a turn):
- Ink: settleControlReply renders the stop-phrase event and settles the
  item; the running turn's busy state is untouched.
- Desktop: redirectPrompt drops the optimistic bubble and reports accepted,
  so the composer does not re-queue it.
- ACP: /steer reports the stop-phrase notice and does not send a prompt.

Greptile review on #141508.

Refs #134889 (TUI-26)
2026-10-19 06:54:34 -07:00
Teknium
b5cd403040 fix(tui): a stop typed behind a running turn keeps that turn's busy state
In queue mode a bare "stop" typed during a long voice turn goes out with
behindTurn. The owner ends the voice chat and answers {voice_stopped: true},
but the reply handler cleared busy and set status ready for the focused
session. The agent turn was still running, so the next input could take
beginOwnedTurn and wipe the live stream buffer.

The reply now releases only the latch this submission took (ownsTurn()), so
a behind-turn stop leaves the running turn's busy and status alone.

Greptile review on #141508.

Refs #134889 (TUI-26)
2026-10-19 06:46:32 -07:00