d734bd43d1
## Thinking Path > - Paperclip is the control plane for autonomous AI companies, so agent work needs visible ownership, recovery, and operator controls. > - This local branch had accumulated several related control-plane reliability and operator-experience fixes across recovery actions, watchdog folding, model-profile defaults, mentions, markdown editing, plugin launchers, and small UI polish. > - The branch needed to be converted into a PR against the current `origin/master` without losing dirty work or including lockfile/workflow churn. > - The safest standalone shape is a single rollup PR because the recovery/server/UI files overlap heavily across the local commits and splitting would create avoidable conflicts. > - This pull request replays the local branch onto latest `origin/master`, preserves the uncommitted work as logical commits, and adds a Zod 4 validator compatibility fix found during verification. > - The benefit is that the May 17 local branch can be reviewed and merged as one coherent, conflict-free branch under the 100-file Greptile limit. ## What Changed - Rebased the local May 17 branch work onto current `origin/master` in a dedicated worktree. - Preserved and committed previously dirty changes for recovery retry handling, plugin/sidebar launcher polish, and `.herenow` ignores. - Added recovery-action behavior for returning source issues to `todo` when retrying source-scoped recovery. - Included the existing local recovery/liveness/watchdog fold, Codex cheap-profile, markdown/mention, duplicate-agent, and UI polish commits from the branch. - Normalized shared validator `z.record(...)` schemas to explicit string-key records for Zod 4 compatibility. - Confirmed the PR has no `pnpm-lock.yaml` or `.github/workflows/*` changes and stays below the 100-file Greptile limit. ## Verification - `pnpm install --frozen-lockfile --ignore-scripts` - `npm run install` in `node_modules/.pnpm/sqlite3@5.1.7/node_modules/sqlite3` to build the local native sqlite3 binding after installing with scripts disabled - `pnpm exec vitest run packages/shared/src/validators/issue.test.ts packages/shared/src/project-mentions.test.ts packages/adapter-utils/src/server-utils.test.ts server/src/__tests__/heartbeat-model-profile.test.ts server/src/__tests__/issue-recovery-actions.test.ts server/src/__tests__/issue-agent-mutation-ownership-routes.test.ts server/src/__tests__/heartbeat-active-run-output-watchdog.test.ts server/src/__tests__/plugin-local-folders.test.ts ui/src/components/IssueRecoveryActionCard.test.tsx ui/src/components/Sidebar.test.tsx ui/src/components/SidebarAccountMenu.test.tsx ui/src/components/IssueProperties.test.tsx ui/src/components/MarkdownEditor.test.tsx ui/src/components/MarkdownBody.test.tsx ui/src/lib/duplicate-agent-payload.test.ts ui/src/pages/Routines.test.tsx` - First pass: 13 files passed with 201 passing tests; 3 server files failed before sqlite3 native binding was built. - After rebuilding sqlite3: `server/src/__tests__/heartbeat-model-profile.test.ts`, `server/src/__tests__/issue-recovery-actions.test.ts`, and `server/src/__tests__/heartbeat-active-run-output-watchdog.test.ts` passed/loaded; embedded Postgres tests were skipped by the local host guard. - `pnpm --filter @paperclipai/shared typecheck` - `pnpm --filter @paperclipai/adapter-utils typecheck` - `pnpm --filter @paperclipai/server typecheck` - `pnpm --filter @paperclipai/ui typecheck` ## Risks - Medium risk: this is a broad rollup PR across recovery semantics, server tests, shared validators, and UI surfaces. - Some embedded Postgres tests skipped locally due the host guard, so CI should provide the stronger database-backed signal. - UI changes were covered by component tests, but no browser screenshot was captured in this PR creation pass. - This branch may overlap with existing recovery/liveness PR work; merge this PR independently or restack/close overlapping branches rather than merging duplicate implementations together. > 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, GPT-5-based coding agent, tool-enabled local repository and GitHub workflow, medium reasoning effort. ## 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 run tests locally and they pass - [x] I have added or updated tests where applicable - [ ] If this change affects the UI, I have included before/after screenshots - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
181 lines
6.6 KiB
TypeScript
181 lines
6.6 KiB
TypeScript
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
import type { ReactNode } from "react";
|
|
import { SourceResolvedFoldCallout } from "@/components/SourceResolvedFoldCallout";
|
|
import { SourceResolvedFoldBadge } from "@/components/SourceResolvedFoldBadge";
|
|
import type { SourceResolvedWatchdogFold } from "@/lib/source-resolved-watchdog-fold";
|
|
|
|
function StoryFrame({ title, description, children }: { title: string; description?: string; children: ReactNode }) {
|
|
return (
|
|
<main className="min-h-screen bg-background p-4 text-foreground sm:p-8">
|
|
<div className="mx-auto max-w-3xl space-y-5">
|
|
<header>
|
|
<div className="text-xs font-medium uppercase tracking-[0.2em] text-muted-foreground">
|
|
Active-run watchdog · source-resolved fold
|
|
</div>
|
|
<h1 className="mt-1 text-2xl font-semibold">{title}</h1>
|
|
{description ? (
|
|
<p className="mt-2 max-w-3xl text-sm text-muted-foreground">{description}</p>
|
|
) : null}
|
|
</header>
|
|
{children}
|
|
</div>
|
|
</main>
|
|
);
|
|
}
|
|
|
|
function buildFold(overrides: Partial<SourceResolvedWatchdogFold> = {}): SourceResolvedWatchdogFold {
|
|
return {
|
|
sourceIssueId: "00000000-0000-0000-0000-000093220000",
|
|
sourceIssueIdentifier: "PAP-9322",
|
|
sourceIssueStatus: "done",
|
|
sameRunEvidenceKind: "activity",
|
|
sameRunEvidenceId: "f49d4f8b-c2ee-4b3d-9d24-32deadbeef01",
|
|
sameRunEvidenceAt: "2026-05-12T18:14:33.000Z",
|
|
silenceStartedAt: "2026-05-12T18:30:00.000Z",
|
|
silenceAgeMs: 18 * 60_000,
|
|
evaluationIssueId: null,
|
|
evaluationIssueIdentifier: null,
|
|
cleanup: {
|
|
attempted: true,
|
|
outcome: "terminated",
|
|
adapterType: "claude_local",
|
|
pid: 23912,
|
|
processGroupId: 23912,
|
|
error: null,
|
|
},
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
const finalizedAt = "2026-05-12T18:48:11.000Z";
|
|
|
|
function DefaultPanel() {
|
|
return <SourceResolvedFoldCallout fold={buildFold()} finalizedAt={finalizedAt} />;
|
|
}
|
|
|
|
const meta = {
|
|
title: "Paperclip/Source-resolved Fold",
|
|
component: DefaultPanel,
|
|
parameters: { layout: "fullscreen" },
|
|
} satisfies Meta<typeof DefaultPanel>;
|
|
|
|
export default meta;
|
|
|
|
type Story = StoryObj<typeof meta>;
|
|
|
|
export const FoldCalloutFullEvidence: Story = {
|
|
render: () => (
|
|
<StoryFrame
|
|
title="Run details — source-resolved fold callout"
|
|
description="Rendered above the log/events area on /agents/:id/runs/:runId when the watchdog auto-folds a stale run whose source already reached a terminal disposition through durable same-run activity."
|
|
>
|
|
<SourceResolvedFoldCallout fold={buildFold()} finalizedAt={finalizedAt} />
|
|
</StoryFrame>
|
|
),
|
|
};
|
|
|
|
export const FoldCalloutWithEvaluationIssue: Story = {
|
|
render: () => (
|
|
<StoryFrame
|
|
title="Fold callout with legacy evaluation issue"
|
|
description="When a stale_active_run_evaluation issue existed, the fold closes it `done` and surfaces the deep-link for forensic continuity."
|
|
>
|
|
<SourceResolvedFoldCallout
|
|
fold={buildFold({
|
|
evaluationIssueId: "00000000-0000-0000-0000-0000eval0001",
|
|
evaluationIssueIdentifier: "PAP-9323",
|
|
cleanup: {
|
|
attempted: true,
|
|
outcome: "termination_sent_still_running",
|
|
adapterType: "claude_local",
|
|
pid: 23912,
|
|
processGroupId: 23912,
|
|
error: null,
|
|
},
|
|
})}
|
|
finalizedAt={finalizedAt}
|
|
/>
|
|
</StoryFrame>
|
|
),
|
|
};
|
|
|
|
export const FoldCalloutCleanupFailed: Story = {
|
|
render: () => (
|
|
<StoryFrame
|
|
title="Fold callout with cleanup error"
|
|
description="Process cleanup is best-effort; the audit message surfaces failure mode and original outcome token (kept as `title` on the span)."
|
|
>
|
|
<SourceResolvedFoldCallout
|
|
fold={buildFold({
|
|
cleanup: {
|
|
attempted: true,
|
|
outcome: "failed",
|
|
adapterType: "claude_local",
|
|
pid: 23912,
|
|
processGroupId: 23912,
|
|
error: "kill ESRCH (process already gone)",
|
|
},
|
|
})}
|
|
finalizedAt={finalizedAt}
|
|
/>
|
|
</StoryFrame>
|
|
),
|
|
};
|
|
|
|
export const FoldCalloutCancelledSource: Story = {
|
|
render: () => (
|
|
<StoryFrame
|
|
title="Fold callout when the source was cancelled"
|
|
description="When the source issue terminated as `cancelled`, the run finalizes as `cancelled` and the callout reflects the source status."
|
|
>
|
|
<SourceResolvedFoldCallout
|
|
fold={buildFold({
|
|
sourceIssueStatus: "cancelled",
|
|
cleanup: {
|
|
attempted: false,
|
|
outcome: "no_process_metadata",
|
|
adapterType: null,
|
|
pid: null,
|
|
processGroupId: null,
|
|
error: null,
|
|
},
|
|
})}
|
|
finalizedAt={finalizedAt}
|
|
/>
|
|
</StoryFrame>
|
|
),
|
|
};
|
|
|
|
export const RunRowBadgeContext: Story = {
|
|
render: () => (
|
|
<StoryFrame
|
|
title="Run-row Source-resolved badge"
|
|
description="Chip placed alongside the existing Profile / silence chips on each run row. Subdued emerald — distinct from the green status checkmark, but not a hot warning."
|
|
>
|
|
<div className="space-y-3 rounded-lg border border-border/60 bg-background/60 p-4 text-xs">
|
|
<div className="flex flex-wrap items-center gap-1.5">
|
|
<span className="font-medium text-foreground">Run</span>
|
|
<code className="rounded bg-background/70 px-1.5 py-0.5 font-mono text-foreground">7accd7a4</code>
|
|
<span className="text-muted-foreground">by ClaudeCoder</span>
|
|
<span className="rounded-md border border-border px-1.5 py-0.5 capitalize text-muted-foreground">succeeded</span>
|
|
<span className="rounded-md border border-emerald-500/30 bg-emerald-500/10 px-1.5 py-0.5 font-medium text-emerald-700 dark:text-emerald-300">
|
|
Completed
|
|
</span>
|
|
<SourceResolvedFoldBadge />
|
|
<span className="ml-auto text-muted-foreground">3m ago</span>
|
|
</div>
|
|
<div className="flex flex-wrap items-center gap-1.5">
|
|
<span className="font-medium text-foreground">Run</span>
|
|
<code className="rounded bg-background/70 px-1.5 py-0.5 font-mono text-foreground">2606404d</code>
|
|
<span className="text-muted-foreground">by ClaudeCoder</span>
|
|
<span className="rounded-md border border-border px-1.5 py-0.5 capitalize text-muted-foreground">succeeded</span>
|
|
<span className="rounded-md border border-emerald-500/30 bg-emerald-500/10 px-1.5 py-0.5 font-medium text-emerald-700 dark:text-emerald-300">
|
|
Completed
|
|
</span>
|
|
<span className="ml-auto text-muted-foreground">12m ago</span>
|
|
</div>
|
|
</div>
|
|
</StoryFrame>
|
|
),
|
|
};
|