Positron Assistant "Apply in Editor" fails
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:
- Open a python or R file
- Ask Positron Assistant for some code changes
- 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)
Recent regression; I JUST fixed this in #6960.
Possibly a Windows path issue? Currently working for me on macOS
Could be Windows only.. I just repro'd again when using "ask" mode, and tried "Apply in editor" to the code block
@jmcphers , this still doesn't appear to be working for me
It works for me on Ubuntu 24 and MacOS, but I still see the error on Windows
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.
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.
Verified Fixed
Positron Version(s) : 2025.08.0-18 OS Version(s) : Windows 11
Test scenario(s)
Apply in editor works as expected!