Chat implicit "active selection" context stays stuck after its source document is closed/deleted
@justschen is already working on this.
Since Jun 18, 2026.
Assessment
This issue has not been assessed yet.
Description
Copilot Chat Extension Version: 0.53.0
VS Code Version: Version: 1.125.0 (Universal)
Commit: 93cfdd489c3b228840d0f86ec77c3636277c93ea
Date: 2026-06-15T22:24:03Z
OS Version: macOS 26.5 (25F71) — Darwin 25.5.0 arm64
Feature (e.g. agent/edit/ask mode): Agent mode (applies to all chat modes)
Selected model (e.g. GPT 4.1, Claude 3.7 Sonnet): All models (model-independent)
Logs: na (no related entries in Copilot Chat log — see Debug data)
Steps to Reproduce:
- Open a document and select some text → it attaches as the implicit "active selection" context chip in the Chat input.
- Delete or close that document while its editor stays focused.
- Submit a chat turn → the stale selection is still attached.
- Try to remove it via "unpin" in the chat window → it only suppresses for one send and re-attaches next turn.
( Symbol pin is still "not attached" though, but visible in Chat window and also llm agrees to see it fresh again. ) - Focus another editor chat window → the chip frequently persists. Cannot get rid of it.
- Make a fresh text selection / copy text in another editor (or open a real file with a selection) → only now does the chip clear.
Remark: _WriteUp via Opus 4.8 of the situation was performend from here on
Summary
The Chat input's implicit "active selection" context is bound to the last active text selection and is only invalidated on the next selection-change event. Closing or deleting the backing document emits no such event, so the chip remains attached and keeps being sent on every turn. "Unpin" does not remove it permanently, and merely focusing another editor is often insufficient.
Current Behaviour
After the source document is closed/deleted, the active-selection chip lingers in the input and re-attaches each turn. It is only cleared when a new selection-change fires elsewhere (selecting/copying text in another editor, or opening a real file with a selection). Reproduced with both a memory:-scheme virtual document and a regular workspace file.
Expected Behaviour
When the backing document of an implicit active-selection context is closed or deleted, the context should be invalidated immediately. Unpinning the chip should also remove it permanently rather than for a single submission.
Workaround
Trigger a fresh selection-change — select or copy text in another editor, or open a different file — which replaces the stale reference. Alternatively start a New Chat or reload the window.
Impact
Stale, unremovable context silently pollutes every subsequent turn, wasting tokens and skewing the model's grounding toward a deleted document, with no reliable UI affordance to clear it.
Debug data
Reviewed GitHub.copilot-chat/GitHub Copilot Chat.log across all windows for the session — no related error/warning is logged, consistent with a renderer-side chat-widget state issue rather than an extension fault. Only unrelated entries were present ([CopilotCLIModels] 401 Unauthorized: Bad credentials at startup, and a benign Error compiling input schema for tool run_in_terminal: unknown keyword "enumDescriptions").
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.9k
- PR merge metrics
- PR metrics pending
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/vscode
-
testplan-item
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
new release
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
testplan-item
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
testplan-item
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
All issues in microsoft/vscode
Similar issues
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 76/100
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
vercel/react-tweet#225 ·