mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-03 11:47:42 +01:00
Fix mobile scrolling inside chat and task cards (#23538)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - People review pending requests in agent chats and tasks. > - The request card sits above the composer in both views. > - On mobile, a long card can extend beyond the visible screen and cannot scroll. > - This pull request limits the card height to part of the visible viewport. > - People can scroll the card to read the details and reach its buttons. ## Linked Issues or Issue Description Fixes: #21626 ## What Changed - Give mobile composer takeover cards their own vertical scrolling and contain their scroll at the edges. - Size the mobile card against the visible chat viewport, including when the keyboard shrinks it. Keep the desktop limit and Inbox behavior unchanged. - Add browser regression tests for touch scrolling through a long confirmation card in Chat and Tasks. ## Verification - On master at `4db307d53c`, both regressions reproduced at 390 × 664 with emulated touch. The card extended past the viewport and a swipe did not move its scroll position. - Both patched Chromium regressions passed. A touch swipe scrolled the card, and subsequent swipes brought the approval button into view. - `pnpm --filter @paperclipai/ui typecheck` passed. - The isolated mobile preview also loaded the Inbox without changing it. Physical iPhone and keyboard testing were not performed. ## Risks - Low risk. The change is limited to the shared composer card layout and does not change how requests are accepted or stored. The composer is already above the 1,000-line threshold; changing its existing card classes keeps the fix local. - A long card uses part of the available height, so its contents scroll instead of pushing the controls offscreen. ## Model Used - OpenAI GPT, in Codex with repository and Chromium tools. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #123` / `Closes #123` / `Refs #123` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [ ] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Scott Tong <1504818+scotttong@users.noreply.github.com>
This commit is contained in:
1 parent
4db307d53c
commit
c655f38b72
3 files changed
+99
-1
No files matched your search
@@ -0,0 +1,92 @@
|
||||
import { expect, test, type APIResponse, type Page } from "@playwright/test";
|
||||
|
||||
test.use({ viewport: { width: 390, height: 664 }, isMobile: true, hasTouch: true });
|
||||
|
||||
async function json(response: APIResponse) {
|
||||
const body = await response.text();
|
||||
expect(response.ok(), `${response.status()} ${body}`).toBeTruthy();
|
||||
return JSON.parse(body);
|
||||
}
|
||||
|
||||
async function swipeUp(page: Page, x: number, y: number) {
|
||||
const session = await page.context().newCDPSession(page);
|
||||
try {
|
||||
await session.send("Input.dispatchTouchEvent", { type: "touchStart", touchPoints: [{ x, y }] });
|
||||
for (let step = 1; step <= 8; step++) {
|
||||
await session.send("Input.dispatchTouchEvent", { type: "touchMove", touchPoints: [{ x, y: y - step * 18 }] });
|
||||
}
|
||||
await session.send("Input.dispatchTouchEvent", { type: "touchEnd", touchPoints: [] });
|
||||
} finally {
|
||||
await session.detach();
|
||||
}
|
||||
}
|
||||
|
||||
for (const surface of ["Chat", "Tasks"]) test(`long mobile approval cards scroll inside ${surface}`, async ({ page, request, browserName }) => {
|
||||
test.skip(browserName !== "chromium", "Uses Chromium touch input, not a programmatic scroll.");
|
||||
test.setTimeout(75_000);
|
||||
const company = await json(await request.post("/api/companies", { data: { name: `Mobile Card Scroll ${surface} ${Date.now()}` } }));
|
||||
const base = `/api/companies/${company.id}`;
|
||||
const experimental = await json(await request.get("/api/instance/settings/experimental"));
|
||||
const preferences = await json(await request.get("/api/workspace-preferences/me"));
|
||||
await page.route("**/api/instance/settings/experimental", route => route.fulfill({
|
||||
json: { ...experimental, enableAgentChat: true, enableClassicTaskInterface: false },
|
||||
}));
|
||||
await page.route("**/api/workspace-preferences/me", route => route.fulfill({
|
||||
json: { ...preferences, coordinatorWorkspaceEnabled: true },
|
||||
}));
|
||||
const agent = await json(await request.post(`${base}/agents`, { data: {
|
||||
name: "Mobile review agent", adapterType: "process", adapterConfig: { command: "/usr/bin/false" },
|
||||
runtimeConfig: { heartbeat: { enabled: false, wakeOnDemand: false } },
|
||||
} }));
|
||||
const issue = surface === "Chat"
|
||||
? await json(await request.post(`${base}/chats/${agent.id}`, { data: {} }))
|
||||
: await json(await request.post(`${base}/issues`, { data: {
|
||||
title: "Review the task approval on mobile", status: "backlog",
|
||||
} }));
|
||||
const title = "Review the long request";
|
||||
await json(await request.post(`/api/issues/${issue.id}/interactions`, { data: {
|
||||
kind: "request_confirmation", title, continuationPolicy: "none",
|
||||
payload: {
|
||||
version: 1, prompt: title, acceptLabel: "Approve test request", rejectLabel: "Decline test request",
|
||||
detailsMarkdown: Array.from({ length: 24 }, (_, index) => `Detail ${index + 1}: Check the recorded evidence before making a decision.`).join("\n\n"),
|
||||
},
|
||||
} }));
|
||||
|
||||
const route = surface === "Chat"
|
||||
? `/${company.issuePrefix}/chats/${agent.id}`
|
||||
: `/${company.issuePrefix}/issues/${issue.identifier}`;
|
||||
await page.goto(route);
|
||||
const card = page.getByTestId("task-chat-composer-takeover");
|
||||
await card.getByText("Details", { exact: true }).tap();
|
||||
await expect(card.getByText("Detail 24:", { exact: false })).toBeAttached();
|
||||
const bounds = await card.boundingBox();
|
||||
expect(bounds).toBeTruthy();
|
||||
const x = Math.round(bounds!.x + bounds!.width / 2);
|
||||
const y = Math.round(Math.min(bounds!.y + bounds!.height - 24, 550));
|
||||
const before = await card.evaluate(node => ({
|
||||
height: node.clientHeight, scrollHeight: node.scrollHeight,
|
||||
top: node.getBoundingClientRect().top, bottom: node.getBoundingClientRect().bottom,
|
||||
viewport: window.visualViewport?.height ?? window.innerHeight,
|
||||
}));
|
||||
expect.soft(before.top, "The expanded card must not start offscreen").toBeGreaterThanOrEqual(0);
|
||||
expect.soft(before.bottom, "The expanded card must fit in the visible viewport").toBeLessThanOrEqual(before.viewport);
|
||||
expect.soft(before.scrollHeight, "Long content must overflow inside the card").toBeGreaterThan(before.height);
|
||||
await swipeUp(page, x, y);
|
||||
await expect.poll(() => card.evaluate(node => node.scrollTop)).toBeGreaterThan(40);
|
||||
for (let i = 0; i < 12; i++) {
|
||||
const more = await card.evaluate(node => node.scrollHeight - node.clientHeight - node.scrollTop);
|
||||
if (more <= 5) break;
|
||||
await swipeUp(page, x, y);
|
||||
}
|
||||
const action = card.getByRole("button", { name: "Approve test request", exact: true });
|
||||
await expect(action).toBeInViewport({ ratio: 1 });
|
||||
const compactHeight = await card.evaluate(node => {
|
||||
const shell = node.closest<HTMLElement>(".paperclip-app-shell")!;
|
||||
const original = shell.style.getPropertyValue("--mobile-chat-viewport-height");
|
||||
shell.style.setProperty("--mobile-chat-viewport-height", "420px");
|
||||
const maxHeight = getComputedStyle(node).maxHeight;
|
||||
shell.style.setProperty("--mobile-chat-viewport-height", original);
|
||||
return maxHeight;
|
||||
});
|
||||
expect(compactHeight).toBe("210px");
|
||||
});
|
||||
@@ -1322,7 +1322,8 @@ export function TaskChatComposer({
|
||||
className={cn(
|
||||
"relative rounded-xl border border-border bg-card p-(--sz-18px) shadow-sm",
|
||||
onWelcomeChoicesRevealed && (revealChoices ? "tc-onboarding-choices" : "invisible"),
|
||||
mobile ? "overflow-visible" : "max-h-(--tc-interaction-card-max-h) overflow-y-auto scrollbar-auto-hide",
|
||||
"overflow-y-auto scrollbar-auto-hide",
|
||||
mobile ? "max-h-(--tc-mobile-interaction-card-max-h) overscroll-y-contain" : "max-h-(--tc-interaction-card-max-h)",
|
||||
)}
|
||||
ref={takeoverElement}
|
||||
inert={Boolean(onWelcomeChoicesRevealed) && !revealChoices}
|
||||
|
||||
@@ -549,6 +549,7 @@
|
||||
--artifact-play-scrim: rgba(0, 0, 0, 0.55);
|
||||
--artifact-hover-ease: 300ms cubic-bezier(0.3, 0, 0.1, 1);
|
||||
--tc-interaction-card-max-h: 50dvh;
|
||||
--tc-mobile-interaction-card-max-h: var(--tc-interaction-card-max-h);
|
||||
/* About 3.5 queued rows, and less on short windows so the conversation stays visible. */
|
||||
--tc-queued-list-max-h: min(calc(var(--spacing) * 40), 28dvh);
|
||||
--shadow-task-composer: 0 2px 8px -2px color-mix(in oklab, var(--foreground) 7%, transparent),
|
||||
@@ -979,6 +980,10 @@ select:where(:not([multiple]):not(.appearance-none)):where(:not([size]), [size="
|
||||
transition: bottom var(--mobile-nav-motion-duration, var(--motion-mobile-nav-enter)) var(--mobile-nav-motion-ease, var(--motion-ease-out-expo));
|
||||
}
|
||||
|
||||
.paperclip-app-shell {
|
||||
--tc-mobile-interaction-card-max-h: calc(var(--mobile-chat-viewport-height) * 0.5);
|
||||
}
|
||||
|
||||
html:has(.paperclip-app-shell:is([data-mobile="true"], [data-keyboard-open="true"]) [data-task-chat-shell]),
|
||||
html:has(.paperclip-app-shell:is([data-mobile="true"], [data-keyboard-open="true"]) [data-task-chat-shell]) body,
|
||||
html:has(.paperclip-app-shell[data-keyboard-open="true"] [data-classic-task-shell]),
|
||||
|
||||
Reference in new issue
Block a user