GeezerVison is showing github.com — feat(app): sidebar reveal animation, hover peek overlay, and weaker d… · evilbuck/opencode@b0bc3d8
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/app/e2e/actions.ts +48-45Lines changed: 48 additions & 45 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -5,10 +5,10 @@ import path from "node:path" | 5 | 5 | import { execSync } from "node:child_process" | 6 | 6 | import { modKey, serverUrl } from "./utils" | 7 | 7 | import { | 8 | | - sessionItemSelector, | 9 | 8 | dropdownMenuTriggerSelector, | 10 | 9 | dropdownMenuContentSelector, | 11 | 10 | projectMenuTriggerSelector, | | 11 | + projectCloseMenuSelector, | 12 | 12 | projectWorkspacesToggleSelector, | 13 | 13 | titlebarRightSelector, | 14 | 14 | popoverBodySelector, | @@ -61,9 +61,9 @@ export async function closeDialog(page: Page, dialog: Locator) { | 61 | 61 | } | 62 | 62 |
| 63 | 63 | export async function isSidebarClosed(page: Page) { | 64 | | - const main = page.locator("main") | 65 | | - const classes = (await main.getAttribute("class")) ?? "" | 66 | | - return classes.includes("xl:border-l") | | 64 | + const button = page.getByRole("button", { name: /toggle sidebar/i }).first() | | 65 | + await expect(button).toBeVisible() | | 66 | + return (await button.getAttribute("aria-expanded")) !== "true" | 67 | 67 | } | 68 | 68 |
| 69 | 69 | export async function toggleSidebar(page: Page) { | @@ -75,48 +75,34 @@ export async function openSidebar(page: Page) { | 75 | 75 | if (!(await isSidebarClosed(page))) return | 76 | 76 |
| 77 | 77 | const button = page.getByRole("button", { name: /toggle sidebar/i }).first() | 78 | | - const visible = await button | 79 | | - .isVisible() | 80 | | - .then((x) => x) | 81 | | - .catch(() => false) | 82 | | - | 83 | | - if (visible) await button.click() | 84 | | - if (!visible) await toggleSidebar(page) | | 78 | + await button.click() | 85 | 79 |
| 86 | | - const main = page.locator("main") | 87 | | - const opened = await expect(main) | 88 | | - .not.toHaveClass(/xl:border-l/, { timeout: 1500 }) | | 80 | + const opened = await expect(button) | | 81 | + .toHaveAttribute("aria-expanded", "true", { timeout: 1500 }) | 89 | 82 | .then(() => true) | 90 | 83 | .catch(() => false) | 91 | 84 |
| 92 | 85 | if (opened) return | 93 | 86 |
| 94 | 87 | await toggleSidebar(page) | 95 | | - await expect(main).not.toHaveClass(/xl:border-l/) | | 88 | + await expect(button).toHaveAttribute("aria-expanded", "true") | 96 | 89 | } | 97 | 90 |
| 98 | 91 | export async function closeSidebar(page: Page) { | 99 | 92 | if (await isSidebarClosed(page)) return | 100 | 93 |
| 101 | 94 | const button = page.getByRole("button", { name: /toggle sidebar/i }).first() | 102 | | - const visible = await button | 103 | | - .isVisible() | 104 | | - .then((x) => x) | 105 | | - .catch(() => false) | 106 | | - | 107 | | - if (visible) await button.click() | 108 | | - if (!visible) await toggleSidebar(page) | | 95 | + await button.click() | 109 | 96 |
| 110 | | - const main = page.locator("main") | 111 | | - const closed = await expect(main) | 112 | | - .toHaveClass(/xl:border-l/, { timeout: 1500 }) | | 97 | + const closed = await expect(button) | | 98 | + .toHaveAttribute("aria-expanded", "false", { timeout: 1500 }) | 113 | 99 | .then(() => true) | 114 | 100 | .catch(() => false) | 115 | 101 |
| 116 | 102 | if (closed) return | 117 | 103 |
| 118 | 104 | await toggleSidebar(page) | 119 | | - await expect(main).toHaveClass(/xl:border-l/) | | 105 | + await expect(button).toHaveAttribute("aria-expanded", "false") | 120 | 106 | } | 121 | 107 |
| 122 | 108 | export async function openSettings(page: Page) { | @@ -220,7 +206,7 @@ export function sessionIDFromUrl(url: string) { | 220 | 206 | } | 221 | 207 |
| 222 | 208 | export async function hoverSessionItem(page: Page, sessionID: string) { | 223 | | - const sessionEl = page.locator(sessionItemSelector(sessionID)).first() | | 209 | + const sessionEl = page.locator(`[data-session-id="${sessionID}"]`).last() | 224 | 210 | await expect(sessionEl).toBeVisible() | 225 | 211 | await sessionEl.hover() | 226 | 212 | return sessionEl | @@ -570,32 +556,42 @@ export async function openProjectMenu(page: Page, projectSlug: string) { | 570 | 556 | const trigger = page.locator(projectMenuTriggerSelector(projectSlug)).first() | 571 | 557 | await expect(trigger).toHaveCount(1) | 572 | 558 |
| | 559 | + const menu = page | | 560 | + .locator(dropdownMenuContentSelector) | | 561 | + .filter({ has: page.locator(projectCloseMenuSelector(projectSlug)) }) | | 562 | + .first() | | 563 | + const close = menu.locator(projectCloseMenuSelector(projectSlug)).first() | | 564 | + | | 565 | + const clicked = await trigger | | 566 | + .click({ timeout: 1500 }) | | 567 | + .then(() => true) | | 568 | + .catch(() => false) | | 569 | + | | 570 | + if (clicked) { | | 571 | + const opened = await menu | | 572 | + .waitFor({ state: "visible", timeout: 1500 }) | | 573 | + .then(() => true) | | 574 | + .catch(() => false) | | 575 | + if (opened) { | | 576 | + await expect(close).toBeVisible() | | 577 | + return menu | | 578 | + } | | 579 | + } | | 580 | + | 573 | 581 | await trigger.focus() | 574 | 582 | await page.keyboard.press("Enter") | 575 | 583 |
| 576 | | - const menu = page.locator(dropdownMenuContentSelector).first() | 577 | 584 | const opened = await menu | 578 | 585 | .waitFor({ state: "visible", timeout: 1500 }) | 579 | 586 | .then(() => true) | 580 | 587 | .catch(() => false) | 581 | 588 |
| 582 | 589 | if (opened) { | 583 | | - const viewport = page.viewportSize() | 584 | | - const x = viewport ? Math.max(viewport.width - 5, 0) : 1200 | 585 | | - const y = viewport ? Math.max(viewport.height - 5, 0) : 800 | 586 | | - await page.mouse.move(x, y) | | 590 | + await expect(close).toBeVisible() | 587 | 591 | return menu | 588 | 592 | } | 589 | 593 |
| 590 | | - await trigger.click({ force: true }) | 591 | | - | 592 | | - await expect(menu).toBeVisible() | 593 | | - | 594 | | - const viewport = page.viewportSize() | 595 | | - const x = viewport ? Math.max(viewport.width - 5, 0) : 1200 | 596 | | - const y = viewport ? Math.max(viewport.height - 5, 0) : 800 | 597 | | - await page.mouse.move(x, y) | 598 | | - return menu | | 594 | + throw new Error(`Failed to open project menu: ${projectSlug}`) | 599 | 595 | } | 600 | 596 |
| 601 | 597 | export async function setWorkspacesEnabled(page: Page, projectSlug: string, enabled: boolean) { | @@ -608,11 +604,18 @@ export async function setWorkspacesEnabled(page: Page, projectSlug: string, enab | 608 | 604 |
| 609 | 605 | if (current === enabled) return | 610 | 606 |
| 611 | | - await openProjectMenu(page, projectSlug) | | 607 | + const flip = async (timeout?: number) => { | | 608 | + const menu = await openProjectMenu(page, projectSlug) | | 609 | + const toggle = menu.locator(projectWorkspacesToggleSelector(projectSlug)).first() | | 610 | + await expect(toggle).toBeVisible() | | 611 | + return toggle.click({ force: true, timeout }) | | 612 | + } | | 613 | + | | 614 | + const flipped = await flip(1500) | | 615 | + .then(() => true) | | 616 | + .catch(() => false) | 612 | 617 |
| 613 | | - const toggle = page.locator(projectWorkspacesToggleSelector(projectSlug)).first() | 614 | | - await expect(toggle).toBeVisible() | 615 | | - await toggle.click({ force: true }) | | 618 | + if (!flipped) await flip() | 616 | 619 |
| 617 | 620 | const expected = enabled ? "New workspace" : "New session" | 618 | 621 | await expect(page.getByRole("button", { name: expected }).first()).toBeVisible() | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/e2e/app/titlebar-history.spec.ts -4Lines changed: 0 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -16,7 +16,6 @@ test("titlebar back/forward navigates between sessions", async ({ page, slug, sd | 16 | 16 |
| 17 | 17 | const link = page.locator(`[data-session-id="${two.id}"] a`).first() | 18 | 18 | await expect(link).toBeVisible() | 19 | | - await link.scrollIntoViewIfNeeded() | 20 | 19 | await link.click() | 21 | 20 |
| 22 | 21 | await expect(page).toHaveURL(new RegExp(`/${slug}/session/${two.id}(?:\\?|#|$)`)) | @@ -56,7 +55,6 @@ test("titlebar forward is cleared after branching history from sidebar", async ( | 56 | 55 |
| 57 | 56 | const second = page.locator(`[data-session-id="${b.id}"] a`).first() | 58 | 57 | await expect(second).toBeVisible() | 59 | | - await second.scrollIntoViewIfNeeded() | 60 | 58 | await second.click() | 61 | 59 |
| 62 | 60 | await expect(page).toHaveURL(new RegExp(`/${slug}/session/${b.id}(?:\\?|#|$)`)) | @@ -76,7 +74,6 @@ test("titlebar forward is cleared after branching history from sidebar", async ( | 76 | 74 |
| 77 | 75 | const third = page.locator(`[data-session-id="${c.id}"] a`).first() | 78 | 76 | await expect(third).toBeVisible() | 79 | | - await third.scrollIntoViewIfNeeded() | 80 | 77 | await third.click() | 81 | 78 |
| 82 | 79 | await expect(page).toHaveURL(new RegExp(`/${slug}/session/${c.id}(?:\\?|#|$)`)) | @@ -102,7 +99,6 @@ test("keyboard shortcuts navigate titlebar history", async ({ page, slug, sdk, g | 102 | 99 |
| 103 | 100 | const link = page.locator(`[data-session-id="${two.id}"] a`).first() | 104 | 101 | await expect(link).toBeVisible() | 105 | | - await link.scrollIntoViewIfNeeded() | 106 | 102 | await link.click() | 107 | 103 |
| 108 | 104 | await expect(page).toHaveURL(new RegExp(`/${slug}/session/${two.id}(?:\\?|#|$)`)) | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/e2e/projects/project-edit.spec.ts +4-14Lines changed: 4 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { test, expect } from "../fixtures" | 2 | | -import { openSidebar } from "../actions" | | 2 | +import { clickMenuItem, openProjectMenu, openSidebar } from "../actions" | 3 | 3 |
| 4 | 4 | test("dialog edit project updates name and startup script", async ({ page, withProject }) => { | 5 | 5 | await page.setViewportSize({ width: 1400, height: 800 }) | 6 | 6 |
| 7 | | - await withProject(async () => { | | 7 | + await withProject(async ({ slug }) => { | 8 | 8 | await openSidebar(page) | 9 | 9 |
| 10 | 10 | const open = async () => { | 11 | | - const header = page.locator(".group\\/project").first() | 12 | | - await header.hover() | 13 | | - const trigger = header.getByRole("button", { name: "More options" }).first() | 14 | | - await expect(trigger).toBeVisible() | 15 | | - await trigger.click({ force: true }) | 16 | | - | 17 | | - const menu = page.locator('[data-component="dropdown-menu-content"]').first() | 18 | | - await expect(menu).toBeVisible() | 19 | | - | 20 | | - const editItem = menu.getByRole("menuitem", { name: "Edit" }).first() | 21 | | - await expect(editItem).toBeVisible() | 22 | | - await editItem.click({ force: true }) | | 11 | + const menu = await openProjectMenu(page, slug) | | 12 | + await clickMenuItem(menu, /^Edit$/i, { force: true }) | 23 | 13 |
| 24 | 14 | const dialog = page.getByRole("dialog") | 25 | 15 | await expect(dialog).toBeVisible() | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/e2e/projects/projects-switch.spec.ts +37-9Lines changed: 37 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { base64Decode } from "@opencode-ai/util/encode" | | 2 | +import type { Page } from "@playwright/test" | 2 | 3 | import { test, expect } from "../fixtures" | 3 | | -import { | 4 | | - defocus, | 5 | | - createTestProject, | 6 | | - cleanupTestProject, | 7 | | - openSidebar, | 8 | | - setWorkspacesEnabled, | 9 | | - sessionIDFromUrl, | 10 | | -} from "../actions" | | 4 | +import { defocus, createTestProject, cleanupTestProject, openSidebar, sessionIDFromUrl } from "../actions" | 11 | 5 | import { projectSwitchSelector, promptSelector, workspaceItemSelector, workspaceNewSessionSelector } from "../selectors" | 12 | 6 | import { createSdk, dirSlug, sessionPath } from "../utils" | 13 | 7 |
| 14 | 8 | function slugFromUrl(url: string) { | 15 | 9 | return /\/([^/]+)\/session(?:\/|$)/.exec(url)?.[1] ?? "" | 16 | 10 | } | 17 | 11 |
| | 12 | +async function workspaces(page: Page, directory: string, enabled: boolean) { | | 13 | + await page.evaluate( | | 14 | + ({ directory, enabled }: { directory: string; enabled: boolean }) => { | | 15 | + const key = "opencode.global.dat:layout" | | 16 | + const raw = localStorage.getItem(key) | | 17 | + const data = raw ? JSON.parse(raw) : {} | | 18 | + const sidebar = data.sidebar && typeof data.sidebar === "object" ? data.sidebar : {} | | 19 | + const current = | | 20 | + sidebar.workspaces && typeof sidebar.workspaces === "object" && !Array.isArray(sidebar.workspaces) | | 21 | + ? sidebar.workspaces | | 22 | + : {} | | 23 | + const next = { ...current } | | 24 | + | | 25 | + if (enabled) next[directory] = true | | 26 | + if (!enabled) delete next[directory] | | 27 | + | | 28 | + localStorage.setItem( | | 29 | + key, | | 30 | + JSON.stringify({ | | 31 | + ...data, | | 32 | + sidebar: { | | 33 | + ...sidebar, | | 34 | + workspaces: next, | | 35 | + }, | | 36 | + }), | | 37 | + ) | | 38 | + }, | | 39 | + { directory, enabled }, | | 40 | + ) | | 41 | +} | | 42 | + | 18 | 43 | test("can switch between projects from sidebar", async ({ page, withProject }) => { | 19 | 44 | await page.setViewportSize({ width: 1400, height: 800 }) | 20 | 45 |
| @@ -60,8 +85,11 @@ test("switching back to a project opens the latest workspace session", async ({ | 60 | 85 | async ({ directory, slug }) => { | 61 | 86 | rootDir = directory | 62 | 87 | await defocus(page) | | 88 | + await workspaces(page, directory, true) | | 89 | + await page.reload() | | 90 | + await expect(page.locator(promptSelector)).toBeVisible() | 63 | 91 | await openSidebar(page) | 64 | | - await setWorkspacesEnabled(page, slug, true) | | 92 | + await expect(page.getByRole("button", { name: "New workspace" }).first()).toBeVisible() | 65 | 93 |
| 66 | 94 | await page.getByRole("button", { name: "New workspace" }).first().click() | 67 | 95 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/app/e2e/projects/workspaces.spec.ts -3Lines changed: 0 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -336,9 +336,6 @@ test("can reorder workspaces by drag and drop", async ({ page, withProject }) => | 336 | 336 | const src = page.locator(workspaceItemSelector(from)).first() | 337 | 337 | const dst = page.locator(workspaceItemSelector(to)).first() | 338 | 338 |
| 339 | | - await src.scrollIntoViewIfNeeded() | 340 | | - await dst.scrollIntoViewIfNeeded() | 341 | | - | 342 | 339 | const a = await src.boundingBox() | 343 | 340 | const b = await dst.boundingBox() | 344 | 341 | if (!a || !b) throw new Error("Failed to resolve workspace drag bounds") | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/e2e/settings/settings-keybinds.spec.ts +6-9Lines changed: 6 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -32,22 +32,19 @@ test("changing sidebar toggle keybind works", async ({ page, gotoSession }) => { | 32 | 32 |
| 33 | 33 | await closeDialog(page, dialog) | 34 | 34 |
| 35 | | - const main = page.locator("main") | 36 | | - const initialClasses = (await main.getAttribute("class")) ?? "" | 37 | | - const initiallyClosed = initialClasses.includes("xl:border-l") | | 35 | + const button = page.getByRole("button", { name: /toggle sidebar/i }).first() | | 36 | + const initiallyClosed = (await button.getAttribute("aria-expanded")) !== "true" | 38 | 37 |
| 39 | 38 | await page.keyboard.press(`${modKey}+Shift+H`) | 40 | | - await page.waitForTimeout(100) | | 39 | + await expect(button).toHaveAttribute("aria-expanded", initiallyClosed ? "true" : "false") | 41 | 40 |
| 42 | | - const afterToggleClasses = (await main.getAttribute("class")) ?? "" | 43 | | - const afterToggleClosed = afterToggleClasses.includes("xl:border-l") | | 41 | + const afterToggleClosed = (await button.getAttribute("aria-expanded")) !== "true" | 44 | 42 | expect(afterToggleClosed).toBe(!initiallyClosed) | 45 | 43 |
| 46 | 44 | await page.keyboard.press(`${modKey}+Shift+H`) | 47 | | - await page.waitForTimeout(100) | | 45 | + await expect(button).toHaveAttribute("aria-expanded", initiallyClosed ? "false" : "true") | 48 | 46 |
| 49 | | - const finalClasses = (await main.getAttribute("class")) ?? "" | 50 | | - const finalClosed = finalClasses.includes("xl:border-l") | | 47 | + const finalClosed = (await button.getAttribute("aria-expanded")) !== "true" | 51 | 48 | expect(finalClosed).toBe(initiallyClosed) | 52 | 49 | }) | 53 | 50 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/app/e2e/sidebar/sidebar-popover-actions.spec.ts +7-4Lines changed: 7 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { test, expect } from "../fixtures" | 2 | 2 | import { closeSidebar, hoverSessionItem } from "../actions" | 3 | | -import { projectSwitchSelector, sessionItemSelector } from "../selectors" | | 3 | +import { projectSwitchSelector } from "../selectors" | 4 | 4 |
| 5 | 5 | test("collapsed sidebar popover stays open when archiving a session", async ({ page, slug, sdk, gotoSession }) => { | 6 | 6 | const stamp = Date.now() | @@ -15,20 +15,23 @@ test("collapsed sidebar popover stays open when archiving a session", async ({ p | 15 | 15 | await gotoSession(one.id) | 16 | 16 | await closeSidebar(page) | 17 | 17 |
| | 18 | + const oneItem = page.locator(`[data-session-id="${one.id}"]`).last() | | 19 | + const twoItem = page.locator(`[data-session-id="${two.id}"]`).last() | | 20 | + | 18 | 21 | const project = page.locator(projectSwitchSelector(slug)).first() | 19 | 22 | await expect(project).toBeVisible() | 20 | 23 | await project.hover() | 21 | 24 |
| 22 | | - await expect(page.locator(sessionItemSelector(one.id)).first()).toBeVisible() | 23 | | - await expect(page.locator(sessionItemSelector(two.id)).first()).toBeVisible() | | 25 | + await expect(oneItem).toBeVisible() | | 26 | + await expect(twoItem).toBeVisible() | 24 | 27 |
| 25 | 28 | const item = await hoverSessionItem(page, one.id) | 26 | 29 | await item | 27 | 30 | .getByRole("button", { name: /archive/i }) | 28 | 31 | .first() | 29 | 32 | .click() | 30 | 33 |
| 31 | | - await expect(page.locator(sessionItemSelector(two.id)).first()).toBeVisible() | | 34 | + await expect(twoItem).toBeVisible() | 32 | 35 | } finally { | 33 | 36 | await sdk.session.delete({ sessionID: one.id }).catch(() => undefined) | 34 | 37 | await sdk.session.delete({ sessionID: two.id }).catch(() => undefined) | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/e2e/sidebar/sidebar-session-links.spec.ts -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -18,7 +18,6 @@ test("sidebar session links navigate to the selected session", async ({ page, sl | 18 | 18 |
| 19 | 19 | const target = page.locator(`[data-session-id="${two.id}"] a`).first() | 20 | 20 | await expect(target).toBeVisible() | 21 | | - await target.scrollIntoViewIfNeeded() | 22 | 21 | await target.click() | 23 | 22 |
| 24 | 23 | await expect(page).toHaveURL(new RegExp(`/${slug}/session/${two.id}(?:\\?|#|$)`)) | |
|