Skip to content

Commit b7ad205

Browse files
committed
app: regression test for the composer footer on a narrow viewport (anomalyco#43295)
Mocks a model with a long display name and a variant, opens a session at 320 px and asserts that the controls row, the model button and the variant chip all end before the send button starts, and that the send button stays inside the viewport. Adds a data-slot="prompt-controls" anchor on the controls row. The idea of asserting the send button's box against the controls' box at 320 px comes from bmpenuelas' anomalyco#43298; this is a fresh spec written for the truncation approach.
1 parent 694f33d commit b7ad205

2 files changed

Lines changed: 88 additions & 0 deletions

File tree

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import { expect, test } from "@playwright/test"
2+
import { base64Encode } from "@opencode-ai/core/util/encode"
3+
import { mockOpenCodeServer } from "../utils/mock-server"
4+
import { expectAppVisible } from "../utils/waits"
5+
6+
// Regression for #43295: on a narrow viewport the V2 composer's agent / model / variant controls used to run under
7+
// the send button. The controls must stay inside the composer and clear of the button; long labels ellipsize.
8+
const directory = "C:/OpenCode/PromptControlsNarrowRegression"
9+
const projectID = "proj_prompt_controls_narrow_regression"
10+
const sessionID = "ses_prompt_controls_narrow_regression"
11+
12+
test("keeps the V2 prompt controls clear of the send button on a narrow viewport", async ({ page }) => {
13+
await page.setViewportSize({ width: 320, height: 800 })
14+
await mockOpenCodeServer(page, {
15+
directory,
16+
project: {
17+
id: projectID,
18+
worktree: directory,
19+
vcs: "git",
20+
name: "prompt-controls-narrow-regression",
21+
time: { created: 1700000000000, updated: 1700000000000 },
22+
sandboxes: [],
23+
},
24+
provider: {
25+
all: [
26+
{
27+
id: "opencode",
28+
name: "OpenCode",
29+
models: {
30+
"long-name-model": {
31+
id: "long-name-model",
32+
name: "A Deliberately Long Model Display Name For Narrow Layouts",
33+
limit: { context: 200_000 },
34+
variants: { high: {} },
35+
},
36+
},
37+
},
38+
],
39+
connected: ["opencode"],
40+
default: { providerID: "opencode", modelID: "long-name-model" },
41+
},
42+
sessions: [
43+
{
44+
id: sessionID,
45+
slug: "prompt-controls-narrow-regression",
46+
projectID,
47+
directory,
48+
title: "Prompt controls narrow regression",
49+
version: "dev",
50+
time: { created: 1700000000000, updated: 1700000000000 },
51+
},
52+
],
53+
pageMessages: () => ({ items: [] }),
54+
})
55+
await page.addInitScript(() => {
56+
localStorage.setItem("settings.v3", JSON.stringify({ general: { newLayoutDesigns: true } }))
57+
})
58+
59+
await page.goto(`/${base64Encode(directory)}/session/${sessionID}`)
60+
const composer = page.locator('[data-component="prompt-input-v2"]')
61+
await expectAppVisible(composer)
62+
63+
const controls = composer.locator('[data-slot="prompt-controls"]')
64+
const submit = composer.locator('[data-action="prompt-submit"]')
65+
const model = composer.locator('[data-action="prompt-model"]')
66+
const variant = composer.getByRole("button", { name: "Choose model variant" })
67+
await expect(submit).toBeVisible()
68+
await expect(model).toBeVisible()
69+
await expect(variant).toBeVisible()
70+
71+
const [controlsBox, submitBox, modelBox, variantBox] = await Promise.all([
72+
controls.boundingBox(),
73+
submit.boundingBox(),
74+
model.boundingBox(),
75+
variant.boundingBox(),
76+
])
77+
expect(controlsBox).not.toBeNull()
78+
expect(submitBox).not.toBeNull()
79+
expect(modelBox).not.toBeNull()
80+
expect(variantBox).not.toBeNull()
81+
82+
// the whole controls row ends where the send button starts, and nothing pokes past the viewport
83+
expect(controlsBox!.x + controlsBox!.width).toBeLessThanOrEqual(submitBox!.x + 1)
84+
expect(variantBox!.x + variantBox!.width).toBeLessThanOrEqual(submitBox!.x + 1)
85+
expect(modelBox!.x + modelBox!.width).toBeLessThanOrEqual(submitBox!.x + 1)
86+
expect(submitBox!.x + submitBox!.width).toBeLessThanOrEqual(320)
87+
})

‎packages/session-ui/src/v2/components/prompt-input/index.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ export function PromptInputV2(props: PromptInputV2Props) {
197197

198198
<div class="flex h-11 items-center px-2">
199199
<div
200+
data-slot="prompt-controls"
200201
class="flex min-w-0 flex-1 items-center gap-1"
201202
aria-hidden={state.mode === "shell"}
202203
inert={state.mode === "shell" ? true : undefined}

0 commit comments

Comments
 (0)