Skip to content

fix(session): publish the operator's prompt as the turn starts - #663

Merged
mohitranka merged 1 commit into
mainfrom
forge/The-user-message-only-shows-up-once-ithe
Sep 13, 2026
Merged

mohitranka merged 1 commit into
mainfrom
forge/The-user-message-only-shows-up-once-ithe

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

Problem

In supervised (repository multi-session) mode the TUI holds no direct session handle, so the conversation is painted from the actor's published snapshot. run_one_inner appended the operator's prompt to the session but published nothing until the turn's closing refresh_actor.

The transcript therefore lagged a whole turn: the reply streamed in with no question above it, and the operator's own message only appeared once the response landed.

The direct single-session path already paints the YOU message immediately (drain_pending_prompt_with_terminal), so this was supervised-only.

Fix

crates/forge-session/src/supervisor.rs: publish the snapshot as soon as the session records the prompt, before the model is asked anything. This is the same pattern ResolveQuestion, SetModel and the Refresh command already use, and calling refresh_actor while holding the session lock is already precedented by Refresh.

Queued prompts are unaffected: while a session is busy the prompt is shown from queued_prompts, and the new publish fires when the driver claims it and records it.

Test

the_operator_message_shows_before_the_answer_lands in crates/forge-tui/src/app/tests/multi_task.rs: a gate holds the model open, and the test requires the operator's message in the transcript (and in the rendered frame) while the turn is Running and no assistant message exists yet.

  • Fails on a clean tree: timed out waiting for 1 user messages (got 0)
  • Passes with the fix

Validation

  • cargo test --package forge-session --locked: 70 passed, 1 pre-existing failure (primary_and_managed_actors_share_hitl_question_and_continue_commands needs a working sandbox-exec, which this environment refuses; it fails identically without this change)
  • cargo test --package forge-tui --locked app::tests: 421 passed, 4 pre-existing failures, all sandbox-exec: sandbox_apply: Operation not permitted on the direct-path bash/background-tool tests
  • cargo fmt --all -- --check clean
  • cargo clippy --package forge-session --package forge-tui --all-targets --locked -- -D warnings clean

In supervised mode the conversation is painted from the actor's snapshot,
and the actor published nothing between appending the operator's message
and the turn's closing refresh. The transcript therefore lagged a whole
turn: the answer streamed in with no question above it, and the message
only appeared once the response landed.

Publish the snapshot as soon as the session records the prompt, matching
what ResolveQuestion, SetModel and Refresh already do.

Regression test: crates/forge-tui/src/app/tests/multi_task.rs holds the
model on a gate and requires the operator's message on screen while no
assistant message exists yet.
@mohitranka
mohitranka merged commit 2cbb425 into main Sep 13, 2026
3 checks passed
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