mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-08 12:33:05 +01:00
## Thinking Path > - Paperclip lets people manage agent work through the board. > - The board already retains loaded reads during a temporary server failure. > - Reloading the page removes that in-memory data. > - A deploy can then leave a returning user without the shell or recent tasks. > - This pull request saves an explicit, limited set of reads in the browser. > - Cached identity supports display while fresh session checks protect writes. ## Linked Issues or Issue Description **What happened?** A reload during an API outage loses the board's loaded reads. An automatic worker update can also reload a hidden tab while a write is pending. **Expected behavior** Show the cached shell and recent tasks during a temporary outage. Limit saved content by user, company, age and build. Clear it on sign-out. Wait for a fresh session before sending account-bound writes. Defer automatic reloads while work is pending. **Steps to reproduce** Open a task and settings while online. Return 503 from the API and reload. Restore the API. Sign out and confirm that saved query records are gone. Discover a worker update while offline or during an autosave and confirm that it waits. Stacked on Refs #18822. Related durable-write foundation: Refs #17960. The outage browser suite follows in a separate test PR. ## What Changed - Persist an exact read allowlist through TanStack Query dehydration and hydration. Save shell preferences, company/sidebar data, agent/project lists, plugin UI metadata, the first inbox page, and 20 recent tasks. Task UUID and identifier reads share one recent-task slot. - Namespace records by user and company. Retain eligible reads across normal memory garbage collection, expire each read after 24 hours, and discard them after a build change. Unstamped builds disable hydration and persistence while retaining sign-out cleanup. Use the existing instance-wide plugin contribution query in the user's root record. - Exclude session credentials and bootstrap data, embedded plan documents, comments, preview work products, provider credentials and environment values, browser capabilities, pairing data, other queries, and mutations. Restore only display identity from session data. Preserve safe agent provider/model display fields and configuration object shapes. Apply the projection on save and restore. - Clear saved reads on sign-out, cross-tab account changes, and definitive session denial. Keep revocation working on plain HTTP without crypto.randomUUID. Use per-user revocation revisions to reject delayed writes and stale records. Preserve a newer account. Remove every UUID/identifier projection and nested inbox copy of a denied task. - Detach shared GETs when the account changes or signs out. Load complete, freshly authorized agents before opening bulk settings from a display-only roster. Retire a pending bulk-editor result or error when row, select-all or clear changes the selection, including a clear/reselect of the same agent. - Require a fresh server lookup before account-bound writes, pending task creation, or mounted autosaves resume. This includes automatic task read receipts, inbox archives, workspace preferences and primary-agent choices, with optimistic archive changes gated too. Cancel the old write scope when the verified user changes. Release completed archives through account-independent cleanup without restoring old cached rows; an old operation cannot clear a newer hide flag. Retry unconfirmed read receipts after a fresh session succeeds for the original account, and remember confirmed receipts across refreshes. Track pending reads per task so opening another task sends its receipt immediately; revisiting reuses an outstanding receipt and its original account scope. - Defer a hidden-tab worker reload until connectivity, mutations, durable sends, and autosaves are safe. Synchronously count each unresolved operation across online rate-limit retries. Release a cancelled target’s unused dirty token when an editor changes tasks; keep stored drafts, admitted saves and queued retries. Cover autosave debounce, newer edits, navigation and undo. ## Verification - Current head `fe4f682c879` is merge-ready: all 54 check runs completed (52 successful, one skipped, one neutral), the legacy Snyk status is successful, and both `ci / verify` and `ci / e2e` pass in run `41752927822`. Greptile Apex reviewed this exact head at 5/5 with zero unresolved threads; the branch has no merge conflicts. All three PRs now meet the merge-ready bar; the stack remains unmerged pending operator approval. - Greptile Apex reviewed exact current head `fe4f682c879` at 5/5 with no actionable findings and zero unresolved threads (summary updated 2026-11-04 at 01:24:40 UTC). Both settings-account and pending-selection findings are fixed, replied to and resolved. The branch has no merge conflicts. Current-head CI now passes in run `41752927822`. - Seventeen new cases cover settings restored from actual saved query records, matching/changed/signed-out identities, denied verification, late crown responses without overwriting newer reads, and bulk-selection changes during successful/failed reads. Sixteen fail the preceding source and one preserves denial compatibility. Both settings paths reuse the existing account-bound mutation guard; its optional explicit QueryClient supports the workspace hook’s existing detached-host mode. Primary-agent optimistic updates begin only after verification and cleanup checks ownership and the cache revision. - Earlier CI run `41749456480` on prior head `2cf7516f18c` has one real server test failure: the owned-runtime case in `idle-completed-history.test.ts` could not reach its HTTP child on port 34757 within 10 seconds (99 refused probes). Its other 1,829 cases pass and three skip; the only other unsuccessful job is the downstream `verify` gate. The exact selected case passes locally, and the entire 75-case file passes in 72.19 seconds on the exact `2cf7516f18c` source tree with isolated PostgreSQL and a real child process on macOS arm64/Node 25.6.1. The Linux CI startup cause remains unknown; these local results are not a fix or CI acceptance. One failed-jobs retry with debug logging was accepted on that unchanged head, then superseded by the later settings fixes. Current-head CI remains required; no source change was made for this failure. - Current cache head `fe4f682c879`, based on read head `09d1db29dea` and master `683fa4725e9`, passes all 1,198 focused tests across twenty-eight files, UI typecheck, token gates and the enforcing query-error guard. Dependent browser head `228c1b68d30` contains this exact application source and passes standalone strict checking of all three browser specs. Current-head CI now passes in run `41752927822`. - Three new navigation regressions fail the preceding application source and pass with the fix. They open three cached tasks before any receipt resolves, leave the page before success or failure, revisit an outstanding read without duplicating it, and recover an older failed receipt after a fresh session succeeds while a later task remains pending. - The fixture repair passes all seven deadline integration cases and the complete server typecheck, including the server test layer. The old assertion deterministically fails at 23:59:06.888 UTC; its one-second-old run also fails the first-second-of-day probe. The corrected fixture passes noon and both midnight probes. The permanent three-case coverage uses seeded 2099 clocks. - Nine new cases cover archive success/failure after sign-out and another account takes over, both mounted and unmounted; cleanup ownership when a newer archive uses the same task; session-check 429 exhaustion followed by matching, changed or signed-out identity; and a failed read receipt followed by a new session read. They verify no old-cache restoration, toast or navigation, retained newer hide flags, no failed-check loop and no duplicate confirmed receipt. Seven fail the previous implementation; two compatibility cases retain account-change suppression. Initial test error-constructor and query-notification timing assumptions were corrected before the passing checks. - The inherited skills/app error-priority fix passes all 60 affected tests and UI typecheck on both application branches. Its twelve new regression cases fail the preceding read implementation. The persisted-cache suite includes 48 cases. - Six new regressions fail against the preceding application source and pass with the fix. Actual worker-update and mutation-cache listeners cannot reload a hidden tab between online 429 retries; the original create key survives, and the update reloads once after a receipt. Real self-hosted and Cloud sign-out work without crypto.randomUUID, with stamped and unstamped builds. Saved reads are removed and account write scopes are invalidated. An initial test-fixture type annotation error was corrected before the passing typecheck. - The 48 cache tests cover actual five-minute memory GC, the 20-task bound across saved and live reads, original 24-hour expiry, denial before session verification, unstamped cleanup, cross-tab revocation and delayed flushes. Private GETs cannot cross account transitions. Bulk edits require complete current agent data. Undo releases the update blocker while preserving the Saved indicator. - All 23 built-UI outage/write/loading cases pass in 4.5 minutes on exact integrated head `228c1b68d30`, containing current cache revision `fe4f682c879`: ten outage, six durable-write and seven loading cases. The run uses bundled Chromium, the built UI, a fresh local-trusted server and isolated embedded PostgreSQL on macOS arm64/Node 25.6.1. All three specs pass standalone strict TypeScript checking. Owned temporary server and database stopped. - Earlier browser runs exposed and fixed cached-header, native Storage cleanup and replay/session defects. A prior run passed 21/22 because real WebSockets contradicted the simulated HTTP outage; the fixture now closes existing socket pairs and holds new sockets through the same outage deadline. An older CI run exposed a disposed response in the Inbox route callback; pre-navigation snapshots remove that lifetime, and the current full run includes that repair. Earlier failures and their diagnosis remain in the discussion. The current full run passes. Broader historical workspace failures remain documented in Refs #18822; this does not claim a clean full workspace suite. - Current-head CI passes on `fe4f682c879`. Controlled local outages do not complete hosted authentication or a real Cloud restart/deploy acceptance. Commands for the current cache change and inherited read fix (the current focused run also includes src/lib/inboxArchiveCache.test.ts and src/pages/Inbox.test.ts): ```sh pnpm --filter @paperclipai/ui exec vitest run src/pages/CompanySkills.test.tsx src/pages/apps/AppNotConnected.test.tsx pnpm --filter @paperclipai/ui exec vitest run src/hooks/useDurableSubmit.test.tsx src/hooks/useDurableAutosave.test.tsx src/hooks/useSignOut.test.tsx src/lib/persisted-query-cache.test.ts src/lib/service-worker-updates.test.ts src/lib/service-worker-cache-policy.test.ts src/lib/pending-send.test.ts src/lib/issue-execution-policy.test.ts src/components/InlineEditor.test.tsx src/components/MarkdownEditor.test.tsx src/components/NewIssueDialog.test.tsx pnpm --filter @paperclipai/ui exec vitest run src/components/agents/AgentBulkRoster.test.tsx src/components/agents/AgentBulkSettingsSheet.test.tsx src/hooks/useAccountBoundMutation.test.tsx src/pages/IssueDetail.test.tsx src/components/TaskChatThread.test.tsx src/components/TaskChatThread.task-creation-order.test.tsx src/api/client.test.ts src/api/agents.test.ts pnpm --filter @paperclipai/ui exec vitest run src/hooks/useCoordinatorWorkspaceEnabled.test.tsx src/context/PrimaryAgentProvider.test.tsx src/components/CoordinatorWorkspaceSetting.test.tsx src/components/primary-agent/PrimaryAgentPresentation.test.tsx src/components/MobileBottomNav.coordinator.test.tsx src/components/CoordinatorSidebar.test.tsx src/pages/Issues.coordinator-routing.test.tsx pnpm --filter @paperclipai/ui typecheck pnpm check:token-gates node scripts/check-query-error-rendering.mjs --enforce --summary ``` ## Risks This deliberately saves task content on the local browser for up to 24 hours. The allowlist excludes credentials and ephemeral capabilities. Local storage can be disabled or full; persistence then fails without blocking the app. Restored data can be stale and never grants server access. A user or access change clears cached account reads and invalidates pending writes. The browser outage suite and real hosted deploy acceptance remain release requirements. There are no migrations or new dependencies. ## Model Used OpenAI `gpt-6.1-sol` through Codex, with xhigh reasoning effort, tool use, and code execution. The context window size is not exposed. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used - [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 described the issue in-PR following the bug report template - [x] I have not referenced internal/instance-local Paperclip issues or links - [x] My branch name describes the change and contains no internal ticket id - [x] The focused local tests for this change pass - [x] I have added tests and updated relevant documentation - [x] I have considered and documented risks above - [x] All Paperclip CI gates are green - [x] 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: devinfoley <139239+devinfoley@users.noreply.github.com> Co-authored-by: Paperclip <noreply@paperclip.ing> Co-authored-by: Bender (Fable) <bender@agents.paperclip.ing> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
254 lines
16 KiB
TypeScript
254 lines
16 KiB
TypeScript
import { expect, test, type APIRequestContext, type APIResponse } from "@playwright/test";
|
|
|
|
async function json(response: APIResponse) {
|
|
expect(response.ok(), `${response.status()} ${await response.text()}`).toBe(true);
|
|
return response.json();
|
|
}
|
|
|
|
async function createTask(request: APIRequestContext) {
|
|
const company = await json(await request.post("/api/companies", { data: { name: "Loading frame verification" } }));
|
|
const title = "Investigate a long-running workspace and preserve its saved findings, document cards, and pending review without moving the initial reading position";
|
|
const issue = await json(await request.post(`/api/companies/${company.id}/issues`, { data: {
|
|
title, status: "backlog", description: "## Saved investigation\n\n" + "Preserve the original report and all saved evidence. ".repeat(20),
|
|
} }));
|
|
return { company, issue, title, route: `/${company.issuePrefix}/issues/${issue.identifier}` };
|
|
}
|
|
|
|
for (const mobile of [false, true]) test(`a rich task uses one stable loading frame (${mobile ? "mobile" : "desktop"})`, async ({ page, request }, info) => {
|
|
test.setTimeout(60_000);
|
|
await page.setViewportSize(mobile ? { width: 390, height: 844 } : { width: 1280, height: 720 });
|
|
const fixture = await createTask(request);
|
|
try {
|
|
for (let index = 0; index < 20; index++) await json(await request.post(`/api/issues/${fixture.issue.id}/comments`, { data: {
|
|
body: `## Saved findings ${index}\n\n` + "Checked the recorded evidence and retained the result for review. ".repeat(12),
|
|
} }));
|
|
await json(await request.put(`/api/issues/${fixture.issue.id}/documents/plan`, { data: {
|
|
title: "Investigation plan", format: "markdown", body: "# Plan\n\nKeep the findings with the original task.",
|
|
} }));
|
|
await json(await request.post(`/api/issues/${fixture.issue.id}/work-products`, { data: {
|
|
type: "pull_request", provider: "github", title: "Saved investigation patch", status: "active",
|
|
url: "https://github.com/example/layout-fixture/pull/42", metadata: { repository: "example/layout-fixture", number: 42 },
|
|
} }));
|
|
await json(await request.post(`/api/issues/${fixture.issue.id}/interactions`, { data: {
|
|
kind: "request_confirmation", title: "Review the saved patch", continuationPolicy: "none",
|
|
payload: { version: 1, prompt: "Approve the saved findings?", acceptLabel: "Approve patch", rejectLabel: "Request changes" },
|
|
} }));
|
|
await page.route("**/api/workspace-preferences/me", async route => {
|
|
const response = await route.fetch();
|
|
await route.fulfill({ json: { ...await response.json(), coordinatorWorkspaceEnabled: true } });
|
|
});
|
|
await page.addInitScript(() => {
|
|
const frames: Array<{ ready: boolean; headerVisible: boolean; loading: number[] | null; loadingComposer: number[] | null; composer: number[] | null; latestY?: number; scrollHeight?: number; loadingFont?: string; titleFont?: string }> = [];
|
|
Object.assign(window, { taskLoadingFrames: frames });
|
|
const sample = () => {
|
|
const box = (selector: string) => {
|
|
const element = document.querySelector(selector);
|
|
if (!element || getComputedStyle(element).visibility !== "visible") return null;
|
|
const rect = element.getBoundingClientRect();
|
|
if (rect.width === 0 || rect.height === 0) return null;
|
|
return [rect.x, rect.y, rect.width, rect.height];
|
|
};
|
|
const font = (selector: string) => {
|
|
const element = document.querySelector(selector);
|
|
return element ? getComputedStyle(element).font : undefined;
|
|
};
|
|
const header = document.querySelector('[data-testid="issue-detail-header"]');
|
|
const bounds = header?.getBoundingClientRect();
|
|
frames.push({
|
|
ready: !!document.querySelector('[data-testid="task-chat-thread"] > [aria-busy="false"]'),
|
|
headerVisible: !!header && getComputedStyle(header).visibility === "visible" && bounds!.bottom > 60 && bounds!.top < innerHeight,
|
|
loading: box('[data-testid="task-chat-loading-frame"]'),
|
|
loadingComposer: box('[data-testid="task-chat-loading-composer"] .paperclip-task-chat-composer'),
|
|
composer: box('[data-testid="task-chat-composer-stack"] .paperclip-task-chat-composer'),
|
|
latestY: [...document.querySelectorAll('[id^="comment-"]')].at(-1)?.getBoundingClientRect().y,
|
|
scrollHeight: document.querySelector('[data-testid="task-chat-scroller"]')?.scrollHeight,
|
|
loadingFont: font('[data-slot="task-loading-title"]'),
|
|
titleFont: font('[data-testid="task-chat-history-content"] [data-testid="issue-detail-header"] h2'),
|
|
});
|
|
requestAnimationFrame(sample);
|
|
};
|
|
requestAnimationFrame(sample);
|
|
});
|
|
await page.goto(fixture.route);
|
|
await expect(page.getByTestId("task-chat-thread").locator(':scope > [aria-busy="false"]')).toBeVisible();
|
|
await expect(page.getByRole("button", { name: "Approve patch", exact: true })).toBeVisible();
|
|
await page.waitForTimeout(500);
|
|
const frames = await page.evaluate(() => (window as unknown as { taskLoadingFrames: Array<{ ready: boolean; headerVisible: boolean; loading: number[] | null; loadingComposer: number[] | null; composer: number[] | null; latestY?: number; scrollHeight?: number; loadingFont?: string; titleFont?: string }> }).taskLoadingFrames);
|
|
await info.attach("loading-frames", { body: JSON.stringify(frames), contentType: "application/json" });
|
|
expect(frames.filter(frame => !frame.ready && frame.headerVisible)).toEqual([]);
|
|
const loading = frames.filter(frame => frame.loading);
|
|
const ready = frames.filter(frame => frame.ready && frame.latestY !== undefined);
|
|
expect(loading.length).toBeGreaterThan(1);
|
|
expect(ready.length).toBeGreaterThan(5);
|
|
for (let dimension = 0; dimension < 4; dimension++) {
|
|
const values = loading.map(frame => frame.loading![dimension]);
|
|
expect(Math.max(...values) - Math.min(...values)).toBeLessThanOrEqual(2);
|
|
expect(Math.abs(loading.at(-1)!.loadingComposer![dimension] - ready[0].composer![dimension])).toBeLessThanOrEqual(2);
|
|
}
|
|
expect(loading.at(-1)!.loadingFont).toBe(ready[0].titleFont);
|
|
expect(Math.max(...ready.map(frame => frame.latestY!)) - Math.min(...ready.map(frame => frame.latestY!))).toBeLessThanOrEqual(2);
|
|
expect(new Set(ready.map(frame => frame.scrollHeight)).size).toBe(1);
|
|
} finally {
|
|
await request.patch(`/api/companies/${fixture.company.id}`, { data: { status: "archived" } });
|
|
}
|
|
});
|
|
|
|
test("Classic startup does not guess a chat layout while personal preferences are pending", async ({ page, request }) => {
|
|
const fixture = await createTask(request);
|
|
let release!: () => void;
|
|
const preferenceReady = new Promise<void>(resolve => { release = resolve; });
|
|
try {
|
|
await page.route("**/api/instance/settings/experimental", async route => {
|
|
const response = await route.fetch();
|
|
await route.fulfill({ json: { ...await response.json(), enableClassicTaskInterface: true, enableStreamlinedUi: false } });
|
|
});
|
|
await page.route("**/api/workspace-preferences/me", async route => {
|
|
await preferenceReady;
|
|
const response = await route.fetch();
|
|
await route.fulfill({ json: { ...await response.json(), coordinatorWorkspaceEnabled: false } });
|
|
});
|
|
await page.goto(fixture.route);
|
|
await expect(page.getByTestId("shell-configuration-loading")).toBeVisible();
|
|
await expect(page.locator("[data-task-chat-shell]")).toHaveCount(0);
|
|
const preparedOutlet = page.getByTestId("shell-prepared-outlet");
|
|
await expect(preparedOutlet).toHaveAttribute("hidden", "");
|
|
await expect(preparedOutlet).toHaveAttribute("inert", "");
|
|
await expect(preparedOutlet).toHaveAttribute("aria-hidden", "true");
|
|
await expect(page.getByTestId("issue-detail-header")).toBeHidden();
|
|
await expect(page.getByRole("heading", { name: fixture.title, exact: true })).toHaveCount(0);
|
|
release();
|
|
await expect(page.getByTestId("issue-detail-header").getByRole("heading", { name: fixture.title, exact: true })).toBeVisible();
|
|
await expect(preparedOutlet).not.toHaveAttribute("hidden", "");
|
|
await expect(preparedOutlet).not.toHaveAttribute("inert", "");
|
|
await expect(preparedOutlet).not.toHaveAttribute("aria-hidden", "true");
|
|
await expect(page.locator("[data-task-chat-shell]")).toHaveCount(0);
|
|
} finally {
|
|
release();
|
|
await request.patch(`/api/companies/${fixture.company.id}`, { data: { status: "archived" } });
|
|
}
|
|
});
|
|
|
|
test("a stalled web font does not hide an otherwise prepared conversation indefinitely", async ({ page, request }) => {
|
|
const fixture = await createTask(request);
|
|
let release!: () => void;
|
|
const fontReady = new Promise<void>(resolve => { release = resolve; });
|
|
try {
|
|
await page.route("**/api/workspace-preferences/me", async route => {
|
|
const response = await route.fetch();
|
|
await route.fulfill({ json: { ...await response.json(), coordinatorWorkspaceEnabled: true } });
|
|
});
|
|
await page.route("**/*.woff2", async route => { await fontReady; await route.abort(); });
|
|
await page.goto(fixture.route, { waitUntil: "domcontentloaded" });
|
|
await expect(page.getByTestId("task-chat-loading-frame")).toBeVisible();
|
|
await expect(page.getByTestId("task-chat-thread").locator(':scope > [aria-busy="false"]')).toBeVisible({ timeout: 5000 });
|
|
await expect(page.getByTestId("task-chat-composer-stack").locator('[contenteditable="true"]')).toBeEditable();
|
|
} finally {
|
|
release();
|
|
await page.unrouteAll({ behavior: "wait" });
|
|
await request.patch(`/api/companies/${fixture.company.id}`, { data: { status: "archived" } });
|
|
}
|
|
});
|
|
|
|
for (const coordinator of [false, true]) test(`mobile chrome stays fixed when personal preferences resolve (Coordinator=${coordinator})`, async ({ page, request }, info) => {
|
|
await page.setViewportSize({ width: 390, height: 844 });
|
|
const fixture = await createTask(request);
|
|
let release!: () => void;
|
|
const preferenceReady = new Promise<void>(resolve => { release = resolve; });
|
|
await page.addInitScript(() => {
|
|
const frames: number[][] = [], frameTimes: number[] = [];
|
|
Object.assign(window, { mobileShellFrames: frames, mobileShellFrameTimes: frameTimes });
|
|
const sample = () => {
|
|
const shell = document.querySelector(".paperclip-app-shell");
|
|
if (shell && shell.getBoundingClientRect().width > 0) {
|
|
const rects = [".app-breadcrumb", ".mobile-bottom-nav", "#main-content"].map(selector => document.querySelector(selector)!.getBoundingClientRect());
|
|
frames.push([innerWidth, innerHeight, scrollX, scrollY, ...rects.flatMap((rect, index) => index === 2 ? [rect.x, rect.y, rect.width] : [rect.x, rect.y, rect.width, rect.height])]);
|
|
frameTimes.push(performance.now());
|
|
}
|
|
requestAnimationFrame(sample);
|
|
};
|
|
requestAnimationFrame(sample);
|
|
});
|
|
try {
|
|
await page.route("**/api/instance/settings/experimental", async route => {
|
|
const response = await route.fetch();
|
|
await route.fulfill({ json: { ...await response.json(), enableClassicTaskInterface: true, enableStreamlinedUi: false } });
|
|
});
|
|
await page.route("**/api/workspace-preferences/me", async route => {
|
|
await preferenceReady;
|
|
const response = await route.fetch();
|
|
await route.fulfill({ json: { ...await response.json(), coordinatorWorkspaceEnabled: coordinator } });
|
|
});
|
|
await page.goto(fixture.route);
|
|
await expect(page.getByTestId("shell-configuration-loading")).toBeVisible();
|
|
await expect(page.locator(".paperclip-app-shell")).toBeHidden();
|
|
expect(await page.evaluate(() => (window as unknown as { mobileShellFrames: number[][] }).mobileShellFrames)).toEqual([]);
|
|
release();
|
|
if (coordinator) await expect(page.getByTestId("task-chat-thread").locator(':scope > [aria-busy="false"]')).toBeVisible();
|
|
else await expect(page.getByTestId("issue-detail-header").getByRole("heading", { name: fixture.title, exact: true })).toBeVisible();
|
|
const ready = await page.evaluate(() => ({
|
|
count: (window as unknown as { mobileShellFrames: number[][] }).mobileShellFrames.length,
|
|
at: performance.now(),
|
|
}));
|
|
let frames: number[][] = [];
|
|
try {
|
|
// Observe six real post-ready frames and preserve the original 300ms
|
|
// interval. Wall time alone does not establish that rAF sampled it.
|
|
await expect.poll(() => page.evaluate(({ count, at }) => {
|
|
const state = window as unknown as { mobileShellFrames: number[][]; mobileShellFrameTimes: number[] };
|
|
return state.mobileShellFrames.length >= count + 6 && (state.mobileShellFrameTimes.at(-1) ?? 0) >= at + 300;
|
|
}, ready)).toBe(true);
|
|
} finally {
|
|
const captured = await page.evaluate(() => {
|
|
const state = window as unknown as { mobileShellFrames: number[][]; mobileShellFrameTimes: number[] };
|
|
return { frames: state.mobileShellFrames, times: state.mobileShellFrameTimes };
|
|
});
|
|
frames = captured.frames;
|
|
await info.attach("mobile-preference-chrome", { body: JSON.stringify(frames), contentType: "application/json" });
|
|
await info.attach("mobile-preference-frame-times", { body: JSON.stringify({ ready, times: captured.times }), contentType: "application/json" });
|
|
}
|
|
expect(frames.length).toBeGreaterThan(5);
|
|
for (let dimension = 0; dimension < frames[0].length; dimension++) {
|
|
const values = frames.map(frame => frame[dimension]);
|
|
expect(Math.max(...values) - Math.min(...values)).toBeLessThanOrEqual(2);
|
|
}
|
|
} finally {
|
|
release();
|
|
await request.patch(`/api/companies/${fixture.company.id}`, { data: { status: "archived" } });
|
|
}
|
|
});
|
|
|
|
test("a seeded Classic loading title uses the resolved title typography", async ({ page, request }) => {
|
|
const fixture = await createTask(request);
|
|
let release!: () => void;
|
|
const coreReady = new Promise<void>(resolve => { release = resolve; });
|
|
try {
|
|
await page.route("**/api/instance/settings/experimental", async route => {
|
|
const response = await route.fetch();
|
|
await route.fulfill({ json: { ...await response.json(), enableClassicTaskInterface: true, enableStreamlinedUi: false } });
|
|
});
|
|
await page.route("**/api/workspace-preferences/me", async route => {
|
|
const response = await route.fetch();
|
|
await route.fulfill({ json: { ...await response.json(), coordinatorWorkspaceEnabled: false } });
|
|
});
|
|
await page.goto(`/${fixture.company.issuePrefix}/issues`);
|
|
await page.getByRole("link").filter({ hasText: fixture.title }).first().click();
|
|
await expect(page.getByTestId("issue-detail-header").getByRole("heading", { name: fixture.title, exact: true })).toBeVisible();
|
|
await page.route("**/api/issues/*", async route => { await coreReady; await route.continue(); });
|
|
// Keep the recent-task title seed, but exercise the loading frame without
|
|
// a persisted full task that would correctly reveal the resolved header.
|
|
await page.addInitScript(() => Object.keys(localStorage).filter(key => key.startsWith("paperclip:query-cache:v1:")).forEach(key => localStorage.removeItem(key)));
|
|
await page.reload({ waitUntil: "domcontentloaded" });
|
|
const loadingTitle = page.getByRole("heading", { name: fixture.title, exact: true });
|
|
await expect(loadingTitle).toBeVisible();
|
|
await expect(page.getByTestId("issue-detail-header")).toHaveCount(0);
|
|
const font = await loadingTitle.evaluate(element => getComputedStyle(element).font);
|
|
release();
|
|
const title = page.getByTestId("issue-detail-header").getByRole("heading", { name: fixture.title, exact: true });
|
|
await expect(title).toBeVisible();
|
|
expect(await title.evaluate(element => getComputedStyle(element).font)).toBe(font);
|
|
} finally {
|
|
release();
|
|
await request.patch(`/api/companies/${fixture.company.id}`, { data: { status: "archived" } });
|
|
}
|
|
});
|