paperclip/ui/src/lib
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
..
acpx-model-filter.test.ts Improve ACPX adapter configuration (#5290) 2026-05-06 06:06:47 -05:00
acpx-model-filter.ts Improve ACPX adapter configuration (#5290) 2026-05-06 06:06:47 -05:00
activity-format.test.ts Add recovery handoff system notices (#5289) 2026-05-06 06:05:58 -05:00
activity-format.ts [codex] Roll up May 17 branch changes (#6210) 2026-05-17 17:15:06 -05:00
agent-config-patch.test.ts [codex] Retry max-turn exhausted heartbeats (#5096) 2026-05-03 11:30:48 -05:00
agent-config-patch.ts Add cheap model profiles for local adapters (#4881) 2026-04-30 15:32:04 -05:00
agent-icons.ts Fix markdown mention chips 2026-03-23 16:57:27 -05:00
agent-onboarding-prompt.ts Improve external agent invite flow (#6183) 2026-05-23 09:09:40 -05:00
agent-order.ts Add shared sidebar section controls (#5585) 2026-05-09 19:49:59 -05:00
agent-skills-state.test.ts Add unmanaged skill provenance to agent skills 2026-03-18 14:21:50 -05:00
agent-skills-state.ts Add unmanaged skill provenance to agent skills 2026-03-18 14:21:50 -05:00
assignees.test.ts Polish issue chat actions and overflow 2026-04-08 06:02:34 -05:00
assignees.ts feat: implement multi-user access and invite flows (#3784) 2026-04-17 09:44:19 -05:00
blockedInbox.test.ts [codex] Add blocked inbox attention view (#5603) 2026-05-13 16:41:36 -05:00
blockedInbox.ts [codex] Add blocked inbox attention view (#5603) 2026-05-13 16:41:36 -05:00
color-contrast.ts fix: improve pill contrast by using WCAG contrast ratios on composited backgrounds 2026-03-23 16:57:27 -05:00
comment-submit-draft.test.ts Fix optimistic comment draft clearing 2026-03-30 14:14:36 -05:00
comment-submit-draft.ts Fix optimistic comment draft clearing 2026-03-30 14:14:36 -05:00
company-export-selection.test.ts Default recurring task exports to checked 2026-03-23 16:57:38 -05:00
company-export-selection.ts Default recurring task exports to checked 2026-03-23 16:57:38 -05:00
company-members.test.ts feat: implement multi-user access and invite flows (#3784) 2026-04-17 09:44:19 -05:00
company-members.ts feat: implement multi-user access and invite flows (#3784) 2026-04-17 09:44:19 -05:00
company-page-memory.ts Add browser-based board CLI auth flow 2026-03-23 08:46:05 -05:00
company-portability-sidebar.test.ts Add SSH environment support (#4358) 2026-04-23 19:15:22 -07:00
company-portability-sidebar.ts Preserve sidebar order in company portability 2026-03-23 16:57:59 -05:00
company-routes.test.ts Add full company search page (#5293) 2026-05-06 06:32:37 -05:00
company-routes.ts Add full company search page (#5293) 2026-05-06 06:32:37 -05:00
company-selection.test.ts Fix manual company switch route sync 2026-03-13 09:47:01 -05:00
company-selection.ts Fix manual company switch route sync 2026-03-13 09:47:01 -05:00
document-annotation-hash.test.ts [codex] Add document annotations and comments (#6733) 2026-05-26 06:41:23 -07:00
document-annotation-hash.ts [codex] Add document annotations and comments (#6733) 2026-05-26 06:41:23 -07:00
document-annotation-selection.test.ts [codex] Add document annotations and comments (#6733) 2026-05-26 06:41:23 -07:00
document-annotation-selection.ts [codex] Add document annotations and comments (#6733) 2026-05-26 06:41:23 -07:00
document-revisions.test.ts [codex] Add issue document locking (#6009) 2026-05-15 08:54:55 -05:00
document-revisions.ts fix(ui): keep latest issue document revision current (#3342) 2026-04-10 17:14:06 -07:00
duplicate-agent-payload.test.ts [codex] Roll up May 17 branch changes (#6210) 2026-05-17 17:15:06 -05:00
duplicate-agent-payload.ts [codex] Roll up May 17 branch changes (#6210) 2026-05-17 17:15:06 -05:00
groupBy.ts Add shared UI primitives, contexts, and reusable components 2026-02-17 09:57:00 -06:00
inbox.test.ts [codex] Add blocked inbox attention view (#5603) 2026-05-13 16:41:36 -05:00
inbox.ts [codex] Add blocked inbox attention view (#5603) 2026-05-13 16:41:36 -05:00
instance-settings.test.ts Add username log censor setting 2026-03-20 08:50:00 -05:00
instance-settings.ts Add username log censor setting 2026-03-20 08:50:00 -05:00
invite-memory.ts feat: implement multi-user access and invite flows (#3784) 2026-04-17 09:44:19 -05:00
issue-assignee-overrides.test.ts Add cheap model profiles for local adapters (#4881) 2026-04-30 15:32:04 -05:00
issue-assignee-overrides.ts Add cheap model profiles for local adapters (#4881) 2026-04-30 15:32:04 -05:00
issue-blockers.ts Guard assigned backlog liveness (#5428) 2026-05-07 12:25:26 -05:00
issue-chat-messages.test.ts fix(ui): fix message attribution for agent-posted comments with user author IDs (#5780) 2026-05-12 01:20:49 -07:00
issue-chat-messages.ts fix(ui): fix message attribution for agent-posted comments with user author IDs (#5780) 2026-05-12 01:20:49 -07:00
issue-chat-scroll.test.ts [codex] Improve issue detail and issue-list UX (#3678) 2026-04-14 12:50:48 -05:00
issue-chat-scroll.ts [codex] Improve issue detail and issue-list UX (#3678) 2026-04-14 12:50:48 -05:00
issue-detail-subissues.test.ts Add ordered sub-issue navigation (#5938) 2026-05-13 15:43:51 -05:00
issue-detail-subissues.ts Add ordered sub-issue navigation (#5938) 2026-05-13 15:43:51 -05:00
issue-execution-policy.ts [codex] Add issue monitor liveness controls (#4988) 2026-05-03 08:58:53 -05:00
issue-filters.test.ts Add planning mode for issue work (#5353) 2026-05-06 07:01:28 -05:00
issue-filters.ts [codex] Add runtime lifecycle recovery and live issue visibility (#4419) 2026-04-24 15:50:32 -05:00
issue-monitor.ts [codex] Add issue monitor liveness controls (#4988) 2026-05-03 08:58:53 -05:00
issue-properties-panel-key.test.ts [codex] Polish issue board workflows (#4224) 2026-04-21 12:25:34 -05:00
issue-properties-panel-key.ts [codex] Polish issue board workflows (#4224) 2026-04-21 12:25:34 -05:00
issue-reference.test.ts Harden control-plane safety and issue identifiers (#5292) 2026-05-06 07:49:47 -05:00
issue-reference.ts Fix Cloud tenant issue identifier routes (#5196) 2026-05-04 13:20:58 -05:00
issue-thread-interactions.test.ts [codex] Add structured issue-thread interactions (#4244) 2026-04-21 20:15:11 -05:00
issue-thread-interactions.ts Add workflow interaction cancellation and issue cost summaries (#4862) 2026-04-30 13:57:25 -05:00
issue-timeline-events.test.ts Show workspace changes and stale notices in issue threads (#5356) 2026-05-06 09:00:54 -05:00
issue-timeline-events.ts Show workspace changes and stale notices in issue threads (#5356) 2026-05-06 09:00:54 -05:00
issue-tree.test.ts Add planning mode for issue work (#5353) 2026-05-06 07:01:28 -05:00
issue-tree.ts [codex] Improve issue thread review flow (#4381) 2026-04-24 08:02:45 -05:00
issueActiveRun.test.ts Fix stale issue live-run state 2026-04-12 20:41:31 -05:00
issueActiveRun.ts Fix stale issue live-run state 2026-04-12 20:41:31 -05:00
issueChatTranscriptRuns.test.ts Refine issue workflow surfaces and live updates 2026-04-09 10:26:17 -05:00
issueChatTranscriptRuns.ts [codex] Add runtime lifecycle recovery and live issue visibility (#4419) 2026-04-24 15:50:32 -05:00
issueDetailBreadcrumb.test.ts Add planning mode for issue work (#5353) 2026-05-06 07:01:28 -05:00
issueDetailBreadcrumb.ts [codex] Add runtime lifecycle recovery and live issue visibility (#4419) 2026-04-24 15:50:32 -05:00
issueDetailCache.test.ts Add planning mode for issue work (#5353) 2026-05-06 07:01:28 -05:00
issueDetailCache.ts [codex] harden authenticated routes and issue editor reliability (#3741) 2026-04-15 08:41:15 -05:00
issueDetailQuery.test.tsx Add planning mode for issue work (#5353) 2026-05-06 07:01:28 -05:00
keyboardShortcuts.test.ts [codex] Improve workspace runtime and navigation ergonomics (#3680) 2026-04-14 12:57:11 -05:00
keyboardShortcuts.ts [codex] Improve workspace runtime and navigation ergonomics (#3680) 2026-04-14 12:57:11 -05:00
legacy-agent-config.test.ts Hide deprecated agent working directory by default 2026-03-20 07:04:41 -05:00
legacy-agent-config.ts Hide deprecated agent working directory by default 2026-03-20 07:04:41 -05:00
line-diff.test.ts Add routine revision history and restore flow (#5285) 2026-05-05 11:54:52 -05:00
line-diff.ts Add routine revision history and restore flow (#5285) 2026-05-05 11:54:52 -05:00
liveIssueIds.test.ts [codex] Add runtime lifecycle recovery and live issue visibility (#4419) 2026-04-24 15:50:32 -05:00
liveIssueIds.ts [codex] Add runtime lifecycle recovery and live issue visibility (#4419) 2026-04-24 15:50:32 -05:00
main-content-focus.test.ts Fix issue detail main-pane focus on navigation 2026-04-09 06:18:27 -05:00
main-content-focus.ts Fix issue detail main-pane focus on navigation 2026-04-09 06:18:27 -05:00
markdownPaste.test.ts Fix markdown paste handling in document editor (#2572) 2026-04-03 08:50:48 -07:00
markdownPaste.ts Fix markdown paste handling in document editor (#2572) 2026-04-03 08:50:48 -07:00
mention-aware-link-node.test.ts Extract mention-aware link node helper and add tests 2026-03-23 20:46:19 -05:00
mention-aware-link-node.ts Refine issue workflow surfaces and live updates 2026-04-09 10:26:17 -05:00
mention-chips.ts [codex] Roll up May 17 branch changes (#6210) 2026-05-17 17:15:06 -05:00
mention-deletion.test.ts Fix atomic markdown mention deletion 2026-03-23 16:57:27 -05:00
mention-deletion.ts Fix atomic markdown mention deletion 2026-03-23 16:57:27 -05:00
model-utils.ts Fix remaining OpenCode review comments 2026-03-05 16:07:12 +01:00
navigation-scroll.test.ts Reset scroll on issue detail navigation 2026-04-12 21:14:12 -05:00
navigation-scroll.ts Reset scroll on issue detail navigation 2026-04-12 21:14:12 -05:00
new-agent-hire-payload.test.ts Add SSH environment support (#4358) 2026-04-23 19:15:22 -07:00
new-agent-hire-payload.ts Add cheap model profiles for local adapters (#4881) 2026-04-30 15:32:04 -05:00
new-agent-runtime-config.test.ts [codex] Raise agent heartbeat concurrency default (#4954) 2026-05-01 10:42:56 -05:00
new-agent-runtime-config.ts Add cheap model profiles for local adapters (#4881) 2026-04-30 15:32:04 -05:00
normalize-markdown.test.ts fix: autoformat pasted markdown in inline editor (#2673) 2026-04-04 11:21:27 -07:00
normalize-markdown.ts fix: autoformat pasted markdown in inline editor (#2673) 2026-04-04 11:21:27 -07:00
onboarding-goal.test.ts Improve onboarding defaults and issue goal fallback 2026-03-12 08:50:31 -05:00
onboarding-goal.ts Improve onboarding defaults and issue goal fallback 2026-03-12 08:50:31 -05:00
onboarding-launch.test.ts Seed onboarding project and issue goal context 2026-03-24 11:48:59 -05:00
onboarding-launch.ts Seed onboarding project and issue goal context 2026-03-24 11:48:59 -05:00
onboarding-route.test.ts test: harden onboarding route coverage 2026-03-18 08:00:02 -05:00
onboarding-route.ts test: harden onboarding route coverage 2026-03-18 08:00:02 -05:00
optimistic-issue-comments.test.ts Add planning mode for issue work (#5353) 2026-05-06 07:01:28 -05:00
optimistic-issue-comments.ts Add recovery handoff system notices (#5289) 2026-05-06 06:05:58 -05:00
optimistic-issue-runs.test.ts [codex] Polish issue board workflows (#4224) 2026-04-21 12:25:34 -05:00
optimistic-issue-runs.ts [codex] Polish issue board workflows (#4224) 2026-04-21 12:25:34 -05:00
paste-normalization.ts fix: autoformat pasted markdown in inline editor (#2673) 2026-04-04 11:21:27 -07:00
portable-files.ts Add company logo portability support 2026-03-19 07:24:04 -05:00
project-order.ts Add shared sidebar section controls (#5585) 2026-05-09 19:49:59 -05:00
project-workspaces-tab.test.ts [codex] Improve workspace navigation and runtime UI (#4089) 2026-04-20 06:14:32 -05:00
project-workspaces-tab.ts [codex] Improve workspace navigation and runtime UI (#4089) 2026-04-20 06:14:32 -05:00
pwa-install-mode.test.ts [codex] Polish board UI mobile flows (#6550) 2026-05-22 10:13:47 -05:00
query-placeholder-data.test.tsx [codex] Improve issue detail and issue-list UX (#3678) 2026-04-14 12:50:48 -05:00
query-placeholder-data.ts [codex] Improve issue detail and issue-list UX (#3678) 2026-04-14 12:50:48 -05:00
queryKeys.ts [codex] Add document annotations and comments (#6733) 2026-05-26 06:41:23 -07:00
recent-assignees.ts [codex] Polish issue and operator workflow UI (#4090) 2026-04-20 06:16:41 -05:00
recent-projects.ts [codex] Polish issue and operator workflow UI (#4090) 2026-04-20 06:16:41 -05:00
recent-searches.ts Add full company search page (#5293) 2026-05-06 06:32:37 -05:00
recent-selections.test.ts [codex] Polish issue and operator workflow UI (#4090) 2026-04-20 06:16:41 -05:00
recent-selections.ts [codex] Polish issue and operator workflow UI (#4090) 2026-04-20 06:16:41 -05:00
recovery-display.ts [codex] Add source-scoped recovery actions (#5599) 2026-05-12 09:37:15 -05:00
remark-soft-breaks.ts feat: polish issue thread markdown and references 2026-04-10 22:26:21 -05:00
reusable-execution-workspaces.test.ts [codex] Add workspace routine run tab (#4958) 2026-05-01 11:58:15 -05:00
reusable-execution-workspaces.ts [codex] Add workspace routine run tab (#4958) 2026-05-01 11:58:15 -05:00
router.tsx Add ordered sub-issue navigation (#5938) 2026-05-13 15:43:51 -05:00
routine-trigger-patch.test.ts fix: address greptile routine review 2026-03-20 16:26:29 -05:00
routine-trigger-patch.ts fix: address greptile routine review 2026-03-20 16:26:29 -05:00
runRetryState.test.ts [codex] Retry max-turn exhausted heartbeats (#5096) 2026-05-03 11:30:48 -05:00
runRetryState.ts [codex] Retry max-turn exhausted heartbeats (#5096) 2026-05-03 11:30:48 -05:00
source-resolved-watchdog-fold.ts [codex] Roll up May 17 branch changes (#6210) 2026-05-17 17:15:06 -05:00
status-colors.ts Expand plugin host surface (#5205) 2026-05-05 07:42:57 -05:00
subIssueDefaults.test.ts Add planning mode for issue work (#5353) 2026-05-06 07:01:28 -05:00
subIssueDefaults.ts [codex] Improve issue detail and issue-list UX (#3678) 2026-04-14 12:50:48 -05:00
successful-run-handoff.test.ts Add recovery handoff system notices (#5289) 2026-05-06 06:05:58 -05:00
successful-run-handoff.ts Add recovery handoff system notices (#5289) 2026-05-06 06:05:58 -05:00
system-notice-comment.test.ts Add recovery handoff system notices (#5289) 2026-05-06 06:05:58 -05:00
system-notice-comment.ts Add recovery handoff system notices (#5289) 2026-05-06 06:05:58 -05:00
timeAgo.ts Add shared UI primitives, contexts, and reusable components 2026-02-17 09:57:00 -06:00
transcriptPresentation.test.ts Polish issue chat chain-of-thought rendering 2026-04-08 06:02:34 -05:00
transcriptPresentation.ts Polish issue chat chain-of-thought rendering 2026-04-08 06:02:34 -05:00
utils.ts Improve operator workflow QoL (#5291) 2026-05-06 06:30:44 -05:00
vite-watch.test.ts [codex] fix worktree dev dependency ergonomics (#3743) 2026-04-15 09:47:29 -05:00
vite-watch.ts [codex] fix worktree dev dependency ergonomics (#3743) 2026-04-15 09:47:29 -05:00
websocket-url.test.ts [codex] Add agent permissions and controls plan (#6386) 2026-05-22 08:12:52 -05:00
websocket-url.ts [codex] Add agent permissions and controls plan (#6386) 2026-05-22 08:12:52 -05:00
workflow-sort.test.ts Present ordered sub-issues as a workflow checklist (#4523) 2026-04-26 07:36:49 -05:00
workflow-sort.ts Present ordered sub-issues as a workflow checklist (#4523) 2026-04-26 07:36:49 -05:00
workspace-routines.test.ts Add routine revision history and restore flow (#5285) 2026-05-05 11:54:52 -05:00
workspace-routines.ts [codex] Add workspace routine run tab (#4958) 2026-05-01 11:58:15 -05:00
worktree-branding.ts Add worktree UI branding 2026-03-13 11:12:43 -05:00
zip.test.ts Handle directory entries in imported zip archives 2026-03-20 14:09:21 -05:00
zip.ts Handle directory entries in imported zip archives 2026-03-20 14:09:21 -05:00