mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-20 18:26:40 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - An agent can propose dashboard areas and responsibilities in one card. > - The card put the area name above a separate “New area” row. > - Responsibility rows had no type label and no visible parent structure. > - This pull request puts area changes in the heading and nests responsibility changes below it. > - People can see what each change creates and where it belongs before they apply it. ## Linked Issues or Issue Description **What existing behavior does this improve?** The dashboard proposal card in task conversations and the dashboard edit module. **Subsystem affected** The board UI and its Storybook examples. **Current behavior** “New area” appears in a row below the area title. New responsibilities appear at the same level. Their type is not stated. **Proposed behavior** “New area” appears beside the area title. Each new responsibility has a label and sits below its parent area. Existing areas have a separate label. Area headings follow the heading level in the dashboard module. **Reason and benefit** The person can see the parent area, the change type and the text to review in that order. Long proposals are easier to scan. **Breaking changes** None. Proposal inputs, indexes, dependencies and apply/decline endpoints stay the same. ## What Changed - Put area changes and their controls in the area heading. - Nest responsibility rows under each area. Label additions, rewords, moves and removals. - Keep the drop/keep dependency behavior and the existing apply payload. - Keep area classification and group partitions in one helper. Expose whether each group has an existing parent area. - Add Storybook examples for the new hierarchy, a narrow layout and a mix of new and existing areas. - Add focused component and browser checks for the hierarchy, responsive layout and apply payload. ## Verification - 24 focused unit tests passed across the proposal card, dashboard module and dashboard helpers. - 25 Chromium checks passed against current-source Storybook after the review refactor, with one worker and no retries. They cover six proposal states in light and dark themes at widths of 390 and 960 pixels, plus the existing apply payload. - The UI typecheck passed in low-memory mode after the review refactor. The initial implementation also passed the static Storybook build; current-head CI supplies broad build coverage. - 30 map/catalog tests passed. Catalog checks, token gates and whitespace checks passed. - A hierarchy regression failed before the fix and passed after it. A later hosted-story check found a skipped heading level. The fix passed the expanded browser checks. - Initial concurrent browser, build and typecheck runs hit the workspace memory limit. The final browser pass used one worker and the typecheck used low-memory mode. - The first CI build stopped because its runner received a shutdown signal after the UI build completed. A new CI run checks the review fixes. - The local verification selector returned exit 2 because the new browser spec is a global CI input. [Current-head CI](https://github.com/paperclipai/paperclip/actions/runs/44333497172) passed typecheck, build, all selected test suites, E2E shards and the final verify gate for `e71916cdde90ede313cc167ab8cfb8a5c3bb501a`. No visual baseline comparison was run because the baseline manifest has no published snapshots. - [Greptile reviewed the current head](https://github.com/paperclipai/paperclip/pull/22180#issuecomment-6982500386) at 5/5 with no findings. Both earlier maintainability threads are resolved; two Paperclip reviews remain pending. ## Risks Low risk. This changes UI structure and labels. Long text and drop/keep controls must continue to fit at narrow widths. The focused browser checks cover those states. Storybook uses synthetic API data and does not prove server persistence or permissions. ## Model Used OpenAI GPT-6 through Codex, with reasoning, tool use and code execution. ## 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 not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run 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 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: Paperclip <noreply@paperclip.ing>
177 lines
7.5 KiB
TypeScript
177 lines
7.5 KiB
TypeScript
import {
|
|
dashboardChangesDroppedWith,
|
|
dashboardChangesKeptWith,
|
|
type ResponsibilityDashboardChange,
|
|
type ResponsibilityDashboardVersionSummary,
|
|
} from "@paperclipai/shared";
|
|
|
|
/**
|
|
* Derivations for the Dashboard's edit module and the proposed-changes card
|
|
* (experimental `enableResponsibilities`): the changes grouped by area, how
|
|
* each reads before and after, and which go together when one is dropped.
|
|
*/
|
|
|
|
export interface DashboardChangeGroup {
|
|
key: string;
|
|
name: string;
|
|
/** The group is a new area. */
|
|
isNew: boolean;
|
|
hasExistingArea: boolean;
|
|
areaChanges: ResponsibilityDashboardChange[];
|
|
responsibilityChanges: ResponsibilityDashboardChange[];
|
|
changes: ResponsibilityDashboardChange[];
|
|
}
|
|
|
|
export function isDashboardAreaChange(change: ResponsibilityDashboardChange): boolean {
|
|
return change.op === "add_area" || change.op === "rename_area" || change.op === "remove_area";
|
|
}
|
|
|
|
function groupKey(change: Pick<ResponsibilityDashboardChange, "groupAreaId" | "groupRef">) {
|
|
if (change.groupRef !== null) return `new:${change.groupRef}`;
|
|
return change.groupAreaId ?? "__none__";
|
|
}
|
|
|
|
/** The changes by area, in the order the agent first named each area; area changes first within a group. */
|
|
export function dashboardChangeGroups(changes: readonly ResponsibilityDashboardChange[]): DashboardChangeGroup[] {
|
|
const groups = new Map<string, Omit<DashboardChangeGroup, "changes">>();
|
|
for (const change of changes) {
|
|
const key = groupKey(change);
|
|
const group = groups.get(key) ?? {
|
|
key,
|
|
name: change.groupName,
|
|
isNew: false,
|
|
hasExistingArea: change.groupAreaId !== null,
|
|
areaChanges: [],
|
|
responsibilityChanges: [],
|
|
};
|
|
if (change.op === "add_area") group.isNew = true;
|
|
if (isDashboardAreaChange(change)) group.areaChanges.push(change);
|
|
else group.responsibilityChanges.push(change);
|
|
groups.set(key, group);
|
|
}
|
|
return [...groups.values()].map((group) => {
|
|
group.areaChanges.sort((a, b) => a.index - b.index);
|
|
group.responsibilityChanges.sort((a, b) => a.index - b.index);
|
|
return { ...group, changes: [...group.areaChanges, ...group.responsibilityChanges] };
|
|
});
|
|
}
|
|
|
|
export interface DashboardChangeWords {
|
|
/** What it reads as today, struck through; null when it is new. */
|
|
before: string | null;
|
|
/** What it will read; null when it goes. */
|
|
after: string | null;
|
|
/** A few muted words when the before and after do not say it on their own. */
|
|
note: string | null;
|
|
}
|
|
|
|
/** How one change reads on the card: a before and an after a person can compare at a glance. */
|
|
export function dashboardChangeWords(change: ResponsibilityDashboardChange): DashboardChangeWords {
|
|
switch (change.op) {
|
|
case "add_area":
|
|
return { before: null, after: change.name, note: null };
|
|
case "rename_area":
|
|
return {
|
|
before: change.fromName,
|
|
after: change.name,
|
|
note: change.sharedWith > 0 ? `Also renamed for ${change.sharedWith === 1 ? "1 other person" : `${change.sharedWith} other people`}` : null,
|
|
};
|
|
case "remove_area":
|
|
return { before: change.groupName, after: null, note: null };
|
|
case "add_responsibility":
|
|
return { before: null, after: change.sentence, note: null };
|
|
case "reword_responsibility":
|
|
return { before: change.fromSentence, after: change.sentence, note: null };
|
|
case "move_responsibility":
|
|
return { before: null, after: change.fromSentence, note: change.fromAreaName ? `Moved from ${change.fromAreaName}` : "Moved here" };
|
|
case "remove_responsibility":
|
|
return { before: change.fromSentence, after: null, note: "Let go" };
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Drop or keep one change. Dropping a new area drops what is filed under it;
|
|
* keeping something filed under a dropped new area keeps the area too.
|
|
*/
|
|
export function toggleDashboardChange(
|
|
changes: readonly ResponsibilityDashboardChange[],
|
|
dropped: ReadonlySet<number>,
|
|
index: number,
|
|
): Set<number> {
|
|
const next = new Set(dropped);
|
|
if (dropped.has(index)) for (const kept of dashboardChangesKeptWith(changes, index)) next.delete(kept);
|
|
else for (const gone of dashboardChangesDroppedWith(changes, index)) next.add(gone);
|
|
return next;
|
|
}
|
|
|
|
/** The indexes to apply; undefined when nothing was dropped (apply them all). */
|
|
export function keptDashboardChanges(changes: readonly ResponsibilityDashboardChange[], dropped: ReadonlySet<number>): number[] | undefined {
|
|
if (dropped.size === 0) return undefined;
|
|
return changes.map((change) => change.index).filter((index) => !dropped.has(index));
|
|
}
|
|
|
|
/** For a dropped change that goes because the new area it needs was dropped: that area's name. */
|
|
export function droppedWithArea(
|
|
changes: readonly ResponsibilityDashboardChange[],
|
|
dropped: ReadonlySet<number>,
|
|
change: ResponsibilityDashboardChange,
|
|
): string | null {
|
|
const needed = change.dependsOn.find((index) => dropped.has(index));
|
|
if (needed === undefined) return null;
|
|
return changes.find((candidate) => candidate.index === needed)?.name ?? null;
|
|
}
|
|
|
|
/** What a kept "remove this area" lets go of, after the kept moves and removals take their items out. */
|
|
export function lettingGoWith(
|
|
changes: readonly ResponsibilityDashboardChange[],
|
|
dropped: ReadonlySet<number>,
|
|
change: ResponsibilityDashboardChange,
|
|
): string[] {
|
|
const leaving = new Set(changes
|
|
.filter((candidate) => !dropped.has(candidate.index)
|
|
&& (candidate.op === "move_responsibility" || candidate.op === "remove_responsibility"))
|
|
.map((candidate) => candidate.responsibilityId));
|
|
// A dropped move out (or removal) leaves the responsibility in the area, so it goes with the area.
|
|
const stayingBehind = changes.filter((candidate) => dropped.has(candidate.index)
|
|
&& ((candidate.op === "move_responsibility" && candidate.fromAreaId === change.groupAreaId)
|
|
|| (candidate.op === "remove_responsibility" && candidate.groupAreaId === change.groupAreaId)));
|
|
const items = [...change.lettingGo];
|
|
for (const candidate of stayingBehind) {
|
|
const { responsibilityId: id, fromSentence: sentence } = candidate;
|
|
if (id && sentence && !items.some((item) => item.id === id)) items.push({ id, sentence });
|
|
}
|
|
return items.filter((item) => !leaving.has(item.id)).map((item) => item.sentence);
|
|
}
|
|
|
|
/** Who caused a version, in a word or a name. */
|
|
export function dashboardVersionWho(version: Pick<ResponsibilityDashboardVersionSummary, "cause" | "actorAgentId">, agentName: (id: string) => string | undefined): string {
|
|
if (version.cause === "restore") return "Restored";
|
|
if (version.cause === "person") return "You";
|
|
return (version.actorAgentId ? agentName(version.actorAgentId) : undefined) ?? "An agent";
|
|
}
|
|
|
|
/** The line the Dashboard shows right after a change, beside Undo. */
|
|
export function dashboardChangeLine(version: Pick<ResponsibilityDashboardVersionSummary, "cause" | "summary">): string {
|
|
if (version.cause === "restore") return "Restored an earlier version.";
|
|
return `${version.summary}.`;
|
|
}
|
|
|
|
/** Undo is dismissed per change, in this browser; works without storage. */
|
|
export const DASHBOARD_UNDO_DISMISSED_STORAGE_KEY = "paperclip:responsibilities:dashboard-undo-dismissed";
|
|
|
|
export function readDismissedUndo(): string | null {
|
|
try {
|
|
return globalThis.localStorage?.getItem(DASHBOARD_UNDO_DISMISSED_STORAGE_KEY) ?? null;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
export function writeDismissedUndo(versionId: string): void {
|
|
try {
|
|
globalThis.localStorage?.setItem(DASHBOARD_UNDO_DISMISSED_STORAGE_KEY, versionId);
|
|
} catch {
|
|
// Private windows and blocked storage: it stays dismissed for this visit only.
|
|
}
|
|
}
|