paperclip/scripts
Devin Foley 97590ff8c4
feat(dev): add pnpm dev:mobile and dev:both for prebuilt UI preview (#10718)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The board UI is a React SPA served by the paperclip server; the
standard local dev flow is `pnpm dev`, which runs vite in dev mode with
HMR and an unbundled module graph
> - The unbundled dev bundle is hundreds of MB of JS across many
requests, which is fine on a local machine but unusable from a phone or
tablet on slow/lossy links (airplane wifi, mobile data, distant tailnet
peers)
> - Contributors who want to iterate on the board from a mobile device
today have no supported way to preview a small production-shaped bundle
without stopping the dev server and running a one-off `vite preview`
with manual proxy plumbing
> - This pull request adds `pnpm dev:mobile` — build the UI and serve
`ui/dist` via `vite preview` on port 3101, with `/api` proxied to the
running dev server on 3100 — plus `pnpm dev:both` to run both flavors
together
> - The benefit is a supported second flavor of the dev server for
phones/tablets that runs alongside the normal one, without touching the
primary `pnpm dev` flow

## Linked Issues or Issue Description

**Subsystem affected**

ui/ — React + Vite board UI

**Problem or motivation**

The vite dev server serves an unbundled module graph, which is fine on
localhost but unusable from a phone or tablet on a slow link.
Contributors testing responsive behavior on mobile devices have no
supported way to serve a small production-shaped SPA against the running
dev API. Running `vite preview` directly does not work either — the
server's board mutation guard checks that the browser's Origin matches
the request Host, and a preview on a second port would fail every
mutation.

**Proposed solution**

Add two root scripts:

- `pnpm dev:mobile` — build `ui/dist` and serve it via `vite preview` on
port 3101, with `/api` proxied to the API server on 3100.
- `pnpm dev:both` — run `pnpm dev` and `pnpm dev:mobile` together in a
single terminal with prefixed output and shared signal handling.

The vite preview config binds `0.0.0.0`, sets `allowedHosts: true` so it
accepts arbitrary hostnames (LAN, tailnet, ngrok, etc.), and the shared
`/api` proxy forwards the client's original Host header as
`x-forwarded-host`. The paperclip server's mutation guard already
prefers `x-forwarded-host` over `host` when computing trusted origins,
so the browser's Origin becomes trusted automatically.

**Alternatives considered**

- Bespoke node proxy script — works but duplicates what vite preview
already does.
- Loosen the mutation guard to accept arbitrary origins — reduces
security for the primary server for the sake of a dev-only workflow.
- Second server config that binds a second port from the paperclip
server itself — much larger change and mixes runtime concerns with a
dev-tooling convenience.

## What Changed

- New `pnpm dev:mobile` script — build UI then run `vite preview` on
port 3101.
- New `pnpm dev:both` script — run `pnpm dev` and `pnpm dev:mobile`
together via `scripts/dev-both.mjs`, which prefixes each child's output,
propagates SIGINT/SIGTERM, and exits when either child exits.
- `ui/vite.config.ts` — add a `preview` block (port 3101, host
`0.0.0.0`, `allowedHosts: true`, shared `/api` proxy).
- New `ui/src/lib/vite-api-proxy.ts` — extracts the `/api` proxy factory
shared by dev and preview, and forwards the client Host as
`x-forwarded-host` (plus `x-forwarded-proto`).
- New unit test `ui/src/lib/vite-api-proxy.test.ts` covering the
header-injection behavior and the pass-through when no Host is present.

## Verification

- `pnpm --filter @paperclipai/ui exec vitest run
src/lib/vite-api-proxy.test.ts` — 3 tests pass.
- `pnpm --filter @paperclipai/ui typecheck` — clean.
- `pnpm --filter @paperclipai/ui build` — clean.
- Manual: ran `vite preview` against an echo listener and confirmed the
request arrives with `x-forwarded-host` set to the client Host header
and `x-forwarded-proto: http`. Then ran `pnpm dev:mobile` against the
live dev server and verified board mutations (mark issue read, resolve
recovery action, run routine) succeed from a second-port browser session
that previously 403'd.

## Risks

Low risk. Changes are limited to dev tooling — no runtime code paths, no
server changes, no schema/migrations. The `apiProxy` refactor is a no-op
behaviorally for the existing dev server (same target, same `ws: true`);
the only new behavior is the two `x-forwarded-*` headers, and the server
side already prefers those headers when trusting origins. `dev:mobile`
and `dev:both` are additive; existing `pnpm dev` is untouched.

## Model Used

Claude Opus 4.7 (1M context), extended thinking, tool use (bash, file
edits).

## 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
2026-08-02 20:26:03 -07:00
..
__tests__ feat(workspaces): defer isolated setup until runtime start (#10653) 2026-08-02 10:37:10 -05:00
install-sh-fixtures feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
mcp-fixtures fix(acpx): decouple host proxy spawn cwd from in-sandbox remoteCwd (#10122) 2026-07-23 16:48:52 -07:00
smoke feat(mcp) [split 1/8]: add fixture demo servers (#9556) 2026-07-14 12:56:21 -05:00
acpx-patch-packaging.test.mjs feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
backfill-issue-reference-mentions.ts Add first-class issue references (#4214) 2026-04-21 10:02:52 -05:00
backup-db.sh Add paperclipai db:backup CLI command 2026-03-05 06:02:12 -06:00
bootstrap-npm-package.mjs Make ACP the default engine for local adapters (#9238) 2026-07-08 19:05:03 -07:00
bootstrap-npm-package.test.mjs Make ACP the default engine for local adapters (#9238) 2026-07-08 19:05:03 -07:00
build-npm.sh feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
build-standalone-public-packages.mjs perf(ci): build standalone public packages concurrently (#8567) 2026-06-23 17:52:12 -07:00
capture-pap-2351-binding-picker.mjs Add secrets provider vaults and remote import (#5429) 2026-05-09 18:22:17 -05:00
check-docker-deps-stage.mjs Add E2B sandbox provider plugin (#4452) 2026-04-25 11:01:11 -07:00
check-forbidden-tokens.mjs Redact current user in comments and token checks 2026-03-11 22:17:21 -05:00
check-no-git-push.mjs PAPA-430: workspace finalize gates + no-remote-git enforcement (#6969) 2026-05-29 08:25:29 -07:00
check-no-git-push.test.mjs PAPA-430: workspace finalize gates + no-remote-git enforcement (#6969) 2026-05-29 08:25:29 -07:00
check-release-package-bootstrap.mjs fix(ci): gate new release packages on npm bootstrap (#5146) 2026-05-03 19:31:28 -07:00
check-release-package-bootstrap.test.mjs fix(ci): gate new release packages on npm bootstrap (#5146) 2026-05-03 19:31:28 -07:00
check-task-chat-motion.mjs feat(ui): chat-style task view behind an experimental flag (#10606) 2026-08-01 02:26:47 -07:00
check-token-gates.mjs feat(ui): single-source design tokens, visual regression suite, and theme retune (#9134) 2026-07-07 16:22:16 -05:00
clean-install-git.sh feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
clean-install-npm.sh feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
clean-onboard-git.sh http clone 2026-03-09 10:03:45 -05:00
clean-onboard-npm.sh scripts 2026-03-03 14:00:10 -06:00
clean-onboard-ref.sh feat: add committed-ref onboarding smoke script 2026-03-09 09:59:43 -05:00
cli-bundled-npm-dependencies.mjs feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
codemod-extract-colors.mjs feat(ui): single-source design tokens, visual regression suite, and theme retune (#9134) 2026-07-07 16:22:16 -05:00
codemod-extract-misc.mjs feat(ui): single-source design tokens, visual regression suite, and theme retune (#9134) 2026-07-07 16:22:16 -05:00
codemod-extract-sizes.mjs feat(ui): single-source design tokens, visual regression suite, and theme retune (#9134) 2026-07-07 16:22:16 -05:00
codemod-extract-type.mjs feat(ui): single-source design tokens, visual regression suite, and theme retune (#9134) 2026-07-07 16:22:16 -05:00
codemod-type-ladder.mjs feat(ui): single-source design tokens, visual regression suite, and theme retune (#9134) 2026-07-07 16:22:16 -05:00
create-github-release.sh Add a feature catalog build artifact derived from the experimental settings schema (#10055) 2026-07-22 18:12:56 -07:00
dev-both.mjs feat(dev): add pnpm dev:mobile and dev:both for prebuilt UI preview (#10718) 2026-08-02 20:26:03 -07:00
dev-runner-output.mjs Guard dev health JSON parsing 2026-04-06 21:23:33 -05:00
dev-runner-output.ts fix(runtime): handle empty dev runner responses 2026-04-06 21:56:13 -05:00
dev-runner-paths.mjs [codex] Add backup endpoint and dev runtime hardening (#4087) 2026-04-20 06:08:55 -05:00
dev-runner-snapshot.mjs Address dev runner snapshot review feedback 2026-06-01 22:03:51 +00:00
dev-runner.mjs [codex] Add skills CLI and catalog management (#6782) 2026-05-28 07:33:51 -10:00
dev-runner.ts feat(workspaces): defer isolated setup until runtime start (#10653) 2026-08-02 10:37:10 -05:00
dev-service-profile.ts Introduce bind presets for deployment setup 2026-04-11 07:09:07 -05:00
dev-service.ts Add idempotent local dev service management 2026-03-29 10:55:26 -05:00
discord-daily-digest.sh [codex] Harden heartbeat scheduling and runtime controls (#4223) 2026-04-21 12:24:11 -05:00
docker-build-test.sh chore(docker): improve base image and organize docker files 2026-04-01 11:36:27 +00:00
docker-entrypoint.sh Ensure app-home ownership before the privilege drop, not only on remap (#10530) 2026-07-30 21:34:45 -07:00
docker-onboard-smoke.sh chore(docker): improve base image and organize docker files 2026-04-01 11:36:27 +00:00
e2e-install-lifecycle.sh feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
e2e-mcp-user-stories.mjs feat(mcp) [split 8/8]: add e2e coverage and operator docs (#9563) 2026-07-14 15:48:57 -05:00
e2e-shard-durations.json fix(ci): preserve required e2e check for sharded runs (#9923) 2026-07-20 16:40:19 -07:00
e2e-shard.mjs fix(ci): preserve required e2e check for sharded runs (#9923) 2026-07-20 16:40:19 -07:00
e2e-update-migrations.sh test(installer): cover cross-version update migrations (#10587) 2026-07-31 18:53:34 -07:00
ensure-plugin-build-deps.mjs [codex] Add skills CLI and catalog management (#6782) 2026-05-28 07:33:51 -10:00
ensure-workspace-package-links.ts [codex] fix worktree dev dependency ergonomics (#3743) 2026-04-15 09:47:29 -05:00
extract-proposed-events.mjs Add telemetry proposal extractor (#9544) 2026-07-13 23:47:27 -07:00
extract-proposed-events.test.mjs Add telemetry proposal extractor (#9544) 2026-07-13 23:47:27 -07:00
general-server-shard-durations.json ci: shard general-server tests 4 ways (#10663) 2026-08-01 19:03:28 -07:00
general-server-shard.mjs perf(ci): balance general-server test shards by recorded suite duration (#9516) 2026-07-13 12:25:54 -07:00
generate-company-assets.ts Address Greptile review on portability PR 2026-03-23 17:23:59 -05:00
generate-feature-catalog.ts Add a feature catalog build artifact derived from the experimental settings schema (#10055) 2026-07-22 18:12:56 -07:00
generate-npm-package-json.mjs feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
generate-org-chart-images.ts Add standalone Playwright-based org chart image generator 2026-03-20 05:55:33 -05:00
generate-org-chart-satori-comparison.ts feat: multi-style pure SVG org chart renderer (no Playwright needed) 2026-03-20 06:33:29 -05:00
generate-plugin-package-json.mjs Add E2B sandbox provider plugin (#4452) 2026-04-25 11:01:11 -07:00
generate-ui-package-json.mjs Publish @paperclipai/ui from release automation 2026-03-26 11:13:11 -05:00
ingest-app-definitions.mjs feat(connections): add AppDefinition Wave 1 catalog (#9981) 2026-07-21 15:57:12 -05:00
install.sh feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
kill-agent-browsers.sh [codex] Stabilize tests and local maintenance assets (#4423) 2026-04-24 15:11:42 -05:00
kill-dev.sh kill chrome test servers too 2026-04-09 06:14:12 -05:00
kill-vitest.sh [codex] Harden heartbeat scheduling and runtime controls (#4223) 2026-04-21 12:24:11 -05:00
kill-workspaces.sh Add workspace runtime kill script 2026-06-05 03:28:07 +00:00
link-plugin-dev-sdk.mjs fix(plugins): move dev SDK linking out of plugin postinstall scripts (#8255) 2026-06-18 07:45:53 -07:00
link-plugin-dev-sdk.test.js fix(plugins): move dev SDK linking out of plugin postinstall scripts (#8255) 2026-06-18 07:45:53 -07:00
measure-issue-chat-long-thread.mjs Improve issue thread scale and markdown polish (#4861) 2026-04-30 13:18:01 -05:00
migrate-inline-env-secrets.ts refactor: rename packages to @paperclipai and CLI binary to paperclipai 2026-03-03 08:45:26 -06:00
paperclip-commit-metrics.ts feat: implement multi-user access and invite flows (#3784) 2026-04-17 09:44:19 -05:00
paperclip-issue-update.sh chore: improve worktree tooling and security docs 2026-04-10 22:26:30 -05:00
prepare-bundled-package.mjs feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
prepare-server-ui-dist.sh ci: speed up PR verify workflow (#6137) 2026-05-16 11:28:25 -07:00
provision-worktree-runtime.sh feat(workspaces): defer isolated setup until runtime start (#10653) 2026-08-02 10:37:10 -05:00
provision-worktree.sh feat(workspaces): defer isolated setup until runtime start (#10653) 2026-08-02 10:37:10 -05:00
release-lib.sh feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
release-lib.test.mjs feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
release-package-manifest.json feat(mcp) [split 1/8]: add fixture demo servers (#9556) 2026-07-14 12:56:21 -05:00
release-package-map.mjs feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
release-package-map.test.mjs feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
release-registry-versions.mjs perf(release): batch npm registry version queries (#9202) 2026-07-08 08:04:39 -07:00
release-registry-versions.test.mjs perf(release): batch npm registry version queries (#9202) 2026-07-08 08:04:39 -07:00
release.sh feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
request-hot-restart.ts fix(server): preserve hot restart intent across path upgrade (#10593) 2026-07-31 21:55:59 -07:00
rollback-latest.sh chore: switch release calver to mdd patch 2026-03-18 07:57:36 -05:00
run-typecheck-build-gaps.mjs Add runtime asset build-gap guard 2026-07-13 08:35:30 -07:00
run-vitest-stable.mjs perf(ci): balance general-server test shards by recorded suite duration (#9516) 2026-07-13 12:25:54 -07:00
screenshot-blocked-inbox.mjs [codex] Add blocked inbox attention view (#5603) 2026-05-13 16:41:36 -05:00
screenshot-file-viewer.mjs Add workspace file viewer and artifact links (#7681) 2026-06-09 17:17:43 -05:00
screenshot-fork-flow.mjs Skill Studio: three-pane skill IDE with sandboxed test runs (#9241) 2026-07-09 13:08:56 -05:00
screenshot-one.mjs Add workspace file viewer and artifact links (#7681) 2026-06-09 17:17:43 -05:00
screenshot-pap2373.mjs Cancel stale queued heartbeats when issue graph changes (PAP-2314) (#4534) 2026-04-26 21:17:38 -05:00
screenshot-recovery-card.cjs [codex] Add source-scoped recovery actions (#5599) 2026-05-12 09:37:15 -05:00
screenshot-subissues.mjs Present ordered sub-issues as a workflow checklist (#4523) 2026-04-26 07:36:49 -05:00
screenshot-verdicts.mjs feat: add attention queue and Decisions surface (#9380) 2026-07-10 17:09:57 -05:00
screenshot.cjs feat: add authenticated screenshot utility (#2622) 2026-04-03 10:51:26 -07:00
serve-storybook-static.mjs [codex] Document Storybook visual baseline platform lock (#9216) 2026-07-08 07:23:02 -05:00
storybook-visual-baseline.mjs feat(ui): single-source design tokens, visual regression suite, and theme retune (#9134) 2026-07-07 16:22:16 -05:00
test-install-sh-docker.sh feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
verify-release-registry-state.mjs fix: harden release registry verification against npm lag (#4816) 2026-05-09 22:18:12 -07:00
verify-release-registry-state.test.mjs fix: harden release registry verification against npm lag (#4816) 2026-05-09 22:18:12 -07:00