mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-26 18:35:33 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - The `@paperclipai/ui` Vitest suite includes 182 component/page test files, many of which boot full jsdom and React module graphs with 6–19 mocks solely to verify wiring that Playwright E2E specs already exercise end-to-end. > - Auth, security, permission, privacy, error-boundary, pure-logic `ui/src/lib` / `ui/src/hooks` / `ui/src/api` suites, and complex interactive client logic must stay intact. > - This pull request removes 36 thin mocked/E2E-duplicated/synthetic-perf jsdom component/page test files (-17,367 LOC), consolidates 7 tiny single-purpose session-replay privacy tests into `ui/src/lib/analytics/replay-masking.test.tsx` with 100% of assertions preserved, converts 2 pure-logic suites from `jsdom` to `node`, and updates affected feature/agent-access map references plus `.github/workflows/ci-incremental-qualification.yml`. > - The benefit is cutting full `@paperclipai/ui` suite execution to ~36s locally (~42s fewer raw test seconds and 42 fewer jsdom boots) while preserving 100% of auth, permission, privacy, and pure-logic coverage. ## Linked Issues or Issue Description Refs #22804 **What existing behavior does this improve?** UI Vitest runtime, signal-to-noise ratio, and jsdom boot overhead in `ui/src/`. **Subsystem affected** ui/ — React + Vite board UI **Current behavior** 36 thin mocked/E2E-duplicated/synthetic-perf jsdom component/page tests and 7 tiny single-purpose session-replay privacy files pay full jsdom+React boot overhead on every UI PR despite duplicate Playwright E2E and pure-logic coverage. **Proposed behavior** Remove the 36 thin mocked/E2E-duplicated jsdom suites, consolidate the 7 session-replay privacy suites into `ui/src/lib/analytics/replay-masking.test.tsx`, convert 2 pure-logic suites to `node`, and keep all maps and incremental qualification checks aligned. ## What Changed - **Deleted 36 thin mocked / E2E-duplicated / synthetic-perf jsdom suites (`-17,367 LOC`):** - Mocked chat-adapter setup & banner wiring (4 files), heavily mocked `Inbox.test.tsx` shell (1 file, 19 mocks; pure logic in `ui/src/lib/inbox.test.ts` and browser E2E retained), synthetic jsdom microbenchmarks & mocked app/browse/connector wiring (9 files), mocked AI-connection & agent-config wiring (6 files), and thin presentational/mocked component wiring (16 files). - **Consolidated 7 tiny session-replay privacy tests into `ui/src/lib/analytics/replay-masking.test.tsx` (498 LOC, 100% of assertions preserved):** `AccountQuotaPanels`, `WebhookFields`, `AiConnectionPicker`, `AiConnectionAccountControls`, `AiConnectionIdentity`, `AiConnectionPoolRunDetails`, and `AgentSetupPrompt`. - **Converted 2 pure-logic suites from `jsdom` to `node` (0 assertions lost):** `ui/src/pages/Secrets.test.ts` and `ui/src/pages/tools/ProfilesTab.test.ts`. - **Retained 100% of high-signal UI coverage:** all 276 `ui/src/lib`, 56 `ui/src/hooks`, 19 `ui/src/context`, 26 `ui/src/api`, 14 `ui/src/adapters`, 6 `ui/src/plugins`, all 94 pure-logic `node` component/page tests, and all auth/security/permission/privacy/error-boundary/complex-interactive suites. - **Updated references:** updated the 7 affected `maps/` files to reference current canonical suites and updated `.github/workflows/ci-incremental-qualification.yml` (`ui/src/pages/Inbox.tsx → Inbox.test.tsx` to `ui/src/pages/Auth.tsx → Auth.test.tsx`). ## Verification - `pnpm exec vitest run --project @paperclipai/ui` — **557/557 files, 6,916 passed | 1 skipped (`36.14s`)** - `pnpm --filter @paperclipai/ui typecheck` — **PASS (0 errors)** - `node scripts/storybook-catalog.mjs` — **PASS (371 files, 3,480 stories)** - `node scripts/check-maps.mjs` — **PASS (35 areas, 192 capability IDs)** - `node scripts/check-query-error-rendering.mjs` — **PASS (0 findings)** - `node scripts/check-test-budget.mjs --base origin/master` — **PASS (588 nightly suites validated)** - Verified `.github/workflows/ci-incremental-qualification.yml` `qualify_test_selection` check locally (`Auth.tsx → Auth.test.tsx`) — **PASS** ## Risks - Low risk: zero production UI code changed; all auth, permission, privacy, replay-masking, error-boundary, pure-logic, and Playwright E2E behavioral checks remain intact. ## Model Used - Google Gemini (Antigravity agent swarm) with extended reasoning, tool use, and local test execution (`e2e-opt`, `verifier`, `ci-pipeline`). ## 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 - [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
97 lines
5.9 KiB
Markdown
97 lines
5.9 KiB
Markdown
---
|
||
navigation: {"section":"Automation and structured work","sectionOrder":60,"order":10}
|
||
---
|
||
|
||
# Routines, schedules, and triggers
|
||
|
||
Operators define repeatable work, configure its inputs and triggers, run it on demand or automatically, and inspect the execution history and resulting tasks.
|
||
|
||
Feature ID: `routines`.
|
||
|
||
Implementation: [routine list](../../ui/src/pages/Routines.tsx), [routine detail](../../ui/src/pages/RoutineDetail.tsx), [routine page](../../ui/src/components/routine-page/RoutinePage.tsx), [edit dialog](../../ui/src/components/routine-page/RoutineEditDialog.tsx), [webhook dialog](../../ui/src/components/routine-page/RoutineWebhookDialog.tsx).
|
||
|
||
Agent access: [companion](../agent-access-map/routines.md).
|
||
|
||
## Sub-features
|
||
|
||
- `definition`: `routines/definition` — save the request, agent, project, variables, and execution context.
|
||
- `triggers`: `routines/triggers` — configure supported schedules/webhooks or other offered triggers.
|
||
- `run-now`: `routines/run-now` — supply inputs and create an observable routine execution.
|
||
- `history`: `routines/history` — inspect resulting tasks and past outcomes.
|
||
- `management`: `routines/management` — organize, pause/disable, archive, and distinguish plugin-managed routines.
|
||
|
||
## How to get to it (user POV)
|
||
|
||
### `routine-editor`
|
||
|
||
Open `/routines`, create one (New routine opens the edit dialog), and inspect
|
||
`/routines/:routineId`. Edit opens the same dialog; older section addresses
|
||
redirect to the page.
|
||
|
||
### `trigger-history`
|
||
|
||
Schedules and webhooks are listed under Repeats on the routine page; a webhook
|
||
opens its dialog there, and both are added or changed in the Edit dialog. Tasks
|
||
the routine created are under History on the page. The page menu leads to
|
||
**Version history** (`/routines/:routineId/history`, configuration versions, not
|
||
executions) and **Audit log** (`/routines/:routineId/activity`). Lists also offer Run now.
|
||
|
||
## Driving it with Playwright and the Paperclip CLI
|
||
|
||
Preconditions: follow the [baseline](./README.md#before-driving-a-journey). Use a disposable routine, deterministic test agent, and harmless target. Record schedule timezone and enabled state.
|
||
|
||
### `routine-editor`
|
||
|
||
Automated: [routine form tests](../../ui/src/components/routine-page/routine-form.test.ts) cover schedule and responsibility sync, and [Routine service](../../server/src/__tests__/routines-service.test.ts) covers server contracts (verify page redirects, History paging, status switch, save conflicts, and running a routine manually).
|
||
|
||
Manual: Save an agent, request, project, and a required variable. Reload and inspect the saved definition. Run now with a distinguishable input, follow the resulting task, and verify its output and history entry. Check a missing required input.
|
||
|
||
Variables are detected from `{{name}}` placeholders; mark a detected variable
|
||
Required and verify missing input prevents Run routine. Configuration can be
|
||
checked without model credentials. A successful subprocess run alone does not
|
||
complete the generated task or establish a useful task output.
|
||
|
||
### `trigger-history`
|
||
|
||
Automated: [webhook instructions](../../ui/src/components/routine-triggers/webhook-instructions.test.ts) and [replay masking](../../ui/src/lib/analytics/replay-masking.test.tsx) cover webhook instructions and secret-field replay blocking; [routine integration](../../server/src/__tests__/routines-e2e.test.ts) is server integration rather than a provider-wide browser proof.
|
||
|
||
Manual: Set a near-term disposable schedule or authorized test webhook, verify one eligible execution and its source trigger, then disable it and confirm further invocations stop. Inspect a failed execution without losing its history. Remove the temporary trigger after testing.
|
||
|
||
Sentry alerts use the ordinary
|
||
`/api/routine-triggers/public/:publicId/fire` webhook and its trigger authentication.
|
||
Configure loop-prevention filters in Sentry as described in the
|
||
[Sentry repair tutorial](../../docs/guides/board-operator/sentry-run-failure-repairs.md).
|
||
|
||
## Gotchas
|
||
|
||
- Saving a schedule does not prove the scheduler invoked it.
|
||
- Timezone, overlap/concurrency rules, and plugin ownership affect behavior.
|
||
- A routine run’s task must still respect pause, access, and budget gates.
|
||
- Managed idle hosts may use the [routine wake protocol](../../doc/idle-sleep-safety.md#scheduled-routine-wake-protocol)
|
||
to sleep between supported future runs. The host must save a durable alarm
|
||
and verify the same generation before stopping. Local execution and catch-up
|
||
remain unchanged. Unsupported triggers and other pending work keep it awake.
|
||
|
||
### Latest skill references
|
||
|
||
Routine instructions retain stable skill mentions. After a project source syncs an
|
||
upstream change, the next execution uses the latest installed version without waiting
|
||
on GitHub. Record the resolved version before/after and verify a resumed execution
|
||
keeps its original version. Private skill references require current project access
|
||
for both the agent and its responsible person.
|
||
|
||
### Storybook verification
|
||
|
||
#### `run-now`
|
||
|
||
Capability ID: `routines/run-now`.
|
||
|
||
Scope: ui
|
||
Storybook: Mount RoutineRunVariablesDialog through actual RoutineDetail with required/default inputs, project/workspace overrides, pending, blocked and failed submission. RunButton-only no-op examples do not supply/run inputs.
|
||
Production: POST /routines/{id}/run must validate variables, create one attributed execution/task and obey pause/access/budget gates; inspect actual task outcome separately.
|
||
Sources: Source: [RoutineRunVariablesDialog.tsx](../../ui/src/components/RoutineRunVariablesDialog.tsx), [RoutineDetail.tsx](../../ui/src/pages/RoutineDetail.tsx), [routines.ts](../../server/src/routes/routines.ts). Tests: [routines-service.test.ts](../../server/src/__tests__/routines-service.test.ts), [routines-e2e.test.ts](../../server/src/__tests__/routines-e2e.test.ts)
|
||
|
||
### Documentation scope: Routines, cases, and status cards
|
||
|
||
All three capabilities have recipes. Trigger/provider/timezone combinations, custom case schemas and summarizer quality need deeper cases.
|