Repository navigation
fix(app): make model picker height adaptive to model count #718
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 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
88ed397
fix(app): make model picker height adaptive to model count
Astro-Han 6db1831
test(app): scope model picker locator by list-scroll slot
Astro-Han cc10500
test(app): assert short-list precondition in model picker spec
Astro-Han ae1007f
test(app): tag model picker height spec @smoke + sync inventory
Astro-Han 2c1b53a
Merge remote-tracking branch 'origin/dev' into claude/fix-model-picke…
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import { test, expect } from "./fixtures" | ||
| import { promptModelSelector } from "./selectors" | ||
|
|
||
| const pickerContentSelector = '[data-picker-content=""]' | ||
| const thinkingTriggerSelector = '[data-action="prompt-model-thinking-trigger"]' | ||
|
|
||
| test("model picker height fits content, no empty bottom space", async ({ page, gotoSession }, testInfo) => { | ||
| await gotoSession() | ||
|
|
||
| const chip = page.locator(promptModelSelector).locator('[data-action="prompt-model"]').first() | ||
| await expect(chip).toBeVisible() | ||
| await chip.click() | ||
|
|
||
| const picker = page.locator(pickerContentSelector).first() | ||
| await expect(picker).toBeVisible() | ||
|
|
||
| const thinking = page.locator(thinkingTriggerSelector) | ||
| await expect(thinking).toBeVisible() | ||
|
|
||
| const items = picker.locator('[data-slot="list-item"]') | ||
| const itemCount = await items.count() | ||
| expect(itemCount, "expected at least one model in the picker").toBeGreaterThan(0) | ||
| const lastItem = items.nth(itemCount - 1) | ||
|
|
||
| const pickerBox = await picker.boundingBox() | ||
| const lastItemBox = await lastItem.boundingBox() | ||
| const thinkingBox = await thinking.boundingBox() | ||
| if (!pickerBox || !lastItemBox || !thinkingBox) throw new Error("picker layout box missing") | ||
|
|
||
| // The model list and the Thinking row are stacked in a flex-col. Between the last | ||
| // visible model and the Thinking row only the list's own gap (12px) plus the | ||
| // section's border + padding belong. When the popover is forced to a fixed 400px | ||
| // and the model list happens to be short, the list-scroll grows to fill flex-1 | ||
| // and an empty band appears above the Thinking row. | ||
| const scrollHeight = await picker | ||
| .locator('[data-slot="list-scroll"]') | ||
| .evaluate((el) => el.scrollHeight) | ||
| const clientHeight = await picker | ||
| .locator('[data-slot="list-scroll"]') | ||
| .evaluate((el) => el.clientHeight) | ||
| const listOverflowing = scrollHeight > clientHeight + 1 | ||
|
|
||
| const lastItemBottom = lastItemBox.y + lastItemBox.height | ||
| const gapBelowLastItem = thinkingBox.y - lastItemBottom | ||
|
|
||
| // If the list scrolls, the last DOM item may be clipped offscreen, so we only | ||
| // require the no-empty-band invariant when the content fits without scrolling. | ||
| if (!listOverflowing) { | ||
| expect( | ||
| gapBelowLastItem, | ||
| "no empty band should appear between last model and Thinking row", | ||
| ).toBeLessThan(40) | ||
| } | ||
|
|
||
| expect(pickerBox.height, "popover height should not exceed the 400px cap").toBeLessThanOrEqual(400) | ||
|
|
||
| const screenshotPath = testInfo.outputPath("model-picker.png") | ||
| await picker.screenshot({ path: screenshotPath }) | ||
| await testInfo.attach("model-picker", { path: screenshotPath, contentType: "image/png" }) | ||
| }) | ||
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.