diff --git a/e2e/recentProjectsByHost.spec.ts b/e2e/recentProjectsByHost.spec.ts index 7e64ecef5..c4a7f83a1 100644 --- a/e2e/recentProjectsByHost.spec.ts +++ b/e2e/recentProjectsByHost.spec.ts @@ -1,6 +1,6 @@ import { expect, stubDesktop, test } from "./fixtures"; -test("keeps the project switcher flat while grouping Welcome and Recent Projects without row overlap", async ({ +test("keeps local and remote projects flat in all recent-project lists without row overlap", async ({ workbench: page, }) => { await page.setViewportSize({ width: 980, height: 740 }); @@ -111,7 +111,7 @@ test("keeps the project switcher flat while grouping Welcome and Recent Projects await page.keyboard.press("Escape"); await expect(projectPopup).toBeHidden(); - // 2. Recent Projects popup groups by host and never overlaps rows (grouped or 3-line search results). + // 2. Recent Projects popup is flat and never overlaps rows, including search results. await page.evaluate(async () => { const popupMod = "/src/features/welcome/RecentProjectsPopup.tsx"; const { showRecentProjectsPopup } = await import(/* @vite-ignore */ popupMod); @@ -128,20 +128,28 @@ test("keeps the project switcher flat while grouping Welcome and Recent Projects expect(boxes[i]!.y).toBeGreaterThanOrEqual(boxes[i - 1]!.y + boxes[i - 1]!.height - 0.5); } }; + await expect(recentDialog.getByRole("option")).toHaveCount(6); + await expect(recentDialog.locator("[aria-expanded]")).toHaveCount(0); + await expect(recentDialog.locator("[data-remote-badge]")).toHaveCount(4); await assertNoVerticalOverlap(); await recentDialog.getByRole("textbox", { name: "Search recent projects" }).fill("openidea_all"); await assertNoVerticalOverlap(); await page.keyboard.press("Escape"); await expect(recentDialog).toBeHidden(); - // 3. Welcome › Projects folds and unfolds host groups. + // 3. Welcome › Projects keeps all projects in recency order without host headers. await page.evaluate(async () => { const projectMod = "/src/platform/project.ts"; const { useProject } = await import(/* @vite-ignore */ projectMod); useProject.setState({ project: null, lightEdit: false }); }); const welcomeList = page.getByRole("listbox", { name: "Recent projects" }); - await expect(welcomeList.getByRole("option")).toHaveCount(11); - await welcomeList.getByRole("option").first().click(); - await expect(welcomeList.getByRole("option")).toHaveCount(9); + const welcomeRows = welcomeList.getByRole("option"); + await expect(welcomeRows).toHaveCount(7); + await expect(welcomeList.locator("[aria-expanded]")).toHaveCount(0); + await expect(welcomeList.locator("[data-remote-badge]")).toHaveCount(4); + await expect(welcomeRows.nth(0)).toContainText("dev@devbox.coder:22:/home/coder/git/openidea_all"); + await expect(welcomeRows.nth(1)).toContainText("dev-mbp1.local:/Users/dev/git/gocommon"); + await expect(welcomeRows.nth(2)).toContainText("~/git/gocommon"); + await expect(welcomeRows.nth(3)).toContainText("dev@devbox.coder:22:/home/coder/git/gocommon"); }); diff --git a/e2e/welcomeProjectsLayout.spec.ts b/e2e/welcomeProjectsLayout.spec.ts index 15b36b5d1..e4260ca06 100644 --- a/e2e/welcomeProjectsLayout.spec.ts +++ b/e2e/welcomeProjectsLayout.spec.ts @@ -42,3 +42,34 @@ test("Welcome keeps project search and actions on one row at a narrow width", as await expect(more).toBeFocused(); await expect(search).toHaveValue("tokio"); }); + +test("Welcome lists local and remote projects at the same level", async ({ workbench: page }) => { + await page.evaluate(async () => { + const projectPath = "/src/platform/project.ts"; + const { useProject } = await import(/* @vite-ignore */ projectPath); + useProject.setState({ project: null, lightEdit: false }); + }); + const list = page.getByRole("listbox", { name: "Recent projects" }); + const rows = list.getByRole("option"); + await expect(rows).toHaveCount(4); + await page.evaluate(async () => { + const recentPath = "/src/features/welcome/recent.ts"; + const { useRecent } = await import(/* @vite-ignore */ recentPath); + useRecent.setState({ + groups: [], + projects: [ + { name: "tty7", path: "ssh://macmini/Users/thomas/repo/tty7", branch: null, openedAtMs: 100 }, + { name: "OpenIDEA", path: "/Users/dev/dev/openidea", branch: null, openedAtMs: 90 }, + { name: "tty7", path: "/Users/dev/dev/tty7", branch: null, openedAtMs: 80 }, + ], + }); + }); + await expect(rows).toHaveCount(3); + await expect(rows.nth(0)).toContainText("macmini:/Users/thomas/repo/tty7"); + await expect(rows.nth(1)).toContainText("OpenIDEA"); + await expect(rows.nth(2)).toContainText("~/dev/tty7"); + await expect(list.locator("[aria-expanded]")).toHaveCount(0); + await expect(list.locator("[data-remote-badge]")).toHaveCount(1); + const avatars = await rows.evaluateAll((els) => els.map((el) => el.firstElementChild!.getBoundingClientRect().x)); + expect(avatars).toEqual([avatars[0], avatars[0], avatars[0]]); +}); diff --git a/src/features/welcome/ProjectsPage.tsx b/src/features/welcome/ProjectsPage.tsx index f66e2c5e0..61ab02e6a 100644 --- a/src/features/welcome/ProjectsPage.tsx +++ b/src/features/welcome/ProjectsPage.tsx @@ -21,26 +21,8 @@ import { showContextMenu, T, } from "@/ui"; -import { - askRemoveRecent, - groupMenu, - HostGroupTitle, - ProjectBadge, - recentMenu, - RemoteHostPill, - splitRemoteMatch, - unavailableTitle, -} from "./RecentList"; -import { - openRecent, - recentRows, - setGroupExpanded, - setHostGroupExpanded, - useRecent, - type HostGroup, - type RecentMatch, - type RecentRow, -} from "./recent"; +import { askRemoveRecent, groupMenu, ProjectBadge, recentMenu, unavailableTitle } from "./RecentList"; +import { openRecent, recentRows, setGroupExpanded, useRecent, type RecentMatch, type RecentRow } from "./recent"; import { projectWindowOverride } from "@/workbench/projectWindow"; import type { RecentProjectGroup } from "@/platform/ipc"; import styles from "./Welcome.module.css"; @@ -265,51 +247,11 @@ function GroupRow({ ); } -/** A host group (`Local` or a remote target): click or Enter folds its projects. */ -function HostGroupRow({ - host, - count, - id, - selected, - onSelect, -}: { - host: HostGroup; - count: number; - id: string; - selected: boolean; - onSelect: () => void; -}) { - const ref = useRef(null); - useEffect(() => { - if (selected) ref.current?.scrollIntoView?.({ block: "nearest" }); - }, [selected]); - return ( -
e.preventDefault()} - onClick={() => { - onSelect(); - setHostGroupExpanded(host.id, !host.expanded); - }} - > - - - {count} -
- ); -} - function ProjectRow({ m, id, selected, nested, - hideHost, onSelect, onOpen, }: { @@ -318,8 +260,6 @@ function ProjectRow({ selected: boolean; /** Listed under a group. */ nested?: boolean; - /** Listed under a host group header that already names the remote host. */ - hideHost?: boolean; onSelect: () => void; /** Its modifier keys pick the window ({@link projectWindowOverride}). */ onOpen: (e: MouseEvent) => void; @@ -330,7 +270,6 @@ function ProjectRow({ const stage = progress ? tx(stageLabel(progress.stage)) + (progress.fraction == null ? "" : ` ${Math.round(progress.fraction * 100)}%`) : null; - const { hostMatch, locationMatch, locationText } = splitRemoteMatch(m); const ref = useRef(null); useEffect(() => { if (selected) ref.current?.scrollIntoView?.({ block: "nearest" }); @@ -372,10 +311,7 @@ function ProjectRow({ {stage} ) : ( - <> - {!hideHost && m.remote && } - - + )} {m.project.branch && ( @@ -423,17 +359,13 @@ export function handleListKey( export function ProjectsPage() { const projects = useRecent((s) => s.projects); const groups = useRecent((s) => s.groups); - const collapsedHosts = useRecent((s) => s.collapsedHosts); const loaded = useRecent((s) => s.loaded); const home = useRecent((s) => s.home); const [query, setQuery] = useState(""); const [active, setActive] = useState(0); const search = useRef(null); const baseId = useId(); - const items = useMemo( - () => recentRows(projects, groups, query, home, collapsedHosts), - [projects, groups, query, home, collapsedHosts], - ); + const items = useMemo(() => recentRows(projects, groups, query, home), [projects, groups, query, home]); const current = Math.max(0, Math.min(active, items.length - 1)); if (!loaded) return null; @@ -453,11 +385,6 @@ export function ProjectsPage() { void setGroupExpanded(row.group.name, e.key === "ArrowRight"); return; } - if (row?.kind === "host") { - e.preventDefault(); - setHostGroupExpanded(row.host.id, e.key === "ArrowRight"); - return; - } } const r = handleListKey(e, { items, current, caretAtEnd }); if (!r) { @@ -484,10 +411,6 @@ export function ProjectsPage() { } return; } - if (match.kind === "host") { - if (r.kind === "open") setHostGroupExpanded(match.host.id, !match.host.expanded); - return; - } if (r.kind === "open") void openRecent(match.m.project, projectWindowOverride(e)); else if (r.kind === "remove") void askRemoveRecent(match.m.project); else { @@ -536,23 +459,13 @@ export function ProjectsPage() { selected={i === current} onSelect={() => setActive(i)} /> - ) : row.kind === "host" ? ( - setActive(i)} - /> ) : ( setActive(i)} onOpen={(e) => void openRecent(row.m.project, projectWindowOverride(e))} /> diff --git a/src/features/welcome/RecentList.tsx b/src/features/welcome/RecentList.tsx index a06e8c7d5..65a28d302 100644 --- a/src/features/welcome/RecentList.tsx +++ b/src/features/welcome/RecentList.tsx @@ -20,7 +20,6 @@ import { IconButton, SearchField, Spinner, - T, listNavigate, showContextMenu, type MenuItem, @@ -45,9 +44,7 @@ import { removeRecent, renameGroup, setGroupExpanded, - setHostGroupExpanded, useRecent, - type HostGroup, type RecentMatch, } from "./recent"; import styles from "./Welcome.module.css"; @@ -99,64 +96,6 @@ export function ProjectBadge({ ); } -/** Splits `pathMatch` of a remote `host:path` display string into host and path highlight indices. */ -export function splitRemoteMatch(m: Pick) { - const { remote, pathMatch } = m; - if (!remote) return { hostMatch: null, locationMatch: pathMatch, locationText: m.displayPath }; - const pathStart = remote.host.length + 1; - return { - hostMatch: pathMatch ? pathMatch.filter((i) => i < remote.host.length) : null, - locationMatch: pathMatch ? pathMatch.filter((i) => i >= pathStart).map((i) => i - pathStart) : null, - locationText: remote.path, - }; -} - -/** SSH / WSL / Dev Container host label shown on remote project rows. */ -export function RemoteHostPill({ - remote, - hostMatch, -}: { - remote: NonNullable; - hostMatch: number[] | null; -}) { - return ( - - - {remote.kindLabel} - - - - ); -} - -/** Icon and label of a `Local` or remote host group header. */ -export function HostGroupTitle({ host, iconSize }: { host: HostGroup; iconSize: number }) { - if (host.kind === "local") { - return ( - <> - - - Local - - - ); - } - return ( - <> - - - {host.kindLabel} - - {host.host} - - - ); -} - /** Change Project Icon…: an SVG or PNG for the project, kept in its `.openidea` folder. */ async function chooseProjectIcon(root: string) { const file = await openDialog({ filters: [{ name: tx("Image files"), extensions: ["svg", "png"] }] }); @@ -314,18 +253,15 @@ function RecentRow({ m, active, compact, - hideHost, onOpened, }: { m: RecentMatch; active: boolean; compact?: boolean; - hideHost?: boolean; onOpened?: () => void; }) { const opening = useRecent((s) => s.opening === m.project.path); const when = relativeTime(m.project.openedAtMs); - const { hostMatch, locationMatch, locationText } = splitRemoteMatch(m); return (
@@ -344,8 +280,7 @@ function RecentRow({ )} - {!hideHost && m.remote && } - + {opening ? ( @@ -387,7 +322,6 @@ export interface RecentListProps { export function RecentList({ exclude, compact, autoFocus, onOpened, className, toolbar }: RecentListProps) { const projects = useRecent((s) => s.projects); const groups = useRecent((s) => s.groups); - const collapsedHosts = useRecent((s) => s.collapsedHosts); const home = useRecent((s) => s.home); const [query, setQuery] = useState(""); const [active, setActive] = useState(0); @@ -397,10 +331,7 @@ export function RecentList({ exclude, compact, autoFocus, onOpened, className, t () => (exclude ? projects.filter((p) => p.path !== exclude) : projects), [projects, exclude], ); - const items = useMemo( - () => recentRows(visibleProjects, groups, query, home, collapsedHosts), - [visibleProjects, groups, query, home, collapsedHosts], - ); + const items = useMemo(() => recentRows(visibleProjects, groups, query, home), [visibleProjects, groups, query, home]); const current = Math.max(0, Math.min(active, items.length - 1)); useEffect(() => { @@ -421,16 +352,10 @@ export function RecentList({ exclude, compact, autoFocus, onOpened, className, t void setGroupExpanded(row.group.name, e.key === "ArrowRight"); return; } - if (row?.kind === "host") { - e.preventDefault(); - setHostGroupExpanded(row.host.id, e.key === "ArrowRight"); - return; - } } if (e.key === "Enter") { e.preventDefault(); if (row?.kind === "group") void setGroupExpanded(row.group.name, !row.group.expanded); - else if (row?.kind === "host") setHostGroupExpanded(row.host.id, !row.host.expanded); else if (row?.kind === "project") open(row.m, e); return; } @@ -540,30 +465,7 @@ export function RecentList({ exclude, compact, autoFocus, onOpened, className, t
); } - if (row.kind === "host") { - return ( -
{ - if (e.button !== 0) return; - e.preventDefault(); - setActive(i); - }} - onClick={() => setHostGroupExpanded(row.host.id, !row.host.expanded)} - > - - - {row.count} -
- ); - } - const nested = row.group !== null || row.hostGroup != null; + const nested = row.group !== null; return (
- +
); }) diff --git a/src/features/welcome/Welcome.module.css b/src/features/welcome/Welcome.module.css index 1f91a5487..4d891b4e5 100644 --- a/src/features/welcome/Welcome.module.css +++ b/src/features/welcome/Welcome.module.css @@ -243,31 +243,6 @@ height: 14px; border-radius: 4px; } -.remoteHostPill { - display: inline-flex; - align-items: center; - align-self: flex-start; - gap: var(--space-1); - max-width: 100%; - min-width: 0; - color: var(--fg-secondary); - --icon-color: var(--fg-muted); - font-size: var(--fs-small); -} -.remoteKind { - flex: none; - font-weight: normal; -} -.remoteDot { - flex: none; - opacity: 0.65; -} -.remoteHostText { - min-width: 0; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} /* A project group: one line, folds its projects. */ .group { align-items: center; @@ -283,27 +258,6 @@ text-overflow: ellipsis; white-space: nowrap; } -.hostTitle { - flex: 1; - min-width: 0; - display: inline-flex; - align-items: center; - gap: var(--space-1); - color: var(--fg-strong); - font-weight: 600; - overflow: hidden; - white-space: nowrap; -} -.hostKind { - flex: none; - color: var(--fg-muted); - font-weight: 500; -} -.hostName { - min-width: 0; - overflow: hidden; - text-overflow: ellipsis; -} .groupCount { color: var(--fg-faint); } diff --git a/src/features/welcome/recent.test.ts b/src/features/welcome/recent.test.ts index 6efe6d25f..4543f2afc 100644 --- a/src/features/welcome/recent.test.ts +++ b/src/features/welcome/recent.test.ts @@ -91,16 +91,11 @@ describe("session restore", () => { describe("project groups", () => { const formatRow = (r: ReturnType[number]) => { if (r.kind === "group") return `[${r.group.name} ${r.count}]`; - if (r.kind === "host") - return `{${r.host.kind === "local" ? "Local" : `${r.host.kindLabel} · ${r.host.host}`} ${r.count}}`; - return `${r.group || r.hostGroup ? " " : ""}${r.m.project.name}`; + return `${r.group ? " " : ""}${r.m.project.name}`; }; - const rows = (query = "") => - recentRows(projects, useRecent.getState().groups, query, "/Users/me", useRecent.getState().collapsedHosts).map( - formatRow, - ); + const rows = (query = "") => recentRows(projects, useRecent.getState().groups, query, "/Users/me").map(formatRow); afterEach(() => { - useRecent.setState({ groups: [], collapsedHosts: [] }); + useRecent.setState({ groups: [] }); localStorage.clear(); }); @@ -138,7 +133,7 @@ describe("project groups", () => { expect(rows()).toEqual(["acme-api", "openidea-ide", "tokio", "notes"]); }); - it("groups ungrouped projects by Local and remote host when remote entries exist", async () => { + it("keeps ungrouped local and remote projects together in recency order", async () => { const mixed = [ { path: "ssh://devbox/srv/acme", name: "acme-remote", openedAtMs: 50, branch: null }, ...projects, @@ -149,25 +144,12 @@ describe("project groups", () => { expect(recentRows(mixed, useRecent.getState().groups, "", "/Users/me").map(formatRow)).toEqual([ "[Pinned 1]", " acme-api", - "{SSH · devbox 2}", - " acme-remote", - " lib-remote", - "{Local 3}", - " openidea-ide", - " tokio", - " notes", - "{WSL · Ubuntu 1}", - " tokio-wsl", - ]); - expect(recentRows(mixed, useRecent.getState().groups, "", "/Users/me", ["local"]).map(formatRow)).toEqual([ - "[Pinned 1]", - " acme-api", - "{SSH · devbox 2}", - " acme-remote", - " lib-remote", - "{Local 3}", - "{WSL · Ubuntu 1}", - " tokio-wsl", + "acme-remote", + "openidea-ide", + "tokio", + "notes", + "tokio-wsl", + "lib-remote", ]); }); }); diff --git a/src/features/welcome/recent.ts b/src/features/welcome/recent.ts index cc0cae97d..0455fafad 100644 --- a/src/features/welcome/recent.ts +++ b/src/features/welcome/recent.ts @@ -32,8 +32,6 @@ interface RecentState { projects: RecentProject[]; /** Project groups (New Project Group…), shown above the ungrouped projects. */ groups: RecentProjectGroup[]; - /** Host group ids (`local`, `ssh:…`, `wsl:…`) folded by the user. */ - collapsedHosts: string[]; loaded: boolean; home: string | null; version: string | null; @@ -41,30 +39,9 @@ interface RecentState { opening: string | null; } -const COLLAPSED_HOSTS_KEY = "openidea.recent.collapsedHosts"; - -function readCollapsedHosts(): string[] { - try { - const raw = JSON.parse(localStorage.getItem(COLLAPSED_HOSTS_KEY) ?? "[]") as unknown; - return Array.isArray(raw) ? raw.filter((v): v is string => typeof v === "string") : []; - } catch { - return []; - } -} - -function writeCollapsedHosts(ids: string[]) { - try { - if (ids.length) localStorage.setItem(COLLAPSED_HOSTS_KEY, JSON.stringify(ids)); - else localStorage.removeItem(COLLAPSED_HOSTS_KEY); - } catch { - /* storage unavailable */ - } -} - export const useRecent = create(() => ({ projects: [], groups: [], - collapsedHosts: readCollapsedHosts(), loaded: false, home: null, version: null, @@ -87,7 +64,6 @@ export async function loadRecent() { if (!isTauri()) { useRecent.setState({ projects: SAMPLE, - collapsedHosts: readCollapsedHosts(), loaded: true, home: "/Users/dev", version: "0.1.0-dev", @@ -103,7 +79,6 @@ export async function loadRecent() { useRecent.setState({ projects: withRemotes(projects), groups, - collapsedHosts: readCollapsedHosts(), loaded: true, version: info?.version ?? useRecent.getState().version, home: home ? home.replace(/\/+$/, "") : useRecent.getState().home, @@ -378,43 +353,23 @@ export function setGroupExpanded(name: string, expanded: boolean) { return saveGroups(groups().map((g) => (g.name === name ? { ...g, expanded } : g))); } -export function setHostGroupExpanded(id: string, expanded: boolean) { - const current = useRecent.getState().collapsedHosts; - const next = expanded ? current.filter((h) => h !== id) : current.includes(id) ? current : [...current, id]; - useRecent.setState({ collapsedHosts: next }); - writeCollapsedHosts(next); -} - -export type HostGroup = - | { id: "local"; kind: "local"; expanded: boolean } - | { - id: string; - kind: RemoteTarget["kind"]; - kindLabel: string; - host: string; - expanded: boolean; - }; - export type RecentRow = | { kind: "group"; group: RecentProjectGroup; count: number } - | { kind: "host"; host: HostGroup; count: number } - | { kind: "project"; m: RecentMatch; group: string | null; hostGroup?: HostGroup | null }; + | { kind: "project"; m: RecentMatch; group: string | null }; /** * The rows of the list: without a query, custom groups first (their projects under the expanded - * ones, most recent first), then the remaining projects grouped by host (`Local` and each remote - * host in MRU order) when any remote project exists, or flat when all projects are local; while - * searching, the matches only. + * ones, most recent first), then all remaining local and remote projects in recency order. + * While searching, the matches only. */ export function recentRows( projects: readonly RecentProject[], groupList: readonly RecentProjectGroup[], query: string, home?: string | null, - collapsedHosts: readonly string[] = [], ): RecentRow[] { const matches = filterRecent(projects, query, home); - if (query.trim()) return matches.map((m) => ({ kind: "project", m, group: null, hostGroup: null })); + if (query.trim()) return matches.map((m) => ({ kind: "project", m, group: null })); const rows: RecentRow[] = []; const grouped = new Set(); for (const group of groupList) { @@ -422,39 +377,11 @@ export function recentRows( members.forEach((m) => grouped.add(m.project.path)); rows.push({ kind: "group", group, count: members.length }); if (group.expanded) { - rows.push(...members.map((m): RecentRow => ({ kind: "project", m, group: group.name, hostGroup: null }))); + rows.push(...members.map((m): RecentRow => ({ kind: "project", m, group: group.name }))); } } - const rest = matches.filter((m) => !grouped.has(m.project.path)); - if (!rest.some((m) => m.remote !== null)) { - for (const m of rest) rows.push({ kind: "project", m, group: null, hostGroup: null }); - return rows; - } - const collapsed = new Set(collapsedHosts); - const buckets = new Map(); - for (const m of rest) { - const id = m.remote ? `${m.remote.kind}:${m.remote.host}` : "local"; - let bucket = buckets.get(id); - if (!bucket) { - const host: HostGroup = m.remote - ? { - id, - kind: m.remote.kind, - kindLabel: m.remote.kindLabel, - host: m.remote.host, - expanded: !collapsed.has(id), - } - : { id: "local", kind: "local", expanded: !collapsed.has("local") }; - bucket = { host, members: [] }; - buckets.set(id, bucket); - } - bucket.members.push(m); - } - for (const { host, members } of buckets.values()) { - rows.push({ kind: "host", host, count: members.length }); - if (host.expanded) { - rows.push(...members.map((m): RecentRow => ({ kind: "project", m, group: null, hostGroup: host }))); - } + for (const m of matches) { + if (!grouped.has(m.project.path)) rows.push({ kind: "project", m, group: null }); } return rows; } diff --git a/src/features/welcome/welcome.test.tsx b/src/features/welcome/welcome.test.tsx index 178ea346d..e64205b13 100644 --- a/src/features/welcome/welcome.test.tsx +++ b/src/features/welcome/welcome.test.tsx @@ -277,7 +277,7 @@ describe("Welcome › Projects", () => { expect(screen.queryByLabelText("Search projects")).toBeNull(); }); - it("groups projects by Local and remote host in MRU order, folds hosts, and flattens on search", async () => { + it("shows local and remote projects in one MRU list, ignoring old collapsed hosts", async () => { recent = [ { name: "gocommon", path: "/Users/me/git/gocommon", branch: "main", openedAtMs: 70 }, { name: "openidea_all", path: "/Users/me/git/openidea_all", branch: null, openedAtMs: 40 }, @@ -308,32 +308,28 @@ describe("Welcome › Projects", () => { }, ]), ); + // Previously collapsed hosts must not hide any projects in the flat list. + localStorage.setItem("openidea.recent.collapsedHosts", JSON.stringify(["local", "ssh:dev@devbox:22"])); await renderWelcome(); const options = () => screen.getAllByRole("option"); expect(options().map((o) => o.textContent)).toEqual([ - "SSH·dev@devbox:222", - expect.stringContaining("openidea_all/home/coder/git/openidea_all"), - expect.stringContaining("gocommon/home/coder/git/gocommon"), - "Local2", + expect.stringContaining("openidea_alldev@devbox:22:/home/coder/git/openidea_all"), expect.stringContaining("gocommon~/git/gocommonmain"), + expect.stringContaining("gocommondev@devbox:22:/home/coder/git/gocommon"), expect.stringContaining("openidea_all~/git/openidea_all"), - "WSL·Ubuntu1", - expect.stringContaining("openidea_all/home/me/git/openidea_all"), + expect.stringContaining("openidea_allUbuntu:/home/me/git/openidea_all"), ]); - // Grouped rows omit the redundant per-row RemoteHostPill while keeping the badge corner. - expect(options()[1]!.querySelector("[data-remote-badge]")).not.toBeNull(); - expect(options()[1]!.querySelector('[data-remote-kind="ssh"]')).toBeNull(); + expect(options().map((o) => !!o.querySelector("[data-remote-badge]"))).toEqual([true, false, true, false, true]); + expect(options().every((o) => !o.hasAttribute("aria-expanded"))).toBe(true); - // Folding SSH · dev@devbox:22 hides its 2 projects and persists across reloads. - fireEvent.click(options()[0]!); - expect(options()).toHaveLength(6); - expect(JSON.parse(localStorage.getItem("openidea.recent.collapsedHosts") ?? "[]")).toEqual(["ssh:dev@devbox:22"]); - - // Searching flattens the list and restores per-row remote host pills even for folded hosts. const search = screen.getByLabelText("Search projects"); - fireEvent.change(search, { target: { value: "openidea_all" } }); - expect(options()).toHaveLength(3); - expect(options()[0]!.querySelector('[data-remote-kind="ssh"]')?.textContent).toContain("dev@devbox:22"); + fireEvent.keyDown(search, { key: "ArrowDown" }); + expect(options()[1]!.getAttribute("aria-selected")).toBe("true"); + fireEvent.change(search, { target: { value: "devbox" } }); + expect(options()).toHaveLength(2); + expect(options()[0]!.textContent).toContain("dev@devbox:22:/home/coder/git/openidea_all"); + fireEvent.change(search, { target: { value: "" } }); + expect(options()).toHaveLength(5); }); it("excludes only the active remote location in RecentProjectsPopup, not a local folder at the same path", async () => { @@ -374,9 +370,7 @@ describe("Welcome › Projects", () => { .getAllByRole("option") .map((o) => o.textContent); expect(texts).toEqual([ - "SSH·mbp.local1", - expect.stringContaining("gocommon/Users/me/git/gocommon"), - "Local1", + expect.stringContaining("gocommonmbp.local:/Users/me/git/gocommon"), expect.stringContaining("openidea_all~/git/openidea_all"), ]); } finally {