Compare commits

..
Author SHA1 Message Date
l0ng-ai 33614e81ef fix(debugger): give Memory class filtering room 2026-11-23 09:06:15 +08:00
l0ng-ai 844c2f3145 test(maven): wait for the background refresh of jdtls import roots (#5272)
external_maven_link_persists_reloads_and_unlink_keeps_files failed on the macOS runner: setting languages.java.maven.linkedProjects refreshes the language server's import roots on a blocking task, and the test read them right after build_model returned. It now waits up to 5 s for them to change.
2026-11-23 05:18:24 +08:00
9 changed files with 162 additions and 97 deletions

No files matched your search

+15 -2
View File
@@ -49,7 +49,7 @@ async fn external_maven_link_persists_reloads_and_unlink_keeps_files() {
assert_eq!(b.pom, canonical);
assert_eq!(dunce::canonicalize(root.join(&b.dir)).unwrap(), sibling);
assert_eq!(host.project("main").unwrap().content_roots(), vec![sibling.clone()]);
assert_eq!(host.project("main").unwrap().lsp.jdtls_import_roots(), vec![sibling.clone()]);
assert_eq!(import_roots(&host, |roots| !roots.is_empty()).await, vec![sibling.clone()]);
let reloaded = ops::build::build_model(&host, "main").await.unwrap();
assert_eq!(
@@ -63,13 +63,26 @@ async fn external_maven_link_persists_reloads_and_unlink_keeps_files() {
let gone = ops::build::build_model(&host, "main").await.unwrap();
assert!(gone.maven.unwrap().projects.iter().all(|p| p.artifact_id != "b"));
assert!(host.project("main").unwrap().content_roots().is_empty());
assert!(host.project("main").unwrap().lsp.jdtls_import_roots().is_empty());
assert!(import_roots(&host, |roots| roots.is_empty()).await.is_empty());
assert_eq!(saved(), Vec::<String>::new());
assert_eq!(std::fs::read_to_string(root.join("pom.xml")).unwrap(), a_pom);
assert_eq!(std::fs::read_to_string(sibling.join("pom.xml")).unwrap(), b_pom);
host.shutdown().await;
}
/// The language server's Maven import roots once `ready` holds: a settings change refreshes them in
/// the background.
async fn import_roots(host: &Host, ready: impl Fn(&[std::path::PathBuf]) -> bool) -> Vec<std::path::PathBuf> {
for _ in 0..200 {
let roots = host.project("main").unwrap().lsp.jdtls_import_roots();
if ready(&roots) {
return roots;
}
tokio::time::sleep(std::time::Duration::from_millis(25)).await;
}
host.project("main").unwrap().lsp.jdtls_import_roots()
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn reactor_module_beside_a_trusted_project_is_a_content_root_until_removed() {
let temp = tempfile::tempdir().unwrap();
+10 -34
View File
@@ -1024,51 +1024,27 @@ test("the Commit tool window restores the draft and author options for the inclu
await expect(message).toHaveValue("Default draft");
});
test("commit message history shows compact message previews above the editor", async ({ workbench: page }) => {
await page.emulateMedia({ reducedMotion: "reduce" });
test("commit message history opens above the message without an empty icon column", async ({ workbench: page }) => {
await stubRepository(page);
await page.keyboard.press("Meta+k");
const message = page.getByRole("textbox", { name: "Commit message" });
await expect(message).toBeVisible();
await page.evaluate((root) => {
localStorage.setItem(
`openidea.vcs.commitMessages:${root}`,
JSON.stringify([
"Update inventory\n\nReview settlement totals",
"Update inventory\n\nReconcile export records",
...Array.from({ length: 7 }, (_, index) => `Earlier message ${index + 1}`),
]),
);
localStorage.setItem(`openidea.vcs.commitMessages:${root}`, JSON.stringify(["Previous commit message"]));
}, ROOT);
await message.fill("Draft");
const history = page.getByRole("button", { name: "Commit Message History" });
await history.click();
await page.getByRole("button", { name: "Commit Message History" }).click();
const menu = page.getByRole("menu", { name: "Recent commit messages" });
const row = menu.getByRole("menuitem", { name: /Update inventory.*Review settlement totals/ });
const row = menu.getByRole("menuitem", { name: "Previous commit message" });
await expect(row).toBeVisible();
const messageBox = (await message.boundingBox())!;
const menuBox = (await menu.locator("..").boundingBox())!;
const rowBox = (await row.boundingBox())!;
expect(messageBox.y - menuBox.y - menuBox.height).toBeCloseTo(3, 0);
expect(Math.abs(menuBox.x - messageBox.x)).toBeLessThan(2);
expect(menuBox.height).toBeLessThan(rowBox.height * 8);
await expect(row).toHaveCSS("font-family", await message.evaluate((el) => getComputedStyle(el).fontFamily));
await expect(row).toHaveCSS("font-size", await message.evaluate((el) => getComputedStyle(el).fontSize));
const messageBox = await message.boundingBox();
const menuBox = await menu.locator("..").boundingBox();
expect(messageBox).not.toBeNull();
expect(menuBox).not.toBeNull();
expect(menuBox!.y + menuBox!.height).toBeLessThan(messageBox!.y);
expect(Math.abs(menuBox!.x - messageBox!.x)).toBeLessThan(2);
await expect(row.locator("span")).toHaveCount(1);
await row.press("Escape");
await expect(menu).toBeHidden();
await expect(message).toHaveValue("Draft");
await history.click();
await row.press("Home");
await expect(row).toBeFocused();
await page.keyboard.press("ArrowDown");
const second = menu.getByRole("menuitem", { name: /Update inventory.*Reconcile export records/ });
await expect(second).toBeFocused();
await page.keyboard.press("Enter");
await expect(message).toHaveValue("Update inventory\n\nReconcile export records");
await expect(message).toBeFocused();
});
test("Amend shows the original author and warns when the committer differs", async ({ workbench: page }) => {
+78
View File
@@ -3,6 +3,7 @@
* with its frames and variables, and stepping and resuming go back to the adapter. The adapter is
* stubbed at the IPC layer; `crates/ide-dap/tests` drives real ones.
*/
import type { JvmMemoryResult } from "../src/platform/ipc";
import { expect, ipcCalls, openFromTree, stubDesktop, test } from "./fixtures";
const ROOT = "/dev/acme-api";
@@ -114,6 +115,83 @@ test("stops at a breakpoint, shows frames and variables, steps and resumes", asy
await expect(debug.getByText("CreateOrderRequest(sku='A-1', qty=2)")).toBeHidden();
});
test("Memory gives class filtering the available toolbar width and exposes changed-only filtering", async ({
workbench: page,
}) => {
const rows = [
{ name: "OrderCache", instances: 64, deltaInstances: 12 },
{ name: "OrderRepository", instances: 16, deltaInstances: 0 },
].map((row) => ({ ...row, bytes: row.instances * 16, deltaBytes: null, module: null, ambiguous: false }));
const result: JvmMemoryResult = {
status: "ready",
snapshot: {
rows,
totalInstances: 80,
totalBytes: 1280,
javaVersion: "21",
takenWhileSuspended: true,
hasBaseline: true,
elapsedMs: 5,
source: "debugger",
},
};
await stubDesktop(page);
await page.evaluate(
async ({ result, id }) => {
const caps = { jvmMemory: true, jvmHeap: true };
window.__ipc.handlers.debug_capabilities = () => caps;
window.__ipc.handlers.debug_jvm_memory_classes = () => result;
const debugPath = "/src/features/debugger/state.ts";
const { adoptSession } = await import(/* @vite-ignore */ debugPath);
adoptSession(id, { adapter: "java-debug", name: "Billing Service", status: "paused", caps });
const dockPath = "/src/workbench/toolwindows/store.ts";
const layout = await import(/* @vite-ignore */ dockPath);
layout.moveToolWindow("debug", "bottom");
layout.setToolWindowSize("bottom", 300);
layout.showToolWindow("debug", true);
},
{ result, id: SESSION },
);
const debug = page.getByRole("region", { name: "Debug", exact: true });
await debug.getByRole("tab", { name: "Memory" }).click();
const toolbar = debug.getByRole("toolbar", { name: "Memory", exact: true });
const filter = toolbar.getByRole("textbox", { name: "Filter classes" });
const options = toolbar.getByRole("button", { name: "View Options" });
const grid = debug.getByRole("grid", { name: "Memory", exact: true });
await expect(grid.getByText("OrderRepository", { exact: true })).toBeVisible();
expect((await filter.boundingBox())!.width).toBeGreaterThan((await toolbar.boundingBox())!.width / 2);
await page.evaluate(async () => {
const dockPath = "/src/workbench/toolwindows/store.ts";
const layout = await import(/* @vite-ignore */ dockPath);
layout.moveToolWindow("debug", "right");
layout.setToolWindowSize("right", 330);
});
await expect.poll(async () => (await toolbar.boundingBox())!.width).toBeCloseTo(330, 0);
const bar = (await toolbar.boundingBox())!;
const gear = (await options.boundingBox())!;
const input = (await filter.boundingBox())!;
expect(input.width).toBeGreaterThan(bar.width / 2);
expect(input.x + input.width).toBeLessThan(gear.x);
expect(gear.x + gear.width).toBeLessThanOrEqual(bar.x + bar.width);
await filter.fill("cache");
await expect(grid.getByText("OrderRepository", { exact: true })).toBeHidden();
await toolbar.getByRole("button", { name: "Clear", exact: true }).click();
await expect(grid.getByText("OrderRepository", { exact: true })).toBeVisible();
await options.press("Enter");
const changed = page.getByRole("menuitemcheckbox", { name: "Changed only" });
await expect(changed).not.toBeChecked();
await changed.press("Enter");
await expect(grid.getByText("OrderRepository", { exact: true })).toBeHidden();
await expect(options).toHaveAttribute("aria-pressed", "true");
await expect(options).toBeFocused();
await options.press("Enter");
await expect(changed).toBeChecked();
});
test("Evaluate keeps a multiline expression and its result visible in a short dialog", async ({ workbench: page }) => {
await page.setViewportSize({ width: 580, height: 420 });
await stubDesktop(page);
@@ -241,7 +241,8 @@ describe("MemoryView", () => {
expect(screen.getByRole("button", { name: "刷新内存视图" }).getAttribute("data-tooltip")).toBe("刷新内存视图");
const filter = screen.getByRole("textbox", { name: "筛选类" });
expect(filter.getAttribute("placeholder")).toBe("筛选类");
expect(screen.getByRole("checkbox", { name: "仅显示有变化的" })).toBeTruthy();
fireEvent.click(screen.getByRole("button", { name: "视图选项" }));
expect(screen.getByRole("menuitemcheckbox", { name: "仅显示有变化的" })).toBeInTheDocument();
} finally {
await setLocale("en");
}
@@ -299,10 +300,15 @@ describe("MemoryView", () => {
expect(screen.getByText("Cache$Entry")).toBeTruthy();
fireEvent.change(screen.getByRole("textbox", { name: "Filter classes" }), { target: { value: "" } });
fireEvent.click(screen.getByRole("checkbox", { name: "Changed only" }));
const options = screen.getByRole("button", { name: "View Options" });
fireEvent.click(options);
fireEvent.click(screen.getByRole("menuitemcheckbox", { name: "Changed only", checked: false }));
expect(screen.getByText("Heap$Live")).toBeTruthy();
expect(screen.queryByText("Cache$Entry")).toBeNull();
expect(screen.queryByText("Dup")).toBeNull();
expect(options).toHaveAttribute("aria-pressed", "true");
fireEvent.click(options);
expect(screen.getByRole("menuitemcheckbox", { name: "Changed only", checked: true })).toBeInTheDocument();
});
it("sorts by the clicked column and reports it with aria-sort", async () => {
@@ -18,8 +18,8 @@
}
.filter {
flex: 0 1 240px;
min-width: 80px;
flex: 1;
min-width: 0;
}
.banner,
+30 -8
View File
@@ -1,7 +1,7 @@
/** Memory tab of the Debug tool window: live instance counts per class of the debugged JVM, and heap capture. */
import { useEffect, useMemo } from "react";
import { useEffect, useMemo, useRef, useState } from "react";
import clsx from "clsx";
import { Checkbox, Icon, IconButton, Input, List, T } from "@/ui";
import { Icon, IconButton, List, Menu, SearchField, T } from "@/ui";
import { executeAction } from "@/platform/actions";
import { useTx } from "@/platform/i18n";
import type { JvmClassRow, JvmMemorySnapshot } from "@/platform/ipc";
@@ -112,6 +112,8 @@ export function MemoryView({ session }: { session: DebugSession }) {
const id = session.id;
const entry = useMemory((s) => s.bySession[id]);
const query = entry?.query ?? DEFAULT_QUERY;
const optionsButton = useRef<HTMLButtonElement>(null);
const [optionsOpen, setOptionsOpen] = useState(false);
const result = entry?.result ?? null;
const snapshot = entry?.snapshot ?? null;
const source = snapshot?.source ?? "histogram";
@@ -161,17 +163,37 @@ export function MemoryView({ session }: { session: DebugSession }) {
disabled={entry?.loading || !canRefresh}
/>
<HeapCaptureButton session={session} />
<Input
<SearchField
className={styles.filter}
value={query.filter}
onChange={(e) => setMemoryQuery(id, { filter: e.target.value })}
onChange={(filter) => setMemoryQuery(id, { filter })}
placeholder="Filter classes"
aria-label="Filter classes"
/>
<Checkbox
checked={query.changedOnly}
onChange={(changedOnly) => setMemoryQuery(id, { changedOnly })}
label="Changed only"
<IconButton
ref={optionsButton}
icon="settings"
title="View Options"
size="small"
iconSize={16}
pressed={query.changedOnly}
aria-haspopup="menu"
aria-expanded={optionsOpen}
onClick={() => setOptionsOpen(!optionsOpen)}
/>
<Menu
open={optionsOpen}
onClose={() => setOptionsOpen(false)}
anchor={optionsButton}
placement="bottom-end"
aria-label="View Options"
items={[
{
label: "Changed only",
checked: query.changedOnly,
run: () => setMemoryQuery(id, { changedOnly: !query.changedOnly }),
},
]}
/>
</div>
{backend && (
-16
View File
@@ -134,22 +134,6 @@
gap: var(--space-0-5) var(--space-1);
padding: var(--space-0-5) 6px var(--space-0-5) 12px;
}
.messageHistory {
--history-row-height: max(var(--h-list-row), calc(1em + var(--space-2)));
min-width: min(180px, calc(100vw - var(--space-3)));
max-height: calc(7 * var(--history-row-height) + var(--space-2) + 2px);
padding-block: var(--space-1);
overflow-x: hidden;
}
.messageHistory [role="menu"] {
max-width: calc(var(--history-columns) + var(--space-4) + var(--space-2));
font-size: inherit;
}
.messageHistory [role="menuitem"] {
height: var(--history-row-height);
margin-inline: var(--space-1);
padding-inline: var(--space-2);
}
.amendTarget {
min-width: 0;
max-width: 112px;
+19 -32
View File
@@ -29,8 +29,7 @@ import {
EmptyState,
Icon,
IconButton,
MenuList,
Popup,
Menu,
Spinner,
SplitGroup,
SplitHandle,
@@ -1375,6 +1374,7 @@ export function CommitMessageField({
const amend = useCommit((s) => s.amend);
const focusTick = useCommit((s) => s.focusTick);
const ref = useRef<HTMLTextAreaElement>(null);
const barRef = useRef<HTMLDivElement>(null);
const [historyOpen, setHistoryOpen] = useState(false);
const historyTick = useCommit((s) => s.historyTick);
const { emptyError } = runner;
@@ -1393,11 +1393,6 @@ export function CommitMessageField({
const cfg = useWorkflowSettings((s) => s.vcs.commit);
const editor = useProject((s) => s.settings?.editor);
const { family, size } = resolveMonoFont(undefined, editor);
const messageFont = {
fontFamily: family,
fontSize: size,
fontWeight: fontWeightOf(editor?.fontWeight, 400),
};
const first = message.split("\n")[0] ?? "";
const tooLong = cfg.limitSubject && first.length > cfg.subjectLimit;
const problems = messageProblems(message, cfg).filter((p) => !p.startsWith("Subject line"));
@@ -1407,7 +1402,7 @@ export function CommitMessageField({
return (
<>
<div className={styles.commitBar}>
<div ref={barRef} className={styles.commitBar}>
<Checkbox checked={amend} onChange={(v) => void setAmend(v)} label="Amend" />
{chooseAmendTarget && amendRoot && <AmendTargetMenu root={amendRoot} />}
<IconButton
@@ -1419,32 +1414,22 @@ export function CommitMessageField({
aria-expanded={historyOpen}
onClick={() => setHistoryOpen((o) => !o)}
/>
<Popup
<Menu
open={historyOpen}
onClose={() => setHistoryOpen(false)}
anchor={ref}
anchor={barRef}
placement="top-start"
offset={3}
role="presentation"
autoFocus={false}
className={styles.messageHistory}
style={{ ...messageFont, ["--history-columns" as string]: `${cfg.subjectLimit}ch` }}
>
<MenuList
onDone={() => setHistoryOpen(false)}
iconColumn={false}
aria-label={tx("Recent commit messages")}
items={history.map((m, i) => ({
id: `h${i}`,
label: m.replace(/\r\n?|\n/g, " ⏎ "),
verbatim: true,
run: () => {
useCommit.setState({ message: m });
ref.current?.focus();
},
}))}
/>
</Popup>
iconColumn={false}
aria-label="Recent commit messages"
items={history.map((m, i) => ({
id: `h${i}`,
label: m.split("\n")[0]!.slice(0, 80),
run: () => {
useCommit.setState({ message: m });
ref.current?.focus();
},
}))}
/>
<CommitMessageActions />
<span className={styles.grow} />
{tooLong && (
@@ -1460,7 +1445,9 @@ export function CommitMessageField({
aria-invalid={emptyError || undefined}
style={{
["--guide" as string]: `${margin}ch`,
...messageFont,
fontFamily: family,
fontSize: size,
fontWeight: fontWeightOf(editor?.fontWeight, 400),
lineHeight: editor?.lineHeight ? `${editor.lineHeight}px` : undefined,
}}
value={message}
-1
View File
@@ -28,7 +28,6 @@
"The Git operation changed. Review the current changes and try again.": "The Git operation changed. Review the current changes and try again.",
"Git operation has no current commit": "Git operation has no current commit",
"Invalid commit message": "Invalid commit message",
"Recent commit messages": "Recent commit messages",
"Invalid commit message file path": "Invalid commit message file path",
"Review staged changes": "Review staged changes",
"Commit and Continue": "Commit and Continue",