## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The board UI saves a read cache in local storage. Since #21671 it also saves the first chat frame of the 20 most recently opened tasks, so a hard load of such a task shows its chat at once. > - The 20-task limit ranks tasks by when this page opened them, or else by when their data was read. > - Task lists and the sidebar's Recents preload the chat of their top rows in the background. Those reads land after the user opens a task, so preloaded tasks rank above the opened one. > - On staging, more than 20 preloaded tasks pushed out the task the user had opened (PAP-4463): neither its record nor its chat was saved, so it never opened from the saved chat. > - This pull request ranks opened tasks first and saves the time each task was last opened with the record, so the order also holds on the next load. > - The benefit is that the tasks the user actually opens are the ones that open instantly next time. ## Linked Issues or Issue Description **Describe the bug** After a hard load of a task, the saved read cache often does not contain that task. Tasks that a list or Recents only preloaded take the 20 slots. **Steps to reproduce** 1. On staging, open a task (for example PAP-4463) while the sidebar Recents and a task list preload other tasks. 2. Read `paperclip:query-cache:v1:<user>:<company>` in local storage after the page settles. 3. The record holds the chat of up to 20 preloaded tasks, and not the opened task. **Expected behavior** The tasks the user opened rank first for the 20-task limit, also after a reload. **Actual behavior** Preloaded tasks have newer read times than the opened task's visit, so they rank first and push it out. Refs #21671. ## What Changed - `ui/src/lib/persisted-query-cache.ts`: the 20-task limit ranks tasks that the user opened before tasks that were only read in the background. Opened tasks are ordered by their latest open, the others by their read time. An open is recorded by the task page (`recordTaskOpen`), keyed by the task's id, so a task row or link never counts and any ref spelling ranks the same. Each company record saves the open times of its saved tasks (`visits`, an optional field), and a restore reads them back. Older records without `visits` still load. Open times are cleared on sign-out, on an account change and for a refused task. - `ui/src/pages/IssueDetail.tsx`: records the open once the task has loaded. - `ui/src/lib/saved-task-chat.test.ts`: a task opened before 25 newer preloads (with mounted detail observers) keeps its record and chat, also after a reload that preloads 25 more; a task opened by a lowercase identifier ranks as opened; another user's record never receives the open times; a refused task's open time is dropped. - `doc/ui-internals.md`: the read-cache rules state the ranking. ## Verification - `cd ui && npx vitest run src/lib/saved-task-chat.test.ts`: 25 passed. With the ranking change reverted, the new case fails. With only the restore of saved visit times disabled, it fails at the after-reload assertion. - `src/lib/persisted-query-cache.test.ts` and `src/lib/restored-task-chat-bootstrap.test.ts` also pass (91 tests across the three files). `pnpm --filter @paperclipai/ui typecheck` passes. - Staging evidence (build `cb4129a91`): the saved company record held chat for preloaded tasks (1.38 MB, 234 entries) and did not contain PAP-4463, whose whole chat is about 105 KB. ## Risks - Low risk. Only the order in which tasks fill the 20 slots changes. The saved data, the bounds, expiry and revocation do not change. The visit times are timestamps under keys that the record already contains. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude Code with tool use (shell, file edits, browser automation). ## 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@paperclipai/ui
Published static assets for the Paperclip board UI.
What gets published
The npm package contains the production build under dist/. It does not ship the UI source tree or workspace-only dependencies.
Storybook
Storybook config, stories, and fixtures live under ui/storybook/.
pnpm --filter @paperclipai/ui storybook
pnpm --filter @paperclipai/ui build-storybook
Typical use
Install the package, then serve or copy the built files from node_modules/@paperclipai/ui/dist.
Editor dependency identity
Keep the root and workspace overrides for @codemirror/state,
@codemirror/view, and @lezer/common aligned. CodeMirror requires shared
extension identity, while Lezer parsers and syntax highlighters require shared
NodeProp IDs. Multiple Lezer copies can crash code-block highlighting with
tags is not iterable. src/lib/codemirror-single-instance.test.ts checks the
installed dependency graph and highlights sample code through the editor's real
language dependencies. GitHub Actions owns regeneration of pnpm-lock.yaml.