nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] Esc during a streaming reply discards the partial text from the screen and from history

Open akramcodez opened this issue 1 week ago • 1 comments

Description

Pressing Esc while a reply is streaming throws away everything the model had already streamed, both on screen and in the history. The chat only shows Interrupted by user., and the next request carries two user messages in a row with no assistant turn between them.

People usually interrupt because of what they just read ("no, not that file"). After the interrupt they can't scroll back to it, and the model doesn't know what it had said, so a follow-up like "stop, do the second option instead" has nothing to refer to. The aborted case keeps cancelled tool calls in history but not streamed text.

Environment

  • OS: macOS 27.2
  • Node version: v22.23.4
  • Nanocoder version: 1.32.0 (main at f181f0ed)
  • Provider: OpenAI-compatible (streaming)
  • Model: any

Steps to Reproduce

  1. Ask for a long answer, so the reply streams for a few seconds.
  2. Press Esc when part of it is on screen.
  3. Send a follow-up message.

Expected Behavior

The streamed text stays in the transcript, marked as interrupted, and is kept in history as an assistant message (with a short note that it was cut off by the user), so the follow-up has context.

Actual Behavior

The partial text disappears from the screen. The request for the follow-up contains:

[system, {user: "first"}, {user: "queued followup"}]

with no assistant message for the interrupted turn.

Logs/Screenshots

This is separate from taking back a prompt with Esc before any output arrives, which should keep working as documented: that case has no partial text to keep.

Additional Context

  • [x] I have searched existing issues to ensure this is not a duplicate
  • [x] I can reproduce this issue consistently
  • [x] This issue occurs with the latest version of nanocoder

akramcodez avatar Nov 25 '26 08:11 akramcodez

I'd like to take this one if it's still free — may I be assigned? Happy to start from a failing test for the streaming + Esc case.

787164510-sudo avatar Nov 25 '26 10:11 787164510-sudo