mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 16:04:21 +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}
|
||||
|
||||
Reference in New Issue
Block a user