mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-15 03:51:22 +02:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Routines are the recurring-work surface that lets a company keep operating without a human manually kicking off every task > - The base routine detail Variation C shell already landed in #7848, but the follow-up branch still had polish work for scheduling, section ergonomics, and the list layout > - Operators need routine edit screens to explain trigger behavior clearly, keep long detail pages usable on mobile/touch devices, and make grouped routine lists easier to scan > - This pull request rebases the remaining branch work onto current `master`, drops the duplicate commits already merged through #7848, and keeps only the new routine UI follow-ups > - The benefit is a cleaner routines workflow without reopening the already-merged shell work or carrying unrelated lockfile, workflow, or screenshot changes ## Linked Issues or Issue Description Refs #7848 Feature follow-up: polish the routines UI after the Variation C routine-detail shell landed. Problem / motivation: - Routine trigger configuration needs clearer previews for manual, schedule, API, and webhook execution modes. - Routine detail sections need better responsive spacing and touch ergonomics. - The routines list grouping should scan like grouped records instead of a table with heavy row dividers. - The routine tests need a React 19-compatible render helper so the focused routine suite can run in this workspace. Proposed solution: - Add cron-fire preview helpers and routine-run display helpers with focused tests. - Expand the routine editable and operate sections with richer trigger, variable, run, activity, and history presentation. - Adjust the routine detail shell and sub-sidebar spacing for mobile/touch layout. - Update grouped routine list presentation to use bordered group headers with borderless rows. - Switch affected routine tests to the repo's `flushSync` render-helper pattern. Alternatives considered: - Leaving the duplicate pre-#7848 commits in the branch would recreate conflicts and make the PR review much larger than the remaining change. - Keeping grouped routine rows inside one bordered table was simpler, but made the grouping hierarchy less legible. Roadmap alignment: - ROADMAP.md lists Scheduled Routines as a core shipped capability and Output/Enforced Outcomes as ongoing priorities. This is polish on that existing routines capability, not a new roadmap-level feature. ## What Changed - Added routine scheduling preview helpers and tests for cron/manual/API/webhook fire-policy display. - Added routine run display helpers and tests for deduped trigger labels and run-row subtitles. - Polished routine detail sections, including trigger summaries, operate views, and env/variable editing ergonomics. - Adjusted routine detail page and sub-sidebar spacing so the title/header area is less pinned and touch layouts center better. - Reworked the routines list grouped layout so group headers are bordered cards and routine rows are borderless inside each group. - Added Storybook coverage for the routines list grouped layout and updated the existing routine detail story. - Repaired routine tests to use `flushSync` helpers compatible with the installed React 19 runtime. ## Verification - `pnpm exec vitest run ui/src/lib/cron-fires.test.ts ui/src/lib/routine-run-display.test.ts ui/src/pages/Routines.test.tsx ui/src/components/RoutineSubSidebar.test.tsx ui/src/components/RoutineSaveBar.test.tsx` - Result: 5 test files passed, 37 tests passed. - Confirmed the rebased PR diff does not include `pnpm-lock.yaml`, `.github/workflows/*`, or committed screenshots. - Confirmed `origin/master` is an ancestor of the pushed branch head after rebase. ## Risks - Medium UI risk: this touches the routine detail and routine list surfaces, so visual regressions are possible in edge cases not covered by the focused tests. - Low data risk: no schema, migration, server API, or lockfile changes are included. - Review note: the branch intentionally force-pushed after rebasing because the original first three commits were already merged through #7848. > 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 runtime, with repository shell/tool access. Exact hosted runtime model identifier and context-window size were not exposed in the execution environment. ## 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 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] 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: Claude Opus 4.8 <noreply@anthropic.com>
215 lines
6.4 KiB
TypeScript
215 lines
6.4 KiB
TypeScript
import { useRef } from "react";
|
|
import {
|
|
Activity as ActivityIcon,
|
|
Circle,
|
|
Clock3,
|
|
History as HistoryIcon,
|
|
KeyRound,
|
|
LayoutGrid,
|
|
Play,
|
|
Send,
|
|
SlidersHorizontal,
|
|
} from "lucide-react";
|
|
import type { LucideIcon } from "lucide-react";
|
|
import { Link } from "@/lib/router";
|
|
import { cn } from "@/lib/utils";
|
|
import {
|
|
ROUTINE_SECTION_KEYS,
|
|
type RoutineSectionKey,
|
|
} from "./routine-sections/context";
|
|
import {
|
|
Select,
|
|
SelectContent,
|
|
SelectGroup,
|
|
SelectItem,
|
|
SelectLabel,
|
|
SelectTrigger,
|
|
SelectValue,
|
|
} from "@/components/ui/select";
|
|
|
|
type NavItem = {
|
|
key: RoutineSectionKey;
|
|
label: string;
|
|
icon: LucideIcon;
|
|
};
|
|
|
|
type NavGroup = {
|
|
label: string;
|
|
items: NavItem[];
|
|
};
|
|
|
|
const NAV_GROUPS: NavGroup[] = [
|
|
{
|
|
label: "Routine",
|
|
items: [
|
|
{ key: "overview", label: "Overview", icon: Circle },
|
|
{ key: "triggers", label: "Triggers", icon: Clock3 },
|
|
{ key: "variables", label: "Variables", icon: LayoutGrid },
|
|
{ key: "secrets", label: "Secrets", icon: KeyRound },
|
|
{ key: "delivery", label: "Delivery", icon: Send },
|
|
],
|
|
},
|
|
{
|
|
label: "Operate",
|
|
items: [
|
|
{ key: "runs", label: "Runs", icon: Play },
|
|
{ key: "activity", label: "Activity", icon: ActivityIcon },
|
|
{ key: "history", label: "History", icon: HistoryIcon },
|
|
],
|
|
},
|
|
];
|
|
|
|
const ALL_ITEMS: NavItem[] = NAV_GROUPS.flatMap((group) => group.items);
|
|
|
|
export function RoutineSubSidebar({
|
|
activeSection,
|
|
hrefFor,
|
|
isSectionDirty,
|
|
hasLiveRun,
|
|
onNavigate,
|
|
}: {
|
|
activeSection: RoutineSectionKey;
|
|
hrefFor: (section: RoutineSectionKey) => string;
|
|
isSectionDirty: (section: RoutineSectionKey) => boolean;
|
|
hasLiveRun: boolean;
|
|
onNavigate: (section: RoutineSectionKey) => void;
|
|
}) {
|
|
const itemRefs = useRef<Array<HTMLAnchorElement | null>>([]);
|
|
|
|
const focusItem = (index: number) => {
|
|
const clamped = (index + ALL_ITEMS.length) % ALL_ITEMS.length;
|
|
itemRefs.current[clamped]?.focus();
|
|
onNavigate(ALL_ITEMS[clamped].key);
|
|
};
|
|
|
|
const handleKeyDown = (event: React.KeyboardEvent, index: number) => {
|
|
switch (event.key) {
|
|
case "ArrowDown":
|
|
event.preventDefault();
|
|
focusItem(index + 1);
|
|
break;
|
|
case "ArrowUp":
|
|
event.preventDefault();
|
|
focusItem(index - 1);
|
|
break;
|
|
case "Home":
|
|
event.preventDefault();
|
|
focusItem(0);
|
|
break;
|
|
case "End":
|
|
event.preventDefault();
|
|
focusItem(ALL_ITEMS.length - 1);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
};
|
|
|
|
let flatIndex = -1;
|
|
|
|
return (
|
|
<nav
|
|
aria-label="Routine sections"
|
|
className="sticky top-0 hidden max-h-[100dvh] w-52 shrink-0 flex-col gap-4 self-start overflow-y-auto border-r border-border bg-sidebar/30 px-3 py-4 md:flex"
|
|
>
|
|
{NAV_GROUPS.map((group) => (
|
|
<div key={group.label} className="flex flex-col gap-0.5">
|
|
<p className="px-3 py-2 text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground/80">
|
|
{group.label}
|
|
</p>
|
|
{group.items.map((item) => {
|
|
flatIndex += 1;
|
|
const index = flatIndex;
|
|
const isActive = item.key === activeSection;
|
|
const Icon = item.icon;
|
|
const dirty = isSectionDirty(item.key);
|
|
const showLiveDot = item.key === "runs" && hasLiveRun;
|
|
return (
|
|
<Link
|
|
key={item.key}
|
|
ref={(node) => {
|
|
itemRefs.current[index] = node;
|
|
}}
|
|
to={hrefFor(item.key)}
|
|
replace
|
|
role="tab"
|
|
aria-current={isActive ? "page" : undefined}
|
|
tabIndex={isActive ? 0 : -1}
|
|
onKeyDown={(event) => handleKeyDown(event, index)}
|
|
onClick={() => onNavigate(item.key)}
|
|
className={cn(
|
|
"flex h-9 items-center gap-2 rounded-md px-3 text-sm transition-colors motion-safe:duration-150",
|
|
isActive
|
|
? "bg-accent text-accent-foreground"
|
|
: "text-muted-foreground hover:bg-accent/50 hover:text-foreground",
|
|
)}
|
|
>
|
|
<Icon className="h-3.5 w-3.5 shrink-0" />
|
|
<span className="truncate">{item.label}</span>
|
|
{showLiveDot ? (
|
|
<span className="ml-auto h-1.5 w-1.5 shrink-0 rounded-full bg-blue-500 motion-safe:animate-pulse" />
|
|
) : dirty ? (
|
|
<span
|
|
aria-label="Unsaved changes"
|
|
className="ml-auto h-1.5 w-1.5 shrink-0 rounded-full bg-amber-500 ring-2 ring-background"
|
|
/>
|
|
) : null}
|
|
</Link>
|
|
);
|
|
})}
|
|
</div>
|
|
))}
|
|
</nav>
|
|
);
|
|
}
|
|
|
|
/** Mobile section picker — collapses the sub-sidebar into a grouped `<Select>`. */
|
|
export function RoutineSectionPicker({
|
|
activeSection,
|
|
onNavigate,
|
|
isSectionDirty,
|
|
}: {
|
|
activeSection: RoutineSectionKey;
|
|
onNavigate: (section: RoutineSectionKey) => void;
|
|
isSectionDirty: (section: RoutineSectionKey) => boolean;
|
|
}) {
|
|
return (
|
|
<div className="sticky top-0 z-10 border-b border-border bg-background px-4 py-2 md:hidden">
|
|
<Select
|
|
value={activeSection}
|
|
onValueChange={(value) => {
|
|
if (ROUTINE_SECTION_KEYS.includes(value as RoutineSectionKey)) {
|
|
onNavigate(value as RoutineSectionKey);
|
|
}
|
|
}}
|
|
>
|
|
<SelectTrigger className="h-11 w-full" aria-label="Routine section">
|
|
<SelectValue />
|
|
</SelectTrigger>
|
|
<SelectContent>
|
|
{NAV_GROUPS.map((group) => (
|
|
<SelectGroup key={group.label}>
|
|
<SelectLabel className="uppercase tracking-[0.12em] text-[11px]">
|
|
{group.label}
|
|
</SelectLabel>
|
|
{group.items.map((item) => (
|
|
<SelectItem key={item.key} value={item.key} className="h-11">
|
|
<span className="flex items-center gap-2">
|
|
<item.icon className="h-3.5 w-3.5" />
|
|
{item.label}
|
|
{isSectionDirty(item.key) ? (
|
|
<span className="h-1.5 w-1.5 rounded-full bg-amber-500" />
|
|
) : null}
|
|
</span>
|
|
</SelectItem>
|
|
))}
|
|
</SelectGroup>
|
|
))}
|
|
</SelectContent>
|
|
</Select>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export { ALL_ITEMS as ROUTINE_NAV_ITEMS };
|