Skip to content

Commit 6b5c0c1

Browse files
author
Eva
committed
fix(workspaces): keep operations widget helpers private
1 parent 0108377 commit 6b5c0c1

3 files changed

Lines changed: 26 additions & 33 deletions

File tree

ui/src/lib/workspace/widgets/agent-status.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type AgentStatusRowModel = {
1919
progress: number | null;
2020
};
2121

22-
export type AgentStatusModel = {
22+
type AgentStatusModel = {
2323
rows: AgentStatusRowModel[];
2424
activeCount: number;
2525
total: number;
@@ -49,7 +49,7 @@ function rowProgress(row: Record<string, unknown>): number | null {
4949
return Math.min(1, Math.max(0, used / budget));
5050
}
5151

52-
export function mapAgentStatus(widget: WorkspaceWidget, value: unknown): AgentStatusModel {
52+
function mapAgentStatus(widget: WorkspaceWidget, value: unknown): AgentStatusModel {
5353
const raw = Array.isArray(value)
5454
? value
5555
: isRecord(value) && Array.isArray(value.sessions)

ui/src/lib/workspace/widgets/approvals.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import {
1616

1717
const DEFAULT_LIMIT = 8;
1818

19-
export type ApprovalsModel = { items: PendingApprovalItem[]; total: number };
19+
type ApprovalsModel = { items: PendingApprovalItem[]; total: number };
2020

21-
export function toWidgetApprovalDecision(decision: ApprovalDecision): "approved" | "rejected" {
21+
function toWidgetApprovalDecision(decision: ApprovalDecision): "approved" | "rejected" {
2222
return decision === "approve" ? "approved" : "rejected";
2323
}
2424

@@ -40,7 +40,7 @@ export function buildWidgetApprovalsSource(
4040
};
4141
}
4242

43-
export function mapApprovals(
43+
function mapApprovals(
4444
widget: WorkspaceWidget,
4545
source: ApprovalsWidgetSource | undefined,
4646
): ApprovalsModel {

ui/src/lib/workspace/widgets/widgets.test.ts

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,8 @@ import { render } from "lit";
77
import { describe, expect, it } from "vitest";
88
import type { WorkspaceWidget } from "../types.ts";
99
import { mapActivity, renderActivity } from "./activity.ts";
10-
import { mapAgentStatus, renderAgentStatus } from "./agent-status.ts";
11-
import {
12-
buildWidgetApprovalsSource,
13-
mapApprovals,
14-
renderApprovals,
15-
toWidgetApprovalDecision,
16-
} from "./approvals.ts";
10+
import { renderAgentStatus } from "./agent-status.ts";
11+
import { buildWidgetApprovalsSource, renderApprovals } from "./approvals.ts";
1712
import { mapCron, renderCron } from "./cron.ts";
1813
import { evaluateEmbedUrl, renderIframeEmbed } from "./iframe-embed.ts";
1914
import { mapInstances, renderInstances } from "./instances.ts";
@@ -48,25 +43,24 @@ const STRICT_EMBED: BuiltinWidgetContext = {
4843

4944
describe("agent-status mapping", () => {
5045
it("maps only keyed sessions and clamps goal progress", () => {
51-
const model = mapAgentStatus(widget({ props: { limit: 2 } }), {
52-
sessions: [
53-
{
54-
key: "agent:one",
55-
displayName: "One",
56-
hasActiveRun: true,
57-
goal: { objective: "Ship the workspace", tokensUsed: 125, tokenBudget: 100 },
58-
},
59-
{ key: "agent:two", status: "idle" },
60-
{ displayName: "missing key" },
61-
],
62-
});
63-
expect(model).toMatchObject({ activeCount: 1, total: 2 });
64-
expect(model.rows[0]).toMatchObject({
65-
key: "agent:one",
66-
active: true,
67-
task: "Ship the workspace",
68-
progress: 1,
69-
});
46+
const container = renderToContainer(
47+
renderAgentStatus(widget({ props: { limit: 2 } }), {
48+
sessions: [
49+
{
50+
key: "agent:one",
51+
displayName: "One",
52+
hasActiveRun: true,
53+
goal: { objective: "Ship the workspace", tokensUsed: 125, tokenBudget: 100 },
54+
},
55+
{ key: "agent:two", status: "idle" },
56+
{ displayName: "missing key" },
57+
],
58+
}),
59+
);
60+
expect(container.querySelectorAll(".workspace-list__row")).toHaveLength(2);
61+
expect(container.textContent).toContain("Ship the workspace");
62+
expect(container.textContent).toContain("100");
63+
expect(container.textContent).not.toContain("missing key");
7064
});
7165

7266
it("renders accessible status text and an empty state", () => {
@@ -102,7 +96,6 @@ describe("approvals mapping", () => {
10296
]);
10397
source.onDecide(source.pending[0]!, "reject");
10498
expect(decisions).toEqual([["pending", "rejected"]]);
105-
expect(toWidgetApprovalDecision("approve")).toBe("approved");
10699
});
107100

108101
it("limits rows and renders explicit approval controls", () => {
@@ -113,13 +106,13 @@ describe("approvals mapping", () => {
113106
],
114107
onDecide: () => undefined,
115108
};
116-
expect(mapApprovals(widget({ props: { limit: 1 } }), source)).toMatchObject({ total: 2 });
117109
const container = renderToContainer(
118110
renderApprovals(widget({ props: { limit: 1 } }), undefined, {
119111
...STRICT_EMBED,
120112
approvals: source,
121113
}),
122114
);
115+
expect(container.querySelectorAll(".workspace-list__row")).toHaveLength(1);
123116
expect(container.querySelectorAll("button")).toHaveLength(2);
124117
expect(container.textContent).toContain("Approve");
125118
expect(container.textContent).toContain("Reject");

0 commit comments

Comments
 (0)