From 9dffb50323f03533925cdc0ea609a8cd98ae404a Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Fri, 20 Nov 2026 08:34:32 +0800 Subject: [PATCH] Keep plugin list and details visible in narrow settings --- e2e/pluginsLayout.spec.ts | 62 ++++++++++++ src/features/plugins/PluginsPage.module.css | 36 ++++--- src/features/plugins/PluginsPage.tsx | 99 ++++++++++++------- .../plugins/__tests__/plugins.test.tsx | 3 +- src/platform/locales/text/en.json | 1 + src/platform/locales/text/zh.json | 1 + 6 files changed, 148 insertions(+), 54 deletions(-) create mode 100644 e2e/pluginsLayout.spec.ts diff --git a/e2e/pluginsLayout.spec.ts b/e2e/pluginsLayout.spec.ts new file mode 100644 index 000000000..3f0812462 --- /dev/null +++ b/e2e/pluginsLayout.spec.ts @@ -0,0 +1,62 @@ +import { expect, test } from "./fixtures"; + +test("Plugin management keeps the selected details reachable when Settings narrows", async ({ workbench: page }) => { + const name = "ReconciliationTimelineInspectorEnterprise"; + const notes = "SettlementTimeline".repeat(18); + await page.evaluate( + async ({ name, notes }) => { + const path = "/src/features/plugins/backend.ts"; + const { createMemoryPluginsBackend, setPluginsBackend } = await import(/* @vite-ignore */ path); + const { plugins } = await createMemoryPluginsBackend().list(); + const longPlugin = { ...plugins[0], id: "settlement-inspector", name, changeNotes: notes }; + setPluginsBackend(createMemoryPluginsBackend([longPlugin, ...plugins.slice(1)])); + }, + { name, notes }, + ); + + await page.setViewportSize({ width: 1080, height: 760 }); + await page.keyboard.press("Meta+,"); + const settings = page.getByRole("dialog", { name: "Settings", exact: true }); + await settings.getByRole("treeitem", { name: "Plugins", exact: true }).click(); + await settings.getByRole("tab", { name: "Installed", exact: true }).click(); + + const filter = settings.getByRole("textbox", { name: "Filter plugins" }); + const list = settings.getByRole("list", { name: "Installed plugins" }); + const details = settings.getByLabel(`${name} details`); + const heading = details.getByRole("heading", { name, exact: true }); + await expect(heading).toBeVisible(); + + const filterBox = (await filter.boundingBox())!; + const headingBox = (await heading.boundingBox())!; + expect(headingBox.x).toBeGreaterThan(filterBox.x + filterBox.width); + + await page.setViewportSize({ width: 520, height: 760 }); + const body = settings.locator("[class*='pageBody']"); + await expect.poll(() => body.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1); + const divider = settings.getByRole("separator", { name: "Resize plugin panes" }); + await expect(divider).toHaveAttribute("aria-orientation", "horizontal"); + const sources = settings.getByRole("tablist", { name: "Plugin sources" }); + await expect(sources.getByRole("tab", { name: "Marketplace" })).toBeVisible(); + await expect(sources.getByRole("tab", { name: "Installed" })).toBeVisible(); + expect(await sources.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1); + + const before = (await divider.boundingBox())!.y; + await divider.focus(); + await page.keyboard.press("ArrowDown"); + await expect.poll(async () => (await divider.boundingBox())!.y).toBeGreaterThan(before); + await expect(details.getByRole("button", { name: "Disable", exact: true })).toBeVisible(); + + await details.getByRole("tab", { name: "What's New" }).click(); + await expect(details.getByText(notes, { exact: true })).toBeVisible(); + expect(await details.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1); + + await filter.click(); + await expect(filter).toBeFocused(); + await filter.pressSequentially("Harbor"); + await list.getByRole("button", { name: /Harbor Night Theme/ }).click(); + await expect(settings.getByRole("heading", { name: "Harbor Night Theme", exact: true })).toBeVisible(); + await page.setViewportSize({ width: 1080, height: 760 }); + await expect(divider).toHaveAttribute("aria-orientation", "vertical"); + await expect(filter).toHaveValue("Harbor"); + await expect(settings.getByRole("heading", { name: "Harbor Night Theme", exact: true })).toBeVisible(); +}); diff --git a/src/features/plugins/PluginsPage.module.css b/src/features/plugins/PluginsPage.module.css index 1ba567451..d0fc0cbd2 100644 --- a/src/features/plugins/PluginsPage.module.css +++ b/src/features/plugins/PluginsPage.module.css @@ -3,23 +3,21 @@ flex-direction: column; min-width: 0; height: 100%; - min-height: 420px; + min-height: 0; } .topBar { display: flex; + flex-wrap: wrap; align-items: center; + justify-content: center; gap: var(--space-1-5); + min-width: 0; } -.side { - display: flex; +.page > .topBar { flex: none; - flex-direction: column; - width: clamp(320px, 42%, 480px); - min-height: 0; - border-right: 1px solid var(--border); + padding: 0 var(--space-2) var(--space-1); } .sourceTabs { - flex: none; border-bottom: 0; } .tabCount { @@ -37,13 +35,14 @@ .searchRow { display: flex; flex: none; + flex-wrap: wrap; align-items: center; gap: var(--space-1-5); padding: 8px; border-bottom: 1px solid var(--border); } .searchField { - flex: 1; + flex: 1 1 132px; min-width: 0; } .spacer { @@ -58,8 +57,6 @@ overflow-wrap: anywhere; } .body { - display: flex; - min-width: 640px; flex: 1; min-height: 0; border-top: 1px solid var(--border); @@ -237,11 +234,14 @@ .details { flex: 1; min-width: 0; - padding: 16px 20px 20px; + min-height: 0; + padding: var(--space-4); overflow: auto; } .detailsEmpty { flex: 1; + min-height: 0; + overflow: auto; } /* Tags, name, vendor, then the actions with the version. */ .header { @@ -258,6 +258,7 @@ color: var(--fg); font: inherit; white-space: pre-wrap; + overflow-wrap: anywhere; } .titleLine { display: flex; @@ -273,15 +274,19 @@ .title { margin: 0; color: var(--fg-strong); - font-size: var(--fs-input-large); + font-size: 1.375em; font-weight: 600; + line-height: 1.3; + overflow-wrap: anywhere; } .version { color: var(--fg-muted); + font-size: var(--fs-small); font-variant-numeric: tabular-nums; } .authors { color: var(--fg-secondary); + overflow-wrap: anywhere; } .headerActions { display: flex; @@ -298,6 +303,7 @@ margin: 10px 0 0; max-width: 640px; color: var(--fg); + overflow-wrap: anywhere; } .details .error { margin-top: 10px; @@ -434,6 +440,7 @@ .consentNotice { display: flex; + flex-wrap: wrap; align-items: center; gap: var(--space-3); justify-content: space-between; @@ -444,8 +451,7 @@ } .categorySelect { - flex: none; - width: 150px; + flex: 0 1 150px; } .ownIcon { background: transparent; diff --git a/src/features/plugins/PluginsPage.tsx b/src/features/plugins/PluginsPage.tsx index 9aa36f576..cd335c3fa 100644 --- a/src/features/plugins/PluginsPage.tsx +++ b/src/features/plugins/PluginsPage.tsx @@ -6,7 +6,7 @@ * There is no network repository: Available lists the plugin packages * available locally (`plugin_catalog`) and installs them from disk. */ -import { useEffect, useMemo, useState, type MouseEvent, type ReactNode } from "react"; +import { useEffect, useLayoutEffect, useMemo, useRef, useState, type MouseEvent, type ReactNode } from "react"; import clsx from "clsx"; import type { CapabilityInfo, @@ -27,6 +27,9 @@ import { SearchField, Select, Spinner, + SplitGroup, + SplitHandle, + SplitPanel, Tabs, showContextMenu, type MenuItem, @@ -1309,6 +1312,19 @@ export function PluginsPage({ initialTab = "marketplace" }: { initialTab?: Tab } const [query, setQuery] = useState(""); const [selectedId, setSelectedId] = useState(null); const [selectedCatalogId, setSelectedCatalogId] = useState(null); + const pageRef = useRef(null); + const [stacked, setStacked] = useState(false); + + useLayoutEffect(() => { + const page = pageRef.current; + if (!page) return; + const measure = () => setStacked(page.clientWidth < 600); + measure(); + if (typeof ResizeObserver === "undefined") return; + const observer = new ResizeObserver(measure); + observer.observe(page); + return () => observer.disconnect(); + }, []); useEffect(() => { void refreshPlugins(); @@ -1403,7 +1419,7 @@ export function PluginsPage({ initialTab = "marketplace" }: { initialTab?: Tab } const headerSlot = useSettingsHeaderSlot(); const header = ( - <> +
{(loading || installing) && } - +
); return ( -
- {headerSlot ? createPortal(header, headerSlot) :
{header}
} +
+ {headerSlot && !stacked ? createPortal(header, headerSlot) : header} {error && (
@@ -1434,8 +1450,13 @@ export function PluginsPage({ initialTab = "marketplace" }: { initialTab?: Tab }
)} -
-
+ +
{catalogError}} )} -
- - {tab === "installed" ? ( - selected ? ( - +
+ + + {tab === "installed" ? ( + selected ? ( + + ) : ( + + Plugins are folders with a plugin.toml + . Use the gear menu to install one from disk, or put dev plugins in{" "} + .openidea/plugins/ inside your project. + + ) + ) : selectedMarket ? ( + { + setTab("installed"); + setSelectedId(id); + }} + /> + ) : selectedEntry ? ( + + ) : marketUrl ? ( + ) : ( - - Plugins are folders with a plugin.toml - . Use the gear menu to install one from disk, or put dev plugins in .openidea/plugins/{" "} - inside your project. + + Install a plugin folder with plugin.toml{" "} + via the gear menu › Install Plugin from Disk…. - ) - ) : selectedMarket ? ( - { - setTab("installed"); - setSelectedId(id); - }} - /> - ) : selectedEntry ? ( - - ) : marketUrl ? ( - - ) : ( - - Install a plugin folder with plugin.toml{" "} - via the gear menu › Install Plugin from Disk…. - - )} -
+ )} + +
); } diff --git a/src/features/plugins/__tests__/plugins.test.tsx b/src/features/plugins/__tests__/plugins.test.tsx index 977667ed6..dfadb2ec1 100644 --- a/src/features/plugins/__tests__/plugins.test.tsx +++ b/src/features/plugins/__tests__/plugins.test.tsx @@ -953,7 +953,8 @@ describe("PluginsPage", () => { await user.click(screen.getByRole("button", { name: "Apply theme Harbor Night" })); await waitFor(() => expect(screen.getByRole("button", { name: "Use Default Theme" })).toBeInTheDocument()); - await user.type(screen.getByLabelText("Filter plugins"), "toy"); + screen.getByLabelText("Filter plugins").focus(); + await user.keyboard("toy"); await waitFor(() => expect(within(list).getAllByRole("listitem")).toHaveLength(1)); expect(screen.getByRole("heading", { level: 2 })).toHaveTextContent("Toy Language"); expect(screen.getByText("Toy (.toy)")).toBeInTheDocument(); diff --git a/src/platform/locales/text/en.json b/src/platform/locales/text/en.json index 817b038ad..89d621d06 100644 --- a/src/platform/locales/text/en.json +++ b/src/platform/locales/text/en.json @@ -2567,6 +2567,7 @@ "Load Maven Project": "Load Maven Project", "Skip": "Skip", "Resize Markdown preview": "Resize Markdown preview", + "Resize plugin panes": "Resize plugin panes", "Run a Python script or module": "Run a Python script or module", "Replace every occurrence of '{pattern}' with '{replacement}' in the scope? The search hit its limit, so it runs again to find the occurrences not listed.": "Replace every occurrence of '{pattern}' with '{replacement}' in the scope? The search hit its limit, so it runs again to find the occurrences not listed.", "Server default": "Server default", diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json index 3058e79ef..d22170a33 100644 --- a/src/platform/locales/text/zh.json +++ b/src/platform/locales/text/zh.json @@ -8946,6 +8946,7 @@ "This Maven project is not loaded": "此 Maven 项目尚未加载", "Load Maven Project": "加载 Maven 项目", "Resize Markdown preview": "调整 Markdown 预览宽度", + "Resize plugin panes": "调整插件列表与详情区域大小", "Server default": "服务器默认值", "New Database": "新建数据库", "Owner:": "所有者:",