[BUG] Agents view drops inbound IDE `at_mentioned` and clears `selection_changed` context for the IDE-connected session
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When the agents view is focused, the CLI silently discards at_mentioned notifications arriving on the IDE WebSocket connection, and clears the tracked selection/current-file context. The IDE still sends both; nothing reaches the prompt and no error is surfaced anywhere.
The handlers for both notifications are keyed to the IDE client of the currently focused context. The agents view focuses an agent whose MCP client list contains no ide client, so the resolver returns undefined, the previously registered handler sees a stale identity, and the notification is dropped on the floor.
This affects any IDE integration over the documented IDE WebSocket protocol. It was found via claudecode.nvim#249, where the plugin's maintainer verified with an instrumented fake IDE client that both notifications are delivered to the CLI:
RECV selection_changed filePath=.../sample.lua isEmpty=false line=0..7
RECV at_mentioned filePath=.../sample.lua lineStart=0 lineEnd=7
Setting CLAUDE_CODE_DISABLE_AGENT_VIEW=1 restores the expected behavior, which isolates the agents view as the cause.
The IDE holds a single connection and has no visibility into — or influence over — which agent the CLI has focused, so this is not addressable from the integration side.
What Should Happen?
Inbound IDE notifications should reach the IDE-connected session regardless of which view has focus. Either:
- Route
at_mentioned/selection_changedto the session that owns the IDE connection, independent of the focused context; or - Forward them to the focused agent.
At minimum they should not be silently discarded — and selection_changed should not actively clear already-valid file context on a focus change.
Error Messages/Logs
None. The failure is silent — the notification is discarded before any logging or telemetry path.
For evidence, here are the handlers extracted from the 2.1.267 binary (minified; names are mangled).
The shared resolver — finds the connected `ide` client **in the focused context's** client list:
function GH(e) {
if (!e) return;
let o = e.find((t) => t.type === "connected" && t.name === "ide");
return o?.type === "connected" ? o : void 0;
}
`at_mentioned` — the guard on the second line of the callback is where the notification is dropped:
var Ka = "at_mentioned",
ja = m(() => c({ method: k(Ka), params: c({ filePath: s(), lineStart: A().optional(), lineEnd: A().optional() }) }));
function N3e(l, b) {
let x = z(() => GH(l), [l]), O = v(void 0);
E(() => {
if (O.current = x, !x) return;
kI(x, ja(), (R) => {
if (O.current !== x) return; // <-- dropped: focused context is not this client
try {
let T = R.params,
w = T.lineStart !== void 0 ? T.lineStart + 1 : void 0,
I = T.lineEnd !== void 0 ? T.lineEnd + 1 : void 0;
b({ filePath: T.filePath, lineStart: w, lineEnd: I }), S("ide_at_mention");
} catch (T) { h(T), f("ide_at_mention", "ide_at_mention_failed"); }
});
}, [x, b]);
}
`selection_changed` — same guard, plus it actively resets the tracked file context when the resolved client changes:
function owe(w, I) {
let ee = v(!1), ae = v(null);
E(() => {
let ge = GH(w);
if (ae.current !== (ge ?? null))
ee.current = !1,
ae.current = ge || null,
I({ lineCount: 0, lineStart: void 0, text: void 0, filePath: void 0 }); // <-- clears current-file info
if (ee.current || !ge) return;
kI(ge, sZt(), (be) => {
if (ae.current !== ge) return; // <-- same drop
...
});
ee.current = !0;
}, [w, I]);
}
Because the `at_mentioned` payload is only `{ filePath, lineStart, lineEnd }`, there is no session or agent identifier an IDE could set to steer routing.
Steps to Reproduce
- Connect an IDE over the IDE WebSocket protocol (reproduced with claudecode.nvim; the same handler path serves all IDE integrations).
- Confirm at-mentions work: select text in the editor, send it, observe the
@file#L1-7mention land in the prompt. - Open the agents view and focus an agent.
- Select text in the editor and send it again.
- Nothing is inserted into the prompt, no error appears, and the current-file indicator is empty.
- Set
CLAUDE_CODE_DISABLE_AGENT_VIEW=1and repeat step 2 — works again.
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.267
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Other
Additional Information
_No response_