GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(app): align search and command palettes (#59604) · abn/opencode@7b1e54a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/app
    • e2e/regression
      • command-palette.spec.ts
    • src
      • new-session
        • view.tsx
      • shell/commands
        • dialog.css
        • dialog.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/app/e2e/regression/command-palette.spec.ts‎

Copy file name to clipboardExpand all lines: packages/app/e2e/regression/command-palette.spec.ts
+54-11Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -619,18 +619,61 @@ test("keeps matching session and file results steady across keystrokes while sea
619619
})
620620
})
621621

622-
test("keeps the same height as the number of results changes", async ({ page }) => {
623-
const { dialog, input } = await openCommandPalette(page)
622+
test("titlebar session search shrinks with results while its field stays anchored through scrolling", async ({
623+
page,
624+
}) => {
625+
await openPaletteWorkspace(page, true, [
626+
{ ...paletteSession, time: { ...paletteSession.time } },
627+
...Array.from({ length: 23 }, (_, index) => ({
628+
...paletteSession,
629+
id: `ses_compact_palette_${index}`,
630+
title: index === 0 ? "Compact keeper needle" : `Compact keeper result ${index}`,
631+
time: { created: 1700000000000 - index - 1, updated: 1700000000000 - index - 1 },
632+
})),
633+
])
634+
await page.getByRole("banner").getByRole("button", { name: "Search sessions", exact: true }).click()
635+
const dialog = page.getByRole("dialog")
636+
const input = dialog.getByRole("combobox")
637+
const options = dialog.getByRole("option")
624638
const container = page.locator('[data-component="dialog-v2"] [data-slot="dialog-container"]')
625-
const height = async () => (await container.boundingBox())?.height
626-
const initial = await height()
627-
expect(initial).toBe(480)
628639

629-
await input.fill("copy session")
630-
await expect(dialog.getByRole("option")).toHaveCount(1)
631-
expect(await height()).toBe(initial)
640+
const geometry = () =>
641+
container.evaluate((element) => ({
642+
height: element.getBoundingClientRect().height,
643+
inputTop: element.querySelector('[role="combobox"]')!.getBoundingClientRect().top,
644+
}))
632645

633-
await input.fill("zzzz no palette match")
634-
await expect(dialog.getByText("No results found")).toBeVisible()
635-
expect(await height()).toBe(initial)
646+
await expect(input).toBeFocused()
647+
await expect(options).toHaveCount(10)
648+
// Hover waits for the field's opening animation to settle before taking the reference position.
649+
await input.hover()
650+
const initial = await geometry()
651+
expect(initial.height).toBeGreaterThan(200)
652+
653+
await input.fill("Compact keeper needle")
654+
await expect(options).toHaveText([/Compact keeper needle/])
655+
await expect.poll(async () => (await geometry()).height).toBeLessThan(initial.height - 100)
656+
await expect.poll(async () => (await geometry()).inputTop).toBeCloseTo(initial.inputTop, 0)
657+
658+
await input.clear()
659+
await expect(options).toHaveCount(10)
660+
await expect.poll(geometry).toEqual({
661+
height: expect.closeTo(initial.height, 0),
662+
inputTop: expect.closeTo(initial.inputTop, 0),
663+
})
664+
665+
// A broader query exposes more than the recent-session limit and must scroll below the field.
666+
await input.fill("Compact keeper")
667+
await expect(options).toHaveCount(23)
668+
const scroll = dialog.locator('[data-slot="search-list-scroll"]')
669+
await expect.poll(() => scroll.evaluate((element) => element.scrollHeight - element.clientHeight)).toBeGreaterThan(0)
670+
await expect.poll(async () => (await geometry()).height).toBeLessThanOrEqual(480)
671+
const last = dialog.getByRole("option", { name: /Compact keeper result 22/ })
672+
await expect(last).not.toBeInViewport()
673+
await scroll.hover()
674+
await page.mouse.wheel(0, 2000)
675+
await expect(last).toBeInViewport()
676+
await expect.poll(() => scroll.evaluate((element) => element.scrollTop)).toBeGreaterThan(0)
677+
await expect.poll(async () => (await geometry()).inputTop).toBeCloseTo(initial.inputTop, 0)
678+
await expect(input).toBeFocused()
636679
})
Collapse file

‎packages/app/src/new-session/view.tsx‎

Copy file name to clipboardExpand all lines: packages/app/src/new-session/view.tsx
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ function NewSessionLocation(props: {
365365
{(directory) => (
366366
<div
367367
class="flex min-w-0 flex-1 justify-end pe-1.5 @max-[560px]:hidden"
368-
style={{ "min-width": `min(calc(100% - 12px), ${Math.ceil(fitted().minimum) + 26}px)` }}
368+
style={{ "min-width": `min(50%, ${Math.ceil(fitted().minimum) + 26}px)` }}
369369
>
370370
<Tooltip
371371
placement="top"
Collapse file

‎packages/app/src/shell/commands/dialog.css‎

Copy file name to clipboardExpand all lines: packages/app/src/shell/commands/dialog.css
+125Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,128 @@
135135
max-width: 100%;
136136
}
137137
}
138+
139+
/* Like the project picker, results grow down from a stable search-field anchor. Other picker dialogs keep their layout. */
140+
[data-component="dialog-v2"]:has(.command-palette-compact) {
141+
align-items: flex-start;
142+
}
143+
144+
[data-component="dialog-v2"]:has(.command-palette-compact) [data-slot="dialog-container"] {
145+
width: min(calc(100vw - 24px), 480px);
146+
height: auto;
147+
max-height: min(calc(100vh - 96px), 480px);
148+
min-height: 0;
149+
margin-top: max(48px, calc((100vh - 480px) / 2));
150+
background: var(--v2-background-bg-layer-01);
151+
box-shadow: var(--v2-elevation-overlay);
152+
}
153+
154+
.command-palette-compact {
155+
[data-slot="search-list-search"] {
156+
position: relative;
157+
padding: 6px 6px 17px;
158+
159+
&::after {
160+
position: absolute;
161+
inset-inline: 0;
162+
bottom: 8px;
163+
border-top: 0.5px solid var(--v2-border-border-base);
164+
content: "";
165+
}
166+
167+
[data-component="text-input-v2"] {
168+
height: 28px;
169+
padding-inline-end: 6px;
170+
background: transparent;
171+
}
172+
173+
[data-component="text-input-v2"]:where(:hover, :focus-within):not([data-disabled], [data-invalid]) {
174+
background: transparent;
175+
}
176+
177+
[data-slot="text-input-v2-value"] {
178+
gap: 6px;
179+
}
180+
181+
[data-slot="text-input-v2-leading-icon"] {
182+
padding-inline-start: 6px;
183+
}
184+
185+
[data-slot="text-input-v2-input"]::placeholder {
186+
color: var(--v2-text-text-base);
187+
opacity: 0.5;
188+
}
189+
}
190+
191+
[data-slot="search-list-results"] {
192+
padding: 0 6px 6px;
193+
}
194+
195+
[data-slot="search-list-section"] {
196+
gap: 4px;
197+
198+
&:not(:last-child) {
199+
padding-bottom: 4px;
200+
}
201+
}
202+
203+
[data-slot="search-list-header"] {
204+
padding-inline: 12px;
205+
background: var(--v2-background-bg-layer-01);
206+
}
207+
208+
[data-slot="search-list-fade"]::before {
209+
background: linear-gradient(var(--v2-background-bg-layer-01), transparent);
210+
}
211+
212+
[data-slot="search-list-row"] {
213+
padding-inline: 6px;
214+
215+
&:is([data-active], :focus-visible) {
216+
background: var(--v2-overlay-simple-overlay-hover);
217+
outline: none;
218+
}
219+
}
220+
221+
.command-palette-row-text {
222+
flex: 1;
223+
}
224+
225+
.command-palette-row-text:has(.command-palette-description) > .command-palette-title {
226+
max-width: 60%;
227+
flex-shrink: 0;
228+
}
229+
230+
.command-palette-description {
231+
flex: 1;
232+
color: var(--v2-text-text-faint);
233+
}
234+
}
235+
236+
[data-color-scheme="dark"] .command-palette-compact [data-slot="search-list-row"]:is([data-active], :focus-visible) {
237+
background: var(--v2-overlay-simple-overlay-hover);
238+
}
239+
240+
@media (max-width: 640px) {
241+
.command-palette-compact {
242+
[data-slot="search-list-row"]:has(.command-palette-description) {
243+
min-height: 40px;
244+
}
245+
246+
.command-palette-row-text:has(.command-palette-description) > .command-palette-title {
247+
max-width: 100%;
248+
}
249+
250+
.command-palette-description {
251+
flex: none;
252+
}
253+
}
254+
}
255+
256+
@media (pointer: coarse) {
257+
.command-palette-compact [data-slot="search-list-row"],
258+
.command-palette-compact [data-slot="search-list-row"]:has(.command-palette-description),
259+
.command-palette-compact [data-slot="search-list-search"] [data-component="text-input-v2"] {
260+
min-height: 44px;
261+
}
262+
}
Collapse file

‎packages/app/src/shell/commands/dialog.tsx‎

Copy file name to clipboardExpand all lines: packages/app/src/shell/commands/dialog.tsx
+12-7Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function CommandPaletteView(props: {
8282
})
8383

8484
return (
85-
<Dialog class="command-palette" size="large">
85+
<Dialog class="command-palette command-palette-compact" size="large" fit>
8686
<DialogBody class="command-palette-body">
8787
<SearchList
8888
query={store.query}
@@ -122,12 +122,12 @@ function PaletteRow(props: {
122122
: undefined
123123

124124
return (
125-
<button type="button" class="command-palette-row group" {...props.row}>
125+
<button type="button" class="command-palette-row group" data-size="compact" {...props.row}>
126126
<Switch
127127
fallback={
128128
<div class="command-palette-row-main">
129129
<FileIcon node={{ path: props.item.path ?? "", type: "file" }} class="command-palette-row-icon size-4" />
130-
<div class="command-palette-file-path">
130+
<div class="command-palette-file-path" dir="ltr">
131131
<span class="command-palette-file-dir">
132132
<SearchHighlight text={getDirectory(props.item.path ?? "")} />
133133
</span>
@@ -141,12 +141,12 @@ function PaletteRow(props: {
141141
<Match when={props.item.type === "command" || props.item.type === "setting"}>
142142
<div class="command-palette-row-main">
143143
<div class="command-palette-row-text">
144-
<span class="command-palette-title palette-menu-title">
144+
<span class="command-palette-title palette-menu-title" dir="auto">
145145
<SearchHighlight text={props.item.title} />
146146
</span>
147147
<Show when={props.item.description}>
148148
{(description) => (
149-
<span class="command-palette-description">
149+
<span class="command-palette-description" dir="auto">
150150
<SearchHighlight text={description()} />
151151
</span>
152152
)}
@@ -164,7 +164,7 @@ function PaletteRow(props: {
164164
<span
165165
aria-hidden="true"
166166
class="pointer-events-none absolute top-1/2 h-3 w-0.5 -translate-y-1/2 rounded-[2px] bg-v2-background-bg-layer-04"
167-
style={{ right: "calc(100% + 4px)" }}
167+
style={{ "inset-inline-start": "-6px" }}
168168
/>
169169
</Show>
170170
<Show when={session()}>
@@ -181,13 +181,18 @@ function PaletteRow(props: {
181181
<div class="command-palette-row-text">
182182
<span
183183
class="command-palette-title palette-menu-title"
184+
dir="auto"
184185
classList={{ "opacity-70": !!props.item.archived }}
185186
>
186187
<SearchHighlight text={props.item.title} />
187188
</span>
188189
<Show when={props.item.description}>
189190
{(description) => (
190-
<span class="command-palette-description" classList={{ "opacity-70": !!props.item.archived }}>
191+
<span
192+
class="command-palette-description"
193+
dir="auto"
194+
classList={{ "opacity-70": !!props.item.archived }}
195+
>
191196
<SearchHighlight text={description()} />
192197
</span>
193198
)}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.