-
Notifications
You must be signed in to change notification settings - Fork 2
feat(sidebar): project rename and remove from sidebar #517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e0bf26a
feat(sidebar): add stable projectKey to group structure
Astro-Han 022b6ee
feat(sidebar): add project rename and remove from sidebar
Astro-Han 60d9d10
fix(sidebar): address PR review feedback
Astro-Han 2e17124
fix(i18n): remove corrupted thinking tags from zh.ts
Astro-Han 27a97e3
fix(tests): remove duplicate projectKeyForSession in test file
Astro-Han a9bea37
fix: add missing i18n key and fix openPawworkHome projectKey
Astro-Han 5cf2534
feat(sidebar): add DialogRenameProject component and E2E screenshots
Astro-Han 66e2cbb
fix(sidebar): projectLabelForSession reads ProjectMeta displayName
Astro-Han bbd0512
fix(sidebar): syncSessionRoute unhides project + label priority fix
Astro-Han f26c424
fix(sidebar): handleRenameProject supports sandbox projects
Astro-Han c9d0de5
chore: add console.error to DialogRenameProject catch block
Astro-Han c97709f
feat(sidebar): use folder state icons for projects
Astro-Han 8e48d8b
refactor(sidebar): update hidden project state by key
Astro-Han File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
174 changes: 174 additions & 0 deletions
174
packages/app/e2e/sidebar/sidebar-project-actions.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,174 @@ | ||
| import { test, expect } from "../fixtures" | ||
| import { openSidebar, withSession, clickMenuItem } from "../actions" | ||
| import { pawworkSidebarSelector, dropdownMenuContentSelector } from "../selectors" | ||
| import type { TestInfo } from "@playwright/test" | ||
|
|
||
| async function capture(page: any, testInfo: TestInfo, name: string) { | ||
| await page.screenshot({ | ||
| path: testInfo.outputPath(`${name}.png`), | ||
| fullPage: true, | ||
| }) | ||
| } | ||
|
|
||
| test("project group can be renamed from sidebar", async ({ page, sdk, gotoSession }, testInfo) => { | ||
| const stamp = Date.now() | ||
| await withSession(sdk, `rename project ${stamp}`, async (a) => { | ||
| await withSession(sdk, `rename project b ${stamp}`, async () => { | ||
| await gotoSession(a.id) | ||
| await openSidebar(page) | ||
|
|
||
| const sidebar = page.locator(pawworkSidebarSelector).first() | ||
|
|
||
| // Switch to project sort so group headers exist. | ||
| await sidebar.locator('[data-action="pawwork-sort-trigger"]').click() | ||
| await page.locator('[data-action="pawwork-sort-option"][data-value="project"]').click() | ||
|
|
||
| const header = sidebar.locator('[data-action="pawwork-group-toggle"]').first() | ||
| await expect(header).toBeVisible() | ||
|
|
||
| // Screenshot: project group header with overflow button | ||
| await capture(page, testInfo, `01-project-header-${stamp}`) | ||
|
|
||
| // Open the project menu via overflow button | ||
| const menuTrigger = sidebar.locator('[data-action="project-row-menu"]').first() | ||
| await expect(menuTrigger).toBeVisible() | ||
| await menuTrigger.click() | ||
|
|
||
| // Screenshot: project menu opened | ||
| await capture(page, testInfo, `02-project-menu-${stamp}`) | ||
|
|
||
| // Click rename | ||
| const menu = page.locator(dropdownMenuContentSelector).first() | ||
| await clickMenuItem(menu, /Rename project/) | ||
|
|
||
| // Dialog should appear | ||
| const dialog = page.locator('[data-component="dialog"]').filter({ hasText: /Rename project/ }).first() | ||
| await expect(dialog).toBeVisible() | ||
|
|
||
| // Screenshot: rename dialog | ||
| await capture(page, testInfo, `03-rename-dialog-${stamp}`) | ||
|
|
||
| // Type new name | ||
| const input = dialog.locator('input').first() | ||
| await input.fill(`Renamed Project ${stamp}`) | ||
|
|
||
| // Save | ||
| const saveButton = dialog.locator('button').filter({ hasText: /Save/ }).first() | ||
| await saveButton.click() | ||
|
|
||
| // Dialog should close | ||
| await expect(dialog).not.toBeVisible() | ||
|
|
||
| // Screenshot: after rename | ||
| await capture(page, testInfo, `04-after-rename-${stamp}`) | ||
|
|
||
| // Header should show new name (with retry since ProjectMeta update is async) | ||
| await expect.poll(async () => await header.textContent()).toContain(`Renamed Project ${stamp}`) | ||
| }) | ||
| }) | ||
| }) | ||
|
|
||
| test("project group can be removed from sidebar", async ({ page, sdk, gotoSession }, testInfo) => { | ||
| const stamp = Date.now() | ||
| await withSession(sdk, `remove project ${stamp}`, async (a) => { | ||
| await withSession(sdk, `remove project b ${stamp}`, async () => { | ||
| await gotoSession(a.id) | ||
| await openSidebar(page) | ||
|
|
||
| const sidebar = page.locator(pawworkSidebarSelector).first() | ||
|
|
||
| // Switch to project sort so group headers exist. | ||
| await sidebar.locator('[data-action="pawwork-sort-trigger"]').click() | ||
| await page.locator('[data-action="pawwork-sort-option"][data-value="project"]').click() | ||
|
|
||
| // Count initial groups | ||
| const initialGroups = sidebar.locator('[data-action="pawwork-group-toggle"]') | ||
| const initialCount = await initialGroups.count() | ||
| expect(initialCount).toBeGreaterThan(0) | ||
|
|
||
| // Open the project menu via overflow button | ||
| const menuTrigger = sidebar.locator('[data-action="project-row-menu"]').first() | ||
| await expect(menuTrigger).toBeVisible() | ||
| await menuTrigger.click() | ||
|
|
||
| // Screenshot: remove menu | ||
| await capture(page, testInfo, `05-remove-menu-${stamp}`) | ||
|
|
||
| // Click remove | ||
| const menu = page.locator(dropdownMenuContentSelector).first() | ||
| await clickMenuItem(menu, /Remove from sidebar/) | ||
|
|
||
| // Confirm dialog should appear | ||
| const dialog = page.locator('[data-component="dialog"]').filter({ hasText: /Remove project from sidebar/ }).first() | ||
| await expect(dialog).toBeVisible() | ||
|
|
||
| // Screenshot: remove confirm dialog | ||
| await capture(page, testInfo, `06-remove-dialog-${stamp}`) | ||
|
|
||
| // Confirm removal | ||
| const confirmButton = dialog.locator('button').filter({ hasText: /Remove/ }).first() | ||
| await confirmButton.click() | ||
|
|
||
| // Dialog should close | ||
| await expect(dialog).not.toBeVisible() | ||
|
|
||
| // Screenshot: after remove (toast may appear) | ||
| await capture(page, testInfo, `07-after-remove-${stamp}`) | ||
|
|
||
| // Group count should decrease | ||
| const remainingGroups = sidebar.locator('[data-action="pawwork-group-toggle"]') | ||
| await expect.poll(async () => await remainingGroups.count()).toBeLessThan(initialCount) | ||
| }) | ||
| }) | ||
| }) | ||
|
|
||
| test("hidden project restores on direct navigation", async ({ page, sdk, gotoSession }) => { | ||
| const stamp = Date.now() | ||
| await withSession(sdk, `restore nav ${stamp}`, async (a) => { | ||
| await withSession(sdk, `restore nav b ${stamp}`, async () => { | ||
| await gotoSession(a.id) | ||
| await openSidebar(page) | ||
|
|
||
| const sidebar = page.locator(pawworkSidebarSelector).first() | ||
|
|
||
| // Switch to project sort | ||
| await sidebar.locator('[data-action="pawwork-sort-trigger"]').click() | ||
| await page.locator('[data-action="pawwork-sort-option"][data-value="project"]').click() | ||
|
|
||
| // Count initial groups | ||
| const groups = sidebar.locator('[data-action="pawwork-group-toggle"]') | ||
| const initialCount = await groups.count() | ||
| expect(initialCount).toBeGreaterThan(0) | ||
|
|
||
| // Remove the project | ||
| const menuTrigger = sidebar.locator('[data-action="project-row-menu"]').first() | ||
| await menuTrigger.click() | ||
|
|
||
| const menu = page.locator(dropdownMenuContentSelector).first() | ||
| await clickMenuItem(menu, /Remove from sidebar/) | ||
|
|
||
| const dialog = page.locator('[data-component="dialog"]').filter({ hasText: /Remove project from sidebar/ }).first() | ||
| await expect(dialog).toBeVisible() | ||
| await dialog.locator('button').filter({ hasText: /Remove/ }).first().click() | ||
|
|
||
| // Group should be hidden | ||
| const countAfterRemove = await groups.count() | ||
| expect(countAfterRemove).toBeLessThan(initialCount) | ||
|
|
||
| // Navigate directly to session via URL (triggers syncSessionRoute → unhideProject) | ||
| await gotoSession(a.id) | ||
|
|
||
| // Wait for sidebar to load content | ||
| await expect(sidebar.locator('[data-session-id]')).not.toHaveCount(0, { timeout: 5000 }) | ||
| await openSidebar(page) | ||
|
|
||
| // Switch to project sort again | ||
| await sidebar.locator('[data-action="pawwork-sort-trigger"]').click() | ||
| await page.locator('[data-action="pawwork-sort-option"][data-value="project"]').click() | ||
|
|
||
| // Group should be back | ||
| const groupsAfter = sidebar.locator('[data-action="pawwork-group-toggle"]') | ||
| await expect.poll(async () => await groupsAfter.count()).toBeGreaterThan(countAfterRemove) | ||
| }) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import { Dialog } from "@opencode-ai/ui/dialog" | ||
| import { Button } from "@opencode-ai/ui/button" | ||
| import { useDialog } from "@opencode-ai/ui/context/dialog" | ||
| import { createSignal } from "solid-js" | ||
| import { useLanguage } from "@/context/language" | ||
|
|
||
| export function DialogRemoveProject(props: { | ||
| name: string | ||
| onConfirm: () => Promise<void> | void | ||
| }) { | ||
| const language = useLanguage() | ||
| const dialog = useDialog() | ||
| const [removing, setRemoving] = createSignal(false) | ||
|
|
||
| const handleRemove = async () => { | ||
| if (removing()) return | ||
| setRemoving(true) | ||
| try { | ||
| await props.onConfirm() | ||
| dialog.close() | ||
| } finally { | ||
| setRemoving(false) | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <Dialog title={language.t("project.remove.title")} fit class="w-full max-w-[420px] mx-auto"> | ||
| <div class="px-6 pt-2 pb-6"> | ||
| <span class="text-13-regular text-fg-strong"> | ||
| {language.t("project.remove.confirm", { name: props.name })} | ||
| </span> | ||
| <p class="mt-2 text-13-regular text-fg-weak"> | ||
| {language.t("project.remove.description")} | ||
| </p> | ||
| </div> | ||
| <div class="flex justify-end gap-2 px-6 pb-6"> | ||
| <Button variant="secondary" onClick={() => dialog.close()} disabled={removing()}> | ||
| {language.t("common.cancel")} | ||
| </Button> | ||
| <Button variant="danger" onClick={handleRemove} disabled={removing()}> | ||
| {language.t("common.remove")} | ||
| </Button> | ||
| </div> | ||
| </Dialog> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import { createSignal } from "solid-js" | ||
| import { Dialog } from "@opencode-ai/ui/dialog" | ||
| import { Button } from "@opencode-ai/ui/button" | ||
| import { TextField } from "@opencode-ai/ui/text-field" | ||
| import { useDialog } from "@opencode-ai/ui/context/dialog" | ||
| import { showToast } from "@opencode-ai/ui/toast" | ||
| import { useLanguage } from "@/context/language" | ||
|
|
||
| export function DialogRenameProject(props: { | ||
| name: string | ||
| onConfirm: (name: string) => Promise<void> | void | ||
| }) { | ||
| const language = useLanguage() | ||
| const dialog = useDialog() | ||
| const [value, setValue] = createSignal(props.name) | ||
| const [saving, setSaving] = createSignal(false) | ||
|
|
||
| const handleSave = async () => { | ||
| const next = value().trim() | ||
| if (!next || saving()) return | ||
| setSaving(true) | ||
| try { | ||
| await props.onConfirm(next) | ||
| dialog.close() | ||
| } catch (error) { | ||
| console.error("Failed to rename project:", error) | ||
| showToast({ | ||
| title: language.t("toast.project.rename.failed.title"), | ||
| description: language.t("toast.project.rename.failed.description"), | ||
| variant: "error", | ||
| }) | ||
| } finally { | ||
| setSaving(false) | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <Dialog title={language.t("project.rename")} fit class="w-full max-w-[420px] mx-auto"> | ||
| <div class="px-6 pt-2 pb-6"> | ||
| <TextField | ||
| aria-label={language.t("project.rename")} | ||
| autofocus | ||
| value={value()} | ||
| onInput={(e: InputEvent & { currentTarget: HTMLInputElement }) => | ||
| setValue(e.currentTarget.value) | ||
| } | ||
| onKeyDown={(e: KeyboardEvent & { currentTarget: HTMLInputElement }) => { | ||
| if (e.key === "Enter") { | ||
| e.preventDefault() | ||
| void handleSave() | ||
| } | ||
| if (e.key === "Escape") { | ||
| e.preventDefault() | ||
| if (saving()) return | ||
| dialog.close() | ||
| } | ||
| }} | ||
| onFocus={(e: FocusEvent & { currentTarget: HTMLInputElement }) => | ||
| e.currentTarget.select() | ||
| } | ||
| /> | ||
| </div> | ||
| <div class="flex justify-end gap-2 px-6 pb-6"> | ||
| <Button variant="secondary" onClick={() => dialog.close()} disabled={saving()}> | ||
| {language.t("common.cancel")} | ||
| </Button> | ||
| <Button | ||
| variant="primary" | ||
| onClick={handleSave} | ||
| disabled={saving() || !value().trim()} | ||
| > | ||
| {language.t("common.save")} | ||
| </Button> | ||
| </div> | ||
| </Dialog> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.