mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-18 14:35:55 +01:00
## Thinking Path > - Paperclip helps people manage AI agents and their work. > - The inbox collects decisions, requests, and updates for the people in a company. > - People need a clear personal queue and a consistent way to answer each request. > - Repeated headings, inconsistent card actions, and separate review flows make that work harder. > - This pull request connects the inbox UI to the routing foundation in #20959. > - Compact cards use shared task controls and open supporting work in a side panel. > - People can answer, claim, transfer, archive, and inspect outcomes from one place. ## Linked Issues or Issue Description **What existing behavior does this improve?** The inbox cards, personal views, shared task controls, and decision history. **Subsystem affected** UI. This PR targets master and uses the routing foundation merged in #20959. **Current behavior** The inbox repeats headings and counts. Cards have different layouts and action placement. The requester can repeat the signed-in person's name. Review and question controls differ between the inbox and task thread. **Proposed behavior** Open Assigned to you by default. Show one count line above the cards. Use a compact card layout with consistent actions and supporting details. Show the requester's avatar and name only when they differ from the signed-in person. Share question controls, including a radio option for Other that reveals a text field when selected. **Reason and benefit** People can scan their queue and complete requests without losing the surrounding task or creating separate drafts for the same review. **Breaking changes** The default inbox view becomes personal. The all-assignee and shared views remain available. Card close menus distinguish personal archive and snooze from shared withdrawal. **Additional context** Refs #20959, #19363, and #19520. Refs #20268 for related actionable-request work. This stack adds personal routing and shared controls. ROADMAP.md includes Multiple Human Users and Agent Reviews and Approvals. ## What Changed - Add personal, unassigned, company, all-assignee, and archived inbox views. Add claim, transfer, personal close actions, receipts, and history controls. - Use compact decision cards with a single count line, one-pixel borders, and equal space above, below, and to the right of each primary action. - Open artifacts and synchronized confirmation/approval controls in a shared side panel. Share their revision drafts and action state with the task thread. Other requests keep one editable form on the inbox card while reviewing an artifact. - Make Other match the question options and reveal its field only when selected. Apply this to inbox and task question cards. - Hide self-requester labels, space agent avatars, and use the standard canceled status icon for withdrawn requests. - Use connector logos in connector cards. Keep the connector promotion background and sidebar border continuous. - Add company and project decision-owner controls and document the updated inbox behavior. ## Verification - The complete [GitHub Actions CI matrix](https://github.com/paperclipai/paperclip/actions/runs/43141559641) passes on `8d81a75e49b518fff6b6ff4c23dd67979b0b97ee` (Linux/Node 24: typecheck, build, general and serialized tests, Runner support, browser shards, and aggregate gates). Greptile is 5/5 on that exact head with zero open findings, and the security scan passes. - Local UI typechecking passes. Eight focused suites pass 382 tests: 236 inbox/review/question/connector tests plus all 146 composer tests. Regressions passed red to green for attachment links, prompt rendering, single-form artifact review, connector scope copy, accessible headings, and the composer test harness's missing theme provider. The final commit changes only that test harness; production code is unchanged from `59d015833f`. - Browser acceptance on the production implementation confirms preserved selected answers with one editable question form, accessible Markdown prompts, inert image references, accurate connector scope copy, native PDF downloads, image sidebar previews, and Open file requesting the attachment endpoint while preserving the inbox URL. Request reads and file responses were intercepted; no question answers were written. The preview is healthy on the final head. - Visual and interaction checks cover Other radio behavior in both themes and on mobile, the loaded Google Calendar logo, and 20px above, below, and to the right of the primary action across all 23 visible cards. The affected desktop/mobile navigation and sidebar specs pass locally and in the final CI browser matrix. - Real-editor browser checks confirm Ctrl/Cmd+Enter cannot bypass another person's confirmation. Cancel preserves the draft and unlocks silently; Continue submits once. Approval write failures remain visible. - `pnpm verify` returns exit 2 because DESIGN.md requires broader coverage; the final full CI matrix supplies every requested gate. Maps and Storybook catalog structural checks pass. The routing foundation #20959 merged after passing 249 database tests, server typechecking, full CI, Greptile 5/5, and security scanning. Its backend and SDK registry are preserved. - Demo data is retained for testing; database suites and browser specs use separate disposable databases. ## Risks - The inbox uses the routing contracts merged in #20959. Personal filters and history affect shared task entry points; the affected controls are included in local regression coverage and full CI. - Personal defaults and close-menu wording change inbox behavior. Existing resolver permissions still control shared actions. - Shared revision state and live invalidation affect two surfaces. Focused tests cover draft synchronization, action locks, and incoming updates. - Visual changes use the existing design tokens and component primitives. ## Model Used OpenAI GPT-6 through Codex. Used repository tools, code execution, and browser checks. This session does not expose a more specific runtime model ID or its context-window size. ## 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 described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links - [x] My branch name describes the change and contains no internal Paperclip ticket id - [x] I have run focused 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: Scott Tong <scott@scottsmbpm5max.lan> Co-authored-by: Paperclip <noreply@paperclip.ing>
155 lines
8.5 KiB
TypeScript
155 lines
8.5 KiB
TypeScript
import { attentionReceiptText, type AttentionItem, type AttentionPersonalView, type DecisionHistoryItem, type DecisionHistoryOutcomeFilter, type DecisionHistoryScope } from "@paperclipai/shared";
|
|
import { queryKeys } from "./queryKeys";
|
|
import { isInlineResolvable } from "./attention";
|
|
|
|
/**
|
|
* The pending feed for one person and one view (PAP-749 plan §1). The key
|
|
* holds the user, so switching accounts never shows the previous person's
|
|
* cached list. The "For you" key is shared by the page, the sidebar, the mobile
|
|
* navigation and the Tasks filter, so the badge always agrees with the list.
|
|
*/
|
|
export const coordinatorAttentionQueryKey = (companyId: string, userId?: string | null, view?: AttentionPersonalView) =>
|
|
userId === undefined && view === undefined
|
|
? [...queryKeys.attention(companyId), "coordinator", "pending"] as const
|
|
: [...queryKeys.attention(companyId), userId, view, "coordinator", "pending"] as const;
|
|
|
|
/**
|
|
* The title a Needs You card leads with, so a list of cards (the Withdraw all
|
|
* stale confirmation) names each one the way the card does (PAP-767). An
|
|
* inline interaction or stalled review card renders its own resolver, and its
|
|
* task link names it; every other card has a heading.
|
|
*/
|
|
export function coordinatorCardTitle(item: AttentionItem) {
|
|
const task = item.relatedIssue ?? (item.subject.kind === "issue" ? item.subject : null);
|
|
const inline = isInlineResolvable(item)
|
|
&& (item.sourceKind === "issue_thread_interaction"
|
|
|| (item.sourceKind === "review" && item.subject.kind === "issue" && item.subject.metadata?.reviewAttentionState === "stalled"));
|
|
if (inline && task?.title) return task.title;
|
|
return coordinatorCardAsk(item, task?.title ?? null) ?? item.subject.title ?? item.whyNow;
|
|
}
|
|
|
|
/**
|
|
* Focus (PAP-770): a card's heading says what to do. Some sources are titled
|
|
* with the bare task or agent name ("Today's weather forecast", "Chief of
|
|
* Staff"), which repeats the task link and asks nothing; those get an ask.
|
|
*/
|
|
function coordinatorCardAsk(item: AttentionItem, taskTitle: string | null): string | null {
|
|
const title = item.subject.title?.trim() || null;
|
|
if (item.sourceKind === "blocker_attention" && title) return `Get “${title}” moving again`;
|
|
if (item.sourceKind === "agent_error_alert") {
|
|
const agent = item.detail?.kind === "agent_error" ? item.detail.agentName ?? title : title;
|
|
return agent ? `${agent} hit an error and needs help` : null;
|
|
}
|
|
if (item.sourceKind === "review" && title && title === taskTitle) return `Review “${title}”`;
|
|
// PAP-775 (UI1): approvals and join requests are answered on the card now.
|
|
if (item.sourceKind === "approval" && title && !/^approve\b/i.test(title)) return `Approve “${title}”?`;
|
|
if (item.sourceKind === "join_request" && title) return `Let ${title} join the company?`;
|
|
return null;
|
|
}
|
|
|
|
/** The context under a card's heading: what happened and what you can do about it. */
|
|
export function coordinatorCardDetail(item: AttentionItem, detailLine: string | null): string | null {
|
|
if (item.sourceKind === "blocker_attention" && item.detail?.kind === "blocker" && !item.detail.blockingIssue) {
|
|
const count = item.detail.blockedTaskCount ?? 0;
|
|
const holding = count > 0 ? `It's holding up ${count} ${count === 1 ? "task" : "tasks"}, and no` : "No";
|
|
return `${holding} one is working on it. Unblock it, reassign it, or nudge its owner.`;
|
|
}
|
|
return detailLine ?? item.whyNow;
|
|
}
|
|
export const coordinatorAttentionSummaryQueryKey = (companyId: string) => [...queryKeys.attention(companyId), "coordinator", "summary"] as const;
|
|
export const coordinatorAttentionTasksQueryKey = (companyId: string) => [...queryKeys.attention(companyId), "coordinator", "tasks"] as const;
|
|
|
|
/** Presentation-only assumption from the prototype, never a retention policy. */
|
|
export const COORDINATOR_RECENT_DECISION_MS = 24 * 60 * 60 * 1_000;
|
|
export function recentDecisionReceipts(items: DecisionHistoryItem[], now: number) {
|
|
return items.filter((item) => Date.parse(item.resolvedAt) + COORDINATOR_RECENT_DECISION_MS > now);
|
|
}
|
|
|
|
/** One canonical pending feed, projected as distinct tasks on the Tasks surface. */
|
|
export function pendingDecisionTaskIds(items: AttentionItem[]) {
|
|
return new Set(items.flatMap((item) => item.relatedIssue ? [item.relatedIssue.id] : item.subject.kind === "issue" ? [item.subject.id] : []));
|
|
}
|
|
|
|
/**
|
|
* The Decision history outcome filter (PAP-749 plan §3). Withdrawn, Expired and
|
|
* Closed with task are separate: a card that closed with its task is not in
|
|
* Expired. "Handled for me" is a different filter (who the card was for), so
|
|
* it is not an outcome here.
|
|
*/
|
|
export const DECISION_HISTORY_OUTCOME_OPTIONS: ReadonlyArray<{ value: DecisionHistoryOutcomeFilter; label: string }> = [
|
|
{ value: "accepted", label: "Approved" },
|
|
{ value: "answered", label: "Answered" },
|
|
{ value: "rejected", label: "Changes requested" },
|
|
{ value: "decided", label: "Decided" },
|
|
{ value: "withdrawn", label: "Withdrawn" },
|
|
{ value: "expired", label: "Expired" },
|
|
{ value: "issue_closed", label: "Closed with task" },
|
|
{ value: "cancelled", label: "Cancelled" },
|
|
];
|
|
|
|
/**
|
|
* Whose decisions Decision history and Recent Decisions list (PAP-768). Your
|
|
* own is the default: what you answered, withdrew or transferred, what a
|
|
* different person handled for you, and the cards that were for you.
|
|
*/
|
|
export const DECISION_HISTORY_SCOPE_OPTIONS: ReadonlyArray<{ value: DecisionHistoryScope; label: string }> = [
|
|
{ value: "mine", label: "Handled by me or for me" },
|
|
{ value: "all", label: "Everyone" },
|
|
];
|
|
export const DEFAULT_DECISION_HISTORY_SCOPE: DecisionHistoryScope = "mine";
|
|
|
|
/**
|
|
* A history entry's headline. When a person acted, it names them with the
|
|
* receipt's verb for the same action ("Approved by @scott", "Kept paused by
|
|
* @dotta"; PAP-749 plan §3, PAP-767). A decision adds the option chosen and an
|
|
* item review its verdict counts. Everything else keeps the server's label.
|
|
*/
|
|
export function decisionHistoryHeadline(item: DecisionHistoryItem, userLabelMap?: ReadonlyMap<string, string> | null) {
|
|
const actorLabel = item.resolvedByUserId ? userLabelMap?.get(item.resolvedByUserId) ?? "someone" : null;
|
|
if (item.action && actorLabel) {
|
|
const line = attentionReceiptText({ outcome: item.action.outcome, actorLabel });
|
|
return item.action.detail ? `${line}: ${item.action.detail}` : line;
|
|
}
|
|
if (item.resultOutcome === "withdrawn" && actorLabel) return `Withdrawn by @${actorLabel}`;
|
|
return item.label;
|
|
}
|
|
|
|
/** The task line of a history entry; an approval with no task names itself instead. */
|
|
export function decisionHistoryContext(item: DecisionHistoryItem) {
|
|
if (!item.issueId) return item.sourceKind === "approval" ? `Approval · ${item.title}` : item.title;
|
|
return [item.issueIdentifier, item.issueTitle].filter(Boolean).join(" · ");
|
|
}
|
|
|
|
/**
|
|
* The toolbar's assignee filter (PAP-775): "Assigned to you" by default, every
|
|
* card the viewer may see ("all", a board member's Everyone), one person, the
|
|
* cards with no owner yet, or company alerts. Each value is one personal view
|
|
* of the feed, plus a person for "user:<id>"; the server routes every card and
|
|
* re-checks every action, so this only picks which cards to list.
|
|
*/
|
|
export type CoordinatorAssignee = "me" | "all" | "unassigned" | "company" | `user:${string}`;
|
|
|
|
/** The URL parameter that names the person in a `user:<id>` filter. */
|
|
export const COORDINATOR_ASSIGNEE_PARAM = "for";
|
|
|
|
export function coordinatorAudienceKey(item: Pick<AttentionItem, "audience">): Exclude<CoordinatorAssignee, "me" | "all"> {
|
|
const audience = item.audience;
|
|
if (audience?.kind === "user" && audience.userId) return `user:${audience.userId}`;
|
|
if (audience?.kind === "pool") return "unassigned";
|
|
return "company";
|
|
}
|
|
|
|
/** The filter a URL shows: its view, narrowed to one person in Everyone. */
|
|
export function coordinatorAssignee(view: AttentionPersonalView, forUserId: string | null | undefined): CoordinatorAssignee | null {
|
|
if (view === "archived") return null;
|
|
if (view === "all") return forUserId ? `user:${forUserId}` : "all";
|
|
return view === "mine" ? "me" : view;
|
|
}
|
|
|
|
/** The view (and person) to load for a filter value; your own name is "Assigned to you". */
|
|
export function coordinatorAssigneeTarget(assignee: CoordinatorAssignee, currentUserId: string | null | undefined): { view: AttentionPersonalView; forUserId: string | null } {
|
|
if (assignee === "me" || assignee === `user:${currentUserId}`) return { view: "mine", forUserId: null };
|
|
if (assignee.startsWith("user:")) return { view: "all", forUserId: assignee.slice(5) };
|
|
return { view: assignee as "all" | "unassigned" | "company", forUserId: null };
|
|
}
|