-
Notifications
You must be signed in to change notification settings - Fork 14
feat(app): hint slash commands in prompt placeholder #830
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 all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
283a6ae
feat(app): hint slash commands in prompt placeholder
Astro-Han b2d4641
test(app): snap prompt placeholder at narrow viewport
Astro-Han a0e075a
fix(app): update e2e placeholder copy assertion
Astro-Han e6d656a
test(app): snap prompt placeholder with right panel open
Astro-Han dbfb7aa
fix(app): reset layout state between locales in placeholder snap
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import { test } from "../fixtures" | ||
| import { promptSelector } from "../selectors" | ||
| import { composeGrid, snapOutputPath, type Shot } from "./_compose" | ||
|
|
||
| test.use({ viewport: { width: 1440, height: 900 }, deviceScaleFactor: 2 }) | ||
|
|
||
| async function snapComposer(page: import("@playwright/test").Page, name: string): Promise<Shot> { | ||
| const prompt = page.locator(promptSelector) | ||
| await prompt.waitFor({ state: "visible", timeout: 30_000 }) | ||
| const placeholder = page.locator('[data-component="prompt-placeholder"]') | ||
| await placeholder.waitFor({ state: "visible", timeout: 30_000 }) | ||
| return { name, buf: await prompt.screenshot() } | ||
| } | ||
|
|
||
| // Locale-independent right-panel toggle. The shared `openRightPanel` helper | ||
| // looks up the button by English aria name and would not find it after the | ||
| // snap switches the app to zh. | ||
| async function ensureRightPanelOpen(page: import("@playwright/test").Page) { | ||
| const toggle = page.locator('[aria-controls="right-panel"]').first() | ||
| await toggle.waitFor({ state: "visible", timeout: 30_000 }) | ||
| const expanded = await toggle.getAttribute("aria-expanded") | ||
| if (expanded === "true") return | ||
| await toggle.click() | ||
| await page.locator('#right-panel').waitFor({ state: "visible", timeout: 5_000 }) | ||
| } | ||
|
|
||
| // 768px matches the Electron window minWidth from packages/desktop-electron/src/main/windows.ts. | ||
| // The placeholder element has `truncate whitespace-nowrap`, so the narrow shot is the only | ||
| // way to catch the `/ for commands` hint being clipped at the smallest supported window. | ||
| // The "squeezed" row also opens the right panel so the prompt width is realistically narrow | ||
| // (window minWidth - sidebar - right panel) instead of just window minWidth. | ||
| const NARROW_WIDTH = 768 | ||
|
|
||
| test("prompt-placeholder", async ({ page, project }) => { | ||
| test.setTimeout(180_000) | ||
|
Astro-Han marked this conversation as resolved.
|
||
|
|
||
| await project.open() | ||
| const enShot = await snapComposer(page, "en-1440") | ||
|
|
||
| await page.setViewportSize({ width: NARROW_WIDTH, height: 900 }) | ||
| const enNarrowShot = await snapComposer(page, "en-768") | ||
|
|
||
| await ensureRightPanelOpen(page) | ||
| const enSqueezedShot = await snapComposer(page, "en-768+rightpanel") | ||
|
|
||
| // Client-side locale is sourced from localStorage. Set it, reload, re-snap all widths. | ||
| // Also clear persisted layout state so the right panel returns to its default closed | ||
| // state for the zh baseline/narrow shots — opening it for the en squeezed shot writes | ||
| // `rightPanel.opened: true` into `pawwork.global.dat:layout`, which survives reload. | ||
| await page.evaluate(() => { | ||
| localStorage.setItem("pawwork.global.dat:language", JSON.stringify({ locale: "zh" })) | ||
| localStorage.removeItem("pawwork.global.dat:layout") | ||
| }) | ||
| await page.setViewportSize({ width: 1440, height: 900 }) | ||
| await page.reload() | ||
| const zhShot = await snapComposer(page, "zh-1440") | ||
|
|
||
| await page.setViewportSize({ width: NARROW_WIDTH, height: 900 }) | ||
| const zhNarrowShot = await snapComposer(page, "zh-768") | ||
|
|
||
| await ensureRightPanelOpen(page) | ||
| const zhSqueezedShot = await snapComposer(page, "zh-768+rightpanel") | ||
|
|
||
| const out = snapOutputPath("prompt-placeholder") | ||
| await composeGrid( | ||
| [enShot, enNarrowShot, enSqueezedShot, zhShot, zhNarrowShot, zhSqueezedShot], | ||
| out, | ||
| ) | ||
| process.stdout.write(`\n[snap] prompt-placeholder grid -> ${out}\n\n`) | ||
| }) | ||
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
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.
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.