mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-03 03:36:57 +01:00
fix(ui): align chat connection and recovery cards
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
43212cb2b7
commit
7657dd91d6
9 files changed
+99
-19
No files matched your search
@@ -42,7 +42,9 @@ export function EmailMessageCard({
|
||||
message,
|
||||
publication,
|
||||
issueId,
|
||||
contextNotice = false,
|
||||
}: {
|
||||
contextNotice?: boolean;
|
||||
message: EmailMessage;
|
||||
publication?: EmailPublicationSummary;
|
||||
issueId: string;
|
||||
@@ -57,7 +59,7 @@ export function EmailMessageCard({
|
||||
aria-label={
|
||||
message.direction === "inbound" ? "Email received" : "Email sent"
|
||||
}
|
||||
className="space-y-4 rounded-xl border border-border bg-card p-5"
|
||||
className={contextNotice ? "task-context-notice space-y-3" : "space-y-4 rounded-xl border border-border bg-card p-5"}
|
||||
>
|
||||
<div className="flex flex-wrap items-center justify-between gap-2">
|
||||
<span className="flex items-center gap-2 text-sm font-semibold">
|
||||
|
||||
@@ -36,6 +36,7 @@ export function EmailTaskActivity({
|
||||
)}
|
||||
{messages.map((m) => (
|
||||
<EmailMessageCard
|
||||
contextNotice
|
||||
key={m.id}
|
||||
issueId={issueId}
|
||||
message={m}
|
||||
@@ -78,7 +79,7 @@ function EmailDelivery({
|
||||
{p.request && !p.providerMessageId && (
|
||||
<article
|
||||
aria-label="Email send intent"
|
||||
className="space-y-3 rounded-lg border border-border p-4"
|
||||
className="task-context-notice space-y-3"
|
||||
>
|
||||
<p className="font-semibold">{p.request.subject ?? "Email reply"}</p>
|
||||
{p.request.to && <p>To: {p.request.to.join(", ")}</p>}
|
||||
|
||||
@@ -36,8 +36,7 @@ describe("stopped task recovery notice", () => {
|
||||
const notice = container.querySelector('[role="status"][aria-label="Task recovery"]')!;
|
||||
expect(notice.textContent).toContain("Recorded work is preserved");
|
||||
expect(notice.textContent).toContain("Retry");
|
||||
expect(notice.classList.contains("border")).toBe(true);
|
||||
expect(notice.classList.contains("bg-muted")).toBe(true);
|
||||
expect(notice.classList.contains("task-context-notice")).toBe(true);
|
||||
expect(notice.querySelector("a")?.getAttribute("href")).toBe("/agents/agent/runs/failed-run");
|
||||
});
|
||||
it.each([false, true])("explains cancelled runs and saved input; continue eligibility %s", async canContinue => {
|
||||
|
||||
@@ -4,9 +4,11 @@ import { agentsApi } from "../api/agents";
|
||||
import { activityApi } from "../api/activity";
|
||||
import { queryKeys } from "../lib/queryKeys";
|
||||
import { Button } from "./ui/button";
|
||||
import { cn } from "../lib/utils";
|
||||
import { Link } from "../lib/router";
|
||||
|
||||
export function ExecutionBlockerNotice({ companyId, issueId, blocker, onRetried }: {
|
||||
export function ExecutionBlockerNotice({ companyId, issueId, blocker, onRetried, className }: {
|
||||
className?: string;
|
||||
companyId: string;
|
||||
issueId: string;
|
||||
blocker: ExecutionBlocker;
|
||||
@@ -33,7 +35,7 @@ export function ExecutionBlockerNotice({ companyId, issueId, blocker, onRetried
|
||||
},
|
||||
});
|
||||
return (
|
||||
<div role="status" aria-label="Task recovery" className="mx-(--sz-execution-blocker-inline) my-(--sz-execution-blocker-block) flex flex-wrap items-center justify-between execution-blocker-notice border border-border bg-muted text-foreground">
|
||||
<div role="status" aria-label="Task recovery" className={cn("task-context-notice flex flex-wrap items-center justify-between gap-2", className)}>
|
||||
<div className="min-w-0 flex-1 break-words">
|
||||
<p>{modelRejected ? "Model unavailable." : "Recovery needed."}{blocker.runError ? ` ${blocker.runError}` : ""}</p>
|
||||
{modelRejected && <p>Choose a supported model or clear the task's model override, then retry.</p>}
|
||||
|
||||
@@ -3,12 +3,14 @@ import { useMutation } from "@tanstack/react-query";
|
||||
import type { IssueRecoveryAction } from "@paperclipai/shared";
|
||||
import { isNativeWorkspaceExportRepairCause } from "@paperclipai/shared";
|
||||
import { issuesApi } from "../api/issues";
|
||||
import { cn } from "../lib/utils";
|
||||
import { Button } from "./ui/button";
|
||||
import { Label } from "./ui/label";
|
||||
import { Textarea } from "./ui/textarea";
|
||||
|
||||
/** Copyback repair preserves the accepted result and never wakes the provider. */
|
||||
export function WorkspaceExportRecovery({ issueId, action, canManage, onQueued }: {
|
||||
export function WorkspaceExportRecovery({ issueId, action, canManage, onQueued, className }: {
|
||||
className?: string;
|
||||
issueId: string; action: IssueRecoveryAction | null; canManage: boolean; onQueued: () => void;
|
||||
}) {
|
||||
const noteId = useId();
|
||||
@@ -23,7 +25,7 @@ export function WorkspaceExportRecovery({ issueId, action, canManage, onQueued }
|
||||
if (!action || !isNativeWorkspaceExportRepairCause(action.cause) || action.ownerType !== "board"
|
||||
|| !["active", "escalated"].includes(action.status) || typeof action.evidence.runId !== "string") return null;
|
||||
const queued = queuedActionVersion === String(action.updatedAt) || action.wakePolicy?.kind === "resume_native_run";
|
||||
return <section aria-label="Workspace export repair" className="flex flex-col gap-2 p-4 text-sm">
|
||||
return <section aria-label="Workspace export repair" className={cn("task-context-notice flex flex-col gap-2", className)}>
|
||||
<p className="font-medium">Workspace export needs repair</p>
|
||||
{queued ? <p role="status">Export is queued for the saved result. The agent will not repeat its work.</p> : <>
|
||||
<p className="text-muted-foreground">{"Automatic workspace export retries stopped. Inspect the export failure, restore provider or destination availability, and preserve the saved files in the retained sandbox. Retry export here when the cause is resolved."}</p>
|
||||
|
||||
@@ -17,6 +17,7 @@ import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { useToast } from "@/context/ToastContext";
|
||||
import { Link } from "@/lib/router";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { queryKeys } from "@/lib/queryKeys";
|
||||
import { useChatConnectorsEnabled, chatProviderVisible } from "@/hooks/useChatConnectorsEnabled";
|
||||
import { issuesApi } from "@/api/issues";
|
||||
@@ -123,6 +124,7 @@ export function useIssueChatBinding(companyId: string, issueId: string) {
|
||||
}
|
||||
|
||||
type ConnectedTaskProps = {
|
||||
className?: string;
|
||||
attachments?: IssueAttachment[];
|
||||
companyId: string;
|
||||
issueId: string;
|
||||
@@ -147,6 +149,7 @@ export function ExternallyConnectedTaskBanner(props: ConnectedTaskProps) {
|
||||
}
|
||||
|
||||
function ConnectedTaskComposer({
|
||||
className,
|
||||
attachments = [],
|
||||
companyId,
|
||||
issueId,
|
||||
@@ -485,7 +488,7 @@ function ConnectedTaskComposer({
|
||||
return (
|
||||
<section
|
||||
aria-label="External conversation"
|
||||
className="space-y-3 rounded-lg border border-border bg-muted/40 p-3 text-sm"
|
||||
className={cn("task-context-notice space-y-3", className)}
|
||||
>
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<div className="flex min-w-0 flex-1 basis-64 items-center gap-3">
|
||||
|
||||
+7
-5
@@ -3120,11 +3120,13 @@ span.paperclip-mention-chip[data-mention-kind="external-object"] {
|
||||
inset-inline: 0;
|
||||
}
|
||||
|
||||
/* Task recovery panel uses the shared spacing, radius, and type scales. */
|
||||
.execution-blocker-notice {
|
||||
gap: calc(var(--spacing) * 2);
|
||||
padding: calc(var(--spacing) * 2) calc(var(--spacing) * 3);
|
||||
border-radius: var(--radius-md);
|
||||
/* Connection and recovery cards share one surface and spacing scale. */
|
||||
.task-context-notice {
|
||||
padding: calc(var(--spacing) * 3);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-lg);
|
||||
background-color: var(--muted);
|
||||
color: var(--foreground);
|
||||
font-size: var(--text-sm);
|
||||
line-height: var(--text-sm--line-height);
|
||||
}
|
||||
|
||||
@@ -7622,6 +7622,7 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS
|
||||
{taskChatShellEnabled ? null : ancestorsNav}
|
||||
|
||||
<ExternallyConnectedTaskBanner
|
||||
className={cn(shellSectionClass, "mt-3")}
|
||||
key={issue.id}
|
||||
attachments={attachments ?? []}
|
||||
companyId={issue.companyId}
|
||||
@@ -7629,6 +7630,15 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS
|
||||
issueCacheRefs={issueCacheRefs}
|
||||
/>
|
||||
|
||||
{resolvedDetailTab === "chat" && (
|
||||
<WorkspaceExportRecovery key={issue.activeRecoveryAction?.id ?? issue.id} issueId={issue.id}
|
||||
className={shellSectionClass}
|
||||
action={issue.activeRecoveryAction ?? null} canManage={canManageBoardRuntime} onQueued={invalidateIssueDetail} />
|
||||
)}
|
||||
{resolvedDetailTab === "chat" && issue.executionBlocker && (
|
||||
<ExecutionBlockerNotice className={shellSectionClass} companyId={issue.companyId} issueId={issue.id} blocker={issue.executionBlocker} onRetried={invalidateIssueDetail} />
|
||||
)}
|
||||
|
||||
{issue.status === "in_review" && issue.externalConversationState === "waiting" && (
|
||||
<p role="status" className="text-sm text-muted-foreground">Reply sent. Send a message to continue.</p>
|
||||
)}
|
||||
@@ -7932,11 +7942,6 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<WorkspaceExportRecovery key={issue.activeRecoveryAction?.id ?? issue.id} issueId={issue.id}
|
||||
action={issue.activeRecoveryAction ?? null} canManage={canManageBoardRuntime} onQueued={invalidateIssueDetail} />
|
||||
{issue.executionBlocker && (
|
||||
<ExecutionBlockerNotice companyId={issue.companyId} issueId={issue.id} blocker={issue.executionBlocker} onRetried={invalidateIssueDetail} />
|
||||
)}
|
||||
{resolvedDetailTab === "chat" ? (
|
||||
<WorkspaceBaseRefRecoveryProvider issue={issue} agentMap={agentMap} onRepaired={() => { invalidateIssueDetail(); invalidateIssueCollections(); }}
|
||||
unavailableReason={!canManageBoardRuntime || !canResolveBoardRecoveryAction ? "You don’t have permission to repair this task’s workspace."
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import { useState } from "react";
|
||||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { expect, within } from "storybook/test";
|
||||
import { ExternallyConnectedTaskBanner } from "@/components/chat/ExternallyConnectedTaskBanner";
|
||||
import { ExecutionBlockerNotice } from "@/components/ExecutionBlockerNotice";
|
||||
import { EmailMessageCard } from "@/components/EmailMessageCard";
|
||||
import { queryKeys } from "@/lib/queryKeys";
|
||||
|
||||
function TaskContextNotices() {
|
||||
const [client] = useState(() => {
|
||||
const cache = new QueryClient({ defaultOptions: { queries: { staleTime: Infinity, retry: false } } });
|
||||
cache.setQueryData(queryKeys.instance.experimentalSettings, { enableChatConnectors: true });
|
||||
cache.setQueryData(["issue-chat-binding", "demo", "context-notices"], {
|
||||
endpointId: "slack-demo", provider: "slack", externalLabel: "#design · Card styling",
|
||||
externalUrl: "https://slack.com", conversationId: "demo-thread", assignedAgentLocked: true,
|
||||
});
|
||||
cache.setQueryData(queryKeys.issues.runs("context-notices"), []);
|
||||
return cache;
|
||||
});
|
||||
return (
|
||||
<QueryClientProvider client={client}>
|
||||
<main className="min-h-screen bg-background p-6 text-foreground">
|
||||
<div className="mx-auto w-full max-w-(--tc-shell-max-w) space-y-3">
|
||||
<h1 className="text-xl font-semibold">Chat connection and recovery</h1>
|
||||
<ExternallyConnectedTaskBanner className="mt-3" companyId="demo" issueId="context-notices" />
|
||||
<ExecutionBlockerNotice companyId="demo" issueId="context-notices" onRetried={() => {}}
|
||||
blocker={{ recoveryActionId: "demo-recovery", cause: "action_outcome_unknown",
|
||||
nextAction: "Inspect the run before continuing. Recorded work is preserved." }} />
|
||||
<EmailMessageCard contextNotice issueId="context-notices" message={{
|
||||
id: "email-demo", providerMessageId: "email-demo", direction: "inbound",
|
||||
from: "operator@example.com", to: ["agent@example.com"], subject: "Card styling",
|
||||
text: "Please keep the connection and recovery cards consistent.",
|
||||
fullText: "Please keep the connection and recovery cards consistent.",
|
||||
commentId: null, attachmentIds: [], timestamp: "2026-10-09T12:00:00Z", automatic: false,
|
||||
}} />
|
||||
</div>
|
||||
</main>
|
||||
</QueryClientProvider>
|
||||
);
|
||||
}
|
||||
|
||||
const meta = {
|
||||
title: "Tasks/Context notices",
|
||||
component: TaskContextNotices,
|
||||
parameters: { layout: "fullscreen" },
|
||||
} satisfies Meta<typeof TaskContextNotices>;
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof meta>;
|
||||
|
||||
export const ConnectionAndRecovery: Story = {
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
const connection = await canvas.findByRole("region", { name: "External conversation" });
|
||||
const recovery = canvas.getByRole("status", { name: "Task recovery" });
|
||||
const email = canvas.getByRole("article", { name: "Email received" });
|
||||
for (const card of [recovery, email]) {
|
||||
await expect(card.getBoundingClientRect().width).toBe(connection.getBoundingClientRect().width);
|
||||
await expect(getComputedStyle(card).backgroundColor).toBe(getComputedStyle(connection).backgroundColor);
|
||||
await expect(getComputedStyle(card).padding).toBe(getComputedStyle(connection).padding);
|
||||
await expect(getComputedStyle(card).borderRadius).toBe(getComputedStyle(connection).borderRadius);
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in new issue
Block a user