mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-18 11:40:39 +09:00
Improve operator workflow QoL (#5291)
## Thinking Path > - Paperclip is a control plane operators use repeatedly to supervise agent companies. > - Common operator workflows depend on fast scanning of inboxes, issue sidebars, workspaces, cost totals, and runtime services. > - Several small UI and service gaps made those workflows slower or less clear. > - This pull request groups the operator-facing QoL changes that can stand alone from recovery and adapter work. > - The benefit is a denser, clearer board experience for issue triage and workspace operation. ## What Changed - Added inbox assignee/project grouping and issue list token/runtime totals. - Improved issue properties with removable blocker chips and workspace task links. - Improved execution workspace layout, runtime controls, issues tab default, and stopped-port reuse behavior. - Added mobile markdown/routine dialog fixes, page title company names, sidebar polish, and dashboard run task label cleanup. ## Verification - `pnpm install --frozen-lockfile` - `pnpm exec vitest run ui/src/lib/inbox.test.ts ui/src/components/IssueProperties.test.tsx ui/src/components/WorkspaceRuntimeControls.test.tsx server/src/__tests__/workspace-runtime.test.ts server/src/__tests__/costs-service.test.ts` ## Risks - Medium UI risk because this touches several operator surfaces. The branch is intentionally grouped around workflow/QoL files and keeps the file count below the Greptile limit. ## Model Used - OpenAI GPT-5 Codex via Paperclip `codex_local` adapter, with shell/git/GitHub CLI tool use. ## 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 - [x] 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>
This commit is contained in:
parent
11ffd6f2c5
commit
424e81d087
47 changed files with 1739 additions and 250 deletions
|
|
@ -3,7 +3,17 @@ import request from "supertest";
|
|||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterAll, afterEach, beforeAll } from "vitest";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { createDb, companies, agents, costEvents, financeEvents, issues, projects } from "@paperclipai/db";
|
||||
import {
|
||||
createDb,
|
||||
companies,
|
||||
agents,
|
||||
activityLog,
|
||||
costEvents,
|
||||
financeEvents,
|
||||
heartbeatRuns,
|
||||
issues,
|
||||
projects,
|
||||
} from "@paperclipai/db";
|
||||
import { costService } from "../services/costs.ts";
|
||||
import { financeService } from "../services/finance.ts";
|
||||
import {
|
||||
|
|
@ -69,6 +79,8 @@ const mockCostService = vi.hoisted(() => ({
|
|||
inputTokens: 0,
|
||||
cachedInputTokens: 0,
|
||||
outputTokens: 0,
|
||||
runCount: 0,
|
||||
runtimeMs: 0,
|
||||
}),
|
||||
windowSpend: vi.fn().mockResolvedValue([]),
|
||||
byProject: vi.fn().mockResolvedValue([]),
|
||||
|
|
@ -231,7 +243,9 @@ describe("cost routes", () => {
|
|||
|
||||
expect(res.status).toBe(200);
|
||||
expect(mockIssueService.getByIdentifier).toHaveBeenCalledWith("PC1A2-1");
|
||||
expect(mockCostService.issueTreeSummary).toHaveBeenCalledWith("company-1", "issue-1");
|
||||
expect(mockCostService.issueTreeSummary).toHaveBeenCalledWith("company-1", "issue-1", {
|
||||
excludeRoot: false,
|
||||
});
|
||||
expect(res.body).toEqual({
|
||||
issueId: "issue-1",
|
||||
issueCount: 1,
|
||||
|
|
@ -240,6 +254,8 @@ describe("cost routes", () => {
|
|||
inputTokens: 0,
|
||||
cachedInputTokens: 0,
|
||||
outputTokens: 0,
|
||||
runCount: 0,
|
||||
runtimeMs: 0,
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -393,6 +409,8 @@ describeEmbeddedPostgres("cost and finance aggregate overflow handling", () => {
|
|||
afterEach(async () => {
|
||||
await db.delete(financeEvents);
|
||||
await db.delete(costEvents);
|
||||
await db.delete(activityLog);
|
||||
await db.delete(heartbeatRuns);
|
||||
await db.delete(issues);
|
||||
await db.delete(projects);
|
||||
await db.delete(agents);
|
||||
|
|
@ -612,9 +630,173 @@ describeEmbeddedPostgres("cost and finance aggregate overflow handling", () => {
|
|||
inputTokens: 60,
|
||||
cachedInputTokens: 6,
|
||||
outputTokens: 12,
|
||||
runCount: 0,
|
||||
runtimeMs: 0,
|
||||
});
|
||||
});
|
||||
|
||||
it("aggregates run wall-clock duration across the recursive issue tree", async () => {
|
||||
const companyId = randomUUID();
|
||||
const agentId = randomUUID();
|
||||
const rootIssueId = randomUUID();
|
||||
const childIssueId = randomUUID();
|
||||
const grandchildIssueId = randomUUID();
|
||||
const siblingIssueId = randomUUID();
|
||||
|
||||
await db.insert(companies).values({
|
||||
id: companyId,
|
||||
name: "Paperclip",
|
||||
issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
|
||||
requireBoardApprovalForNewAgents: false,
|
||||
});
|
||||
await db.insert(agents).values({
|
||||
id: agentId,
|
||||
companyId,
|
||||
name: "Run Agent",
|
||||
role: "engineer",
|
||||
status: "active",
|
||||
adapterType: "codex_local",
|
||||
adapterConfig: {},
|
||||
runtimeConfig: {},
|
||||
permissions: {},
|
||||
});
|
||||
await db.insert(issues).values([
|
||||
{
|
||||
id: rootIssueId,
|
||||
companyId,
|
||||
title: "Root",
|
||||
status: "in_progress",
|
||||
priority: "medium",
|
||||
issueNumber: 1,
|
||||
identifier: "TST-1",
|
||||
},
|
||||
{
|
||||
id: childIssueId,
|
||||
companyId,
|
||||
parentId: rootIssueId,
|
||||
title: "Child",
|
||||
status: "in_progress",
|
||||
priority: "medium",
|
||||
issueNumber: 2,
|
||||
identifier: "TST-2",
|
||||
},
|
||||
{
|
||||
id: grandchildIssueId,
|
||||
companyId,
|
||||
parentId: childIssueId,
|
||||
title: "Grandchild",
|
||||
status: "done",
|
||||
priority: "medium",
|
||||
issueNumber: 3,
|
||||
identifier: "TST-3",
|
||||
},
|
||||
{
|
||||
id: siblingIssueId,
|
||||
companyId,
|
||||
title: "Sibling",
|
||||
status: "done",
|
||||
priority: "medium",
|
||||
issueNumber: 4,
|
||||
identifier: "TST-4",
|
||||
},
|
||||
]);
|
||||
|
||||
const linkedViaContextRunId = randomUUID();
|
||||
const linkedViaActivityRunId = randomUUID();
|
||||
const grandchildRunId = randomUUID();
|
||||
const siblingRunId = randomUUID();
|
||||
const livePartialRunId = randomUUID();
|
||||
|
||||
await db.insert(heartbeatRuns).values([
|
||||
// 60s run linked to root via contextSnapshot.issueId
|
||||
{
|
||||
id: linkedViaContextRunId,
|
||||
companyId,
|
||||
agentId,
|
||||
invocationSource: "on_demand",
|
||||
status: "completed",
|
||||
startedAt: new Date("2026-04-10T00:00:00.000Z"),
|
||||
finishedAt: new Date("2026-04-10T00:01:00.000Z"),
|
||||
contextSnapshot: { issueId: rootIssueId },
|
||||
},
|
||||
// 120s run linked to child via activity_log
|
||||
{
|
||||
id: linkedViaActivityRunId,
|
||||
companyId,
|
||||
agentId,
|
||||
invocationSource: "on_demand",
|
||||
status: "completed",
|
||||
startedAt: new Date("2026-04-10T00:05:00.000Z"),
|
||||
finishedAt: new Date("2026-04-10T00:07:00.000Z"),
|
||||
},
|
||||
// 30s run linked to grandchild
|
||||
{
|
||||
id: grandchildRunId,
|
||||
companyId,
|
||||
agentId,
|
||||
invocationSource: "on_demand",
|
||||
status: "completed",
|
||||
startedAt: new Date("2026-04-10T00:10:00.000Z"),
|
||||
finishedAt: new Date("2026-04-10T00:10:30.000Z"),
|
||||
contextSnapshot: { issueId: grandchildIssueId },
|
||||
},
|
||||
// sibling run NOT under root – should be excluded
|
||||
{
|
||||
id: siblingRunId,
|
||||
companyId,
|
||||
agentId,
|
||||
invocationSource: "on_demand",
|
||||
status: "completed",
|
||||
startedAt: new Date("2026-04-10T00:20:00.000Z"),
|
||||
finishedAt: new Date("2026-04-10T00:21:00.000Z"),
|
||||
contextSnapshot: { issueId: siblingIssueId },
|
||||
},
|
||||
// Still-running run on child (no finishedAt) – should contribute (now - startedAt)
|
||||
{
|
||||
id: livePartialRunId,
|
||||
companyId,
|
||||
agentId,
|
||||
invocationSource: "on_demand",
|
||||
status: "running",
|
||||
startedAt: new Date(Date.now() - 5_000),
|
||||
contextSnapshot: { issueId: childIssueId },
|
||||
},
|
||||
]);
|
||||
|
||||
await db.insert(activityLog).values({
|
||||
companyId,
|
||||
runId: linkedViaActivityRunId,
|
||||
actorType: "agent",
|
||||
actorId: agentId,
|
||||
agentId,
|
||||
action: "issue.checked_out",
|
||||
entityType: "issue",
|
||||
entityId: childIssueId,
|
||||
details: {},
|
||||
});
|
||||
|
||||
const summary = await costs.issueTreeSummary(companyId, rootIssueId);
|
||||
|
||||
expect(summary.issueCount).toBe(3);
|
||||
// 3 finished runs in tree (root, child via activity, grandchild) + 1 live run
|
||||
expect(summary.runCount).toBe(4);
|
||||
// 60s + 120s + 30s = 210s = 210_000ms from finished runs.
|
||||
// Live run adds ~5_000ms; allow some slack so the assertion isn't flaky.
|
||||
expect(summary.runtimeMs).toBeGreaterThanOrEqual(210_000 + 4_000);
|
||||
expect(summary.runtimeMs).toBeLessThan(210_000 + 60_000);
|
||||
|
||||
// excludeRoot drops the root issue's own runs (the 60s contextSnapshot run)
|
||||
// while keeping the child + grandchild runs and any live child run.
|
||||
const descendantsOnly = await costs.issueTreeSummary(companyId, rootIssueId, {
|
||||
excludeRoot: true,
|
||||
});
|
||||
expect(descendantsOnly.issueCount).toBe(2);
|
||||
expect(descendantsOnly.runCount).toBe(3);
|
||||
// 120s + 30s = 150s + ~5s live run
|
||||
expect(descendantsOnly.runtimeMs).toBeGreaterThanOrEqual(150_000 + 4_000);
|
||||
expect(descendantsOnly.runtimeMs).toBeLessThan(150_000 + 60_000);
|
||||
});
|
||||
|
||||
it("aggregates finance event sums above int32 without raising Postgres integer overflow", async () => {
|
||||
const companyId = randomUUID();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue