From b2fda77a4f6a69bfc3895c88b4d06b0f3c1a336e Mon Sep 17 00:00:00 2001 From: usrnk1 <7547651+usrnk1@users.noreply.github.com> Date: Tue, 17 Nov 2026 15:46:41 +0100 Subject: [PATCH] fix(app): keep long prompts folded during session creation (#64452) --- .../app/e2e/regression/new-session.spec.ts | 41 +++++++++++++++---- packages/app/src/session/route.tsx | 1 + .../src/message/message-content.tsx | 3 +- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/packages/app/e2e/regression/new-session.spec.ts b/packages/app/e2e/regression/new-session.spec.ts index 9ab171fa4dc..7fd2ccf56e5 100644 --- a/packages/app/e2e/regression/new-session.spec.ts +++ b/packages/app/e2e/regression/new-session.spec.ts @@ -806,18 +806,37 @@ test("a pending worktree session keeps Session as its mobile title until the gen await expect(label).toHaveText("Generated session title") }) -test("the title and message stay stable through worktree creation", async ({ page }) => { - const mock = await openWorktreeDraft(page, pendingDraft) - const pending = await submitPending(page, mock) +test("the title and folded message stay stable through worktree creation", async ({ page }) => { + const mock = await openWorktreeDraft(page, { + ...pendingDraft, + seed: { settings: { general: { foldUserMessages: true } } }, + }) + + const wrappedPrompt = `${text} `.repeat(35).trimEnd() + + const [firstHeight, pending] = await Promise.all([ + page.waitForFunction(() => { + const message = document.querySelector('[data-component="session-preparing"] [data-component="user-message"]') + + if (message?.checkVisibility({ checkVisibilityCSS: true, checkOpacity: true })) { + return message.getBoundingClientRect().height + } + }), + submitPending(page, mock, wrappedPrompt), + ]) + + const readMore = pending.message.getByRole("button", { name: "Read more", expanded: false }) + await expect(readMore).toBeVisible() await draftFollowUp(page) - await editor(page).press("ControlOrMeta+Home") + await editor(page).evaluate((element) => getSelection()!.collapse(element, 0)) const title = page.locator("[data-session-title]").getByRole("heading", { level: 1 }) const before = await title.boundingBox() const messageBefore = await pending.message.boundingBox() + expect(await firstHeight.jsonValue()).toBe(messageBefore?.height) // Observe painted frames during the handoff, without using frame counts to wait for readiness. const observation = await page.evaluateHandle(() => { - const frames: { title: string | null; message: boolean; spinner: boolean; draft: string | null }[] = [] + const frames: { title: string | null; messageHeight: number | null; spinner: boolean; draft: string | null }[] = [] let frame = 0 const visible = (element: Element | null) => @@ -825,10 +844,13 @@ test("the title and message stay stable through worktree creation", async ({ pag const sample = () => { const title = document.querySelector("[data-session-title] h1") + + const message = document.querySelector('[data-component="user-message"]') + const editor = document.querySelector('[data-component="composer-editor"]') frames.push({ title: visible(title) ? title!.textContent : null, - message: visible(document.querySelector('[data-component="user-message"]')), + messageHeight: visible(message) ? message!.getBoundingClientRect().height : null, spinner: visible( document.querySelector('[data-titlebar-tab-slot][data-active="true"] [data-component="activity-ring"]'), ), @@ -854,7 +876,8 @@ test("the title and message stay stable through worktree creation", async ({ pag await expect(title).toHaveText("Created workspace session") await expect(pending.shimmer).toHaveCount(0) - await expect(pending.message.locator('[data-slot="user-message-text"]')).toHaveText(text) + await expect(pending.message.locator('[data-slot="user-message-fold"]')).toHaveText(wrappedPrompt) + await expect(readMore).toBeVisible() await expect(editor(page)).toHaveText(followUp) await expect(editor(page)).toBeFocused() // The DOM can reach the final state before the sampler's next frame; wait until a sample has observed it. @@ -866,7 +889,7 @@ test("the title and message stay stable through worktree creation", async ({ pag expect( frames.filter( (frame) => - !frame.message || + frame.messageHeight !== messageBefore?.height || !frame.spinner || frame.draft !== followUp || !["Session", "Created workspace session"].includes(frame.title ?? ""), @@ -1558,7 +1581,7 @@ async function submitPending(page: Page, mock: Awaited { - measure() + // The bubble gets its wrapping width after the surrounding view mounts. + queueMicrotask(measure) const observer = new ResizeObserver(measure) observer.observe(content!) onCleanup(() => observer.disconnect())