дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-22 09:30:46 +02:00
fix(debugger): align the thread selector with the frames pane (#4961)
- Give the thread selector the width of the call stack header, with the standard workbench font and a fixed chevron at the trailing edge. - Show a leading icon for running, suspended, and breakpoint threads in both the header and the menu. Keep the status text in the menu and make the selected thread's full name and status available in the header tooltip and accessible description.
Цей коміт міститься в:
1 джерело
d507e67123
коміт
6b2b4a96e7
10 files changed
+124
-19
No files matched your search
@@ -0,0 +1,66 @@
|
||||
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
|
||||
|
||||
test("shows thread states in the compact frames header and switches frames by keyboard", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 940, height: 740 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async () => {
|
||||
const stateModule = "/src/features/debugger/state.ts";
|
||||
const workbenchModule = "/src/workbench/contributions.ts";
|
||||
const { adoptSession } = await import(/* @vite-ignore */ stateModule);
|
||||
const { toolWindowService } = await import(/* @vite-ignore */ workbenchModule);
|
||||
const frame = (id: number, name: string) => ({
|
||||
id,
|
||||
name,
|
||||
path: null,
|
||||
line: 0,
|
||||
column: 0,
|
||||
presentationHint: null,
|
||||
});
|
||||
const handlers = window.__ipc.handlers;
|
||||
handlers.debug_stack_trace = ({ threadId }) => [frame(Number(threadId) * 10, "writeLedger")];
|
||||
handlers.debug_scopes = () => [];
|
||||
adoptSession(97, {
|
||||
name: "Settlement",
|
||||
adapter: "debugpy",
|
||||
status: "paused",
|
||||
stoppedThread: 1,
|
||||
selectedThread: 1,
|
||||
stopReason: "breakpoint",
|
||||
suspendedThreads: [{ id: 2, reason: "pause", description: null }],
|
||||
threads: [
|
||||
{ id: 1, name: "MainThread" },
|
||||
{ id: 2, name: "Audit writer" },
|
||||
{ id: 3, name: "Regional settlement reconciliation worker with a long queue name" },
|
||||
],
|
||||
selectedFrame: 10,
|
||||
frames: [frame(10, "settle")],
|
||||
});
|
||||
toolWindowService().show("debug", true);
|
||||
});
|
||||
|
||||
const debug = page.getByRole("region", { name: "Debug", exact: true });
|
||||
const thread = debug.getByRole("button", { name: "Thread", exact: true });
|
||||
await expect(thread).toBeVisible();
|
||||
const remainder = await thread.evaluate((button) => button.parentElement!.clientWidth - button.clientWidth);
|
||||
expect(remainder).toBeLessThan(12);
|
||||
await expect(thread).toHaveAccessibleDescription("MainThread (At breakpoint)");
|
||||
const frames = debug.getByRole("listbox", { name: "Frames" });
|
||||
await expect(frames.getByText("settle", { exact: true })).toBeVisible();
|
||||
|
||||
await thread.press("ArrowDown");
|
||||
const menu = page.getByRole("listbox", { name: "Thread" });
|
||||
await expect(menu).toBeInViewport({ ratio: 1 });
|
||||
await expect(menu.getByRole("option", { name: "MainThread At breakpoint" })).toBeVisible();
|
||||
await expect(menu.getByRole("option", { name: "Audit writer Suspended" })).toBeVisible();
|
||||
await expect(
|
||||
menu.getByRole("option", { name: /Regional settlement reconciliation worker .* Running/ }),
|
||||
).toBeVisible();
|
||||
await page.keyboard.press("ArrowDown");
|
||||
await page.keyboard.press("Enter");
|
||||
await expect(menu).toBeHidden();
|
||||
await expect(thread).toHaveAccessibleDescription("Audit writer (Suspended)");
|
||||
await expect(frames.getByText("writeLedger", { exact: true })).toBeVisible();
|
||||
expect(await ipcCalls(page, "debug_stack_trace")).toEqual([{ session: 97, threadId: 2 }]);
|
||||
});
|
||||
@@ -109,13 +109,14 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex: none;
|
||||
height: 30px;
|
||||
height: var(--h-field);
|
||||
padding: 0 var(--space-1);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.threadSelect {
|
||||
max-width: 100%;
|
||||
width: 100%;
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
|
||||
.frameList {
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
type TabItem,
|
||||
T,
|
||||
} from "@/ui";
|
||||
import type { SelectOption } from "@/ui/Select";
|
||||
import { revealVertically } from "@/ui/Tabs";
|
||||
import { setMuted, useBreakpoints } from "../breakpoints/store";
|
||||
import { frameLabel, groupFrames } from "../frames";
|
||||
@@ -374,6 +375,37 @@ function ThreadsAndVariables({ session }: { session: DebugSession }) {
|
||||
);
|
||||
}
|
||||
|
||||
function ThreadSelector({ session }: { session: DebugSession }) {
|
||||
const tr = useTx();
|
||||
const value = session.selectedThread == null ? null : String(session.selectedThread);
|
||||
const options = session.threads.map<SelectOption>(({ id, name }) => {
|
||||
const option = { value: String(id), label: name, verbatim: true };
|
||||
if (!isLive(session)) return option;
|
||||
if (!isThreadSuspended(session, id)) return { ...option, icon: "thread-running", detail: "Running" };
|
||||
const reason =
|
||||
id === session.stoppedThread ? session.stopReason : session.suspendedThreads?.find((t) => t.id === id)?.reason;
|
||||
return reason === "breakpoint" || reason?.endsWith(" breakpoint")
|
||||
? { ...option, icon: "thread-breakpoint", detail: "At breakpoint" }
|
||||
: { ...option, icon: "thread-suspended", detail: "Suspended" };
|
||||
});
|
||||
const selected = options.find((option) => option.value === value);
|
||||
const summary = selected?.detail ? `${selected.label} (${tr(selected.detail)})` : selected?.label;
|
||||
return (
|
||||
<div className={styles.threadHeader}>
|
||||
<Select
|
||||
value={value}
|
||||
options={options}
|
||||
onChange={(v) => void selectThread(session.id, Number(v))}
|
||||
aria-label="Thread"
|
||||
aria-description={summary}
|
||||
title={summary}
|
||||
variant="ghost"
|
||||
className={styles.threadSelect}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function FramesPane({ session }: { session: DebugSession }) {
|
||||
const root = useProject((s) => s.project?.root ?? null);
|
||||
const [showAll, setShowAll] = useState(false);
|
||||
@@ -399,23 +431,7 @@ function FramesPane({ session }: { session: DebugSession }) {
|
||||
};
|
||||
return (
|
||||
<div className={styles.frames}>
|
||||
{session.threads.length > 0 && (
|
||||
<div className={styles.threadHeader}>
|
||||
<Select
|
||||
value={session.selectedThread != null ? String(session.selectedThread) : null}
|
||||
options={session.threads.map((t) => ({
|
||||
value: String(t.id),
|
||||
label: t.name,
|
||||
verbatim: true,
|
||||
detail: isThreadSuspended(session, t.id) ? "suspended" : undefined,
|
||||
}))}
|
||||
onChange={(v) => void selectThread(session.id, +v)}
|
||||
aria-label="Thread"
|
||||
variant="ghost"
|
||||
className={styles.threadSelect}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{session.threads.length > 0 && <ThreadSelector session={session} />}
|
||||
<div
|
||||
ref={list}
|
||||
className={styles.frameList}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"At breakpoint": "At breakpoint",
|
||||
"Build and Run": "Build and Run",
|
||||
"Gradle runtime": "Gradle runtime",
|
||||
"Open diff as editor tab": "Open diff as editor tab",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"At breakpoint": "停在断点",
|
||||
"Build and Run": "构建和运行",
|
||||
"Gradle runtime": "Gradle 运行环境",
|
||||
"Open diff as editor tab": "以编辑器标签页打开差异",
|
||||
|
||||
@@ -42,7 +42,9 @@ export interface SelectProps<V extends string = string> {
|
||||
/** `ghost` renders as plain text + chevron (title bar widgets); `chip` as a chip that opens. */
|
||||
variant?: "framed" | "ghost" | "chip";
|
||||
className?: string;
|
||||
title?: string;
|
||||
"aria-label"?: string;
|
||||
"aria-description"?: string;
|
||||
/** Custom trigger content. */
|
||||
renderValue?: (option: SelectOption<V> | undefined) => ReactNode;
|
||||
/** Show a search box in the popup (useful for long option lists); typing on the closed trigger opens it with that text. */
|
||||
@@ -324,6 +326,7 @@ export function Select<V extends string = string>({
|
||||
disabled,
|
||||
variant = "framed",
|
||||
className,
|
||||
title,
|
||||
renderValue,
|
||||
searchable = false,
|
||||
onPreview,
|
||||
@@ -355,6 +358,8 @@ export function Select<V extends string = string>({
|
||||
aria-haspopup="listbox"
|
||||
aria-expanded={open}
|
||||
aria-label={given(aria["aria-label"])}
|
||||
aria-description={aria["aria-description"]}
|
||||
title={title}
|
||||
disabled={disabled}
|
||||
className={clsx(styles.trigger, styles[variant], className)}
|
||||
onClick={() => (open ? setOpen(false) : openPopup())}
|
||||
|
||||
@@ -480,6 +480,9 @@ const ICONS = {
|
||||
"stop-filled": "run/stop_stroke",
|
||||
resume: "run/resume",
|
||||
pause: "run/pause",
|
||||
"thread-running": "openidea/debugger/threadRunning",
|
||||
"thread-suspended": "openidea/debugger/threadSuspended",
|
||||
"thread-breakpoint": "openidea/debugger/threadBreakpoint",
|
||||
"step-over": "run/stepOver",
|
||||
"step-into": "run/stepInto",
|
||||
"step-out": "run/stepOut",
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M2.5 4.5h7m-7 3.5h4m-4 3.5h4" stroke="var(--fg-muted)" stroke-linecap="round"/>
|
||||
<circle cx="11.5" cy="9.5" r="3" fill="var(--danger)"/>
|
||||
</svg>
|
||||
|
Після Ширина: | Висота: | Розмір: 252 B |
@@ -0,0 +1,4 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M2.5 4.5h7m-7 3.5h4m-4 3.5h4" stroke="var(--fg-muted)" stroke-linecap="round"/>
|
||||
<path d="M9.5 6.5v6l5-3-5-3Z" fill="var(--success)"/>
|
||||
</svg>
|
||||
|
Після Ширина: | Висота: | Розмір: 250 B |
@@ -0,0 +1,4 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M2.5 4.5h7m-7 3.5h4m-4 3.5h4" stroke="var(--fg-muted)" stroke-linecap="round"/>
|
||||
<path d="M9.5 7v5m3-5v5" stroke="var(--fg)" stroke-width="1.5" stroke-linecap="round"/>
|
||||
</svg>
|
||||
|
Після Ширина: | Висота: | Розмір: 284 B |
Reference in new issue
Заблокувати користувача