Repository navigation
IDE/editor context persists after closing file #24184
Description
Activity
- addedopentuiThis relates to changes in v1.0, now that opencode uses opentuiThis relates to changes in v1.0, now that opencode uses opentui
on Apr 24, 2026 I am also seeing the same issue in WSL. There is no obvious way around it, because once a selection is made it sticks, even if you then start opencode from the terminal.
Using /new does not clear it either
I asked opencode to analyse the issue. This is what it diagnosed and i can confirm the workaround works
Root Cause
The editor.ts context introduced in v1.14.23 scans
~/.claude/ide/*.lockfiles — these are written by the Claude Code VS Code extension (not OpenCode's own extension). It finds the lock file for your workspace, opens a WebSocket to VS Code, and subscribes toselection_changedevents.The bug is that
store.selectionis never cleared. When you close the file or move away in VS Code, the WebSocket either goes silent (noselection_changedevent fires tonullthe selection) or the connection drops and reconnects — but on reconnect there's no"clear selection"event, so the last known value persists in the store indefinitely.
Workarounds (no downgrade needed)
Most effective — delete the lock files:
rm ~/.claude/ide/*.lockReacted by Gabriel FilipekThanks, the workaround seems to be working. But it's still annoying to do, and I'd rather see it fixed on OpenCode's side if possible.
Please fix this. It's so annoying. the file is stuck in the context at all time. I'm having this behavior in Windows, macOS and WSL.
@dacarey Thank you for the workaround. This did the trick for the time being. 👍🏻
I have a PR that addresses part of this behaviour #24323
but for what it's worth claude code extension never emits the info that the files are closed unfortunately
Reacted by Faisal Alkheraiji and Bian PratamaI have a PR that addresses part of this behaviour #24323
but for what it's worth claude code extension never emits the info that the files are closed unfortunately
Thank you for identifing the root cause. I disbaled Claude Code extension in VSCode until this is fixed
I have a PR that addresses part of this behaviour #24323
but for what it's worth claude code extension never emits the info that the files are closed unfortunatelyThank you for identifing the root cause. I disbaled Claude Code extension in VSCode until this if fixed
Yes, I did these things too for the time being:
- Disable the Claude Code VS Code extension.
- Delete the lock files:
rm ~/.claude/ide/*.lock.
thank for this report, acknowledged, I know what the issue is and I will fix it asap! will be fixed in the next version (either tonight or tomorrow morning)
Reacted by Faisal Alkheraiji and Gabriel Filipekby the way, if this feature worked as expected, do you find this feature useful?
Reacted by Gabriel Filipekby the way, if this feature worked as expected, do you find this feature useful?
@jlongster yes definitely. It worked great the first time i used it in a single focussed session. and after looking through your PR work i think theres tons of value with a nicely exposed API for other plugins to tap into.
I would find it quite useful. Even better if I could highlight a specific part of the file, like a function or whatever, and OC would see the file and my highlighted text. Could be a nice way to point it to specific things.
But as long as there is no stale context after closing the file, everything else is a bonus.
Thanks for quick response.Even better if I could highlight a specific part of the file, like a function or whatever, and OC would see the file and my highlighted text
@gabethehuman that's exactly what it does! if you select some code you'll see the filename + the selected range and it will send that file, selection range, and the highlighted section as text as context
Great :) If it disappears from the context after I close the file, then I will use the hell out of that feature :)
Sorry if this is a stupid question, but is there a way to disable this? My vscode is rarely ever in-sync with what im doing in opencode so it kinda seems like context pollution for those that dont want it.
Reacted by Vinícius Gonçalves de Oliveira, Gabriel Filipek and SD#24661 improves this feature and adds the ability to disable it
The PR:
- Improves the prompt to make it clear that might not be relevant
- Only sends the context once. If you keep prompting, it won't send it again unless you move around in the editor
These changes should reduce the chance that this context will pollute anything. We'd like to keep this on because it's much more likely to be helpful and it's not very discoverable, but we've added a way to opt-out: you can open commands (ctrl+p) and select "Disable file context" to turn it off entirely (this will be global for your machine)
Reacted by SD and Gabriel FilipekRegarding the original issue: unfortunately we aren't able to solve this right now. Most of you are using the Claude Code extension to host the server, and it doesn't send any event when the file closes and no new file is open. Until we develop our own plugins and have more control, we can't fix that
However, since we've tweaked the prompts and only send it once it'll only be sent with the next prompt, after which it will go away
Reacted by Jermiah JosephIn the next version, you can select "Disable file context" from the command menu to disable it
Reacted by Faisal Alkheraiji and Jermiah JosephThank you @jlongster for providing option to disable this. I can see the use case of this feature. However, having the flexibility to enable/disable it is the way to go
this should be released
my mistake, it wasn't released yet but we have a release going out now
Reacted by Gabriel Filipek
Description
Since 1.14.23, OpenCode shows the currently-open file in the TUI prompt area, e.g.
testfile.py.Problem:
When I close that file in the editor, OpenCode keeps showing/injecting the old file context. The LLM then assumes my unrelated prompt is about that stale file and tries to modify it.
Expected:
When the active editor file is closed, OpenCode should clear the editor context and stop injecting "user opened this file" or equivalent context into the prompt.
Plugins
No response
OpenCode version
1.14.23
Steps to reproduce
opencodein VSCode terminalScreenshot and/or share link
we open file,

testfile.pyappears near the bottom:we close this file,

testfile.pyremainsOperating System
WSL2 inside Windows 11, latest versions.
Terminal
Bash inside VSCode, WSL2