Files
PaperClipAI/tests/perf/collections/README.md
T
DottaandClaude Opus 5.5 490d97bf1e test(perf): guard Mine against waiting on the company-wide workspace list (#20419)
> Follows #20388 (merged as 50df9a19b9). This PR adds only test and
fixture files. It changes no product code.

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The Mine inbox (`/:companyPrefix/issues?view=mine`) is the first
page an operator opens
> - On an instance with 8,758 execution workspaces, Mine took about 13 s
to show rows. It loaded every workspace in the company
(`execution-workspaces?summary=true`, 2.5 MB) and kept all rows hidden
until that read finished
> - #20388 fixes this. Mine now reads only the workspaces its rows
reference (`ids` filter), and waits for them only when the rows show
workspace data
> - The collections perf suite did not catch the regression. Its fixture
has almost no execution workspaces, and it has no check on the workspace
read
> - This pull request adds a workspace-scale fixture and a spec that
fails if Mine requests the company-wide list again, or if Mine rows wait
for the workspace read when no workspace data is shown
> - The benefit is a regression guard that fails on `master` before
#20388 and passes with it

## Linked Issues or Issue Description

Refs #20388

**What happened?**
The collections perf suite could not detect that Mine waited on a
company-wide execution-workspace list. The fixture had no workspace
scale, and no assertion covered the workspace request or the reveal
gate.

**What did you expect?**
A browser check that fails when Mine requests the unfiltered workspace
list, or when Mine rows wait on a workspace read that does not change
what the rows show.

**Steps to reproduce**
Run `tests/perf/collections` against `master` UI assets on a company
with thousands of execution workspaces. All existing checks pass,
although Mine requests the full list and holds rows for it.

## What Changed

- `tests/perf/collections/workspace-fixture.ts` (new): a retained
company with 6,000 execution workspaces. 4,000 of them belong to
finished tasks. 12 Mine tasks each run in their own isolated workspace.
Mine tasks come from the API. The API cannot create execution
workspaces, so the bulk rows go to the disposable instance database
directly (same pattern as
`tests/e2e/legacy-failure-continuation.spec.ts`). The database URL comes
from `PAPERCLIP_CONFIG` or `PAPERCLIP_COLLECTION_PERF_DATABASE_URL`,
loopback only. The fixture uses the existing retain/404 rule.
- `tests/perf/collections/mine-workspaces.spec.ts` (new), cold load of
`/:prefix/issues?view=mine`:
1. Mine requests only `ids`-filtered `execution-workspaces?summary=true`
reads, and only for the workspaces its rows reference. No unfiltered
read.
2. With the Workspace column off and no workspace grouping, all Mine
rows appear while every workspace read is held.
3. With the Workspace column on, each row shows its isolated workspace
name.
4. Records cold time from navigation start to the first Mine row (two
frames after mount, as in `measure-mine-context.ts`) over at least 5
runs. It attaches the samples and the median. It is not a budget.
- `tests/perf/collections/README.md`: documents the fixture, its
database prerequisite, and the checks.

## Verification

Local disposable instance (`onboard --yes --run`, `local_trusted`,
embedded PostgreSQL, `PAPERCLIP_UI_DEV_MIDDLEWARE=false`, production UI
builds). Both arms used the same server (this branch) and the same
database. Only the UI assets changed, so this is a UI comparison. The
`master` UI does not send `ids`.

```sh
PAPERCLIP_CONFIG=<instance>/config.json PAPERCLIP_COLLECTION_PERF_BASE_URL=http://127.0.0.1:3219 \
  pnpm exec playwright test --config tests/perf/collections/playwright.config.ts mine-workspaces.spec.ts
```

**Fails on `origin/master` UI at 5858cef8f9 (before #20388 merged):**

```
✘ 1 Mine reads only the execution workspaces its rows reference
    Error: Mine requested the company-wide list of 6000 workspaces
    +   "/api/companies/<id>/execution-workspaces?summary=true",
✘ 2 Mine rows appear while workspace reads are pending when no workspace data is shown
    Error: Mine rows waited for the workspace read
    expect(locator).toBeVisible() failed … timeout 15000ms
✓ 3 the Workspace column resolves each Mine row's isolated workspace name
✓ 4 records cold time to Mine rows
2 failed, 2 passed
```

**Passes on this branch (#20388 UI):**

```
✓ 1 Mine reads only the execution workspaces its rows reference
✓ 2 Mine rows appear while workspace reads are pending when no workspace data is shown
✓ 3 the Workspace column resolves each Mine row's isolated workspace name
✓ 4 records cold time to Mine rows
4 passed
```

**Cold time to first Mine row, 5 runs each, fresh browser contexts,
1440×900:**

| Scenario | `master` UI median (samples) | This branch median (samples)
|
| --- | --- | --- |
| Native loopback, no interception | 472 ms (461, 466, 472, 483, 523) |
425 ms (406, 417, 425, 429, 998) |
| Workspace reads delayed 3,000 ms (diagnostic, intercepted) | 3,523 ms
(3488–3539) | 546 ms (471–1754) |

On this fixture the unfiltered list is 1.55 MB but returns in about 40
ms on loopback. The filtered read is 3.2 KB in about 4 ms. So native
loopback timing does not separate the arms. The delayed scenario shows
the dependency: on `master`, rows wait for the full workspace delay. No
hard time budget is added. The suite has no CI timing convention, and
the structural assertions are the guard.

**CI status of this suite:** `tests/perf/collections` runs in no GitHub
workflow. It is a manual suite against a disposable local instance (see
its README). The new spec runs the same way as the existing specs: same
directory, same `playwright.config.ts`, no new config. The Vitest checks
in #20388 (`ui/src/pages/Inbox.test.tsx`) remain the CI guard for the
reveal rule.

**Full collections suite on this branch:** 19 passed, 5 failed. The 5
failures are existing cases (`startup-regressions`: two partial-source
cases and two 429 cases; `startup`: "Coordinator Inbox retains aggregate
Mine reads when Streamlined UI is disabled"). They fail the same way on
the `origin/master` UI with the new spec excluded. This PR does not
cause them.

`pnpm verify`: exit 2 (README is a global CI input), so required CI
supplies broad coverage. `tsc -p tests/tsconfig.playwright.json` passes
(the CI typecheck project that covers `tests/perf`).

## Risks

- Low risk. Test and fixture files only.
- The fixture writes rows straight to the database. It needs
`PAPERCLIP_CONFIG` or `PAPERCLIP_COLLECTION_PERF_DATABASE_URL`, and
refuses non-loopback databases. Without either variable the spec fails
with a clear message.
- The timing case changes the real `enableIsolatedWorkspaces` instance
setting and restores it in `finally`.
- Seeding 6,000 workspaces takes about 10 s on the first run. Later runs
reuse the retained fixture.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, via Claude Code with
tool use (shell, file edits, Playwright runs). Extended reasoning on.

## 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: #` / `Closes
#` / `Refs #` 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
- [x] 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

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 20:29:56 -06:00

8.5 KiB

Tasks and Inbox cold-open checks

Run against a disposable local instance with production UI assets. The suite creates 220 unassigned backlog tasks and 110 board approvals. It does not invoke a model. The origin must be a loopback address.

pnpm --filter @paperclipai/ui build
PAPERCLIP_COLLECTION_PERF_BASE_URL=http://127.0.0.1:3219 \
  pnpm exec playwright test --config tests/perf/collections/playwright.config.ts

Start the isolated instance with PAPERCLIP_UI_DEV_MIDDLEWARE=false to serve the production build. The instance and its database must be disposable. These tests retain and reuse their fixture in test-results/collections/fixture.json; they only replace it when the previous company's API returns 404. Other errors fail.

The journeys check desktop and phone row budgets, incremental scrolling, retained row identity and height, shared count-only navigation, the Coordinator Inbox with Streamlined UI disabled, and the page-owned Needs You feed and Needs attention task index. Screenshots and failure traces stay in test-results. Request counts and row budgets are acceptance checks. They do not establish an end-to-end latency improvement. Measure cold, warm, and Back timings separately with the same fixture, assets, cache, viewport, and CPU/network settings.

parent-context.spec.ts holds the complete Mine response, including parent metadata, then checks row geometry through deferred visible diagnostics. Mine uses one assembled source read; it does not fetch parent or failed-task context from the browser before reveal. Recent retains its separate index/context path. startup-regressions.spec.ts covers session bootstrap and legacy fallback, partial source errors, resolved failure context, scoped 429 recovery, and archive/Undo persistence. Its authenticated session and failed-run responses are simulated transport fixtures over a real local board. They do not prove hosted login or model execution. The embedded bootstrap case holds separate company/access responses until Mine rows appear. Initial WebSocket reconciliation may request those endpoints in the background; their responses must not block the first rows. Missing or mismatched bootstrap data still requires the ordinary fallback reads. The two 429 cases keep the existing automatic backoff and Retry-After policy. They allow 45 seconds for its bounded retry window before exercising manual Retry. Other cases keep the normal short assertion timeout. Timing samples do not accelerate the browser clock.

mine-workspaces.spec.ts guards Mine against waiting on a company-wide execution-workspace list. Its fixture (workspace-fixture.ts) adds a company with 6,000 execution workspaces, 4,000 of them created for finished tasks, and 12 Mine tasks that each run in their own isolated workspace. The API cannot create execution workspaces, so this fixture writes those rows to the instance database. Set PAPERCLIP_CONFIG to the disposable instance's config.json (embedded PostgreSQL), or PAPERCLIP_COLLECTION_PERF_DATABASE_URL to its loopback database. The fixture is retained in test-results/collections/workspace-fixture.json with the same 404 rule as the main fixture. The spec routes isolated workspaces on for its own pages. It checks that Mine requests only ids-filtered workspace summaries for the workspaces its rows reference, that rows appear while those reads are held when neither the Workspace column nor workspace grouping is active, and that the Workspace column still shows each row's workspace name. Its timing case turns on the real isolated-workspaces setting, restores it, and records cold time from navigation start to the first Mine row (two frames after mount) over PAPERCLIP_COLLECTION_PERF_TIMING_RUNS runs (default and minimum 5). It records a native scenario without request interception and a separate diagnostic scenario that delays workspace reads by 3 seconds. The timings are attached evidence, not budgets.

Run these focused browser checks before the full collection suite:

PAPERCLIP_COLLECTION_PERF_BASE_URL=http://127.0.0.1:<candidate-ui-port> \
  pnpm exec playwright test --config tests/perf/collections/playwright.config.ts \
  parent-context.spec.ts startup-regressions.spec.ts

To collect timings, build the pinned baseline production assets once and retain that output. Build candidate UI assets only when their inputs change. Serve both outputs from stable loopback origins. If server behavior changes, each origin must proxy its matching pinned API revision against the same disposable database. Using the candidate API for both arms proves only a UI comparison. Keep agents and external providers inactive. Neither arm may migrate or reseed the shared fixture during a comparison.

The harness checks the configured API against each UI proxy, records HTML and entry-asset SHA-256 receipts, and records both serving API revisions. Supply full source SHAs to label the client artifacts, then run:

INBOX_BASELINE_URL=http://127.0.0.1:<baseline-port> \
INBOX_CANDIDATE_URL=http://127.0.0.1:<candidate-port> \
INBOX_BASELINE_API_URL=http://127.0.0.1:<baseline-api-port> \
INBOX_CANDIDATE_API_URL=http://127.0.0.1:<candidate-api-port> \
INBOX_BASELINE_SOURCE_REVISION=<full-baseline-sha> \
INBOX_CANDIDATE_SOURCE_REVISION=<full-candidate-sha> \
  node --import ./server/node_modules/tsx/dist/loader.mjs \
  tests/perf/collections/measure-mine-context.ts

The script retains a four-parent, 30-child fixture, archives three completed parents, and enables the personal Coordinator preference. Both APIs must expose that same company. It runs five alternating pairs by default. INBOX_PAIRS, INBOX_FIXTURE_FILE, and INBOX_OUTPUT override the count and evidence paths. No request interception is used in timings. INBOX_NETWORK_LATENCY_MS accepts an integer from 0 to 2000 and defaults to 0 (native loopback). A nonzero value uses Chromium CDP network emulation on every page, with unlimited throughput and unchanged CPU. Record native and 100 ms latency runs in separate INBOX_OUTPUT files; each sample labels its scenario. CDP specifies minimum request-to-response-header latency. This controlled extra round-trip scenario tests serial request dependencies; it does not prove hosted latency or reproduce the full staging network.

By default, INBOX_HTTP_CACHE=warm warms each browser context once, then reloads the document for each initial sample. This retains HTTP cache while clearing app query state. INBOX_HTTP_CACHE=cold uses fresh browser contexts; INBOX_HTTP_CACHE=both records these scenarios separately. Warm Recent-to-Mine navigation and task-to-Mine Back retain query state. Use INBOX_HEADFUL=1 and PAPERCLIP_PLAYWRIGHT_CHANNEL=chrome when installed Chrome is the intended browser.

Initial readiness requires visible Mine rows plus two animation frames. The report retains every sample and failure, exact row membership/order, row geometry, asset identities, full API resource timings, request statuses and primary-request start. Health, session, board access, companies and preferences remain timing controls. A faster initial total alone does not attribute a gain to its final context response. The fixed post-reveal window defaults to two seconds; INBOX_TAIL_MS changes it, up to 30 seconds. Counts retain 429s and unfinished requests rather than treating them as successful work. Use the same immutable asset cache policy on both origins and stop builds and suites during timing runs.

Startup cases also check that shared collection controls do not require the task-detail bundle before reveal, even when a different organization is remembered. Code warms after the collection paints, or on task-link intent. A successful immutable response allows module preloading to compile the cached chunk without executing it. A failed fetch leaves the collection usable and permits navigation without a document reload. Direct task URLs preload their static dependencies while identity is pending. These cases must run with production assets: development modules do not exercise the bundle boundaries.

The functional cases route feature settings and delayed responses. Routing disables browser HTTP caching. For warm-cache timings, set the real local feature settings and use fresh browser contexts without request interception. Keep normal cache writes enabled so code warmed after paint can be used on the next task open. Retain intercepted runs as separate diagnostic evidence. Match the server's hashed asset cache policy (public, max-age=31536000, immutable); Vite preview's default no-cache policy adds revalidation that the shipped server does not require. Keep HTML uncached and return 404 for missing assets.