positron icon indicating copy to clipboard operation
positron copied to clipboard

Positron Assistant "Apply in Editor" fails

Open jonvanausdeln opened this issue 9 months ago • 3 comments

System details:

Positron and OS details:

Positron Version: 2025.05.0 (system setup) build 26
Code - OSS Version: 1.98.0
Commit: f034cf42c2707c46479841ef5fbe3a68ae255053
Date: 2025-04-08T03:45:02.257Z
Electron: 34.2.0
Chromium: 132.0.6834.196
Node.js: 20.18.2
V8: 13.2.152.36-electron.0
OS: Windows_NT x64 10.0.26100

Interpreter details:

N/A

Using Cluade 3.5 Sonnet LLM

Describe the issue:

When trying to apply code from the chat into the editor, it fails and gives an error.

Steps to reproduce the issue:

  1. Open a python or R file
  2. Ask Positron Assistant for some code changes
  3. Try to "Apply in Editor" selection

https://github.com/user-attachments/assets/5b9183d6-fdc7-4495-8a7a-567de1d97ed9

Expected or desired behavior:

Code changes to be applied

Were there any error messages in the UI, Output panel, or Developer Tools console?

DEBUG [CHAT] extension request DONE positron.positron-assistant 233198 workbench.desktop.main.js:20985 ERR l is not iterable: TypeError: l is not iterable at Object.provideMappedEdits (c:\Program Files\Positron\resources\app\extensions\positron-assistant\dist\extension.js:2:549673) at async _$lRc.$mapCode (file:///c:/Program%20Files/Positron/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:79775:20)

jonvanausdeln avatar Apr 08 '25 22:04 jonvanausdeln

Recent regression; I JUST fixed this in #6960.

jmcphers avatar Apr 09 '25 23:04 jmcphers

Possibly a Windows path issue? Currently working for me on macOS

jmcphers avatar May 08 '25 15:05 jmcphers

Could be Windows only.. I just repro'd again when using "ask" mode, and tried "Apply in editor" to the code block

Image

jonvanausdeln avatar May 11 '25 00:05 jonvanausdeln

@jmcphers , this still doesn't appear to be working for me

Image

It works for me on Ubuntu 24 and MacOS, but I still see the error on Windows

jonvanausdeln avatar Jun 05 '25 20:06 jonvanausdeln

Shoot, I still can't reproduce this on Windows, but I'll try by using files that look more like yours. Moving back to the Backlog.

jmcphers avatar Jun 07 '25 00:06 jmcphers

I paired with @jonvanausdeln to debug this. It turns out that this isn't a Windows issue at all; it is due to being signed into to the Echo provider and the Anthropic provider simultaneously.

When making a request to Apply in Editor, the selected model for the associated chat session is not sent to the provider (Assistant extension). Consequently, the provider just picks the first available model as a fallback.

https://github.com/posit-dev/positron/blob/5e2561a20b0ac6ae9755fad6271ae90a37b8b89a/extensions/positron-assistant/src/edits.ts#L80-L85

So, we're not asking Anthropic to map edits -- we're asking the Echo provider, which just returns the request as the response. Of course, that means the response doesn't have the format we assume it does, resulting in errors.

The correct fix here would be to fix the edit tool so that it uses the chat model selected in the Chat pane, not whatever chat model was registered first. But since we're single provider right now, I'm going to argue we can defer this.

jmcphers avatar Jun 17 '25 18:06 jmcphers

Verified Fixed

Positron Version(s) : 2025.08.0-18 OS Version(s) : Windows 11

Test scenario(s)

Apply in editor works as expected!

jonvanausdeln avatar Jul 02 '25 16:07 jonvanausdeln