mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-05 23:06:17 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Each agent can report to a manager agent. The user selects the manager in the "Reports to" picker. > - The picker shows candidate managers in directory order. This order is not alphabetical. > - When a company has many agents, the user cannot easily find a specific agent in the list. > - This pull request sorts the picker rows alphabetically by agent name. > - The benefit is that the user finds a manager faster, and the order agrees with the sidebar. ## Linked Issues or Issue Description **Is your feature request related to a problem?** The "Reports to" picker on the agent profile lists agents in an unpredictable order (for example: "Mac Coder", "Bug Bot", "Nibbler", "CTO"). It is hard to find one agent in a long list. **Describe the solution you'd like** Sort the picker rows alphabetically by agent name. Ignore letter case. Put "Agent 2" before "Agent 10". **Describe alternatives you've considered** Sorting the agent list in each caller. This change sorts inside the shared `ReportsToPicker` component instead, so the agent profile and the agent configuration form both get the same order. ## What Changed - Added `reportsToPickerRows` to `ui/src/components/ReportsToPicker.tsx`. It removes terminated and excluded agents, then sorts the rows by name with `localeCompare` (`sensitivity: "base"`, `numeric: true`). - `ReportsToPicker` uses this function for its rows. "No manager" stays at the top. - The picker indexes `disabledAgentIds` in a `Set`. Before, it scanned the array once per row. - Added `ui/src/components/ReportsToPicker.test.ts` with unit tests for the order and the filter. ## Verification - `cd ui && npx vitest run src/components/ReportsToPicker.test.ts`: 2 tests pass. - Red check: the same tests fail on the previous code. - `npx tsc --noEmit -p ui/tsconfig.json` shows no errors in the changed files. - 1,000-agent test bounds the sort work with a throwing name-read counter (per `rules/ui-render-cost.mdc`). - Manual: ran the branch on a local dev server with 13 agents. The "Reports to" picker showed: Agent 2, Agent 10, Bug Bot (Deprecated), CEO Agent, CTO, Dickens, Engineer Agent, Fry (Codex), Mac Coder, nibbler, Reviewie, Slow Query (GLM), Test Gardener (GLM). ## Risks - Low risk. The change is UI-only and changes only the row order. Filter and selection behavior do not change. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude Code with tool use (shell, file edit) and image input. ## 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) - [ ] 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: devinfoley <139239+devinfoley@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
60 lines
2.0 KiB
TypeScript
60 lines
2.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { Agent } from "@paperclipai/shared";
|
|
import { reportsToPickerRows } from "./ReportsToPicker";
|
|
|
|
function agent(id: string, name: string, status: Agent["status"] = "idle"): Agent {
|
|
return { id, name, status } as Agent;
|
|
}
|
|
|
|
describe("reportsToPickerRows", () => {
|
|
it("lists candidate managers alphabetically by name, ignoring case", () => {
|
|
const rows = reportsToPickerRows([
|
|
agent("1", "Mac Coder"),
|
|
agent("2", "Bug Bot (Deprecated)"),
|
|
agent("3", "nibbler"),
|
|
agent("4", "CTO"),
|
|
agent("5", "Agent 10"),
|
|
agent("6", "Agent 2"),
|
|
]);
|
|
expect(rows.map((row) => row.name)).toEqual([
|
|
"Agent 2",
|
|
"Agent 10",
|
|
"Bug Bot (Deprecated)",
|
|
"CTO",
|
|
"Mac Coder",
|
|
"nibbler",
|
|
]);
|
|
});
|
|
|
|
it("sorts a large agent directory with n log n name reads", () => {
|
|
const size = 1000;
|
|
const limit = 2 * size * Math.ceil(Math.log2(size)) + size;
|
|
let nameReads = 0;
|
|
const agents = Array.from({ length: size }, (_, index) => {
|
|
const name = `Agent ${(index * 7919) % size}`;
|
|
const row = { id: String(index), status: "idle" } as Agent;
|
|
Object.defineProperty(row, "name", {
|
|
get() {
|
|
nameReads += 1;
|
|
if (nameReads > limit) throw new Error(`name read more than ${limit} times`);
|
|
return name;
|
|
},
|
|
});
|
|
return row;
|
|
});
|
|
|
|
const rows = reportsToPickerRows(agents);
|
|
|
|
expect(rows).toHaveLength(size);
|
|
expect(rows[0]!.name).toBe("Agent 0");
|
|
expect(rows[size - 1]!.name).toBe(`Agent ${size - 1}`);
|
|
});
|
|
|
|
it("drops terminated and excluded agents without mutating the input", () => {
|
|
const agents = [agent("1", "Zed"), agent("2", "Gone", "terminated"), agent("3", "Self"), agent("4", "Amy")];
|
|
const rows = reportsToPickerRows(agents, ["3"]);
|
|
expect(rows.map((row) => row.id)).toEqual(["4", "1"]);
|
|
expect(agents.map((row) => row.id)).toEqual(["1", "2", "3", "4"]);
|
|
});
|
|
});
|