6b7f6ce4b8
## Thinking Path > - Paperclip orchestrates AI agents through a company-scoped control plane. > - The affected surface is the board UI for issue threads, issue lists, routines, dialogs, navigation, and issue review indicators. > - Closed PR #4692 bundled backend, schema, docs, workflow, and UI/QoL work into one oversized change set. > - Greptile could not keep reviewing that broad PR because it exceeded the 100-file review limit and mixed unrelated concerns. > - This pull request extracts the UI/QoL slice into a fresh branch under the review limit while leaving workflow and lockfile churn out. > - The benefit is a focused review path for the board UI performance and workflow improvements without reopening the oversized PR. ## What Changed - Added long issue-thread virtualization, scroll-container binding, anchor preservation, latest-comment jump targeting, and related regression/perf fixtures. - Improved issue list scalability with scroll-based loading, server offset parameters, and pagination-focused UI tests. - Reduced new issue dialog typing churn and split dialog action subscriptions so broad layout/nav surfaces avoid unnecessary renders. - Added routine variables help and routine description mention options for users, agents, and projects. - Added productivity review badge/link UI and fixed the badge to use Paperclip's company-prefixed router link. - Kept the split PR below Greptile's review limit and excluded `.github/workflows/pr.yml` and `pnpm-lock.yaml`. ## Verification - `pnpm install --no-frozen-lockfile` in the clean worktree to install `@tanstack/react-virtual` locally without committing lockfile churn. - `pnpm --filter @paperclipai/ui exec vitest run --config vitest.config.ts src/components/IssueChatThread.test.tsx src/components/IssuesList.test.tsx src/components/NewIssueDialog.test.tsx src/pages/Routines.test.tsx src/pages/Issues.test.tsx` passed: 5 files, 83 tests. - `pnpm --filter @paperclipai/ui typecheck` passed. - `git diff --check origin/master..HEAD` passed. - Split-scope checks: 53 changed files; no `.github/workflows/pr.yml`; no `pnpm-lock.yaml`. - Screenshots were not captured in this heartbeat; the changes are primarily virtualization, routing, pagination, and editor behavior covered by focused regression tests. ## Risks - Moderate UI risk because issue-thread virtualization changes scroll behavior on long conversations; regression tests cover anchor jumps, latest-comment targeting, row metadata, and short-thread fallback. - Moderate integration risk because the issue-list offset parameter and productivity review field depend on matching API behavior. - Dependency risk: the UI package adds `@tanstack/react-virtual` while repository policy keeps `pnpm-lock.yaml` out of PRs, so CI must resolve dependency changes through the repo's normal lockfile policy. > 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 coding agent, tool-enabled local repository and GitHub workflow. Exact runtime context window was not exposed by the harness. ## 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>
228 lines
7.3 KiB
TypeScript
228 lines
7.3 KiB
TypeScript
import { useEffect } from "react";
|
|
import { useParams } from "@/lib/router";
|
|
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
|
import { goalsApi } from "../api/goals";
|
|
import { projectsApi } from "../api/projects";
|
|
import { assetsApi } from "../api/assets";
|
|
import { usePanel } from "../context/PanelContext";
|
|
import { useCompany } from "../context/CompanyContext";
|
|
import { useDialogActions } from "../context/DialogContext";
|
|
import { useBreadcrumbs } from "../context/BreadcrumbContext";
|
|
import { queryKeys } from "../lib/queryKeys";
|
|
import { GoalProperties } from "../components/GoalProperties";
|
|
import { GoalTree } from "../components/GoalTree";
|
|
import { StatusBadge } from "../components/StatusBadge";
|
|
import { InlineEditor } from "../components/InlineEditor";
|
|
import { EntityRow } from "../components/EntityRow";
|
|
import { PageSkeleton } from "../components/PageSkeleton";
|
|
import { cn, projectUrl } from "../lib/utils";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
|
import { Plus, SlidersHorizontal } from "lucide-react";
|
|
import type { Goal, Project } from "@paperclipai/shared";
|
|
|
|
interface GoalPropertiesToggleButtonProps {
|
|
panelVisible: boolean;
|
|
onShowProperties: () => void;
|
|
}
|
|
|
|
export function GoalPropertiesToggleButton({
|
|
panelVisible,
|
|
onShowProperties,
|
|
}: GoalPropertiesToggleButtonProps) {
|
|
return (
|
|
<Button
|
|
variant="ghost"
|
|
size="icon-xs"
|
|
className={cn(
|
|
"hidden md:inline-flex shrink-0 transition-opacity duration-200",
|
|
panelVisible ? "opacity-0 pointer-events-none w-0 overflow-hidden" : "opacity-100",
|
|
)}
|
|
onClick={onShowProperties}
|
|
title="Show properties"
|
|
>
|
|
<SlidersHorizontal className="h-4 w-4" />
|
|
</Button>
|
|
);
|
|
}
|
|
|
|
export function GoalDetail() {
|
|
const { goalId } = useParams<{ goalId: string }>();
|
|
const { selectedCompanyId, setSelectedCompanyId } = useCompany();
|
|
const { openNewGoal } = useDialogActions();
|
|
const { openPanel, closePanel, panelVisible, setPanelVisible } = usePanel();
|
|
const { setBreadcrumbs } = useBreadcrumbs();
|
|
const queryClient = useQueryClient();
|
|
|
|
const {
|
|
data: goal,
|
|
isLoading,
|
|
error
|
|
} = useQuery({
|
|
queryKey: queryKeys.goals.detail(goalId!),
|
|
queryFn: () => goalsApi.get(goalId!),
|
|
enabled: !!goalId
|
|
});
|
|
const resolvedCompanyId = goal?.companyId ?? selectedCompanyId;
|
|
|
|
const { data: allGoals } = useQuery({
|
|
queryKey: queryKeys.goals.list(resolvedCompanyId!),
|
|
queryFn: () => goalsApi.list(resolvedCompanyId!),
|
|
enabled: !!resolvedCompanyId
|
|
});
|
|
|
|
const { data: allProjects } = useQuery({
|
|
queryKey: queryKeys.projects.list(resolvedCompanyId!),
|
|
queryFn: () => projectsApi.list(resolvedCompanyId!),
|
|
enabled: !!resolvedCompanyId
|
|
});
|
|
|
|
useEffect(() => {
|
|
if (!goal?.companyId || goal.companyId === selectedCompanyId) return;
|
|
setSelectedCompanyId(goal.companyId, { source: "route_sync" });
|
|
}, [goal?.companyId, selectedCompanyId, setSelectedCompanyId]);
|
|
|
|
const updateGoal = useMutation({
|
|
mutationFn: (data: Record<string, unknown>) =>
|
|
goalsApi.update(goalId!, data),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({
|
|
queryKey: queryKeys.goals.detail(goalId!)
|
|
});
|
|
if (resolvedCompanyId) {
|
|
queryClient.invalidateQueries({
|
|
queryKey: queryKeys.goals.list(resolvedCompanyId)
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
const uploadImage = useMutation({
|
|
mutationFn: async (file: File) => {
|
|
if (!resolvedCompanyId) throw new Error("No company selected");
|
|
return assetsApi.uploadImage(
|
|
resolvedCompanyId,
|
|
file,
|
|
`goals/${goalId ?? "draft"}`
|
|
);
|
|
}
|
|
});
|
|
|
|
const childGoals = (allGoals ?? []).filter((g) => g.parentId === goalId);
|
|
const linkedProjects = (allProjects ?? []).filter((p) => {
|
|
if (!goalId) return false;
|
|
if (p.goalIds.includes(goalId)) return true;
|
|
if (p.goals.some((goalRef) => goalRef.id === goalId)) return true;
|
|
return p.goalId === goalId;
|
|
});
|
|
|
|
useEffect(() => {
|
|
setBreadcrumbs([
|
|
{ label: "Goals", href: "/goals" },
|
|
{ label: goal?.title ?? goalId ?? "Goal" }
|
|
]);
|
|
}, [setBreadcrumbs, goal, goalId]);
|
|
|
|
useEffect(() => {
|
|
if (goal) {
|
|
openPanel(
|
|
<GoalProperties
|
|
goal={goal}
|
|
onUpdate={(data) => updateGoal.mutate(data)}
|
|
/>
|
|
);
|
|
}
|
|
return () => closePanel();
|
|
}, [goal]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
|
|
if (isLoading) return <PageSkeleton variant="detail" />;
|
|
if (error) return <p className="text-sm text-destructive">{error.message}</p>;
|
|
if (!goal) return null;
|
|
|
|
return (
|
|
<div className="space-y-6">
|
|
<div className="space-y-3">
|
|
<div className="flex items-center gap-2">
|
|
<span className="text-xs uppercase text-muted-foreground">
|
|
{goal.level}
|
|
</span>
|
|
<StatusBadge status={goal.status} />
|
|
<div className="ml-auto">
|
|
<GoalPropertiesToggleButton
|
|
panelVisible={panelVisible}
|
|
onShowProperties={() => setPanelVisible(true)}
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
<InlineEditor
|
|
value={goal.title}
|
|
onSave={(title) => updateGoal.mutate({ title })}
|
|
as="h2"
|
|
className="text-xl font-bold"
|
|
/>
|
|
|
|
<InlineEditor
|
|
value={goal.description ?? ""}
|
|
onSave={(description) => updateGoal.mutate({ description })}
|
|
as="p"
|
|
className="text-sm text-muted-foreground"
|
|
placeholder="Add a description..."
|
|
multiline
|
|
imageUploadHandler={async (file) => {
|
|
const asset = await uploadImage.mutateAsync(file);
|
|
return asset.contentPath;
|
|
}}
|
|
/>
|
|
</div>
|
|
|
|
<Tabs defaultValue="children">
|
|
<TabsList>
|
|
<TabsTrigger value="children">
|
|
Sub-Goals ({childGoals.length})
|
|
</TabsTrigger>
|
|
<TabsTrigger value="projects">
|
|
Projects ({linkedProjects.length})
|
|
</TabsTrigger>
|
|
</TabsList>
|
|
|
|
<TabsContent value="children" className="mt-4 space-y-3">
|
|
<div className="flex items-center justify-start">
|
|
<Button
|
|
size="sm"
|
|
variant="outline"
|
|
onClick={() => openNewGoal({ parentId: goalId })}
|
|
>
|
|
<Plus className="h-3.5 w-3.5 mr-1.5" />
|
|
Sub Goal
|
|
</Button>
|
|
</div>
|
|
{childGoals.length === 0 ? (
|
|
<p className="text-sm text-muted-foreground">No sub-goals.</p>
|
|
) : (
|
|
<GoalTree goals={childGoals} goalLink={(g) => `/goals/${g.id}`} />
|
|
)}
|
|
</TabsContent>
|
|
|
|
<TabsContent value="projects" className="mt-4">
|
|
{linkedProjects.length === 0 ? (
|
|
<p className="text-sm text-muted-foreground">No linked projects.</p>
|
|
) : (
|
|
<div className="border border-border">
|
|
{linkedProjects.map((project) => (
|
|
<EntityRow
|
|
key={project.id}
|
|
title={project.name}
|
|
subtitle={project.description ?? undefined}
|
|
to={projectUrl(project)}
|
|
trailing={<StatusBadge status={project.status} />}
|
|
/>
|
|
))}
|
|
</div>
|
|
)}
|
|
</TabsContent>
|
|
</Tabs>
|
|
</div>
|
|
);
|
|
}
|