H3: Phpactor UX: fast tick while indexing, progress, messages, php -l

- Session tick: 1 ms while Phpactor reports work-done progress and in a
  session's first 120 s, otherwise 25 ms as before. Fast intervals use
  thread::sleep, because recv_timeout wakes at most ~64/s on Windows.
  First useful completion on 2,000 classes: 71.6 s -> 20.7-26.9 s.
- $/progress -> lspProgress {active, title?, message?, percentage?},
  progress in lsp.status, a status-bar item (LspProgressItem).
- window/showMessage -> notification.lsp.message (repeats within 30 s and
  the known Windows lint-provider complaint only logged); showMessage,
  logMessage and stderr in a 1,000-line log, new command lsp.log.
- Lutra's own php -l on Windows (lsp/php_lint.rs): on open and save, one
  worker thread, lutra_proc::spawn, stdin, 10 s timeout, output caps;
  merged into diagnosticsChanged with source "php -l".
- editor.completion.delayMs stays 0 (measured: 100 ms only delays the
  list; Phpactor marks every list incomplete).
- Fake server: scripted notifications after initialized.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-10-25 17:33:26 +01:00
parent 8701f50d37
commit e128400246
21 changed files with 1752 additions and 48 deletions

View file

@ -1,5 +1,6 @@
//! Language server commands of M3.3: `diagnostics.list`, `lsp.status` and
//! `lsp.restart`. The wiring itself lives in [`crate::lsp`].
//! `lsp.restart`, and `lsp.log` (H3). The wiring itself lives in
//! [`crate::lsp`].
use serde::Deserialize;
use serde_json::{Value, json};
@ -16,6 +17,7 @@ pub fn register(registry: &mut Registry) -> Result<(), EngineError> {
registry.register(Box::new(List))?;
registry.register(Box::new(Status))?;
registry.register(Box::new(Restart))?;
registry.register(Box::new(Log))?;
Ok(())
}
@ -70,15 +72,20 @@ impl Command for Status {
label: "Language Server Status",
menu_path: None,
default_shortcut: None,
params: "none; returns { state: starting|ready|restarting|failed|stopped, message?, startupMs? } (startupMs: from start to the first ready)",
params: "none; returns { state: starting|ready|restarting|failed|stopped, message?, startupMs?, progress: { active, title?, message?, percentage? } } (startupMs: from start to the first ready; progress: the newest running work-done progress task, as lspProgress reports it)",
}
}
fn run(&self, state: &mut State, _params: Value) -> Result<Outcome, EngineError> {
let mut value = serde_json::to_value(state.lsp.status())
.map_err(|e| EngineError::Internal(e.to_string()))?;
if let (Some(ms), Some(object)) = (state.lsp.startup_ms(), value.as_object_mut()) {
object.insert("startupMs".into(), Value::from(ms));
let progress = serde_json::to_value(state.lsp.progress())
.map_err(|e| EngineError::Internal(e.to_string()))?;
if let Some(object) = value.as_object_mut() {
if let Some(ms) = state.lsp.startup_ms() {
object.insert("startupMs".into(), Value::from(ms));
}
object.insert("progress".into(), progress);
}
Ok(Outcome::value(value))
}
@ -108,3 +115,23 @@ impl Command for Restart {
Ok(Outcome::value(Value::Null))
}
}
/// `lsp.log`: the language server's recent messages, log messages and
/// stderr lines, oldest first.
pub struct Log;
impl Command for Log {
fn spec(&self) -> &CommandSpec {
&CommandSpec {
id: "lsp.log",
label: "Show PHP Language Server Log",
menu_path: None,
default_shortcut: None,
params: "none; returns { lines: string[] }, oldest first, at most 1000: \"[level] text\" for window/logMessage, \"[show level] text\" for window/showMessage, \"[stderr] text\" for stderr lines",
}
}
fn run(&self, state: &mut State, _params: Value) -> Result<Outcome, EngineError> {
Ok(Outcome::value(json!({ "lines": state.lsp.log() })))
}
}