paperclip/ui/src
scotttong 4e9a78db58
feat(ui): persist task chat composer drafts (#11076)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - People send task instructions through the board task chat.
> - A page refresh or task switch can discard an unfinished message in
the redesigned composer.
> - The existing task chat already supplies a task-specific draft key.
> - The redesigned composer must use that key without changing
attachment or send behavior.
> - This pull request restores, saves, and clears text drafts in the
redesigned composer.
> - The benefit is that users can return to unfinished task messages
without losing their text.

## Linked Issues or Issue Description

Related prior work: #11070. This pull request extracts only the final
composer draft behavior from that larger draft.

**Subsystem affected**

ui/ — React + Vite board UI.

**Problem or motivation**

The redesigned task chat composer does not use the draft key that the
task thread already provides. A refresh, navigation, or unmount can lose
an unfinished message.

**Proposed solution**

Persist text drafts by task key in local storage. Restore a draft when
the composer mounts. Save changes after a short delay and flush pending
text during unload or unmount. Clear the draft only after a successful
send.

**Alternatives considered**

The composer could save on every keystroke. A short delay avoids
unnecessary synchronous storage writes. The feature could also stay in
the larger predecessor PR, but a focused PR is easier to review and
verify.

**Roadmap alignment**

This is a focused usability improvement for the task conversation
surface. It does not add or duplicate a roadmap capability.

## What Changed

- Added safe draft storage helpers for load, save, and clear operations.
- Connected the task-specific draft key to the redesigned task chat
composer.
- Preserved drafts across debounce windows, unmounts, page unloads,
failed sends, and React Strict Mode probes.
- Cleared drafts after successful sends without changing current
attachment safeguards.
- Added focused composer and thread integration tests.

## Verification

- `pnpm check:token-gates`
- `pnpm --filter @paperclipai/ui typecheck`
- `pnpm --filter @paperclipai/ui exec vitest run
src/components/task-chat/TaskChatComposer.test.tsx
src/components/TaskChatThread.test.tsx`

## Risks

- Local storage can be unavailable or full. The helpers catch storage
errors and keep the composer usable.
- Only text is persisted. Attachments, work mode, and assignee
selections remain session state.
- Draft keys remain task-scoped, so text does not cross task boundaries.

> 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 with model `gpt-5`. The context-window size is not exposed
in this environment. The model used agentic reasoning, tool use, code
execution, and test execution.

## 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

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-08-07 18:32:49 -07:00
..
adapters feat(mcp) [split 6/8]: add Tools and Profiles UI foundation (#9561) 2026-07-14 15:31:12 -05:00
api feat(apps): support multiple provider connections (#11060) 2026-08-07 16:28:04 -05:00
components feat(ui): persist task chat composer drafts (#11076) 2026-08-07 18:32:49 -07:00
context feat(ui): show task identifier in task-detail breadcrumb header (#10933) 2026-08-05 19:14:51 -07:00
fixtures feat(interactions): add governed agent addressees (#10252) 2026-08-04 12:51:06 -05:00
hooks revert(ui): back out onboarding port (#10786) (#11067) 2026-08-07 14:55:34 -07:00
i18n [codex] Add full locale catalog (#6070) 2026-05-16 08:24:31 -05:00
lib feat(ui): persist task chat composer drafts (#11076) 2026-08-07 18:32:49 -07:00
pages revert(ui): back out onboarding port (#10786) (#11067) 2026-08-07 14:55:34 -07:00
plugins fix(runtime): stop Live badge and Working shimmer after task teardown (#10985) 2026-08-07 07:23:56 -07:00
App.activity-routing.test.tsx feat(activity): merge the audit page into one rich Activity page (#10838) 2026-08-04 23:30:23 -05:00
App.cases-routing.test.tsx test(ui): isolate Cases routing regression (#10591) 2026-07-31 18:54:53 -07:00
App.test.tsx feat: refine app connections and legacy worktree startup (#11040) 2026-08-07 14:26:40 -05:00
App.tsx feat: refine app connections and legacy worktree startup (#11040) 2026-08-07 14:26:40 -05:00
bootstrapSetup.ts [codex] Add private browser first-admin claim flow (#6755) 2026-05-27 21:15:01 -10:00
index.css revert(ui): back out onboarding port (#10786) (#11067) 2026-08-07 14:55:34 -07:00
main.tsx fix(ui): reap React 19.2 performance-track measures (memory leak) (#9827) 2026-07-18 14:05:25 -05:00
vite-env.d.ts Add feedback voting and thumbs capture flow 2026-04-02 09:11:49 -05:00