Skip to content

Fix HITL turn stall, composer escape traps, and unvalidated /model ids - #123

Merged
github-actions[bot] merged 2 commits into
mainfrom
fix/hitl-stall-and-composer-escape-traps
Aug 2, 2026
Merged

github-actions[bot] merged 2 commits into
mainfrom
fix/hitl-stall-and-composer-escape-traps

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

Summary

Four P0/P1 findings from a hands-on beta-readiness audit, each reproduced live against the built binary and now covered by a regression test:

  • HITL approval silently stalls the turn forever (P0/P1). Approving (or auto-approving, or denying) a tool call that paused for human approval executed the tool but never re-armed the turn loop — resolve_hitl only runs the tool and transitions the session lifecycle, it doesn't drive the follow-up model call. The header kept displaying "Working" indefinitely with nothing actually in flight, uncancellable and unrecoverable short of killing the whole process. resolve_hitl_overlay and drain_auto_hitl now re-arm pending_turn_continue, the same mechanism dequeue_and_send_next already uses, so run_loop restarts the model call on its next tick.
  • Bare / command palette has no cancel (P0). Typing / opens the command palette, but Esc silently moved focus off the composer without clearing the pending text, leaving the dropdown rendered but orphaned — nothing then routed Backspace/Enter/Tab back to it, so the only way out was running one of the 8 listed commands or force-quitting the app. Esc now closes an open slash palette first, and also requests a graceful turn cancellation when the composer is busy (mirroring Ctrl+C's existing first-press-interrupts / second-press-quits behavior, which previously had no Esc equivalent at all).
  • /model <name> accepts nonexistent models (P0). Any string whose prefix matched a connected provider became the active model with no check that the model itself existed in that provider's catalog — e.g. /model connect silently set the active selection to xai/connect, a model that doesn't exist, and the picker's own header disagreed with its own model list as a result. Now validated against the provider's live catalog when one is available; unknown models are rejected with a clear warning instead of applied.
  • Help's own advertised shortcut doesn't work (P1). Help's text says "? Help", but ? typed a literal character into the composer instead of opening Help. Now opens Help specifically when the composer is empty (so typing ? mid-message is unaffected).

Test plan

  • cargo test --package forge-tui — 673 passed, 0 failed (670 pre-existing + 3 new regression tests)
  • cargo check --workspace — zero warnings
  • New regression test (approving_a_hitl_gated_tool_resumes_the_turn_instead_of_stalling_forever) verified to fail without the approvals.rs fix and pass with it
  • Live-verified against cargo build --release --package forge-cli: bare / + Esc now closes cleanly, /model connect is rejected with a warning instead of corrupting state, ? on empty composer opens Help, and a real shell-approval flow now reaches a truthful ✓ Completed/✗ Failed instead of hanging on "Working" forever

Four separate P0/P1 usability-audit findings, all reproduced live against
the built binary and covered by new regression tests:

- Approving (or auto-approving/denying) a tool call that paused for HITL
  approval executed the tool but never re-armed the turn loop, so the
  follow-up model call silently never ran. The header kept reading
  "Working" forever with nothing actually in flight, recoverable only by
  killing the whole process. `resolve_hitl_overlay`/`drain_auto_hitl` now
  re-arm `pending_turn_continue` the same way `dequeue_and_send_next` does.

- The bare `/` command palette had no way to cancel or edit: Esc silently
  moved focus off the composer without clearing the pending "/" text,
  leaving the dropdown rendered but orphaned (nothing routed
  Backspace/Enter/Tab back to it). Esc now closes an open slash palette
  first, and also requests a graceful turn cancellation when the composer
  is busy, mirroring Ctrl+C's existing first-press behavior.

- `/model <name>` applied any string whose prefix matched a connected
  provider as the active model, with no check that the model itself
  existed — e.g. `/model connect` silently became the active selection
  `xai/connect`. Now validated against the provider's live catalog when
  one is available.

- `?` on an empty composer typed a literal character instead of opening
  Help, contradicting Help's own advertised shortcut. Now opens Help when
  the composer is empty; typing `?` mid-message is unaffected.
@github-actions
github-actions Bot enabled auto-merge (squash) August 2, 2026 02:17
@github-actions
github-actions Bot merged commit d0d1ed5 into main Aug 2, 2026
6 checks passed
mohitranka added a commit that referenced this pull request Aug 21, 2026
#123)

* Fix HITL turn stall, escape traps, and unvalidated /model ids

Four separate P0/P1 usability-audit findings, all reproduced live against
the built binary and covered by new regression tests:

- Approving (or auto-approving/denying) a tool call that paused for HITL
  approval executed the tool but never re-armed the turn loop, so the
  follow-up model call silently never ran. The header kept reading
  "Working" forever with nothing actually in flight, recoverable only by
  killing the whole process. `resolve_hitl_overlay`/`drain_auto_hitl` now
  re-arm `pending_turn_continue` the same way `dequeue_and_send_next` does.

- The bare `/` command palette had no way to cancel or edit: Esc silently
  moved focus off the composer without clearing the pending "/" text,
  leaving the dropdown rendered but orphaned (nothing routed
  Backspace/Enter/Tab back to it). Esc now closes an open slash palette
  first, and also requests a graceful turn cancellation when the composer
  is busy, mirroring Ctrl+C's existing first-press behavior.

- `/model <name>` applied any string whose prefix matched a connected
  provider as the active model, with no check that the model itself
  existed — e.g. `/model connect` silently became the active selection
  `xai/connect`. Now validated against the provider's live catalog when
  one is available.

- `?` on an empty composer typed a literal character instead of opening
  Help, contradicting Help's own advertised shortcut. Now opens Help when
  the composer is empty; typing `?` mid-message is unaffected.

* Apply cargo fmt
mohitranka added a commit that referenced this pull request Sep 11, 2026
#123)

* Fix HITL turn stall, escape traps, and unvalidated /model ids

Four separate P0/P1 usability-audit findings, all reproduced live against
the built binary and covered by new regression tests:

- Approving (or auto-approving/denying) a tool call that paused for HITL
  approval executed the tool but never re-armed the turn loop, so the
  follow-up model call silently never ran. The header kept reading
  "Working" forever with nothing actually in flight, recoverable only by
  killing the whole process. `resolve_hitl_overlay`/`drain_auto_hitl` now
  re-arm `pending_turn_continue` the same way `dequeue_and_send_next` does.

- The bare `/` command palette had no way to cancel or edit: Esc silently
  moved focus off the composer without clearing the pending "/" text,
  leaving the dropdown rendered but orphaned (nothing routed
  Backspace/Enter/Tab back to it). Esc now closes an open slash palette
  first, and also requests a graceful turn cancellation when the composer
  is busy, mirroring Ctrl+C's existing first-press behavior.

- `/model <name>` applied any string whose prefix matched a connected
  provider as the active model, with no check that the model itself
  existed — e.g. `/model connect` silently became the active selection
  `xai/connect`. Now validated against the provider's live catalog when
  one is available.

- `?` on an empty composer typed a literal character instead of opening
  Help, contradicting Help's own advertised shortcut. Now opens Help when
  the composer is empty; typing `?` mid-message is unaffected.

* Apply cargo fmt
mohitranka added a commit that referenced this pull request Sep 11, 2026
#123)

* Fix HITL turn stall, escape traps, and unvalidated /model ids

Four separate P0/P1 usability-audit findings, all reproduced live against
the built binary and covered by new regression tests:

- Approving (or auto-approving/denying) a tool call that paused for HITL
  approval executed the tool but never re-armed the turn loop, so the
  follow-up model call silently never ran. The header kept reading
  "Working" forever with nothing actually in flight, recoverable only by
  killing the whole process. `resolve_hitl_overlay`/`drain_auto_hitl` now
  re-arm `pending_turn_continue` the same way `dequeue_and_send_next` does.

- The bare `/` command palette had no way to cancel or edit: Esc silently
  moved focus off the composer without clearing the pending "/" text,
  leaving the dropdown rendered but orphaned (nothing routed
  Backspace/Enter/Tab back to it). Esc now closes an open slash palette
  first, and also requests a graceful turn cancellation when the composer
  is busy, mirroring Ctrl+C's existing first-press behavior.

- `/model <name>` applied any string whose prefix matched a connected
  provider as the active model, with no check that the model itself
  existed — e.g. `/model connect` silently became the active selection
  `xai/connect`. Now validated against the provider's live catalog when
  one is available.

- `?` on an empty composer typed a literal character instead of opening
  Help, contradicting Help's own advertised shortcut. Now opens Help when
  the composer is empty; typing `?` mid-message is unaffected.

* Apply cargo fmt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant