mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-03 20:09:33 +01:00
0434e7f3aa2ca43873f0af56e731a094fc92ab41
1
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
ce2e6ccc00 |
feat(ui): surface channel, key-values, lease, and schema elements on tasks (#23382)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Paperclip tasks and comments now store channel, key-value, claim lease, profile attribution, and structured schema fields on existing issue and comment tables (`channelId`, `kvLabels`, `schemaBlocks`, `resultSchemaRef`, `createdByProfile`, `actorProfile`, and claim lease fields). > - Existing board task views (`IssueProperties`, `MarkdownBody`, `CommentThread`, `IssueChatThread`, and `IssueDetail`) do not yet display these fields, and canonical `/api/issues/:id` routes do not resolve `channelPath` or strip `claimTokenHash` at serialization time. > - Users and reviewers cannot see channel provenance, key-values, active or expired claim leases, `--as <profile>` attribution, or structured `schema=<name>@<version>` blocks when they open a task in the UI. > - This pull request synchronizes the shared `Issue` and `IssueComment` contracts, resolves `channelPath` only when channel access and actor scopes allow it, strips `claimTokenHash` from issue responses, renders channel, key-values, lease, result schema, and structured schema cards across existing task views (only when set), and adds production-component Storybooks. > - The benefit is that existing task surfaces show channel, lease, key-value, profile, and schema state cleanly in place without cluttering standard tasks or adding a separate Channels navigation item, while preserving secret isolation on claim tokens. ## Linked Issues or Issue Description Refs #23329 Refs #23330 **What existing behavior does this improve?** Existing task detail, properties, Markdown body, comment thread, chat thread, and `/api/issues` HTTP serialization for tasks that carry channel, claim lease, key-value, profile attribution, or structured schema data. **Subsystem affected** Cross-cutting (`packages/shared`, `server/`, `ui/`, `ui/storybook/`, and `docs/api/`) **Current behavior** Canonical `/api/issues` routes return raw issue columns without a resolved `channelPath` and include `claimTokenHash: null` on the response shape. In `ui/`, `IssueProperties` omits channel provenance, `Key-values` editing, claim lease status, `resultSchemaRef` verification, and `--as <profile>` creator attribution. `MarkdownBody` renders ```` ```json schema=<name>@<version> ```` blocks only as plain code blocks, and comment threads show `local-board` or generic user labels instead of `actorProfile` and omit comment-level key-values. **Proposed behavior** `Issue` and `IssueComment` expose safe coordination and schema fields in `@paperclipai/shared`. Server issue routes strip `claimTokenHash` from serialized issue objects and resolve `channelPath` in batch via `findInaccessibleChannelIds` only when actor scopes and channel membership succeed (with zero extra SQL queries when `channelId` is null). `IssueProperties` mounts cohesive task property rows (`structured-task-rows.tsx`) strictly when set: `#<channelPath>` badge on `Channel`, inline `Key-values` add/edit/remove with CAS preconditions (`PATCH /api/issues/:id/kv-labels`), active vs expired `Lease` status with inline status dot and live countdown, `Result schema` matching status, and creator `--as <profile>` attribution. `MarkdownBody` and task discussion/chat threads render token-styled `SchemaBlockCard` views (`finding@1`, `test-report@1`, `git-commit@1`, `pull-request@1`, and custom `<name>@<version>` schemas) with a `Structured` / `JSON` toggle, deduplicated standalone `schemaBlocks`, `--as <actorProfile>` attribution, and comment key-value pills. Four production-component Storybooks document these states under `tasks-channels-leases-and-schemas`. **Reason and benefit** Agents and CLI workflows coordinate through existing Paperclip tasks and comments. Surfacing channel provenance, claim leases, key-values, profile attribution, and typed schema blocks directly on existing task views (and hiding those rows completely when unset) lets people inspect and edit structured task state in place without introducing new top-level navigation, while guaranteeing that `claimTokenHash` never leaves the server. **Breaking changes** None for external callers. `claimTokenHash` is omitted from serialized `/api/issues` JSON responses as a security invariant, and `channelPath` (`string | null`) is added on canonical issue read and update responses. ## What Changed - `packages/shared/src/types/issue.ts` and `tests/runner-e2e/source-sdk-public-inputs.json`: expose safe fields on `Issue` (`channelId`, `channelPath`, `createdByProfile`, `kvLabels`, `schemaBlocks`, `resultSchemaRef`, `claimEpoch`, `claimHolderAgentId`, `claimHolderUserId`, `claimHolderProfile`, `claimLeasedAt`, `claimLeaseExpiresAt`, `claimAttemptCount`) and `IssueComment` (`actorProfile`, `kvLabels`, `schemaBlocks`), never `claimTokenHash`, and synchronize the SDK public input registry pin. - `server/src/services/issues.ts`, `server/src/routes/issues.ts`, and `docs/api/issues.md`: omit `claim_token_hash` from SQL issue selections and `withIssueLabels`, strip `claimTokenHash` on HTTP serialization across issue routes, clear `kvLabels` and `schemaBlocks` on tombstoned comments, resolve `channelPath` in batch via `resolveHeadlessActor` and `findInaccessibleChannelIds` (zero extra SQL queries when `channelId` is `null`), and document the API response contract. - `server/src/__tests__/fixtures/issue-detail-response.json`, `server/src/__tests__/issue-activity-events-routes.test.ts`, and `server/src/__tests__/headless-channels-schemas-batch.test.ts`: update issue detail and update response snapshots (`channelPath: null`, no `claimTokenHash`) and add route contract coverage for `channelPath` visibility, scope enforcement, comment fields, and `claimTokenHash` omission. - `ui/src/api/issues.ts` and `ui/src/api/issues.test.ts`: add `issuesApi.updateKvLabels` targeting `PATCH /api/issues/:id/kv-labels` with CAS precondition normalization (`set`, `unset`, `if`) and unit test coverage. - `ui/src/components/issue-properties/structured-task-rows.tsx` and `IssueProperties.tsx`: add `IssueChannelRow`, `IssueKvLabelsRow` (`Key-values` with inline edit, remove, `+ Add`, CAS preconditions, touch-safe 16px inputs, and complete omission when empty), `IssueClaimLeaseRow` (inline status dot, live countdown, and omission when unset or released), `IssueResultSchemaRow` (unwrapping `InfiniteData` and identifier-keyed comment query caches, plus distinguishing `"unverified"` truncated scans from `"missing"`), and `IssueProfileAttributionRow`. - `ui/src/components/SchemaBlockCard.tsx`, `ui/src/lib/schema-block-utils.ts`, and `ui/src/components/MarkdownBody.tsx`: parse ```` ```json schema=<name>@<version> ```` fences (plus `{ schema, data }` JSON envelopes) via a static remark plugin and a bounded linear $O(N)$ single-pass CommonMark fence scanner (no multi-line backtracking regexes); render semantic-token cards for `finding@1`, `test-report@1`, `git-commit@1`, `pull-request@1`, and custom `<name>@<version>` blocks with `Structured` / `JSON` toggle, `https://`-only link safety, malformed-JSON code-block fallback, and iterative stack-safe `schemaBlocks` deduplication. - `ui/src/components/CommentStructuredMeta.tsx`, `CommentThread.tsx`, `IssueChatThread.tsx`, `TaskChatBubble.tsx`, `TaskChatDescriptionBubble.tsx`, `IssueDetail.tsx`, and chat adapters: render `--as <actorProfile>` attribution, comment-level key-value chips, and unfenced `schemaBlocks` across classic and chat task threads. - `ui/storybook/stories/tasks/channels-leases-and-schemas.stories.tsx`: add `ChannelTaskPropertiesActiveLease`, `ExpiredLeaseProperties`, `BuiltInAndCustomSchemaBlocks`, and `ChannelTaskThreadEndToEnd` stories registered under `tasks-channels-leases-and-schemas`. - `ui/src/components/issue-properties/structured-task-rows.test.tsx` and `ui/src/components/SchemaBlockCard.test.tsx`: add unit tests covering unset-row omission on standard tasks, single-badge channel provenance, CAS key-value mutations and `409` conflict rollback, inline lease status dots and countdown expiry, `InfiniteData` comment unwrapping, structured schema cards, malformed JSON fallback, linear $O(N)$ scanning on 5,000 unterminated JSON fences, newline-clamped markdown bounds, and deep deduplication. ## Verification - `pnpm --filter @paperclipai/shared build` — passed. - `cd server && node scripts/typecheck-layers.mjs` — passed (0 errors across all layers and test trees). - `cd server && npx vitest run src/__tests__/service-read-disconnect-retry.test.ts src/__tests__/issue-activity-events-routes.test.ts src/__tests__/issue-detail-statements.test.ts src/__tests__/headless-channels-schemas-batch.test.ts` — passed (54/54 tests). - `pnpm --filter @paperclipai/ui typecheck` — passed (0 errors). - `cd ui && npx vitest run src/components/issue-properties/structured-task-rows.test.tsx src/components/SchemaBlockCard.test.tsx src/api/issues.test.ts src/lib/issue-chat-messages.test.ts src/components/task-chat/task-chat-adapter.test.ts` — passed (115/115 tests). - `node scripts/check-token-gates.mjs`, `node scripts/check-test-budget.mjs`, `node scripts/check-module-boundaries.mjs`, and `node scripts/check-query-error-rendering.mjs` — all passed. - `node scripts/storybook-catalog.mjs && node scripts/storybook-catalog.mjs --check` and `node --test scripts/check-maps.test.mjs scripts/storybook-catalog.test.mjs scripts/storybook-feature-index.test.mjs` — passed (30/30 tests). - `pnpm --filter @paperclipai/ui build-storybook` — passed and verified built story IDs (`tasks-channels-leases-and-schemas--channel-task-properties-active-lease`, `tasks-channels-leases-and-schemas--expired-lease-properties`, `tasks-channels-leases-and-schemas--built-in-and-custom-schema-blocks`, `tasks-channels-leases-and-schemas--channel-task-thread-end-to-end`). ## Risks - Low risk. Standard board tasks with unset `Channel`, `Key-values`, `Lease`, and `Result schema` omit all four property rows completely, preserving existing `IssueProperties` layout and SQL query count (`0` extra queries when `channelId` is `null`). - Fenced code blocks without `schema=<name>@<version>` metadata (or with invalid JSON) fall back directly to the existing `CodeBlock` renderer. ## Model Used - Google Gemini (`gemini-3.1-pro` / Antigravity agentic coding runtime with extended thinking, code search, file editing, and terminal verification tools). ## 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> |