mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-04 02:32:07 +01:00
## Thinking Path > - Paperclip helps people manage AI agents and their work. > - People need consistent UI patterns to review and control that work. > - The current board uses related layouts and controls with different spacing, type, and behavior. > - That drift makes it hard for a designer or an agent to build a new page from a reliable reference. > - Storybook can show the shared patterns and the states they need to support. > - This pull request adds design proposals, a local sandbox, and reusable UI controls so people can compare the patterns in context. > - The benefit is a clearer design system that agents can use to build consistent UI. ## Linked Issues or Issue Description **Subsystem affected** `ui/` — React board UI and Storybook. **Problem or motivation** Board pages repeat visual and interaction decisions. Storybook did not provide a complete reference for task views, conversation states, typography, toolbars, tabs, and light/dark colors. People could not compare a proposed pattern with the running board in one place. **Proposed solution** Add a staged Design Proposals catalog with foundations, components, layouts, and page specimens. Add an opt-in sandbox. Reuse production components where possible. Include synthetic conversation states and shared controls so reviewers can compare and refine them. **Alternatives considered** Separate static mockups would not show keyboard behavior, responsive layout, or real component states. Rebuilding each page only in Storybook would allow the reference to drift from the board. **Roadmap alignment** This improves existing board UI and Skills Manager surfaces. It does not add a new control-plane capability. ## What Changed - Added dark and light color references, typography and conversation specimens, and component stories for buttons, tabs, toolbars, sidebar, popovers, activity, and task lists. - Added a local design sandbox with synthetic task conversation playback and representative states. - Shared collection toolbars and navigation patterns across task, agent, project, routine, skill, connector, and artifact pages. - Added the streamlined Skills tabs and a My Skills collection that uses the shared skill cards. - Restored saved-thread access during synthetic playback, kept connector searchbox semantics, and updated reproduction checks after moving trial stories. - Documented the proposed patterns and added focused UI, catalog, and browser checks. ## Verification - `pnpm check:token-gates`, `node scripts/check-maps.mjs`, and `node scripts/storybook-catalog.mjs --check` passed. - Full workspace `pnpm -r typecheck` and `pnpm build` passed after merging master. After the review fixes, focused UI typecheck, `pnpm build-storybook`, 23 Skills Sources tests, and all 15 Storybook typography browser tests passed. - Focused task-thread and system-notice suites passed: 251 tests. Connector Browse passed 84 tests; the connector, attachment, recovery, and Storybook flyout browser journeys passed locally. - A local full Vitest run hit one intermittent chat-channels integration failure; that test passed in isolation. GitHub CI [39347996059](https://github.com/paperclipai/paperclip/actions/runs/39347996059) passed on the exact latest commit: 55 successful checks and two skipped draft-only Storybook jobs. - Greptile reviewed the exact latest commit at 5/5 with no new comments or open review threads. GitHub reports the branch as cleanly mergeable. ## Risks - This PR changes 206 files and exceeds the repository's 100-file review target. Review by commit and consider a scoped split before merge. - Design Proposals are staged references. Fixture interactions do not prove API behavior, permissions, or provider execution. - UI changes to shared controls may affect pages outside the proposal sandbox. Focused browser checks and the full CI matrix passed. ## Model Used - OpenAI Codex, GPT-6 family. The exact runtime model ID and context window are not exposed in this session. The model used reasoning, code execution, browser inspection, and local tests. Earlier branch commits were also AI-assisted in this Codex conversation. ## 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 available in this session) - [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 where applicable - [x] I have either linked existing issues or described the issue in-PR following the relevant issue template - [x] I have not referenced internal or instance-local Paperclip issues or links - [x] My branch name describes the change and contains no internal 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 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@scotts-mbp-m5-max.local> Co-authored-by: Paperclip <noreply@paperclip.ing>
514 lines
19 KiB
TypeScript
514 lines
19 KiB
TypeScript
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
import { Check, Loader2, Settings2, X } from "lucide-react";
|
|
import type { Agent, AttentionItem } from "@paperclipai/shared";
|
|
import { useParams } from "@/lib/router";
|
|
import { attentionApi } from "../api/attention";
|
|
import { agentsApi } from "../api/agents";
|
|
import { authApi } from "../api/auth";
|
|
import { decisionQueuesApi } from "../api/decisionQueues";
|
|
import { useCompany } from "../context/CompanyContext";
|
|
import { useBreadcrumbs } from "../context/BreadcrumbContext";
|
|
import { useToastActions } from "../context/ToastContext";
|
|
import { useInboxDismissals } from "../hooks/useInboxBadge";
|
|
import { queryKeys } from "../lib/queryKeys";
|
|
import {
|
|
ATTENTION_AGING_DAYS,
|
|
attentionIsAging,
|
|
buildAttentionFilterOptions,
|
|
buildDeskShelves,
|
|
defaultAttentionFilterState,
|
|
filterAttentionItems,
|
|
groupAttentionItems,
|
|
loadAttentionFilters,
|
|
loadAttentionGroupBy,
|
|
loadAttentionSortOrder,
|
|
loadCollapsedAttentionGroupKeys,
|
|
resolveAttentionDateRange,
|
|
saveAttentionFilters,
|
|
saveAttentionGroupBy,
|
|
saveAttentionSortOrder,
|
|
saveCollapsedAttentionGroupKeys,
|
|
sortAttentionItems,
|
|
type AttentionDateRangeId,
|
|
type AttentionFilterState,
|
|
type AttentionGroup,
|
|
type AttentionGroupBy,
|
|
type AttentionSortOrder,
|
|
} from "../lib/attention";
|
|
import { cn } from "../lib/utils";
|
|
import { PageSkeleton } from "../components/PageSkeleton";
|
|
import { AttentionQueueRow } from "../components/AttentionQueueRow";
|
|
import { DecisionsToolbar } from "../components/DecisionsToolbar";
|
|
import { Curtain, AgingItemRow } from "../components/DecisionShelf";
|
|
import { DecisionQueueRail } from "../components/DecisionQueueRail";
|
|
import { DecisionDateChips, type AttentionCustomRange } from "../components/DecisionDateChips";
|
|
import { IssueGroupHeader } from "../components/IssueGroupHeader";
|
|
import { Button } from "../components/ui/button";
|
|
import { Popover, PopoverContent, PopoverTrigger } from "../components/ui/popover";
|
|
|
|
/**
|
|
* Queue page. A single queue's pending
|
|
* decisions with per-item resolution, exclusion (with an optional reason), and
|
|
* the queue's seed-rules card with an enable/disable toggle.
|
|
*
|
|
* The queue exposes the same toolbar the desk does — filter,
|
|
* group-by, sort, the arrival timeline groupings, the date-range chips, and the
|
|
* aging shelf — sharing the desk's `DecisionsToolbar`, grouping helpers, and
|
|
* shelf components so a decision looks, groups, and resolves the same wherever it
|
|
* is surfaced.
|
|
*/
|
|
export function DecisionQueuePage() {
|
|
const { selectedCompanyId } = useCompany();
|
|
const { setBreadcrumbs } = useBreadcrumbs();
|
|
const { pushToast } = useToastActions();
|
|
const queryClient = useQueryClient();
|
|
const params = useParams<{ key: string }>();
|
|
const queueKey = params.key ?? "";
|
|
const [expandedId, setExpandedId] = useState<string | null>(null);
|
|
const { dismiss, snooze } = useInboxDismissals(selectedCompanyId);
|
|
|
|
const [searchQuery, setSearchQuery] = useState("");
|
|
|
|
// Toolbar preferences (persisted to localStorage, shared with the desk).
|
|
const [groupBy, setGroupBy] = useState<AttentionGroupBy>(() => loadAttentionGroupBy());
|
|
const [sortOrder, setSortOrder] = useState<AttentionSortOrder>(() => loadAttentionSortOrder());
|
|
const [filters, setFilters] = useState<AttentionFilterState>(() => defaultAttentionFilterState);
|
|
const [collapsedGroupKeys, setCollapsedGroupKeys] = useState<Set<string>>(() => new Set());
|
|
const [agingOpen, setAgingOpen] = useState(false);
|
|
|
|
// Date-range chips (§4.2) — resolve to server-side activity bounds.
|
|
const [dateRange, setDateRange] = useState<AttentionDateRangeId>("all");
|
|
const [customRange, setCustomRange] = useState<AttentionCustomRange>({ from: null, to: null });
|
|
|
|
const activityBounds = useMemo(
|
|
() => resolveAttentionDateRange(dateRange, Date.now(), customRange),
|
|
[dateRange, customRange],
|
|
);
|
|
|
|
const { data: queues } = useQuery({
|
|
queryKey: queryKeys.decisionQueues.list(selectedCompanyId!),
|
|
queryFn: () => decisionQueuesApi.list(selectedCompanyId!),
|
|
enabled: !!selectedCompanyId,
|
|
});
|
|
const queue = useMemo(() => queues?.find((q) => q.key === queueKey) ?? null, [queues, queueKey]);
|
|
|
|
const {
|
|
data: feed,
|
|
isLoading,
|
|
error,
|
|
} = useQuery({
|
|
queryKey: [
|
|
...queryKeys.attention(selectedCompanyId!),
|
|
"queue",
|
|
queueKey,
|
|
activityBounds.activitySince ?? null,
|
|
activityBounds.activityUntil ?? null,
|
|
],
|
|
queryFn: () => attentionApi.list(selectedCompanyId!, { queue: queueKey, all: true, ...activityBounds }),
|
|
enabled: !!selectedCompanyId && !!queueKey,
|
|
refetchOnWindowFocus: true,
|
|
});
|
|
|
|
const { data: agents } = useQuery({
|
|
queryKey: queryKeys.agents.list(selectedCompanyId!),
|
|
queryFn: () => agentsApi.list(selectedCompanyId!),
|
|
enabled: !!selectedCompanyId,
|
|
});
|
|
const { data: session } = useQuery({
|
|
queryKey: queryKeys.auth.session,
|
|
queryFn: () => authApi.getSession(),
|
|
});
|
|
const currentUserId = session?.user?.id ?? session?.session?.userId ?? null;
|
|
|
|
const agentMap = useMemo(() => {
|
|
const map = new Map<string, Agent>();
|
|
for (const agent of agents ?? []) map.set(agent.id, agent);
|
|
return map;
|
|
}, [agents]);
|
|
|
|
useEffect(() => {
|
|
setBreadcrumbs([{ label: "Decisions", href: "/decisions" }, { label: queue?.title ?? queueKey }]);
|
|
}, [setBreadcrumbs, queue?.title, queueKey]);
|
|
|
|
// Re-hydrate per-company preferences when the company changes.
|
|
useEffect(() => {
|
|
setFilters(loadAttentionFilters(selectedCompanyId));
|
|
setCollapsedGroupKeys(loadCollapsedAttentionGroupKeys(selectedCompanyId));
|
|
}, [selectedCompanyId]);
|
|
|
|
// The server's clock at feed time — used for the arrival/decide-by shelves and
|
|
// the aging idle labels so they match the desk exactly.
|
|
const now = useMemo(
|
|
() => (feed?.generatedAt ? new Date(feed.generatedAt).getTime() : Date.now()),
|
|
[feed?.generatedAt],
|
|
);
|
|
|
|
const activeItems = useMemo(
|
|
() => (feed?.items ?? []).filter((item) => !(item.dismissal?.isActive ?? false)),
|
|
[feed],
|
|
);
|
|
|
|
// Aging shelf (§4.4): items the server flags as idle past retention leave the
|
|
// live list for their own curtain, mirroring the desk.
|
|
const agingItems = useMemo(() => activeItems.filter(attentionIsAging), [activeItems]);
|
|
const listItems = useMemo(() => activeItems.filter((item) => !attentionIsAging(item)), [activeItems]);
|
|
|
|
const filterOptions = useMemo(() => buildAttentionFilterOptions(listItems), [listItems]);
|
|
|
|
// Filter → sort → group, matching the desk. In the default (ungrouped) view the
|
|
// list groups by arrival ("New today" / "Earlier", plus a "Decide now" shelf
|
|
// when something carries an explicit due decide-by); any explicit group-by keeps
|
|
// the Inbox-style activity grouping.
|
|
const groups = useMemo<AttentionGroup[]>(() => {
|
|
const filtered = filterAttentionItems(listItems, filters, searchQuery);
|
|
if (groupBy === "none") {
|
|
return buildDeskShelves(filtered, now);
|
|
}
|
|
const sorted = sortAttentionItems(filtered, sortOrder);
|
|
return groupAttentionItems(sorted, groupBy);
|
|
}, [listItems, filters, searchQuery, sortOrder, groupBy, now]);
|
|
|
|
const visibleCount = useMemo(() => groups.reduce((sum, group) => sum + group.items.length, 0), [groups]);
|
|
|
|
const updateGroupBy = (next: AttentionGroupBy) => {
|
|
setGroupBy(next);
|
|
saveAttentionGroupBy(next);
|
|
};
|
|
const updateSortOrder = (next: AttentionSortOrder) => {
|
|
setSortOrder(next);
|
|
saveAttentionSortOrder(next);
|
|
};
|
|
const updateFilters = (next: AttentionFilterState) => {
|
|
setFilters(next);
|
|
saveAttentionFilters(selectedCompanyId, next);
|
|
};
|
|
const toggleGroupCollapse = (key: string) => {
|
|
setCollapsedGroupKeys((prev) => {
|
|
const next = new Set(prev);
|
|
if (next.has(key)) next.delete(key);
|
|
else next.add(key);
|
|
saveCollapsedAttentionGroupKeys(selectedCompanyId, next);
|
|
return next;
|
|
});
|
|
};
|
|
|
|
const handleToggleExpand = useCallback((item: AttentionItem) => {
|
|
setExpandedId((prev) => (prev === item.id ? null : item.id));
|
|
}, []);
|
|
const invalidate = () => {
|
|
queryClient.invalidateQueries({ queryKey: queryKeys.attention(selectedCompanyId!) });
|
|
queryClient.invalidateQueries({ queryKey: queryKeys.decisionQueues.list(selectedCompanyId!) });
|
|
};
|
|
|
|
const toggleSeedRules = useMutation({
|
|
mutationFn: (enabled: boolean) =>
|
|
decisionQueuesApi.update(selectedCompanyId!, queueKey, { seedRulesEnabled: enabled }),
|
|
onSuccess: () => queryClient.invalidateQueries({ queryKey: queryKeys.decisionQueues.list(selectedCompanyId!) }),
|
|
onError: (err) =>
|
|
pushToast({
|
|
title: "Could not update seeding",
|
|
body: err instanceof Error ? err.message : "Please try again.",
|
|
tone: "error",
|
|
}),
|
|
});
|
|
|
|
if (!selectedCompanyId) {
|
|
return <p className="text-sm text-muted-foreground">Select an organization first.</p>;
|
|
}
|
|
if (isLoading) {
|
|
return <PageSkeleton variant="approvals" />;
|
|
}
|
|
|
|
const isEmpty = activeItems.length === 0;
|
|
|
|
return (
|
|
<div className="max-w-3xl space-y-4">
|
|
<div className="space-y-4">
|
|
<div className="min-w-0">
|
|
<h1 className="text-xl font-bold">{queue?.title ?? queueKey}</h1>
|
|
{queue?.description && <p className="mt-0.5 text-sm text-muted-foreground">{queue.description}</p>}
|
|
</div>
|
|
<DecisionsToolbar
|
|
query={searchQuery}
|
|
onQueryChange={setSearchQuery}
|
|
visibleCount={visibleCount}
|
|
filterOptions={filterOptions}
|
|
filters={filters}
|
|
onFiltersChange={updateFilters}
|
|
groupBy={groupBy}
|
|
onGroupByChange={updateGroupBy}
|
|
sortOrder={sortOrder}
|
|
onSortOrderChange={updateSortOrder}
|
|
/>
|
|
</div>
|
|
|
|
<div className="space-y-2">
|
|
<DecisionQueueRail companyId={selectedCompanyId} activeQueueKey={queueKey} />
|
|
<DecisionDateChips
|
|
value={dateRange}
|
|
custom={customRange}
|
|
onChange={(value, custom) => {
|
|
setDateRange(value);
|
|
setCustomRange(custom);
|
|
}}
|
|
/>
|
|
</div>
|
|
|
|
{queue && queue.seedRules.length > 0 && (
|
|
<SeedRulesCard
|
|
enabled={queue.seedRulesEnabled}
|
|
rules={queue.seedRules.map((rule) => rule.description)}
|
|
pending={toggleSeedRules.isPending}
|
|
onToggle={() => toggleSeedRules.mutate(!queue.seedRulesEnabled)}
|
|
/>
|
|
)}
|
|
|
|
{error && <p className="text-sm text-destructive">{(error as Error).message}</p>}
|
|
|
|
{isEmpty ? (
|
|
<div className="rounded-xl border border-dashed border-border py-14 text-center">
|
|
<p className="text-sm font-medium text-foreground">This queue is empty.</p>
|
|
<p className="mt-1 text-xs text-muted-foreground">
|
|
Decisions land here when they match the queue's rules or an agent adds them.
|
|
</p>
|
|
</div>
|
|
) : (
|
|
<div className="space-y-4">
|
|
{visibleCount === 0 ? (
|
|
<div className="rounded-xl border border-dashed border-border py-10 text-center">
|
|
<p className="text-sm font-medium text-foreground">No decisions match your search or filters.</p>
|
|
<p className="mt-1 text-xs text-muted-foreground">Adjust or clear your search and filters to see the rest.</p>
|
|
</div>
|
|
) : (
|
|
groups.map((group) => {
|
|
const groupLabel = group.label;
|
|
const collapsed = groupLabel !== null && collapsedGroupKeys.has(group.key);
|
|
return (
|
|
<section key={group.key} className="space-y-2">
|
|
{groupLabel !== null && (
|
|
<IssueGroupHeader
|
|
label={groupLabel}
|
|
collapsible
|
|
collapsed={collapsed}
|
|
onToggle={() => toggleGroupCollapse(group.key)}
|
|
trailing={
|
|
<span className="text-xs tabular-nums text-muted-foreground">{group.items.length}</span>
|
|
}
|
|
/>
|
|
)}
|
|
{!collapsed && (
|
|
<div className="space-y-4">
|
|
{group.items.map((item) => (
|
|
<QueueItemRow
|
|
key={item.id}
|
|
item={item}
|
|
companyId={selectedCompanyId}
|
|
queueKey={queueKey}
|
|
agentMap={agentMap}
|
|
agents={agents}
|
|
currentUserId={currentUserId}
|
|
expanded={expandedId === item.id}
|
|
onToggleExpand={handleToggleExpand}
|
|
onDismiss={(next) => dismiss(next.dismissalKey)}
|
|
onSnooze={(next, until) => snooze(next.dismissalKey, until)}
|
|
onExcluded={invalidate}
|
|
/>
|
|
))}
|
|
</div>
|
|
)}
|
|
</section>
|
|
);
|
|
})
|
|
)}
|
|
|
|
{agingItems.length > 0 && (
|
|
<Curtain
|
|
label="Aging"
|
|
count={agingItems.length}
|
|
open={agingOpen}
|
|
onToggle={() => setAgingOpen((prev) => !prev)}
|
|
>
|
|
<p className="text-xs text-muted-foreground">
|
|
Idle past {ATTENTION_AGING_DAYS} days — kept off the queue. Keep any you still want surfaced.
|
|
</p>
|
|
{agingItems.map((item) => (
|
|
<AgingItemRow
|
|
key={item.id}
|
|
item={item}
|
|
companyId={selectedCompanyId}
|
|
now={now}
|
|
agentMap={agentMap}
|
|
agents={agents}
|
|
currentUserId={currentUserId}
|
|
expanded={expandedId === item.id}
|
|
onToggleExpand={handleToggleExpand}
|
|
onDismiss={(next) => dismiss(next.dismissalKey)}
|
|
onSnooze={(next, until) => snooze(next.dismissalKey, until)}
|
|
/>
|
|
))}
|
|
</Curtain>
|
|
)}
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Auto-seed card: explains in place what seeding does — the queue's seed rules
|
|
* (from `DECISION_QUEUE_SEEDS`) that pull matching decisions in automatically —
|
|
* and what the toggle changes. Disabling stops only the automatic adds; anything
|
|
* already here stays, and manual adds keep working.
|
|
*/
|
|
function SeedRulesCard({
|
|
enabled,
|
|
rules,
|
|
pending,
|
|
onToggle,
|
|
}: {
|
|
enabled: boolean;
|
|
rules: string[];
|
|
pending: boolean;
|
|
onToggle: () => void;
|
|
}) {
|
|
return (
|
|
<div className="rounded-xl border border-border bg-muted/20 p-3">
|
|
<div className="flex items-start justify-between gap-3">
|
|
<div className="flex min-w-0 items-start gap-2">
|
|
<Settings2 className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" />
|
|
<div className="min-w-0 space-y-1">
|
|
<p className="text-sm font-medium text-foreground">Auto-seeding is {enabled ? "on" : "off"}</p>
|
|
<p className="text-xs text-muted-foreground">
|
|
{enabled
|
|
? "This queue fills itself automatically. Decisions are added the moment they match any of its rules:"
|
|
: "Automatic adds are paused. These rules would add decisions to the queue when on:"}
|
|
</p>
|
|
<ul className="mt-0.5 space-y-0.5">
|
|
{rules.map((rule) => (
|
|
<li key={rule} className="flex items-start gap-1.5 text-xs text-muted-foreground">
|
|
<Check className="mt-0.5 h-3 w-3 shrink-0" />
|
|
{rule}
|
|
</li>
|
|
))}
|
|
</ul>
|
|
<p className="text-(length:--text-nano) text-muted-foreground">
|
|
{enabled
|
|
? "Turning it off stops new automatic adds only — decisions already here stay, and you can still add or remove decisions by hand."
|
|
: "Adding or removing decisions by hand still works while automatic seeding is off."}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<Button type="button" variant="outline" size="xs" className="h-7 shrink-0" disabled={pending} onClick={onToggle}>
|
|
{pending && <Loader2 className="h-3 w-3 animate-spin" />}
|
|
{enabled ? "Disable" : "Enable"}
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function QueueItemRow({
|
|
item,
|
|
companyId,
|
|
queueKey,
|
|
agentMap,
|
|
agents,
|
|
currentUserId,
|
|
expanded,
|
|
onToggleExpand,
|
|
onDismiss,
|
|
onSnooze,
|
|
onExcluded,
|
|
}: {
|
|
item: AttentionItem;
|
|
companyId: string;
|
|
queueKey: string;
|
|
agentMap: Map<string, Agent>;
|
|
agents: Agent[] | undefined;
|
|
currentUserId: string | null;
|
|
expanded: boolean;
|
|
onToggleExpand: (item: AttentionItem) => void;
|
|
onDismiss: (item: AttentionItem) => void;
|
|
onSnooze: (item: AttentionItem, snoozedUntil: string) => void;
|
|
onExcluded: () => void;
|
|
}) {
|
|
const { pushToast } = useToastActions();
|
|
const [open, setOpen] = useState(false);
|
|
const [reason, setReason] = useState("");
|
|
const exclude = useMutation({
|
|
mutationFn: async () => {
|
|
await decisionQueuesApi.removeItem(
|
|
companyId,
|
|
queueKey,
|
|
item.sourceKind,
|
|
item.subject.id,
|
|
reason.trim() || undefined,
|
|
);
|
|
},
|
|
onSuccess: () => {
|
|
setOpen(false);
|
|
setReason("");
|
|
pushToast({ title: "Removed from queue", body: item.subject.title ?? undefined, tone: "info" });
|
|
onExcluded();
|
|
},
|
|
onError: (err) =>
|
|
pushToast({
|
|
title: "Could not exclude",
|
|
body: err instanceof Error ? err.message : "Please try again.",
|
|
tone: "error",
|
|
}),
|
|
});
|
|
|
|
return (
|
|
<div className="space-y-1.5">
|
|
<div className="flex items-center justify-end px-1">
|
|
<Popover open={open} onOpenChange={setOpen}>
|
|
<PopoverTrigger asChild>
|
|
<Button type="button" variant="ghost" size="xs" className="h-7 gap-1 text-muted-foreground">
|
|
<X className="h-3.5 w-3.5" />
|
|
Exclude
|
|
</Button>
|
|
</PopoverTrigger>
|
|
<PopoverContent align="end" className="w-64 space-y-2 p-3">
|
|
<p className="text-xs font-medium text-foreground">Remove from this queue</p>
|
|
<textarea
|
|
value={reason}
|
|
onChange={(event) => setReason(event.target.value)}
|
|
placeholder="Reason (optional)…"
|
|
className="min-h-16 w-full rounded-sm border border-border bg-background px-2 py-1 text-xs"
|
|
/>
|
|
<div className="flex justify-end gap-1">
|
|
<Button type="button" variant="ghost" size="xs" onClick={() => setOpen(false)}>
|
|
Cancel
|
|
</Button>
|
|
<Button
|
|
type="button"
|
|
size="xs"
|
|
className={cn(exclude.isPending && "opacity-80")}
|
|
disabled={exclude.isPending}
|
|
onClick={() => exclude.mutate()}
|
|
>
|
|
{exclude.isPending && <Loader2 className="h-3 w-3 animate-spin" />}
|
|
Exclude
|
|
</Button>
|
|
</div>
|
|
</PopoverContent>
|
|
</Popover>
|
|
</div>
|
|
<AttentionQueueRow
|
|
item={item}
|
|
companyId={companyId}
|
|
expanded={expanded}
|
|
onToggleExpand={onToggleExpand}
|
|
onDismiss={onDismiss}
|
|
onSnooze={onSnooze}
|
|
agentMap={agentMap}
|
|
agents={agents}
|
|
showTriage
|
|
currentUserId={currentUserId}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|