nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] Restarting ACP creates a new backend session without resetting or re-syncing the webview transcript

Open akramcodez opened this issue 1 month ago • 2 comments

Description

Running nanocoder.restartAcp disposes and restarts the child CLI process. NanocoderAcpClient.setConnection() clears this._sessionId = undefined. When the new process connects and handshake finishes, _initializeSessionIfReady() automatically creates a brand-new backend session. However, the webview transcript is never cleared, reloaded, or notified. The user sees their prior conversation, but the new backend agent has zero context from earlier turns.

Environment

  • OS: Linux (reviewed); macOS / Windows potentially affected
  • Node version: >= 22.0.0
  • Nanocoder version: 1.31.0

Steps to Reproduce

  1. Carry out a conversation with Nanocoder in the chat webview.
  2. Run command Nanocoder: Restart Nanocoder Agent Process (nanocoder.restartAcp).
  3. Notice that the chat transcript remains visible.
  4. Send a follow-up question referencing an earlier turn (e.g., "What did we just discuss?").

Expected Behavior

After ACP restarts:

  • The extension should automatically attempt to resume the last active session ID on the new process, OR
  • The webview transcript should be explicitly reset with an announcement that the agent process was restarted in a fresh session.

Actual Behavior

The webview displays the old conversation, but prompts are dispatched to a blank backend session with no prior history.

Logs/Screenshots

(Illustrative control flow from source inspection)

Manually restarting ACP process...
[Extension] Webview ready; waiting for ACP handshake.
ACP Initialized.
[Extension] Session initialized automatically: session-new-uuid
// Webview transcript never received {type: 'clear'} or history reload

Additional Context

  • [x] No matching open issue found in issue search performed on 2026-10-12
  • [x] Relevant code paths inspected at commit d5ff9c37

Implementation Notes (optional)

  • Files:
    • plugins/vscode/src/extension.ts:109-117
    • plugins/vscode/src/chat-webview-provider.ts:512-536
  • Track the last active sessionId before disposing AcpProcessManager.
  • In _initializeSessionIfReady(), attempt resumeSession(previousSessionId) before falling back to newSession(). If falling back to a new session, notify the webview to clear and announce the reset.

akramcodez avatar Oct 12 '26 11:10 akramcodez

Would love to work on this issue will soon propose my plan!

rishu685 avatar Oct 12 '26 15:10 rishu685

Hi @rishu685, I’m assigning this one to you. I’ll review your PR this time. Going forward, please comment on the issue first and wait until you’re assigned before you start working on it. That way we avoid duplicate work and keep things fair for everyone. Thanks for contributing!

addyCooks avatar Nov 06 '26 07:11 addyCooks