Порівняти коміти

...
5 змінених файлів з 74 додано та 117 видалено

No files matched your search

+4 -5
Переглянути файл
@@ -41,7 +41,8 @@ test("project switcher keeps names and metadata on separate lines and highlights
await page.getByRole("button", { name: "acme-api", exact: true }).click();
const popup = page.getByRole("dialog", { name: "Projects" });
await expect(popup.getByText("Release Tools")).toBeVisible();
await expect(popup.getByText("Recent Projects")).toBeVisible();
await expect(popup.getByText("Release Tools")).toHaveCount(0);
const local = popup.getByRole("option", { name: new RegExp(NAME) });
await expectBelow(local, NAME, PATH);
await expectBelow(local, PATH, BRANCH);
@@ -51,10 +52,8 @@ test("project switcher keeps names and metadata on separate lines and highlights
const remote = popup.getByRole("option", { name: /Payment Ledger/ });
await expect(remote.locator("[data-remote-badge]")).toHaveCount(1);
await expect(remote.locator('[data-remote-kind="ssh"]')).toBeVisible();
await expect(local.locator("[data-remote-badge]")).toHaveCount(0);
await expectBelow(remote, "Payment Ledger", HOST);
await expectBelow(remote, HOST, REMOTE_PATH);
await expectBelow(remote, "Payment Ledger", `${HOST}:${REMOTE_PATH}`);
await page.setViewportSize({ width: 960, height: 700 });
await page.keyboard.type(HOST);
@@ -66,7 +65,7 @@ test("project switcher keeps names and metadata on separate lines and highlights
await page.keyboard.press("Escape");
await page.keyboard.type(`${HOST}:${REMOTE_PATH}`);
await expect(remote.locator("mark")).toHaveText([HOST, REMOTE_PATH]);
await expect(remote.locator("mark")).toHaveText(`${HOST}:${REMOTE_PATH}`);
await page.keyboard.press("Escape");
await page.keyboard.type("acme-api");
+31 -3
Переглянути файл
@@ -1,6 +1,6 @@
import { expect, stubDesktop, test } from "./fixtures";
test("groups recent projects by Local and remote host across Welcome, Recent Projects, and Project Popup without row overlap", async ({
test("keeps the project switcher flat while grouping Welcome and Recent Projects without row overlap", async ({
workbench: page,
}) => {
await page.setViewportSize({ width: 980, height: 740 });
@@ -71,15 +71,43 @@ test("groups recent projects by Local and remote host across Welcome, Recent Pro
}
});
// 1. Project Widget dropdown keeps Open Projects flat and groups Recent Projects by host.
// 1. The project widget uses the same row layout for local and remote projects.
await page.getByRole("button", { name: "openidea_all" }).click();
const projectPopup = page.getByRole("dialog", { name: "Projects" });
await expect(projectPopup).toBeVisible();
await expect(projectPopup).toContainText("Open Projects");
await expect(projectPopup).toContainText("Recent Projects");
await expect(projectPopup).toContainText("dev-mbp1.local");
await expect(projectPopup).toContainText("Local");
await expect(projectPopup.getByText("Local", { exact: true })).toHaveCount(0);
await expect(projectPopup).toContainText("Ubuntu-24.04");
// The two section headers and every project badge share the same left inset.
const headers = [
projectPopup.getByText("Open Projects", { exact: true }),
projectPopup.getByText("Recent Projects", { exact: true }),
];
const headerMetrics = await Promise.all(
headers.map((header) =>
header.evaluate((el) => {
const style = getComputedStyle(el);
const rect = el.getBoundingClientRect();
return { x: rect.x + parseFloat(style.paddingLeft), height: rect.height, fontSize: style.fontSize };
}),
),
);
expect(headerMetrics[1]).toEqual(headerMetrics[0]);
const projectRows = projectPopup.getByRole("option").filter({ hasText: "/git/" });
await expect(projectRows).toHaveCount(7);
await expect(projectRows.locator("[data-remote-badge]")).toHaveCount(4);
const rowMetrics = await projectRows.evaluateAll((rows) =>
rows.map((el) => ({
x: el.firstElementChild!.getBoundingClientRect().x,
height: el.getBoundingClientRect().height,
})),
);
for (const row of rowMetrics) expect(row.x).toBeCloseTo(headerMetrics[0]!.x, 0);
// Both open projects have no branch metadata and must have identical heights.
expect(rowMetrics[0]!.height).toBeCloseTo(rowMetrics[1]!.height, 0);
await expect(projectPopup.getByRole("separator")).toHaveCount(2);
await page.keyboard.press("Escape");
await expect(projectPopup).toBeHidden();
+5 -11
Переглянути файл
@@ -57,24 +57,18 @@
}
.separator {
height: 1px;
margin: 5px 12px;
margin: var(--space-1-5) calc(var(--space-1-5) + var(--space-2));
background: var(--border);
}
.header {
padding: 4px 16px 2px;
display: flex;
align-items: center;
min-height: var(--h-list-row);
padding: var(--space-0-5) calc(var(--space-1-5) + var(--space-2));
color: var(--fg-muted);
font-size: var(--fs-small);
font-weight: 600;
}
.groupHeader {
display: flex;
align-items: center;
gap: var(--space-1-5);
padding: 6px 16px 2px;
color: var(--fg);
font-weight: 600;
white-space: nowrap;
--icon-color: var(--fg-muted);
}
.badge {
align-self: flex-start;
+24 -20
Переглянути файл
@@ -75,7 +75,7 @@ describe("ProjectPopup", () => {
expect(within(list).getAllByText("FastAPIProject")).toHaveLength(1);
const remoteRow = within(list).getByText("FastAPIProject").closest('[role="option"]')!;
expect(remoteRow.querySelector("[data-remote-badge]")).not.toBeNull();
expect(remoteRow.querySelector('[data-remote-kind="wsl"]')?.textContent).toContain("WSL");
expect(remoteRow.textContent).toContain("Ubuntu-24.04:/root/projetos/FastAPIProject");
});
it("leaves local project avatars and rows free of remote badges", async () => {
@@ -96,12 +96,11 @@ describe("ProjectPopup", () => {
const rows = screen.getAllByRole("option").filter((r) => r.textContent?.includes("same-name"));
expect(rows).toHaveLength(2);
expect(rows[0]!.querySelector("[data-remote-badge]")).not.toBeNull();
expect(rows[0]!.querySelector('[data-remote-kind="ssh"]')?.textContent).toContain("SSH");
expect(rows[0]!.textContent).toContain("devbox:/home/me/same-name");
expect(rows[1]!.querySelector("[data-remote-badge]")).toBeNull();
expect(rows[1]!.querySelector("[data-remote-kind]")).toBeNull();
});
it("lists recent projects under the Welcome screen's groups, collapsed or not, then the ungrouped ones", async () => {
it("lists recent projects in recency order regardless of Welcome groups", async () => {
open = [{ name: "current", root: "/w/current", current: true, remote: null }];
recent = [project("current", 9), project("example-web", 5), project("loose", 4), project("example-api", 3)];
groups = [
@@ -115,14 +114,16 @@ describe("ProjectPopup", () => {
<ProjectPopup anchor={anchor} onClose={() => {}} />
</>,
);
await screen.findByText("Frontend");
await screen.findByText("Open Projects");
await screen.findByText("Recent Projects");
const text = screen.getByRole("listbox").textContent ?? "";
const order = ["Recent Projects", "Frontend", "example-web", "Backend", "example-api", "loose"];
const order = ["Recent Projects", "example-web", "loose", "example-api"];
expect(order.map((t) => text.indexOf(t))).toEqual([...order.map((t) => text.indexOf(t))].sort((a, b) => a - b));
expect(order.every((t) => text.includes(t))).toBe(true);
// The open project stays under Open Projects only.
expect(within(screen.getByRole("listbox")).getAllByText("current")).toHaveLength(1);
expect(screen.getAllByRole("option").map((o) => o.textContent)).not.toContain("Frontend");
expect(text).not.toContain("Frontend");
expect(text).not.toContain("Backend");
});
it("opens a recent project in a new window with Shift or Ctrl, in this one with Alt", async () => {
@@ -173,7 +174,7 @@ describe("ProjectPopup", () => {
expect(openRecent).toHaveBeenLastCalledWith(exampleWeb, null);
});
it("groups Recent Projects by host in MRU order while keeping Open Projects flat", async () => {
it("keeps local and remote projects in a flat recency-ordered list with remote badges", async () => {
const sshA = { kind: "ssh", config: "devbox" } as const;
const sshB = { kind: "ssh", config: "mbp" } as const;
open = [{ name: "openidea_all", root: "/Users/me/git/openidea_all", current: true, remote: null }];
@@ -198,22 +199,25 @@ describe("ProjectPopup", () => {
const order = [
"Open Projects",
"Recent Projects",
"SSH·devbox",
"/srv/openidea_all",
"/srv/gocommon",
"Local",
"devbox:/srv/openidea_all",
"~/git/gocommon",
"mbp:/Users/dev/gocommon",
"devbox:/srv/gocommon",
"~/git/superpowers",
"SSH·mbp",
"/Users/dev/gocommon",
];
expect(order.every((t) => text.includes(t))).toBe(true);
expect(order.map((t) => text.indexOf(t))).toEqual([...order.map((t) => text.indexOf(t))].sort((a, b) => a - b));
// Rows inside a host group omit the duplicate per-row host pill; typing to filter flattens and restores it.
const groupedRemote = within(list).getByText("/srv/openidea_all").closest('[role="option"]')!;
expect(groupedRemote.querySelector('[data-remote-kind="ssh"]')).toBeNull();
fireEvent.keyDown(list, { key: "g" });
const searchedRemote = within(list).getByText("/srv/gocommon").closest('[role="option"]')!;
expect(searchedRemote.querySelector('[data-remote-kind="ssh"]')?.textContent).toContain("devbox");
expect(text).not.toContain("Local");
const remoteRow = within(list).getByText("devbox:/srv/openidea_all").closest('[role="option"]')!;
expect(remoteRow.querySelector("[data-remote-badge]")).not.toBeNull();
const localRow = within(list).getByText("~/git/gocommon").closest('[role="option"]')!;
expect(localRow.querySelector("[data-remote-badge]")).toBeNull();
for (const key of "devbox") fireEvent.keyDown(list, { key });
const matches = within(list).getAllByRole("option");
expect(matches).toHaveLength(2);
for (const row of matches) {
expect(row.querySelector("[data-remote-badge]")).not.toBeNull();
expect(row.querySelector("mark")?.textContent).toBe("devbox");
}
});
});
+10 -78
Переглянути файл
@@ -4,25 +4,8 @@ import { executeAction, useActions } from "@/platform/actions";
import { call, commands, isTauri, type OpenProject, type RecentProject } from "@/platform/ipc";
import { HighlightedText, Icon, Popup, showContextMenu, type IconName, T } from "@/ui";
import type { ProjectPopupProps } from "@/workbench/contributions";
import {
askRemoveRecent,
HostGroupTitle,
ProjectBadge,
projectAppearanceMenu,
recentMenu,
RemoteHostPill,
splitRemoteMatch,
unavailableTitle,
} from "./RecentList";
import {
filterRecent,
loadRecent,
openRecent,
recentRows,
useRecent,
type HostGroup,
type RecentMatch,
} from "./recent";
import { askRemoveRecent, ProjectBadge, projectAppearanceMenu, recentMenu, unavailableTitle } from "./RecentList";
import { filterRecent, loadRecent, openRecent, useRecent, type RecentMatch } from "./recent";
import styles from "./ProjectPopup.module.css";
import { tx } from "@/platform/i18n";
import { parseRemoteLocation, remoteLocation } from "@/platform/remote";
@@ -30,7 +13,7 @@ import { projectWindowOverride, type ProjectWindowOverride } from "@/workbench/p
type Entry =
| { kind: "action"; id: string; label: string; icon: IconName }
| { kind: "project"; open: boolean; m: RecentMatch; group?: string | null; hostGroup?: HostGroup | null };
| { kind: "project"; open: boolean; m: RecentMatch };
const ACTIONS: { id: string; label: string; icon: IconName }[] = [
{ id: "file.newProject", label: "New Project…", icon: "plus" },
@@ -55,13 +38,11 @@ function useOpenProjects(): OpenProject[] {
}
/**
* The title bar project widget's popup, after IDEA's ProjectWidget: actions, open projects, recent
* projects (under the Welcome screen's project groups, then the ungrouped ones); type to filter.
* The title bar project widget's popup: actions, open projects and a flat recent list; type to filter.
*/
export function ProjectPopup({ anchor, onClose }: ProjectPopupProps) {
const actions = useActions((s) => s.actions);
const recent = useRecent((s) => s.projects);
const groups = useRecent((s) => s.groups);
const home = useRecent((s) => s.home);
const openProjects = useOpenProjects();
const [query, setQuery] = useState("");
@@ -82,22 +63,14 @@ export function ProjectPopup({ anchor, onClose }: ProjectPopupProps) {
open: true,
m,
}));
// Every group lists its projects here, collapsed on the Welcome screen or not; a search is flat.
const expanded = groups.map((g) => ({ ...g, expanded: true }));
const rest = recentRows(
const rest = filterRecent(
recent.filter((r) => !openPaths.has(r.path)),
expanded,
query,
home,
[],
).flatMap((r) =>
r.kind === "project"
? [{ kind: "project" as const, open: false, m: r.m, group: r.group, hostGroup: r.hostGroup ?? null }]
: [],
);
).map((m) => ({ kind: "project" as const, open: false, m }));
const acts = query ? [] : ACTIONS.filter((a) => actions.has(a.id)).map((a) => ({ kind: "action" as const, ...a }));
return [...acts, ...open, ...rest];
}, [actions, recent, groups, home, openProjects, query]);
}, [actions, recent, home, openProjects, query]);
const current = Math.min(active, entries.length - 1);
useEffect(() => {
@@ -182,7 +155,6 @@ export function ProjectPopup({ anchor, onClose }: ProjectPopupProps) {
<T>Recent Projects</T>
</Header>
)}
{e.kind === "project" && !e.open && <GroupBoundary entry={e} previous={entries[i - 1]} />}
<div
role="option"
aria-selected={i === current}
@@ -208,7 +180,7 @@ export function ProjectPopup({ anchor, onClose }: ProjectPopupProps) {
<span className={styles.label}>{tx(e.label)}</span>
</>
) : (
<ProjectRow m={e.m} active={i === current} hideHost={!e.open && e.hostGroup != null} />
<ProjectRow m={e.m} active={i === current} />
)}
</div>
</div>
@@ -232,46 +204,7 @@ function Header({ first, children }: { first: boolean; children: ReactNode }) {
);
}
function sectionKey(entry: Entry | undefined): string | null {
if (entry?.kind !== "project" || entry.open) return null;
if (entry.group) return `group:${entry.group}`;
if (entry.hostGroup) return `host:${entry.hostGroup.id}`;
return null;
}
/** A project or host group's name above its first project; a separator where sections change. */
function GroupBoundary({
entry,
previous,
}: {
entry: Extract<Entry, { kind: "project" }>;
previous: Entry | undefined;
}) {
const prevRecent = previous?.kind === "project" && !previous.open;
const before = sectionKey(previous);
const current = sectionKey(entry);
if (current === before) return null;
if (current === null) return <div className={styles.separator} role="separator" />;
return (
<>
{prevRecent && <div className={styles.separator} role="separator" />}
<div className={styles.groupHeader}>
{entry.group ? (
<>
<Icon name="folder" size={14} />
<span className={styles.label}>{entry.group}</span>
</>
) : (
entry.hostGroup && <HostGroupTitle host={entry.hostGroup} iconSize={14} />
)}
</div>
</>
);
}
function ProjectRow({ m, active, hideHost }: { m: RecentMatch; active: boolean; hideHost?: boolean }) {
const { hostMatch, locationMatch, locationText } = splitRemoteMatch(m);
function ProjectRow({ m, active }: { m: RecentMatch; active: boolean }) {
return (
<>
<ProjectBadge
@@ -287,8 +220,7 @@ function ProjectRow({ m, active, hideHost }: { m: RecentMatch; active: boolean;
indices={m.nameMatch}
tone={active ? "accent" : "strong"}
/>
{!hideHost && m.remote && <RemoteHostPill remote={m.remote} hostMatch={hostMatch} />}
<HighlightedText className={styles.path} text={locationText} indices={locationMatch} />
<HighlightedText className={styles.path} text={m.displayPath} indices={m.pathMatch} />
{m.project.branch && (
<span className={styles.metadata}>
<Icon name="branch" size={12} />