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:
parent
8701f50d37
commit
e128400246
21 changed files with 1752 additions and 48 deletions
|
|
@ -6,6 +6,10 @@
|
|||
* list (empty items remove the file); `diagnostics.list` loads every
|
||||
* file on start and when a project opens, and `lsp.status` the server's
|
||||
* state, which then follows `lspStatus`. A project close clears both.
|
||||
* - **Progress (H3):** the server's newest work-done progress task
|
||||
* (`progress` of `lsp.status`, then `lspProgress`), shown by
|
||||
* `LspProgressItem` in the status bar. It clears when the server stops,
|
||||
* restarts or fails, and on project close.
|
||||
* - **Editor:** every change is handed to the editor's lint extension
|
||||
* ({@link publishDiagnostics}), which draws the underlines and gutter
|
||||
* markers.
|
||||
|
|
@ -48,6 +52,16 @@ export interface LspStatus {
|
|||
message: string | null;
|
||||
}
|
||||
|
||||
/** The language server's newest running work-done progress task. */
|
||||
export interface LspProgress {
|
||||
/** Its title, such as `Indexing workspace`. */
|
||||
title: string;
|
||||
/** Its latest message, if any. */
|
||||
message: string | null;
|
||||
/** 0–100, if the server gives one. */
|
||||
percentage: number | null;
|
||||
}
|
||||
|
||||
/** The diagnostics of one file. */
|
||||
export interface ProblemFile {
|
||||
/** Project-relative path with `/`. */
|
||||
|
|
@ -160,6 +174,30 @@ export function toStatus(raw: unknown): LspStatus | null {
|
|||
return { state: known, message: typeof message === "string" ? message : null };
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the payload of `lspProgress` or the `progress` of `lsp.status`.
|
||||
*
|
||||
* @param raw - untrusted.
|
||||
* @returns the running task, or null when none runs or it is malformed.
|
||||
*/
|
||||
export function toProgress(raw: unknown): LspProgress | null {
|
||||
if (typeof raw !== "object" || raw === null) {
|
||||
return null;
|
||||
}
|
||||
const { active, title, message, percentage } = raw as Record<string, unknown>;
|
||||
if (active !== true) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
title: typeof title === "string" ? title.slice(0, 200) : "",
|
||||
message: typeof message === "string" ? message.slice(0, 500) : null,
|
||||
percentage:
|
||||
typeof percentage === "number" && Number.isFinite(percentage)
|
||||
? Math.round(Math.min(100, Math.max(0, percentage)))
|
||||
: null,
|
||||
};
|
||||
}
|
||||
|
||||
/** The Problems store. */
|
||||
export const useProblemsStore = defineStore("problems", () => {
|
||||
/** Whether the tool window is shown in the bottom panel. */
|
||||
|
|
@ -170,6 +208,8 @@ export const useProblemsStore = defineStore("problems", () => {
|
|||
const files = shallowRef<ProblemFile[]>([]);
|
||||
/** The language server's state; null before the first report. */
|
||||
const lsp = ref<LspStatus | null>(null);
|
||||
/** The server's running work-done progress task; null when none. */
|
||||
const progress = ref<LspProgress | null>(null);
|
||||
/** Key of the selected row. */
|
||||
const selectedKey = ref<string | null>(null);
|
||||
/** Bumped when the window should take the keyboard focus. */
|
||||
|
|
@ -226,6 +266,9 @@ export const useProblemsStore = defineStore("problems", () => {
|
|||
const [list, status] = await Promise.all([run("diagnostics.list"), run("lsp.status")]);
|
||||
if (status.ok) {
|
||||
lsp.value = toStatus(status.value) ?? lsp.value;
|
||||
const value = status.value;
|
||||
const raw = typeof value === "object" && value !== null && !Array.isArray(value) ? value.progress : null;
|
||||
progress.value = toProgress(raw);
|
||||
}
|
||||
if (!list.ok) {
|
||||
return;
|
||||
|
|
@ -255,9 +298,15 @@ export const useProblemsStore = defineStore("problems", () => {
|
|||
}
|
||||
} else if (event.kind === "lspStatus") {
|
||||
lsp.value = toStatus(event) ?? lsp.value;
|
||||
if (lsp.value && lsp.value.state !== "ready" && lsp.value.state !== "starting") {
|
||||
progress.value = null;
|
||||
}
|
||||
} else if (event.kind === "lspProgress") {
|
||||
progress.value = toProgress(event);
|
||||
} else if (event.kind === "projectClosed") {
|
||||
clear();
|
||||
lsp.value = null;
|
||||
progress.value = null;
|
||||
} else if (event.kind === "projectOpened") {
|
||||
void load();
|
||||
}
|
||||
|
|
@ -323,6 +372,7 @@ export const useProblemsStore = defineStore("problems", () => {
|
|||
expanded,
|
||||
files,
|
||||
lsp,
|
||||
progress,
|
||||
rows,
|
||||
counts,
|
||||
selectedKey,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue