PM: merge H3 Phpactor UX: fast indexing tick, progress, messages, php -l
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
ac007a7d59
21 changed files with 1752 additions and 48 deletions
|
|
@ -1,11 +1,13 @@
|
|||
<script setup lang="ts">
|
||||
/**
|
||||
* Status bar along the bottom of the main window. Shows the product name and
|
||||
* version, or the last engine error.
|
||||
* version, or the last engine error, and on the right the language server's
|
||||
* progress (H3).
|
||||
*/
|
||||
import { computed } from "vue";
|
||||
import { t } from "../i18n";
|
||||
import { useAppStore } from "../stores/app";
|
||||
import LspProgressItem from "./problems/LspProgressItem.vue";
|
||||
|
||||
const app = useAppStore();
|
||||
|
||||
|
|
@ -25,6 +27,7 @@ const label = computed(() => {
|
|||
data-test="status-bar"
|
||||
>
|
||||
<span>{{ label }}</span>
|
||||
<LspProgressItem />
|
||||
</footer>
|
||||
</template>
|
||||
|
||||
|
|
|
|||
84
ui/src/components/problems/LspProgressItem.vue
Normal file
84
ui/src/components/problems/LspProgressItem.vue
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
<script setup lang="ts">
|
||||
/**
|
||||
* Status-bar item (H3): the language server's running work-done progress
|
||||
* task (`lspProgress`), such as Phpactor indexing the workspace, with its
|
||||
* title and percentage. Its latest message (`500/2001 (24.99%, …)`) is the
|
||||
* tooltip. Hidden while no task runs. State comes from the Problems store.
|
||||
*/
|
||||
import { LoaderCircle } from "@lucide/vue";
|
||||
import { computed } from "vue";
|
||||
import { t } from "../../i18n";
|
||||
import { useProblemsStore } from "./problems";
|
||||
|
||||
const problems = useProblemsStore();
|
||||
|
||||
/** The visible text, or null when no task runs. */
|
||||
const text = computed(() => {
|
||||
const progress = problems.progress;
|
||||
if (!progress) {
|
||||
return null;
|
||||
}
|
||||
const title = progress.title === "" ? t("problems.lsp.progress.working") : progress.title;
|
||||
return progress.percentage === null
|
||||
? title
|
||||
: t("problems.lsp.progress.percentage", { title, percentage: progress.percentage });
|
||||
});
|
||||
|
||||
/** The tooltip and accessible label. */
|
||||
const label = computed(() => {
|
||||
const progress = problems.progress;
|
||||
if (!progress || text.value === null) {
|
||||
return "";
|
||||
}
|
||||
const base = t("problems.lsp.progress.label", { title: text.value });
|
||||
return progress.message ? `${base} (${progress.message})` : base;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span
|
||||
v-if="text !== null"
|
||||
class="lsp-progress"
|
||||
role="status"
|
||||
:title="label"
|
||||
:aria-label="label"
|
||||
data-test="lsp-progress"
|
||||
>
|
||||
<LoaderCircle
|
||||
class="lsp-progress__icon"
|
||||
:size="12"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span>{{ text }}</span>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.lsp-progress {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
margin-left: auto;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 40%;
|
||||
}
|
||||
|
||||
.lsp-progress__icon {
|
||||
flex: none;
|
||||
animation: lsp-progress-spin 1.2s linear infinite;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.lsp-progress__icon {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes lsp-progress-spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@
|
|||
"notification.close": "Close notification",
|
||||
"notification.command.failed": "{command} failed: {message}",
|
||||
"notification.lsp.failed": "The PHP language server stopped: {reason}. Run Restart PHP Language Server to try again.",
|
||||
"notification.lsp.message": "PHP language server: {message}",
|
||||
"notification.lsp.renamed": "Renamed to {name}: {edits} changes in {files} files ({written} closed files saved)",
|
||||
"notification.project.notLocal": "The chosen folder is not on this computer: {reason}",
|
||||
"notification.project.openFailed": "Cannot open {path}: {reason}",
|
||||
|
|
@ -156,6 +157,9 @@
|
|||
"problems.file.count": "{count} problems",
|
||||
"problems.list.label": "Problems of the project",
|
||||
"problems.lsp.failed": "Phpactor stopped: {message}",
|
||||
"problems.lsp.progress.label": "Language server: {title}",
|
||||
"problems.lsp.progress.percentage": "{title} {percentage}%",
|
||||
"problems.lsp.progress.working": "Language server working…",
|
||||
"problems.lsp.restarting": "Phpactor is restarting: {message}",
|
||||
"problems.lsp.starting": "Phpactor is starting…",
|
||||
"problems.lsp.stopped": "No PHP language server is running. It starts when PHP and Phpactor are available.",
|
||||
|
|
|
|||
|
|
@ -128,6 +128,17 @@ export type EngineEventPayload =
|
|||
/** Why it restarts or failed; unchecked. */
|
||||
message?: unknown;
|
||||
}
|
||||
| {
|
||||
kind: "lspProgress";
|
||||
/** Whether a work-done progress task runs; unchecked. */
|
||||
active: unknown;
|
||||
/** Its title; unchecked. */
|
||||
title?: unknown;
|
||||
/** Its latest message; unchecked. */
|
||||
message?: unknown;
|
||||
/** 0–100; unchecked. */
|
||||
percentage?: unknown;
|
||||
}
|
||||
| {
|
||||
kind: "diagnosticsChanged";
|
||||
/** Project-relative path of the file; unchecked, it comes from the engine. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue