paperclip/packages/db/src/migrations
Dotta b7545823be
[codex] Add document annotations and comments (#6733)
## Thinking Path

> - Paperclip orchestrates AI-agent companies through issues, documents,
runs, and durable company-scoped state.
> - Issue documents are where agents and operators capture plans,
handoffs, and work products.
> - Before this change, document collaboration could only happen through
whole-document edits and detached issue comments.
> - Inline document annotations need stable anchors, revision-aware
persistence, and UI affordances that do not break existing document
editing.
> - This pull request adds company-scoped document annotation threads,
comments, anchor snapshots, API routes, and board UI.
> - The benefit is that operators and agents can discuss specific
document passages without losing context as documents evolve.

## What Changed

- Added document annotation tables, schema exports, shared types,
validators, anchor hashing, and text-anchor helpers.
- Added server-side document annotation services and issue routes for
listing, creating, commenting, resolving, and reopening annotation
threads.
- Included annotation summaries in relevant issue document reads and
backup/recovery document workspace behavior.
- Added React UI for inline document highlights, comment panels, mobile
sheet behavior, deep-link focus, and resolved/open filtering.
- Added annotation design artifacts, Storybook coverage, screenshots,
and a screenshot helper script.
- Rebased the branch onto current `paperclipai/paperclip` `master` and
renumbered the annotation migration from `0085_old_swarm` to
`0091_old_swarm`; the SQL uses `IF NOT EXISTS` guards so environments
that previously applied the old migration number can safely apply the
new one.
- Adjusted the new annotation UI tests to use a local async flush helper
because this workspace's React 19.2.4 export does not expose
`React.act`.

## Verification

- `pnpm run preflight:workspace-links && pnpm exec vitest run
packages/shared/src/document-anchors.test.ts
server/src/__tests__/document-annotation-routes.test.ts
server/src/__tests__/document-annotations-service.test.ts
ui/src/components/DocumentAnnotationLayer.test.tsx
ui/src/components/IssueDocumentAnnotations.test.tsx
ui/src/lib/document-annotation-hash.test.ts
ui/src/lib/document-annotation-selection.test.ts`
- Confirmed `git diff --check` passes.
- Confirmed no `pnpm-lock.yaml` or `.github/workflows/*` files are
included in the PR diff.

## Risks

- Medium risk: this adds new persisted annotation tables and routes
across db/shared/server/ui.
- Migration risk is reduced by moving the branch migration to
`0091_old_swarm` after upstream `0090_resource_memberships` and keeping
the SQL idempotent for old `0085_old_swarm` adopters.
- UI risk is mostly around text range anchoring and panel positioning
across long documents, folded content, and mobile layouts; the PR
includes focused unit coverage and design screenshots.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

- OpenAI Codex, GPT-5 coding agent, tool-using software engineering
mode. Context window size is not exposed in this Paperclip runtime.

## 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 run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] If this change affects the UI, I have included before/after
screenshots
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-05-26 06:41:23 -07:00
..
meta [codex] Add document annotations and comments (#6733) 2026-05-26 06:41:23 -07:00
0000_mature_masked_marvel.sql Expand data model with companies, approvals, costs, and heartbeats 2026-02-17 09:07:22 -06:00
0001_fast_northstar.sql Add agent runtime DB schemas and expand shared types 2026-02-17 12:24:38 -06:00
0002_big_zaladane.sql Add agent runtime DB schemas and expand shared types 2026-02-17 12:24:38 -06:00
0003_shallow_quentin_quire.sql Add issue identifiers, activity run tracking, and migration inspection 2026-02-19 09:09:26 -06:00
0004_issue_identifiers.sql Add issue identifiers, activity run tracking, and migration inspection 2026-02-19 09:09:26 -06:00
0005_chief_luke_cage.sql Add agent config revisions, issue-approval links, and robust migration reconciliation 2026-02-19 13:02:14 -06:00
0006_overjoyed_mister_sinister.sql Add agent config revisions, issue-approval links, and robust migration reconciliation 2026-02-19 13:02:14 -06:00
0007_new_quentin_quire.sql Add agent task sessions table, session types, and programmatic DB backup 2026-02-19 14:01:40 -06:00
0008_amused_zzzax.sql Add secrets infrastructure: DB tables, shared types, env binding model, and migration improvements 2026-02-19 15:43:43 -06:00
0009_fast_jackal.sql Add secrets infrastructure: DB tables, shared types, env binding model, and migration improvements 2026-02-19 15:43:43 -06:00
0010_stale_justin_hammer.sql chore: add assets/attachments DB migration, CLI docs, and lockfile 2026-02-20 10:33:36 -06:00
0011_windy_corsair.sql feat: add project_goals many-to-many join table 2026-02-20 13:43:25 -06:00
0012_perpetual_ser_duncan.sql Implement issue execution lock with deferred wake promotion 2026-02-20 15:48:22 -06:00
0013_dashing_wasp.sql Implement issue execution lock with deferred wake promotion 2026-02-20 15:48:22 -06:00
0014_many_mikhail_rasputin.sql feat: add auth/access foundation - deps, DB schema, shared types, and config 2026-02-23 14:40:16 -06:00
0015_project_color_archived.sql feat: foldable PROJECTS section in sidebar with color support 2026-02-23 09:14:08 -06:00
0016_agent_icon.sql feat: add agent icons with picker and collapsible sidebar section 2026-02-23 12:25:13 -06:00
0017_tiresome_gabe_jones.sql fix(db): cast REPEAT count to integer in migration 0017 2026-02-23 16:25:23 -06:00
0018_flat_sleepwalker.sql feat: add issue labels (DB schema, API, and service) 2026-02-25 08:38:37 -06:00
0019_public_victor_mancha.sql feat: add project workspaces (DB, API, service, and UI) 2026-02-25 08:38:46 -06:00
0020_white_anita_blake.sql feat: workspace improvements - nullable cwd, repo-only workspaces, and resolution refactor 2026-02-25 21:35:33 -06:00
0021_chief_vindicator.sql feat: per-issue assignee adapter overrides (model, effort, workspace) 2026-02-26 10:32:44 -06:00
0022_company_brand_color.sql feat: join request claim secrets, onboarding API, and company branding 2026-02-26 16:33:20 -06:00
0023_fair_lethal_legion.sql feat: join request claim secrets, onboarding API, and company branding 2026-02-26 16:33:20 -06:00
0024_far_beast.sql Add touched/unread inbox issue semantics 2026-03-06 08:21:03 -06:00
0025_nasty_salo.sql Persist issue read state and clear unread on open 2026-03-06 08:34:19 -06:00
0026_lying_pete_wisdom.sql Add worktree-aware workspace runtime support 2026-03-10 10:58:38 -05:00
0027_tranquil_tenebrous.sql Add project-first execution workspace policies 2026-03-10 10:58:43 -05:00
0028_harsh_goliath.sql feat(issues): add issue documents and inline editing 2026-03-13 21:30:48 -05:00
0029_plugin_tables.sql Merge public-gh/master into feature/plugin-runtime-instance-cleanup 2026-03-14 10:46:19 -05:00
0030_rich_magneto.sql Use asset-backed company logos 2026-03-16 09:25:39 -05:00
0031_zippy_magma.sql feat(costs): add billing, quota, and budget control plane 2026-03-16 15:11:01 -05:00
0032_pretty_doctor_octopus.sql feat(costs): add billing, quota, and budget control plane 2026-03-16 15:11:01 -05:00
0033_shiny_black_tarantula.sql Harden budget enforcement and migration startup 2026-03-16 15:11:34 -05:00
0034_fat_dormammu.sql Fix budget incident resolution edge cases 2026-03-16 16:48:13 -05:00
0035_marvelous_satana.sql Merge remote-tracking branch 'public-gh/master' into paperclip-subissues 2026-03-16 17:19:55 -05:00
0036_cheerful_nitro.sql Add instance experimental setting for isolated workspaces 2026-03-17 09:24:28 -05:00
0037_friendly_eddie_brock.sql Add workspace operation tracking and fix project properties JSX 2026-03-17 09:36:35 -05:00
0038_careless_iron_monger.sql Improve orphaned local heartbeat recovery 2026-03-20 06:05:15 -05:00
0039_fat_magneto.sql fix: renumber worktree merge history migrations 2026-03-20 17:23:45 -05:00
0040_eager_shotgun.sql fix: renumber worktree merge history migrations 2026-03-20 17:23:45 -05:00
0041_curly_maria_hill.sql fix: renumber worktree merge history migrations 2026-03-20 17:23:45 -05:00
0042_spotty_the_renegades.sql fix: renumber worktree merge history migrations 2026-03-20 17:23:45 -05:00
0043_reflective_captain_universe.sql fix: renumber worktree merge history migrations 2026-03-20 17:23:45 -05:00
0044_illegal_toad.sql Address Greptile review on board CLI auth 2026-03-23 08:46:05 -05:00
0045_workable_shockwave.sql Add the inbox mine tab and archive flow 2026-03-26 16:09:43 -05:00
0046_smooth_sentinels.sql fix(db): make document revision migration replay-safe 2026-03-31 08:09:00 -05:00
0047_overjoyed_groot.sql fix: make feedback migration replay-safe after rebase 2026-04-02 10:54:56 -05:00
0048_flashy_marrow.sql feat(routines): add workspace-aware routine runs 2026-04-02 11:38:57 -05:00
0049_flawless_abomination.sql fix: address greptile feedback for blocker dependencies 2026-04-06 09:03:13 -05:00
0050_stiff_luckman.sql Add project-level environment variables 2026-04-06 21:23:30 -05:00
0051_young_korg.sql Speed up issue search 2026-04-06 21:25:41 -05:00
0052_mushy_trauma.sql Generate execution policy migration 2026-04-07 17:43:10 -05:00
0053_sharp_wild_child.sql Persist non-issue inbox dismissals 2026-04-09 06:16:05 -05:00
0054_draft_routines.sql Add draft routine defaults and run-time overrides 2026-04-09 10:19:52 -05:00
0055_kind_weapon_omega.sql fix: harden heartbeat and adapter runtime workflows 2026-04-10 22:26:21 -05:00
0056_spooky_ultragirl.sql [codex] Improve workspace runtime and navigation ergonomics (#3680) 2026-04-14 12:57:11 -05:00
0057_tidy_join_requests.sql feat: implement multi-user access and invite flows (#3784) 2026-04-17 09:44:19 -05:00
0058_wealthy_starbolt.sql [codex] Add run liveness continuations (#4083) 2026-04-20 06:01:49 -05:00
0059_plugin_database_namespaces.sql [codex] Add plugin orchestration host APIs (#4114) 2026-04-20 08:52:51 -05:00
0060_orange_annihilus.sql Add first-class issue references (#4214) 2026-04-21 10:02:52 -05:00
0061_lively_thor_girl.sql [codex] Harden heartbeat scheduling and runtime controls (#4223) 2026-04-21 12:24:11 -05:00
0062_routine_run_dispatch_fingerprint.sql [codex] Harden heartbeat scheduling and runtime controls (#4223) 2026-04-21 12:24:11 -05:00
0063_issue_thread_interactions.sql [codex] Add structured issue-thread interactions (#4244) 2026-04-21 20:15:11 -05:00
0064_issue_thread_interaction_idempotency.sql [codex] Add structured issue-thread interactions (#4244) 2026-04-21 20:15:11 -05:00
0065_environments.sql Add local environment lifecycle (#4297) 2026-04-22 20:07:41 -07:00
0066_issue_tree_holds.sql [codex] Add issue subtree pause, cancel, and restore controls (#4332) 2026-04-23 14:51:46 -05:00
0067_agent_default_environment.sql Add SSH environment support (#4358) 2026-04-23 19:15:22 -07:00
0068_environment_local_driver_unique.sql Add SSH environment support (#4358) 2026-04-23 19:15:22 -07:00
0069_liveness_recovery_dedupe.sql [codex] Add runtime lifecycle recovery and live issue visibility (#4419) 2026-04-24 15:50:32 -05:00
0070_active_run_output_watchdog.sql [codex] Add runtime lifecycle recovery and live issue visibility (#4419) 2026-04-24 15:50:32 -05:00
0071_default_hire_approval_off.sql [codex] Harden recovery issue handling (#4600) 2026-04-27 15:02:47 -05:00
0072_large_sandman.sql [codex] Harden recovery issue handling (#4600) 2026-04-27 15:02:47 -05:00
0073_shiny_salo.sql [codex] Split backend control-plane QoL slice (#4700) 2026-04-28 16:46:45 -05:00
0074_striped_genesis.sql [codex] Split backend control-plane QoL slice (#4700) 2026-04-28 16:46:45 -05:00
0075_cultured_sebastian_shaw.sql [codex] Add issue monitor liveness controls (#4988) 2026-05-03 08:58:53 -05:00
0076_useful_elektra.sql Expand plugin host surface (#5205) 2026-05-05 07:42:57 -05:00
0077_unusual_karnak.sql Add routine revision history and restore flow (#5285) 2026-05-05 11:54:52 -05:00
0078_white_darwin.sql Show workspace changes and stale notices in issue threads (#5356) 2026-05-06 09:00:54 -05:00
0079_company_search_document_indexes.sql Add full company search page (#5293) 2026-05-06 06:32:37 -05:00
0080_company_search_fuzzystrmatch.sql Add full company search page (#5293) 2026-05-06 06:32:37 -05:00
0081_optimal_dormammu.sql Add planning mode for issue work (#5353) 2026-05-06 07:01:28 -05:00
0082_dry_vision.sql Add secrets provider vaults and remote import (#5429) 2026-05-09 18:22:17 -05:00
0083_company_secret_provider_configs.sql Add secrets provider vaults and remote import (#5429) 2026-05-09 18:22:17 -05:00
0084_issue_recovery_actions.sql [codex] Add source-scoped recovery actions (#5599) 2026-05-12 09:37:15 -05:00
0085_tranquil_the_executioner.sql [codex] Add issue document locking (#6009) 2026-05-15 08:54:55 -05:00
0086_routine_env_runtime_contract.sql [codex] Add routine env secrets support (#6212) 2026-05-17 16:30:34 -05:00
0087_backfill_environment_manage_human_defaults.sql [codex] Add agent permissions and controls plan (#6386) 2026-05-22 08:12:52 -05:00
0088_backfill_principal_access_compatibility.sql [codex] Add agent permissions and controls plan (#6386) 2026-05-22 08:12:52 -05:00
0089_cloud_upstreams.sql [codex] Add local Cloud Upstream sync (#6548) 2026-05-22 09:56:22 -05:00
0090_resource_memberships.sql [codex] Add resource membership controls (#6677) 2026-05-25 13:12:41 -05:00
0091_old_swarm.sql [codex] Add document annotations and comments (#6733) 2026-05-26 06:41:23 -07:00