mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 08:03:19 +00: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.
This commit is contained in:
@@ -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>
|
||||
|
After Width: | Height: | Size: 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>
|
||||
|
After Width: | Height: | Size: 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>
|
||||
|
After Width: | Height: | Size: 284 B |
Reference in New Issue
Block a user