mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-23 08:49:33 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba3d870ed1 |
No files matched your search
@@ -122,6 +122,45 @@ test("a long Run tab fits its side panel with room for the pin and close buttons
|
||||
await expect(run).toBeHidden();
|
||||
});
|
||||
|
||||
test("the Run toolbar keeps primary actions in one row in a side dock", async ({ workbench: page }) => {
|
||||
const output = "Waiting for orders. ".repeat(8).trim();
|
||||
await stubRun(page, [{ kind: "stdout", text: `${output}\n` }], null);
|
||||
const dock = async (width: number) => {
|
||||
await page.evaluate(async (width) => {
|
||||
const path = "/src/workbench/toolwindows/store.ts";
|
||||
const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ path);
|
||||
moveToolWindow("run", "right");
|
||||
setToolWindowSize("right", width);
|
||||
}, width);
|
||||
};
|
||||
await dock(200);
|
||||
await page.keyboard.press("Control+r");
|
||||
const run = page.getByRole("region", { name: "Run", exact: true });
|
||||
const toolbar = run.getByRole("toolbar", { name: "Run actions" });
|
||||
const console = run.getByRole("log");
|
||||
await expect(console).toContainText(output);
|
||||
await expect
|
||||
.poll(() => toolbar.evaluate((el) => new Set([...el.querySelectorAll("button")].map((b) => b.offsetTop)).size))
|
||||
.toBe(1);
|
||||
const more = toolbar.getByRole("button", { name: "More Actions" });
|
||||
const menu = page.getByRole("menu", { name: "More Actions" });
|
||||
await more.press("Enter");
|
||||
const wrap = menu.getByRole("menuitemcheckbox", { name: "Soft-Wrap" });
|
||||
await expect(wrap).toHaveAttribute("aria-checked", "false");
|
||||
await expect(menu.getByRole("menuitemcheckbox", { name: "Scroll to End" })).toHaveAttribute("aria-checked", "true");
|
||||
await wrap.click();
|
||||
await expect(menu).toBeHidden();
|
||||
await expect.poll(() => console.evaluate((el) => el.scrollWidth <= el.clientWidth + 1)).toBe(true);
|
||||
|
||||
await dock(340);
|
||||
await expect(toolbar.getByRole("button", { name: "Soft-Wrap" })).toHaveAttribute("aria-pressed", "true");
|
||||
await expect(toolbar.getByRole("button", { name: "Scroll to End" })).toBeVisible();
|
||||
await more.click();
|
||||
await expect(menu.getByRole("menuitemcheckbox")).toHaveCount(0);
|
||||
await menu.getByRole("menuitem", { name: "Edit Configurations…" }).click();
|
||||
await expect(page.getByRole("dialog", { name: "Run/Debug Configurations" })).toBeVisible();
|
||||
});
|
||||
|
||||
test("a short Run pane has room for the full toolbar above the output", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 400, height: 500 });
|
||||
const output = "Watching for changes…";
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
Icon,
|
||||
IconButton,
|
||||
Menu,
|
||||
type MenuItem,
|
||||
SplitGroup,
|
||||
SplitHandle,
|
||||
SplitPanel,
|
||||
@@ -100,21 +101,33 @@ export function SessionPanel({
|
||||
const [selectedTest, setSelectedTest] = useState<string | null>(null);
|
||||
const [findOpen, setFindOpen] = useState(false);
|
||||
const body = useRef<HTMLDivElement>(null);
|
||||
const moreButton = useRef<HTMLButtonElement>(null);
|
||||
const [moreOpen, setMoreOpen] = useState(false);
|
||||
const [compactToolbar, setCompactToolbar] = useState(false);
|
||||
const [stackedTests, setStackedTests] = useState(false);
|
||||
const testSplit = useRef<GroupImperativeHandle>(null);
|
||||
const testLayouts = useRef<Record<keyof typeof TEST_SPLIT_DEFAULTS, Layout>>({ ...TEST_SPLIT_DEFAULTS });
|
||||
const testOrientation = stackedTests ? "vertical" : "horizontal";
|
||||
const hasRuntime = !!rt;
|
||||
const hasTests = !!rt?.tests;
|
||||
const canUpdateApplication = isUpdatable(session.config);
|
||||
const hasFlutterActions = supportsHotReload(session.config);
|
||||
// Eight standard buttons with group spacing and insets, then 24 px plus gap per extra button.
|
||||
const fullToolbarWidth = 228 + 26 * (Number(hasTests) + Number(canUpdateApplication) + 2 * Number(hasFlutterActions));
|
||||
useLayoutEffect(() => {
|
||||
const pane = body.current;
|
||||
if (!hasTests || !pane) return;
|
||||
const measure = () => setStackedTests(pane.clientWidth < 560);
|
||||
if (!hasRuntime || !pane || (!showLifecycle && !hasTests)) return;
|
||||
const measure = () => {
|
||||
const width = pane.clientWidth;
|
||||
if (showLifecycle) setCompactToolbar(width < fullToolbarWidth);
|
||||
if (hasTests) setStackedTests(width < 560);
|
||||
};
|
||||
measure();
|
||||
if (typeof ResizeObserver === "undefined") return;
|
||||
const resize = new ResizeObserver(measure);
|
||||
resize.observe(pane);
|
||||
return () => resize.disconnect();
|
||||
}, [hasTests]);
|
||||
}, [hasRuntime, hasTests, showLifecycle, fullToolbarWidth]);
|
||||
useLayoutEffect(() => {
|
||||
if (hasTests) testSplit.current?.setLayout(testLayouts.current[testOrientation]);
|
||||
}, [hasTests, testOrientation]);
|
||||
@@ -157,7 +170,24 @@ export function SessionPanel({
|
||||
}, [selectedTest, rt, version]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
if (!rt) return null;
|
||||
const toggleWrap = () => setWrapOverride(!softWrap);
|
||||
const overflowConsoleToggles = showLifecycle && compactToolbar && !rt.terminal;
|
||||
const consoleToggles = [
|
||||
{ label: "Scroll to End", icon: "scroll-to-end", checked: follow, run: () => setFollow((v) => !v) },
|
||||
{ label: "Soft-Wrap", icon: "soft-wrap", checked: softWrap, run: () => setWrapOverride(!softWrap) },
|
||||
];
|
||||
const moreItems: MenuItem[] = [{ kind: "action", action: "run.editConfigs", arg: session.config.id }];
|
||||
if (overflowConsoleToggles) {
|
||||
moreItems.unshift(...consoleToggles, { kind: "separator" });
|
||||
}
|
||||
const stopButton = (
|
||||
<IconButton
|
||||
icon="stop"
|
||||
title={session.status === "stopping" ? tx`Stopping… (click to kill)` : "Stop"}
|
||||
tone={running ? "danger" : "default"}
|
||||
disabled={!running}
|
||||
onClick={() => void stopSession(session.id)}
|
||||
/>
|
||||
);
|
||||
|
||||
const consoleColumn = (
|
||||
<div className={styles.consoleColumn}>
|
||||
@@ -223,6 +253,7 @@ export function SessionPanel({
|
||||
shortcut={shortcutLabel("run.rerun")}
|
||||
onClick={() => rerunSession(session.id)}
|
||||
/>
|
||||
{!hasFlutterActions && stopButton}
|
||||
{/* Switch the launch mode: the same configuration started under the debugger. */}
|
||||
<IconButton
|
||||
icon="debug"
|
||||
@@ -240,14 +271,7 @@ export function SessionPanel({
|
||||
onClick={() => void rerunFailed(session.id)}
|
||||
/>
|
||||
)}
|
||||
<IconButton
|
||||
icon="stop"
|
||||
title={session.status === "stopping" ? tx`Stopping… (click to kill)` : "Stop"}
|
||||
tone={running ? "danger" : "default"}
|
||||
disabled={!running}
|
||||
onClick={() => void stopSession(session.id)}
|
||||
/>
|
||||
{isUpdatable(session.config) && (
|
||||
{canUpdateApplication && (
|
||||
<IconButton
|
||||
icon="refresh"
|
||||
title="Update Application"
|
||||
@@ -256,8 +280,9 @@ export function SessionPanel({
|
||||
onClick={() => showApplicationUpdate(session.id)}
|
||||
/>
|
||||
)}
|
||||
{supportsHotReload(session.config) && (
|
||||
{hasFlutterActions && (
|
||||
<>
|
||||
{stopButton}
|
||||
<IconButton
|
||||
icon="hot-reload"
|
||||
title="Hot Reload"
|
||||
@@ -286,23 +311,41 @@ export function SessionPanel({
|
||||
pressed={findOpen}
|
||||
onClick={() => setFindOpen((v) => !v)}
|
||||
/>
|
||||
<IconButton
|
||||
icon="scroll-to-end"
|
||||
title="Scroll to End"
|
||||
pressed={follow}
|
||||
onClick={() => setFollow((v) => !v)}
|
||||
/>
|
||||
<IconButton icon="soft-wrap" title="Soft-Wrap" pressed={softWrap} onClick={toggleWrap} />
|
||||
{!overflowConsoleToggles &&
|
||||
consoleToggles.map(({ label, icon, checked, run }) => (
|
||||
<IconButton key={label} icon={icon} title={label} pressed={checked} onClick={run} />
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
<IconButton icon="trash" title="Clear All" onClick={() => clearConsole(session.id)} />
|
||||
</div>
|
||||
<div className={styles.toolbarGroup}>
|
||||
<IconButton
|
||||
icon="settings"
|
||||
title="Edit Configurations…"
|
||||
onClick={() => void executeAction("run.editConfigs", session.config.id)}
|
||||
/>
|
||||
{showLifecycle ? (
|
||||
<>
|
||||
<IconButton
|
||||
ref={moreButton}
|
||||
icon="more-horizontal"
|
||||
title="More Actions"
|
||||
aria-haspopup="menu"
|
||||
aria-expanded={moreOpen}
|
||||
onClick={() => setMoreOpen((open) => !open)}
|
||||
/>
|
||||
<Menu
|
||||
open={moreOpen}
|
||||
anchor={moreButton}
|
||||
aria-label="More Actions"
|
||||
placement="bottom-end"
|
||||
items={moreItems}
|
||||
onClose={() => setMoreOpen(false)}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<IconButton
|
||||
icon="settings"
|
||||
title="Edit Configurations…"
|
||||
onClick={() => void executeAction("run.editConfigs", session.config.id)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div ref={body} className={styles.sessionBody}>
|
||||
|
||||
Reference in new issue
Block a user