fix(lsp): Start JSON-RPC requests after the notifications before them

ide-jsonrpc handled incoming notifications in order on a dedicated thread
but started each incoming request on its own blocking task right away, so
a request could be handled before a notification that arrived ahead of
it. The mock language server in the ide-lsp tests answered
`textDocument/references` before applying the `didOpen` of a file opened
for a project-wide search (missing results, a search finishing before the
test could cancel it or open the file), and on the client side an ACP
`session/request_permission` could overtake the `session/update` that
announced its tool call (ide-agent polled for up to 200 ms to cover it).

A request now starts once every notification received before it has been
handled; requests still run concurrently. The ide-agent polling is gone.

Tests no longer depend on timing:
- the references tests hold the mock's answer with a gate and cancel or
  open the file while it is held, instead of sleeping and measuring;
- the indexing retry ends indexing once the first answer is out;
- the crash/restart test counts Ready/Crashed statuses instead of reading
  the last one, which a restart can already have replaced;
- the mock records a notification under the same lock as its effect, and
  `eventually` waits up to 30 s;
- the TCP tests hold their port bound (not listening) instead of freeing
  it for another test to take, and listen only after the command started.

Claude-Session: https://claude.ai/code/session_01VUYsdXA2nkF5v6zsC93dpn
Цей коміт міститься в:
l0ng-ai committed 2026-10-27 21:57:42 +08:00
1 джерело 2fe6b7b87b
коміт 00a647daa2
6 files changed
+126 -53

No files matched your search

-9
Переглянути файл
@@ -923,15 +923,6 @@ impl Task {
.collect()
})
.unwrap_or_default();
// The tool call it is about arrives as a notification on another thread: let it land first.
if let Some(tool) = params.pointer("/toolCall/toolCallId").and_then(Value::as_str) {
for _ in 0..20 {
if self.state.lock().timeline.has_tool(tool) {
break;
}
std::thread::sleep(Duration::from_millis(10));
}
}
let (tx, rx) = std::sync::mpsc::channel();
let entry = self.push_entry(AgentEntry::Permission { id, title, options: options.clone(), chosen: None });
self.permissions.lock().insert(id, tx);
-4
Переглянути файл
@@ -37,10 +37,6 @@ impl Timeline {
t
}
pub fn has_tool(&self, id: &str) -> bool {
self.tools.contains_key(id)
}
pub fn push(&mut self, entry: AgentEntry) -> usize {
self.entries.push(entry);
self.entries.len() - 1