Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai 3fe3088bc8 fix(tools): offer an IDE copy only for a tool found on PATH
An executable chosen in settings wins over the IDE's own copy, so its
install button stays a plain Install.
2026-11-17 19:13:45 +08:00
l0ng-ai 1d9759dda7 feat(tools): show which language servers are interchangeable and which run together
- Interchangeable servers are one radio group (Automatic / each server / None),
  with the server that will run tagged In use.
- Servers that run alongside them are listed separately, each with its own
  on/off box in the list; the box in the details pane is gone.
- Missing tools in the language's banner jump to their row.
- A server found on PATH offers Install IDE Copy instead of a bare Install.
- Languages are listed by popularity; a search lists name matches first.
2026-11-17 17:04:38 +08:00
13 змінених файлів з 411 додано та 227 видалено

No files matched your search

+32
Переглянути файл
@@ -123,6 +123,10 @@
flex: 1;
}
.banner {
display: flex;
flex-wrap: wrap;
align-items: baseline;
gap: var(--space-2);
padding: 6px 8px;
border-radius: var(--radius-small);
background: var(--bg-control);
@@ -198,6 +202,34 @@
font-size: var(--fs-tiny);
line-height: 16px;
}
.runTag {
background: color-mix(in srgb, var(--success) 18%, transparent);
color: var(--success);
}
.lead {
display: flex;
flex: none;
align-items: center;
padding-left: 10px;
}
.lead + .tableMain {
padding-left: 6px;
}
.group {
display: flex;
flex-direction: column;
gap: var(--space-1);
}
.groupTitle {
display: flex;
align-items: baseline;
gap: var(--space-2);
color: var(--fg-strong);
}
.groupHint {
color: var(--fg-subtle);
font-size: var(--fs-small);
}
.updateTag {
background: color-mix(in srgb, var(--accent) 18%, transparent);
color: var(--accent);
+257 -39
Переглянути файл
@@ -5,21 +5,34 @@
* actions and settings under its table. Settings are staged in the dialog and
* written on Apply / OK; installs run right away.
*/
import { useEffect, useMemo, useState, type KeyboardEvent } from "react";
import { useEffect, useId, useMemo, useRef, useState, type KeyboardEvent, type ReactNode } from "react";
import clsx from "clsx";
import type { ToolInfo } from "@/bindings";
import { Badge, Button, EmptyState, fileIconName, Icon, IconButton, ProgressBar, SearchField, Spinner, T } from "@/ui";
import {
Badge,
Button,
Checkbox,
EmptyState,
fileIconName,
Icon,
IconButton,
ProgressBar,
Radio,
SearchField,
Spinner,
T,
} from "@/ui";
import { sampleFileName } from "@/platform/fileTypes";
import type { LanguageChoice } from "./backend";
import { onIdeEvent } from "@/platform/ipc";
import { useProject } from "@/platform/project";
import { useSettingsForm } from "@/workbench/contributions";
import {
AlternativesRow,
languageNames,
NewServerDialog,
Section,
ServerSettings,
setServerEnabled,
ToolSettings,
useLanguageChoices,
} from "./ServerSettings";
@@ -81,7 +94,45 @@ function languageEntry(name: string, tools: ToolInfo[]): LanguageEntry {
return { name, tools, missing, state };
}
/** One entry per language the tools serve, by name; tools serving none come last. */
/** Widely used languages first, most used first; the rest follow by name. */
const POPULAR = [
"JavaScript",
"TypeScript",
"Python",
"Java",
"C#",
"HTML",
"CSS",
"SQL",
"Shell Script",
"C++",
"C",
"Go",
"PHP",
"Rust",
"Kotlin",
"Swift",
"Ruby",
"Dart",
"Lua",
"Scala",
"PowerShell",
"Vue",
"Svelte",
"Astro",
"Elixir",
"Haskell",
"Zig",
];
/** A language's place in the list: JSX variants right after their language. */
function popularity(name: string): number {
const base = name.replace(/ JSX$/, "");
const i = POPULAR.indexOf(base);
return i < 0 ? POPULAR.length : i + (base === name ? 0 : 0.5);
}
/** One entry per language the tools serve, popular languages first; tools serving none come last. */
export function groupByLanguage(tools: readonly ToolInfo[]): LanguageEntry[] {
const byName = new Map<string, ToolInfo[]>();
for (const t of tools)
@@ -91,20 +142,28 @@ export function groupByLanguage(tools: readonly ToolInfo[]): LanguageEntry[] {
byName.set(lang, list);
}
return [...byName]
.sort(([a], [b]) => (a === OTHER ? 1 : b === OTHER ? -1 : a.localeCompare(b)))
.sort(([a], [b]) => (a === OTHER ? 1 : b === OTHER ? -1 : popularity(a) - popularity(b) || a.localeCompare(b)))
.map(([name, list]) => languageEntry(name, list));
}
/** Languages whose name or one of whose tools matches `query`; `needsSetup` keeps the ones missing tools. */
/**
* Languages whose name or one of whose tools matches `query`, those matched by name first
* (names starting with the query before the rest); `needsSetup` keeps the ones missing tools.
*/
export function filterLanguages(langs: readonly LanguageEntry[], query: string, needsSetup: boolean): LanguageEntry[] {
const q = query.trim().toLowerCase();
return langs.filter(
(l) =>
(!needsSetup || l.missing.length > 0) &&
(!q ||
l.name.toLowerCase().includes(q) ||
l.tools.some((t) => [t.name, t.displayName, t.command].some((s) => s.toLowerCase().includes(q)))),
);
const rank = (l: LanguageEntry) => {
if (!q) return 0;
const name = l.name.toLowerCase();
if (name.startsWith(q)) return name === q ? 0 : 1;
if (name.includes(q)) return 2;
return l.tools.some((t) => [t.name, t.displayName, t.command].some((s) => s.toLowerCase().includes(q))) ? 3 : -1;
};
return langs
.map((l) => [l, rank(l)] as const)
.filter(([l, r]) => r >= 0 && (!needsSetup || l.missing.length > 0))
.sort((a, b) => a[1] - b[1])
.map(([l]) => l);
}
/** A server added in this dialog, listed before Apply checks its executable. */
@@ -162,6 +221,10 @@ function ToolTable({
disabled,
label,
onSelect,
leading,
trailing,
before,
after,
}: {
tools: ToolInfo[];
selected: string | null;
@@ -169,13 +232,22 @@ function ToolTable({
disabled: (t: ToolInfo) => boolean;
label: string;
onSelect: (name: string) => void;
/** A control before each tool's name, e.g. the radio or on/off box that says whether it runs. */
leading?: (t: ToolInfo) => ReactNode;
/** A tag after each tool's name. */
trailing?: (t: ToolInfo) => ReactNode;
/** Rows above and below the tools (a group's Automatic and None choices). */
before?: ReactNode;
after?: ReactNode;
}) {
const busy = useTools((s) => s.jobs);
const updates = useTools((s) => s.updates);
return (
<ul className={styles.table} aria-label={label}>
{before}
{tools.map((t) => (
<li key={t.name} className={clsx(styles.tableRow, t.name === selected && styles.tableRowSelected)}>
{leading && <span className={styles.lead}>{leading(t)}</span>}
<button
type="button"
className={styles.tableMain}
@@ -187,11 +259,12 @@ function ToolTable({
{pending.has(t.name) ? tx("New") : STATUS_LABEL[t.status]}
</Badge>
<span className={clsx(styles.toolName, disabled(t) && styles.toolOff)}>{t.displayName}</span>
{disabled(t) && (
{!leading && disabled(t) && (
<span className={styles.tag}>
<T>Disabled</T>
</span>
)}
{trailing?.(t)}
{t.status === "installed" && updates[t.name] && (
<span className={clsx(styles.tag, styles.updateTag)}>
<T>Update</T>
@@ -212,10 +285,103 @@ function ToolTable({
)}
</li>
))}
{after}
</ul>
);
}
/** "ty (Python)" is just "ty" next to "Language server for Python". */
function shortName(t: ToolInfo, languages: readonly string[]): string {
const suffix = /^(.*) \((.+)\)$/.exec(t.displayName);
return suffix && languages.includes(suffix[2]!) ? suffix[1]! : t.displayName;
}
/**
* Interchangeable servers (a server and its `fallback`s) as one radio group:
* Automatic keeps them all on so the first one available runs, or exactly one
* runs, or none. The server that will run is tagged.
*/
function ServerChoice({
names,
tools,
servers,
...table
}: {
names: string[];
tools: ToolInfo[];
servers: Record<string, ServerEntry>;
selected: string | null;
pending: ReadonlySet<string>;
disabled: (t: ToolInfo) => boolean;
onSelect: (name: string) => void;
}) {
const form = useSettingsForm();
const group = useId();
const members = names.map((n) => tools.find((t) => t.name === n)).filter((t): t is ToolInfo => !!t);
const common = members.reduce<string[]>(
(acc, t) => acc.filter((l) => t.languages.includes(l)),
members[0]!.languages,
);
const label = common.length ? tx`Language server for ${common.join(", ")}` : tx("Language server");
const enabled = names.filter((n) => servers[n]?.enabled !== false);
const value =
enabled.length === names.length
? "auto"
: enabled.length === 0
? "none"
: enabled.length === 1
? enabled[0]!
: null;
const running = members.find((t) => enabled.includes(t.name) && t.status !== "missing");
const choose = (choice: string) => {
for (const n of names) setServerEnabled(form, n, choice === "auto" || choice === n);
};
const order = members.map((t) => shortName(t, common)).join(" → ");
const extra = (choice: "auto" | "none", text: string, hint: string) => (
<li className={styles.tableRow}>
<span className={styles.lead}>
<Radio name={group} checked={value === choice} onChange={() => choose(choice)} aria-label={text} />
</span>
<button type="button" className={styles.tableMain} onClick={() => choose(choice)}>
<span className={styles.toolName}>{text}</span>
<span className={styles.toolStatus}>{hint}</span>
</button>
</li>
);
return (
<div className={styles.group} role="radiogroup" aria-label={label}>
<div className={styles.groupTitle}>
{label}
<span className={styles.groupHint}>
<T>Only one runs at a time</T>
</span>
</div>
<ToolTable
{...table}
tools={members}
label={label}
leading={(t) => (
<Radio
name={group}
checked={value === t.name}
onChange={() => choose(t.name)}
aria-label={tx`Use only ${t.displayName}`}
/>
)}
trailing={(t) =>
t === running && (
<span className={clsx(styles.tag, styles.runTag)}>
<T>In use</T>
</span>
)
}
before={extra("auto", tx("Automatic"), tx`First available: ${order}`)}
after={extra("none", tx("None"), tx("No language server for these files"))}
/>
</div>
);
}
/** The selected tool under its table: install actions, progress, log and settings. */
function ToolDetails({ tool, language, pending }: { tool: ToolInfo; language: string; pending: boolean }) {
const job = useTools((s) => s.jobs[tool.name]);
@@ -250,7 +416,11 @@ function ToolDetails({ tool, language, pending }: { tool: ToolInfo; language: st
variant={tool.status === "missing" || update ? "primary" : "secondary"}
disabled={busy}
title={
tool.installMethod ? tx`Installs into the IDE's own tools folder via ${tool.installMethod}` : undefined
tool.status === "onPath" && tool.path
? tx`Installs a copy into the IDE's own tools folder, used instead of ${tool.path}`
: tool.installMethod
? tx`Installs into the IDE's own tools folder via ${tool.installMethod}`
: undefined
}
onClick={() => void installTool(tool.name)}
aria-label={
@@ -261,7 +431,13 @@ function ToolDetails({ tool, language, pending }: { tool: ToolInfo; language: st
: tx`Install ${tool.displayName}`
}
>
{update ? "Update" : tool.status === "installed" ? "Reinstall" : "Install"}
{update
? tx("Update")
: tool.status === "installed"
? tx("Reinstall")
: tool.status === "onPath"
? tx("Install IDE Copy")
: tx("Install")}
</Button>
)}
{tool.canUninstall && (
@@ -307,7 +483,7 @@ function ToolDetails({ tool, language, pending }: { tool: ToolInfo; language: st
</div>
)}
{tool.kind === "languageServer" ? (
<ServerSettings tool={tool} pending={pending} showAlternatives={false} />
<ServerSettings tool={tool} pending={pending} />
) : (
tool.kind === "debugger" && <ToolSettings tool={tool} />
)}
@@ -318,7 +494,12 @@ function ToolDetails({ tool, language, pending }: { tool: ToolInfo; language: st
/** The language's file-type icon, as in the Project view. */
function LanguageIcon({ name, known }: { name: string; known: readonly LanguageChoice[] }) {
const lang = known.find((l) => l.name === name);
const sample = lang ? sampleFileName({ extensions: lang.extensions ?? [], filenames: lang.filenames }) : null;
const sample = lang
? sampleFileName({
extensions: lang.extensions ?? [],
filenames: lang.filenames,
})
: null;
return <Icon name={name === OTHER ? "package" : sample ? fileIconName(sample) : "file-text"} size={16} />;
}
@@ -343,15 +524,29 @@ function LanguageDetails({
servers: Record<string, ServerEntry>;
onSelectTool: (name: string) => void;
}) {
const form = useSettingsForm();
const jobs = useTools((s) => s.jobs);
const [tone, stateLabel] = STATE_BADGE[language.state];
const installable = language.missing.filter((t) => t.canInstall && !jobs[t.name]);
const count = installable.length;
const missingNames = language.missing.map((t) => t.displayName).join(", ");
const disabled = (t: ToolInfo) => servers[t.name]?.enabled === false;
const selected = language.tools.find((t) => t.name === selectedTool) ?? language.tools[0] ?? null;
const pane = useRef<HTMLDivElement>(null);
// The tool's row is already listed; its details open under its table.
const reveal = (name: string) => {
onSelectTool(name);
pane.current
?.querySelector<HTMLElement>(`[data-tool="${CSS.escape(name)}"]`)
?.scrollIntoView?.({ block: "start", behavior: "smooth" });
};
const table = {
selected: selected?.name ?? null,
pending,
disabled,
onSelect: onSelectTool,
};
return (
<div className={styles.language} aria-label={tx`${language.name} tools`}>
<div ref={pane} className={styles.language} aria-label={tx`${language.name} tools`}>
<div className={styles.languageHeader}>
<LanguageIcon name={language.name} known={known} />
<span className={styles.languageTitle}>{language.name === OTHER ? tx(OTHER) : language.name}</span>
@@ -365,13 +560,18 @@ function LanguageDetails({
</div>
{language.missing.length > 0 && (
<div className={styles.banner} role="note">
{tx`Not installed: ${missingNames}.`}
<T>Not installed:</T>
{language.missing.map((t) => (
<button key={t.name} type="button" className={styles.linkButton} onClick={() => reveal(t.name)}>
{t.displayName}
</button>
))}
</div>
)}
{KINDS.map(([kind, title]) => {
let tools = language.tools.filter((t) => t.kind === kind);
const tools = language.tools.filter((t) => t.kind === kind);
if (!tools.length) return null;
// Interchangeable servers: their picker, then the servers in preference order.
// Interchangeable servers form a radio group each; the rest run alongside them.
// A group belongs to this language when all of its servers serve it (kmp-lsp is in
// the Java group and the Kotlin one).
const names = new Set(tools.map((t) => t.name));
@@ -381,28 +581,46 @@ function LanguageDetails({
...new Map(
tools
.filter((t) => t.alternatives.length > 1 && t.alternatives.every((n) => names.has(n)))
.map((t) => [t.alternatives.join("\n"), t]),
.map((t) => [t.alternatives.join("\n"), t.alternatives]),
).values(),
]
: [];
if (groups.length) {
const order = groups.flatMap((g) => g.alternatives);
const rank = (t: ToolInfo) => (order.includes(t.name) ? order.indexOf(t.name) : order.length);
tools = [...tools].sort((a, b) => rank(a) - rank(b));
}
const grouped = new Set(groups.flat());
const rest = tools.filter((t) => !grouped.has(t.name));
const toggles = kind === "languageServer";
return (
<Section key={kind} title={title}>
{groups.map((t) => (
<AlternativesRow key={t.alternatives.join("\n")} tool={t} names={t.alternatives} />
{groups.map((g) => (
<ServerChoice key={g.join("\n")} names={g} tools={tools} servers={servers} {...table} />
))}
<ToolTable
tools={tools}
selected={selected?.name ?? null}
pending={pending}
disabled={disabled}
label={tx(title)}
onSelect={onSelectTool}
/>
{rest.length > 0 && (
<div className={styles.group}>
{groups.length > 0 && (
<div className={styles.groupTitle}>
<T>Additional servers</T>
<span className={styles.groupHint}>
<T>Run alongside the one above</T>
</span>
</div>
)}
<ToolTable
{...table}
tools={rest}
label={tx(title)}
leading={
toggles
? (t) => (
<Checkbox
checked={!disabled(t)}
onChange={(on) => setServerEnabled(form, t.name, on)}
aria-label={tx`Use ${t.displayName}`}
/>
)
: undefined
}
/>
</div>
)}
{selected && tools.includes(selected) && (
<ToolDetails
key={selected.name}
+10 -98
Переглянути файл
@@ -7,7 +7,7 @@
import { useEffect, useId, useMemo, useRef, useState, type ReactNode } from "react";
import clsx from "clsx";
import type { ToolInfo } from "@/bindings";
import { Checkbox, Dialog, Icon, IconButton, Input, Popup, SearchField, Select, T } from "@/ui";
import { Checkbox, Dialog, Icon, IconButton, Input, Popup, SearchField, T } from "@/ui";
import { tx } from "@/platform/i18n";
import { useSettingsForm } from "@/workbench/contributions";
import { toolsBackend, type LanguageChoice } from "./backend";
@@ -27,7 +27,6 @@ import {
type ServerEntry,
type ServerField,
} from "./serverConfig";
import { STATUS_LABEL, useTools } from "./store";
import styles from "./ServerSettings.module.css";
let languageList: Promise<LanguageChoice[]> | null = null;
@@ -354,86 +353,23 @@ export function ToolSettings({ tool }: { tool: ToolInfo }) {
}
/**
* Interchangeable servers (a server and its `fallback`s): one picker for the
* group instead of an on/off box per server. Automatic keeps them all on, so
* the first one available runs.
* Stages a server on or off. On is the default, so only a project spells it out
* (to win over a global "off").
*/
export function AlternativesRow({ tool, names }: { tool: ToolInfo; names: string[] }) {
const form = useSettingsForm();
const tools = useTools((s) => s.tools);
const servers = (form.useValue("languageServers") ?? {}) as Record<string, ServerEntry>;
const members = names.map((name) => tools.find((t) => t.name === name));
const common = members.reduce<string[]>(
(acc, t) => (t ? acc.filter((l) => t.languages.includes(l)) : acc),
tool.languages,
);
const languages = common.join(", ");
// "ty (Python)" is just "ty" next to "Language server for Python".
const short = names.map((name, i) => {
const display = members[i]?.displayName ?? name;
const suffix = /^(.*) \((.+)\)$/.exec(display);
return suffix && common.includes(suffix[2]!) ? suffix[1]! : display;
});
const enabled = names.filter((name) => servers[name]?.enabled !== false);
const value =
enabled.length === names.length
? "auto"
: enabled.length === 0
? "none"
: enabled.length === 1
? enabled[0]!
: null;
const options = [
{ value: "auto", label: tx("Automatic") },
...names.map((name, i) => {
const t = members[i];
return {
value: name,
label: short[i]!,
detail: t ? tx(STATUS_LABEL[t.status]) : undefined,
};
}),
{ value: "none", label: tx("None") },
];
const order = short.join(" → ");
const label = languages ? tx`Language server for ${languages}` : tx("Language server");
return (
<Row label={label} hint={tx`Only one of these runs at a time. Automatic uses the first one available: ${order}.`}>
<Select
aria-label={label}
value={value}
placeholder={tx("Custom combination")}
options={options}
onChange={(choice) => {
for (const name of names) {
const on = choice === "auto" || choice === name;
// Same as the on/off box: on is the default, so only a project spells it out.
form.set(serverKey(name, "enabled"), on ? (form.scope === "project" ? true : null) : false);
}
}}
/>
</Row>
);
export function setServerEnabled(form: ReturnType<typeof useSettingsForm>, name: string, on: boolean) {
form.set(serverKey(name, "enabled"), on ? (form.scope === "project" ? true : null) : false);
}
/** A language server: on/off, executable, startup options, workspace configuration. */
export function ServerSettings({
tool,
pending,
showAlternatives = true,
}: {
tool: ToolInfo;
pending: boolean;
/** False where the page already shows the picker for the server's alternatives. */
showAlternatives?: boolean;
}) {
/**
* A language server: executable, startup options, workspace configuration.
* Whether it runs is chosen in the page's server table.
*/
export function ServerSettings({ tool, pending }: { tool: ToolInfo; pending: boolean }) {
const form = useSettingsForm();
const entry = useServerEntry(tool.name);
const custom = (entry.languages?.length ?? 0) > 0;
const set = (field: ServerField) => (value: unknown) => form.set(serverKey(tool.name, field), value);
const known = useLanguageChoices();
const languagesId = useId();
const languages = custom ? languageNames(entry.languages ?? [], known) : tool.languages;
const defaultOptions = useMemo(() => {
try {
return tool.defaultInitializationOptions ? JSON.parse(tool.defaultInitializationOptions) : null;
@@ -442,33 +378,9 @@ export function ServerSettings({
}
}, [tool.defaultInitializationOptions]);
const overridden = !custom && Object.keys(entry).length > 0;
// A server can be an alternative for several languages (kmp-lsp: Java and Kotlin): one picker each.
const tools = useTools((s) => s.tools);
const groups = useMemo(() => {
const byKey = new Map<string, string[]>();
for (const t of [tool, ...tools])
if (t.alternatives.length > 1 && t.alternatives.includes(tool.name))
byKey.set(t.alternatives.join("\n"), t.alternatives);
return [...byKey.values()];
}, [tool, tools]);
return (
<div className={styles.form}>
{groups.length ? (
showAlternatives && groups.map((names) => <AlternativesRow key={names.join("\n")} tool={tool} names={names} />)
) : (
<Checkbox
checked={entry.enabled !== false}
label={
languages.length
? tx`Use ${tool.displayName} for ${languages.join(", ")} files`
: tx`Use ${tool.displayName}`
}
// Enabled is the default; a project says so explicitly to win over a global "off".
onChange={(on) => set("enabled")(on ? (form.scope === "project" ? true : null) : false)}
/>
)}
<Section title="Executable">
<ExecutableRow tool={tool} pending={pending} />
{custom && (
+30 -46
Переглянути файл
@@ -97,25 +97,21 @@ describe("Language Servers page settings", () => {
const pythonPicker = async (user: ReturnType<typeof userEvent.setup>) => {
const python = await open(user, "Python");
await user.click(listItem("pyright")!);
// No on/off box: the group's picker replaces it.
expect(
within(details("Pyright")).queryByRole("checkbox", {
name: /^Use Pyright/,
}),
).toBeNull();
return python.getByRole("button", { name: "Language server for Python" });
// No on/off box: the group's radios say which one runs.
expect(within(details("Pyright")).queryByRole("checkbox", { name: /^Use / })).toBeNull();
return within(python.getByRole("radiogroup", { name: "Language server for Python" }));
};
it("lists one picker per group of interchangeable servers, above them", async () => {
it("lists each group of interchangeable servers as one radio group", async () => {
const user = userEvent.setup();
renderPage();
const picker = await pythonPicker(user);
expect(picker).toHaveTextContent("Automatic");
const group = await pythonPicker(user);
expect(group.getByRole("radio", { name: "Automatic" })).toBeChecked();
// The language is in the label already, so names drop a "(Python)" suffix.
expect(screen.getByText(/basedpyright → Pyright → ty → Pyrefly\.$/)).toBeInTheDocument();
expect(group.getByText("First available: basedpyright → Pyright → ty → Pyrefly")).toBeInTheDocument();
const go = await open(user, "Go");
expect(within(details("gopls")).getByRole("checkbox", { name: /Use gopls/ })).toBeInTheDocument();
expect(go.queryByRole("button", { name: /^Language server for/ })).toBeNull();
expect(go.getByRole("checkbox", { name: "Use gopls" })).toBeInTheDocument();
expect(go.queryByRole("radiogroup")).toBeNull();
});
it("shows a shared alternative in the group of each language it serves", async () => {
@@ -136,34 +132,27 @@ describe("Language Servers page settings", () => {
const user = userEvent.setup();
renderPage();
const java = await open(user, "Java");
expect(
java.getAllByRole("button", { name: /^Language server for/ }).map((b) => b.getAttribute("aria-label")),
).toEqual(["Language server for Java"]);
expect(java.getAllByRole("radiogroup").map((g) => g.getAttribute("aria-label"))).toEqual([
"Language server for Java",
]);
const kotlin = await open(user, "Kotlin");
expect(
kotlin.getAllByRole("button", { name: /^Language server for/ }).map((b) => b.getAttribute("aria-label")),
).toEqual(["Language server for Kotlin"]);
await user.click(listItem("kmp-lsp")!);
expect(
within(details("kmp-lsp")).queryByRole("button", {
name: /^Language server for/,
}),
).toBeNull();
expect(kotlin.getAllByRole("radiogroup").map((g) => g.getAttribute("aria-label"))).toEqual([
"Language server for Kotlin",
]);
expect(kotlin.getByRole("radio", { name: "Use only kmp-lsp" })).toBeInTheDocument();
});
it("selects exactly one Python analyzer and restores automatic fallback without writing defaults", async () => {
const user = userEvent.setup();
renderPage();
const picker = await pythonPicker(user);
expect(picker).toHaveTextContent("Automatic");
await user.click(picker);
await user.click(screen.getByRole("option", { name: /^ty/ }));
const group = await pythonPicker(user);
await user.click(group.getByRole("radio", { name: /^Use only ty/ }));
expect(stagedFor("languageServers.basedpyright.enabled")).toBe(false);
expect(stagedFor("languageServers.pyright.enabled")).toBe(false);
expect(stagedFor("languageServers.ty.enabled")).toBeNull();
expect(picker).toHaveTextContent("ty");
await user.click(picker);
await user.click(screen.getByRole("option", { name: /Automatic/ }));
expect(group.getByRole("radio", { name: /^Use only ty/ })).toBeChecked();
expect(group.getByRole("radio", { name: "Automatic" })).not.toBeChecked();
await user.click(group.getByRole("radio", { name: "Automatic" }));
for (const name of ["basedpyright", "pyright", "ty", "pyrefly"]) {
expect(stagedFor(`languageServers.${name}.enabled`)).toBeNull();
expect(useTestForm.getState().values).not.toHaveProperty(`languageServers.${name}.enabled`);
@@ -177,16 +166,14 @@ describe("Language Servers page settings", () => {
<LanguageServersPage />
</TestSettingsForm>,
);
const picker = await pythonPicker(user);
await user.click(picker);
await user.click(screen.getByRole("option", { name: /^Pyright/ }));
const group = await pythonPicker(user);
await user.click(group.getByRole("radio", { name: /^Use only Pyright/ }));
expect(stagedFor("languageServers.basedpyright.enabled")).toBe(false);
expect(stagedFor("languageServers.pyright.enabled")).toBe(true);
expect(stagedFor("languageServers.ty.enabled")).toBe(false);
expect(stagedFor("languageServers.pyrefly.enabled")).toBe(false);
expect(picker).toHaveTextContent("Pyright");
await user.click(picker);
await user.click(screen.getByRole("option", { name: /Automatic/ }));
expect(group.getByRole("radio", { name: /^Use only Pyright/ })).toBeChecked();
await user.click(group.getByRole("radio", { name: "Automatic" }));
for (const name of ["basedpyright", "pyright", "ty", "pyrefly"]) {
expect(stagedFor(`languageServers.${name}.enabled`)).toBe(true);
}
@@ -226,18 +213,15 @@ describe("Language Servers page settings", () => {
await user.paste('{ "check": { "command": "clippy" } }');
expect(stagedFor("languageServers.rust-analyzer.initializationOptions")).toEqual({ check: { command: "clippy" } });
// Turned off: marked in the list.
await user.click(
within(pane).getByRole("checkbox", {
name: /Use rust-analyzer for Rust files/,
}),
);
// Turned off from its box in the list.
const use = () => screen.getByRole("checkbox", { name: "Use rust-analyzer" });
await user.click(use());
expect(stagedFor("languageServers.rust-analyzer.enabled")).toBe(false);
expect(listItem("rust-analyzer")).toHaveTextContent("Disabled");
expect(use()).not.toBeChecked();
await user.click(within(pane).getByRole("button", { name: "Restore Defaults" }));
expect(stagedFor("languageServers.rust-analyzer")).toBeNull();
expect(listItem("rust-analyzer")).not.toHaveTextContent("Disabled");
expect(use()).toBeChecked();
expect(args).toHaveValue("");
});
+59 -21
Переглянути файл
@@ -110,16 +110,17 @@ describe("tools store", () => {
it("groups tools by language and filters by text and missing tools", () => {
const langs = groupByLanguage(sampleTools());
// Popular languages first, then by name.
expect(langs.map((l) => l.name)).toEqual([
"C",
"C++",
"Go",
"JavaScript",
"Kotlin",
"Python",
"Ruby",
"Rust",
"TypeScript",
"Python",
"C++",
"C",
"Go",
"Rust",
"Kotlin",
"Ruby",
"Zig",
]);
const go = langs.find((l) => l.name === "Go")!;
@@ -137,7 +138,7 @@ describe("tools store", () => {
expect(langs.find((l) => l.name === "Python")!.missing.map((t) => t.name)).toEqual(["basedpyright"]);
expect(filterLanguages(langs, "dlv", false).map((l) => l.name)).toEqual(["Go"]);
expect(filterLanguages(langs, "codelldb", false).map((l) => l.name)).toEqual(["C", "C++", "Rust"]);
expect(filterLanguages(langs, "codelldb", false).map((l) => l.name)).toEqual(["C++", "C", "Rust"]);
expect(filterLanguages(langs, "", true).map((l) => l.name)).not.toContain("TypeScript");
});
@@ -401,7 +402,11 @@ describe("LanguageServersPage", () => {
await open(user, "Go");
await user.click(toolItem("delve"));
const details = screen.getByLabelText("Delve (Go debugger) details");
await user.click(within(details).getByRole("button", { name: "Install Delve (Go debugger)" }));
await user.click(
within(details).getByRole("button", {
name: "Install Delve (Go debugger)",
}),
);
await user.click(within(details).getByRole("button", { name: "Cancel" }));
await waitFor(() => expect(useTools.getState().logs["delve"]?.error).toBe("Cancelled"));
expect(toolItem("delve")).toHaveTextContent("Missing");
@@ -432,23 +437,29 @@ describe("LanguageServersPage", () => {
expect(language("Go")).not.toHaveTextContent("missing");
});
it("shows the picker of interchangeable servers once, above them", async () => {
it("lists interchangeable servers in their radio group, in preference order", async () => {
const user = userEvent.setup();
renderPage();
const python = await open(user, "Python");
expect(
within(python).getAllByRole("button", {
name: "Language server for Python",
}),
).toHaveLength(1);
const rows = within(within(python).getByRole("list", { name: "Language Servers" })).getAllByRole("button", {
name: /^(?!Install)/,
const group = within(python).getByRole("radiogroup", {
name: "Language server for Python",
});
const rows = [...group.querySelectorAll<HTMLElement>("[data-tool]")];
expect(rows.map((r) => r.dataset.tool)).toEqual(["basedpyright", "pyright", "ty", "pyrefly"]);
await user.click(toolItem("ty"));
expect(
within(screen.getByLabelText("ty (Python) details")).queryByRole("button", { name: /^Language server/ }),
).toBeNull();
expect(within(screen.getByLabelText("ty (Python) details")).queryByRole("radio")).toBeNull();
});
it("jumps to a missing tool from the language's banner", async () => {
const user = userEvent.setup();
renderPage();
const rust = await open(user, "Rust");
await user.click(
within(within(rust).getByRole("note")).getByRole("button", {
name: /CodeLLDB/i,
}),
);
expect(toolItem("codelldb")).toHaveAttribute("aria-current", "true");
});
it("explains why a tool cannot be installed", async () => {
@@ -461,6 +472,33 @@ describe("LanguageServersPage", () => {
expect(screen.queryByRole("button", { name: /^Install Missing/ })).toBeNull();
});
it("offers an IDE copy only for a tool found on PATH", async () => {
backend.tools.push({
...sampleTools().find((t) => t.name === "gopls")!,
name: "golangci-lint-langserver",
displayName: "golangci-lint-langserver",
status: "custom",
path: "/opt/bin/golangci-lint-langserver",
});
const user = userEvent.setup();
renderPage();
await open(user, "TypeScript");
await user.click(toolItem("typescript-language-server"));
const onPath = within(screen.getByLabelText("typescript-language-server details")).getByRole("button", {
name: "Install typescript-language-server",
});
expect(onPath).toHaveTextContent("Install IDE Copy");
expect(onPath).toHaveAttribute("title", expect.stringContaining("/opt/homebrew/bin/typescript-language-server"));
// The executable chosen in settings wins over an IDE copy, so it is a plain Install.
await open(user, "Go");
await user.click(toolItem("golangci-lint-langserver"));
expect(
within(screen.getByLabelText("golangci-lint-langserver details")).getByRole("button", {
name: "Install golangci-lint-langserver",
}),
).toHaveTextContent(/^Install$/);
});
it("notes the other languages a shared tool serves", async () => {
const user = userEvent.setup();
renderPage();
@@ -494,7 +532,7 @@ describe("LanguageServersPage", () => {
renderPage();
await open(user, "Go");
await user.keyboard("{ArrowDown}");
expect(screen.getByLabelText("JavaScript tools")).toBeInTheDocument();
expect(screen.getByLabelText("Rust tools")).toBeInTheDocument();
});
it("filters to languages missing tools and by tool name", async () => {
+10 -2
Переглянути файл
@@ -1680,7 +1680,6 @@
"Also used for {others}; settings apply to all of them.": "Also used for {others}; settings apply to all of them.",
"{name} tools": "{name} tools",
"Install Missing ({count})": "Install Missing ({count})",
"Not installed: {missingNames}.": "Not installed: {missingNames}.",
"Language servers, formatters and debug adapters for each language. Missing tools can be installed into the IDE's own tools folder; nothing is downloaded until you click Install.": "Language servers, formatters and debug adapters for each language. Missing tools can be installed into the IDE's own tools folder; nothing is downloaded until you click Install.",
"Show Only Languages Missing Tools": "Show Only Languages Missing Tools",
"Language or tool": "Language or tool",
@@ -2358,5 +2357,14 @@
"No such file or folder": "No such file or folder",
"Choose a folder": "Choose a folder",
"Nothing to annotate": "Nothing to annotate",
"The file has no committed history in Git.": "The file has no committed history in Git."
"The file has no committed history in Git.": "The file has no committed history in Git.",
"Only one runs at a time": "Only one runs at a time",
"Use only {displayName}": "Use only {displayName}",
"First available: {order}": "First available: {order}",
"No language server for these files": "No language server for these files",
"Installs a copy into the IDE's own tools folder, used instead of {path}": "Installs a copy into the IDE's own tools folder, used instead of {path}",
"Install IDE Copy": "Install IDE Copy",
"Not installed:": "Not installed:",
"Additional servers": "Additional servers",
"Run alongside the one above": "Run alongside the one above"
}
-3
Переглянути файл
@@ -4232,7 +4232,6 @@
"Checked when the settings are applied.": "Se verifica al aplicar la configuración.",
"Using": "Usando",
"Not found on PATH.": "No se encontró en PATH.",
"Use {displayName} for {join} files": "Usar {displayName} para archivos {join}",
"Files marking the workspace root.": "Archivos que marcan la raíz del espacio de trabajo.",
"Merged over the defaults shown when empty.": "Se combina sobre los valores predeterminados mostrados cuando está vacío.",
"Workspace Configuration": "Configuración del espacio de trabajo",
@@ -4741,9 +4740,7 @@
"Unversioned": "Sin control de versiones",
"Merge conflict": "Conflicto de fusión",
"Automatic": "Automático",
"Custom combination": "Combinación personalizada",
"Language server for {languages}": "Servidor de lenguaje para {languages}",
"Only one of these runs at a time. Automatic uses the first one available: {order}.": "Solo se ejecuta uno de estos a la vez. Automático utiliza el primero disponible: {order}.",
"Configure the settings related to version control used in your project": "Configure los ajustes relacionados con el control de versiones utilizado en su proyecto",
"Use non-modal commit interface": "Usar interfaz de confirmación no modal",
"When off, Alt key combinations still work but pressing Alt alone does not focus the main menu": "Si está desactivado, las combinaciones con Alt siguen funcionando, pero pulsar Alt solo no enfoca el menú principal",
-3
Переглянути файл
@@ -4094,7 +4094,6 @@
"Checked when the settings are applied.": "Vérifié à l'application des paramètres.",
"Using": "Utilise",
"Not found on PATH.": "Introuvable dans le PATH.",
"Use {displayName} for {join} files": "Utiliser {displayName} pour les fichiers {join}",
"Files marking the workspace root.": "Fichiers marquant la racine de l'espace de travail.",
"Merged over the defaults shown when empty.": "Fusionnées avec les valeurs par défaut affichées si vide.",
"Workspace Configuration": "Configuration de l'espace de travail",
@@ -4596,9 +4595,7 @@
"Unversioned": "Non versionné",
"Merge conflict": "Conflit de fusion",
"Automatic": "Automatique",
"Custom combination": "Combinaison personnalisée",
"Language server for {languages}": "Serveur de langage pour {languages}",
"Only one of these runs at a time. Automatic uses the first one available: {order}.": "Un seul de ces serveurs s'exécute à la fois. Automatique utilise le premier disponible : {order}.",
"Configure the settings related to version control used in your project": "Configurez les paramètres du contrôle de version utilisé dans votre projet",
"Use non-modal commit interface": "Utiliser l'interface de commit non modale",
"When off, Alt key combinations still work but pressing Alt alone does not focus the main menu": "Si désactivé, les raccourcis avec Alt fonctionnent toujours, mais Alt seul ne donne pas le focus au menu principal",
-3
Переглянути файл
@@ -4295,7 +4295,6 @@
"Checked when the settings are applied.": "설정을 적용할 때 확인됩니다.",
"Using": "사용 중",
"Not found on PATH.": "PATH에서 찾을 수 없습니다.",
"Use {displayName} for {join} files": "{join} 파일에 {displayName} 사용",
"Files marking the workspace root.": "작업 공간 루트를 나타내는 파일입니다.",
"Merged over the defaults shown when empty.": "비어 있을 때 표시되는 기본값 위에 병합됩니다.",
"Workspace Configuration": "작업 공간 구성",
@@ -4809,9 +4808,7 @@
"Unversioned": "버전 관리되지 않음",
"Merge conflict": "병합 충돌",
"Automatic": "자동",
"Custom combination": "사용자 지정 조합",
"Language server for {languages}": "{languages}용 언어 서버",
"Only one of these runs at a time. Automatic uses the first one available: {order}.": "한 번에 하나만 실행됩니다. 자동은 사용 가능한 첫 번째 항목을 사용합니다: {order}.",
"Configure the settings related to version control used in your project": "프로젝트에서 사용하는 버전 관리 관련 설정을 구성합니다",
"Use non-modal commit interface": "비모달 커밋 인터페이스 사용",
"When off, Alt key combinations still work but pressing Alt alone does not focus the main menu": "끄면 Alt 조합키는 계속 동작하지만 Alt 단독 키는 메인 메뉴에 포커스를 주지 않습니다",
-3
Переглянути файл
@@ -4185,7 +4185,6 @@
"Checked when the settings are applied.": "Weryfikowane w momencie zastosowania ustawień.",
"Using": "Używanie",
"Not found on PATH.": "Nie znaleziono w zmiennej środowiskowej PATH.",
"Use {displayName} for {join} files": "Użyj {displayName} dla plików {join}",
"Files marking the workspace root.": "Pliki wyznaczające katalog główny przestrzeni roboczej.",
"Merged over the defaults shown when empty.": "Scalone z domyślnymi wartościami wyświetlanymi, gdy pole jest puste.",
"Workspace Configuration": "Konfiguracja przestrzeni roboczej",
@@ -4693,9 +4692,7 @@
"Unversioned": "Nieobjęte kontrolą wersji",
"Merge conflict": "Konflikt scalania",
"Automatic": "Automatycznie",
"Custom combination": "Kombinacja niestandardowa",
"Language server for {languages}": "Serwer językowy dla {languages}",
"Only one of these runs at a time. Automatic uses the first one available: {order}.": "Tylko jeden z nich działa w danym momencie. Tryb automatyczny korzysta z pierwszego dostępnego: {order}.",
"Configure the settings related to version control used in your project": "Konfiguruj ustawienia związane z systemem kontroli wersji używanym w projekcie",
"Use non-modal commit interface": "Użyj niemodalnego interfejsu zatwierdzania (commit)",
"When off, Alt key combinations still work but pressing Alt alone does not focus the main menu": "Gdy wyłączone, kombinacje z Alt nadal działają, ale samo naciśnięcie Alt nie przenosi fokusa na menu główne",
-3
Переглянути файл
@@ -4198,7 +4198,6 @@
"Checked when the settings are applied.": "Verificado quando as configurações são aplicadas.",
"Using": "Usando",
"Not found on PATH.": "Não encontrado no PATH.",
"Use {displayName} for {join} files": "Usar {displayName} para arquivos {join}",
"Files marking the workspace root.": "Arquivos que marcam a raiz do espaço de trabalho.",
"Merged over the defaults shown when empty.": "Mesclado sobre os padrões mostrados quando vazio.",
"Workspace Configuration": "Configuração do espaço de trabalho",
@@ -4707,9 +4706,7 @@
"Unversioned": "Não versionado",
"Merge conflict": "Conflito de mesclagem",
"Automatic": "Automático",
"Custom combination": "Combinação personalizada",
"Language server for {languages}": "Servidor de linguagem para {languages}",
"Only one of these runs at a time. Automatic uses the first one available: {order}.": "Apenas um deles é executado por vez. O modo Automático usa o primeiro disponível: {order}.",
"Configure the settings related to version control used in your project": "Configure as opções relacionadas ao controle de versão usado em seu projeto",
"Use non-modal commit interface": "Usar interface de commit não modal",
"When off, Alt key combinations still work but pressing Alt alone does not focus the main menu": "Quando desativado, combinações com Alt continuam funcionando, mas pressionar Alt sozinho não focaliza o menu principal",
+10 -5
Переглянути файл
@@ -4996,7 +4996,6 @@
"Checked when the settings are applied.": "应用设置后检查。",
"Using": "使用",
"Not found on PATH.": "在 PATH 中未找到。",
"Use {displayName} for {join} files": "对 {join} 文件使用 {displayName}",
"Files marking the workspace root.": "标记工作区根目录的文件。",
"Merged over the defaults shown when empty.": "与默认值(为空时显示)合并。",
"Workspace Configuration": "工作区配置",
@@ -5529,9 +5528,7 @@
"Unversioned": "未跟踪",
"Merge conflict": "合并冲突",
"Automatic": "自动",
"Custom combination": "自定义组合",
"Language server for {languages}": "{languages} 语言服务器",
"Only one of these runs at a time. Automatic uses the first one available: {order}.": "这些服务器同一时间只运行一个。自动模式使用第一个可用的:{order}。",
"Configure the settings related to version control used in your project": "配置项目中使用的版本控制相关设置",
"Use non-modal commit interface": "使用非模态提交界面",
"When off, Local Changes and Stash are tabs of the Git tool window and Commit opens a dialog.": "关闭时,本地更改和贮藏作为 Git 工具窗口的标签页显示,提交时打开对话框。",
@@ -8069,7 +8066,6 @@
"Also used for {others}; settings apply to all of them.": "也用于 {others};这里的设置对它们全部生效。",
"{name} tools": "{name} 工具",
"Install Missing ({count})": "安装缺少的工具({count})",
"Not installed: {missingNames}.": "未安装:{missingNames}。",
"Language servers, formatters and debug adapters for each language. Missing tools can be installed into the IDE's own tools folder; nothing is downloaded until you click Install.": "每种语言使用的语言服务器、格式化器和调试适配器。缺少的工具可以安装到 IDE 自己的工具目录;点击安装之前不会下载任何内容。",
"Show Only Languages Missing Tools": "只显示缺少工具的语言",
"Language or tool": "语言或工具",
@@ -8738,5 +8734,14 @@
"No such file or folder": "文件或文件夹不存在",
"Choose a folder": "请选择文件夹",
"Nothing to annotate": "没有可注解的内容",
"The file has no committed history in Git.": "此文件在 Git 中没有已提交的历史。"
"The file has no committed history in Git.": "此文件在 Git 中没有已提交的历史。",
"Only one runs at a time": "同一时间只运行一个",
"Use only {displayName}": "只使用 {displayName}",
"First available: {order}": "按顺序使用第一个可用的:{order}",
"No language server for these files": "这些文件不使用语言服务器",
"Installs a copy into the IDE's own tools folder, used instead of {path}": "在 IDE 自己的工具目录中安装一份,替代 {path}",
"Install IDE Copy": "安装到 IDE",
"Not installed:": "未安装:",
"Additional servers": "附加服务器",
"Run alongside the one above": "与上面选中的服务器同时运行"
}
+3 -1
Переглянути файл
@@ -63,10 +63,11 @@ export interface RadioProps {
label?: ReactNode;
disabled?: boolean;
className?: string;
"aria-label"?: string;
}
/** Radio button, drawn like the checkbox with a round box and a dot. */
export function Radio({ checked, onChange, name, label, disabled, className }: RadioProps) {
export function Radio({ checked, onChange, name, label, disabled, className, ...aria }: RadioProps) {
const id = useId();
const tx = useGivenTx();
return (
@@ -79,6 +80,7 @@ export function Radio({ checked, onChange, name, label, disabled, className }: R
className={styles.native}
checked={checked}
disabled={disabled}
aria-label={tx(aria["aria-label"])}
onChange={onChange}
/>
<span className={clsx(styles.box, styles.radio, checked && styles.on)} aria-hidden />