Skip to content

Commit e8044fd

Browse files
authored
fix(ui): group Skill Workshop applied revisions per skill with inline history (#125794)
The Applied view rendered every applied proposal as an independent recency-sorted row, so one skill's revision history looked like duplicate skills. Applied now shows one row per live skill with a revision-count badge and grouped tab count; the detail pane gains a lazily loaded History section with operations from the ledger's recorded kind. Pending/rejected/quarantined/stale keep one row per proposal. Fixes #125632
1 parent 029f6c1 commit e8044fd

15 files changed

Lines changed: 687 additions & 148 deletions

‎config/assertion-safety-baseline.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4297,7 +4297,7 @@ ui/src/pages/skill-workshop/header-controls.ts 1
42974297
ui/src/pages/skill-workshop/route.ts 1
42984298
ui/src/pages/skill-workshop/self-learning.ts 1
42994299
ui/src/pages/skill-workshop/skill-workshop-page.ts 1
4300-
ui/src/pages/skill-workshop/view.ts 2
4300+
ui/src/pages/skill-workshop/view.ts 1
43014301
ui/src/pages/skills/view.ts 3
43024302
ui/src/pages/usage/heatmap.ts 1
43034303
ui/src/pages/usage/usage-page.ts 1

‎ui/src/i18n/locales/en.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3494,6 +3494,14 @@ export const en: TranslationMap = {
34943494
yesterday: "Yesterday",
34953495
earlier: "Earlier this week",
34963496
},
3497+
applied: {
3498+
history: "History",
3499+
revision: "{count} revision",
3500+
revisions: "{count} revisions",
3501+
create: "Create",
3502+
update: "Update",
3503+
version: "v{version}",
3504+
},
34973505
previewContext: "in {slug}",
34983506
actions: {
34993507
close: "Close",
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import { describe, expect, it } from "vitest";
2+
import {
3+
filterSkillWorkshopAppliedSkills,
4+
filterSkillWorkshopProposals,
5+
type SkillWorkshopProposal,
6+
type SkillWorkshopProposalStatus,
7+
} from "./index.ts";
8+
9+
function proposal(options: {
10+
key: string;
11+
kind?: SkillWorkshopProposal["kind"];
12+
status?: SkillWorkshopProposalStatus;
13+
slug?: string;
14+
description?: string;
15+
updatedAt?: number;
16+
}): SkillWorkshopProposal {
17+
const kind = options.kind ?? "update";
18+
return {
19+
key: options.key,
20+
kind,
21+
slug: options.slug ?? "release-sanity",
22+
name: `${kind === "create" ? "Create" : "Update"} ${options.slug ?? "release-sanity"}`,
23+
oneLine: options.description ?? `Description for ${options.key}`,
24+
body: "## Workflow\n- Verify the release.",
25+
status: options.status ?? "applied",
26+
version: 1,
27+
revisionHash: null,
28+
createdAt: options.updatedAt ?? 1,
29+
updatedAt: options.updatedAt,
30+
recencyGroup: "today",
31+
ageLabel: "now",
32+
supportFiles: [],
33+
isNew: false,
34+
};
35+
}
36+
37+
describe("Skill Workshop proposal filtering", () => {
38+
it("keeps every revision in an update-only lineage labeled Update", () => {
39+
const [skill] = filterSkillWorkshopAppliedSkills(
40+
[proposal({ key: "new", updatedAt: 2 }), proposal({ key: "old", updatedAt: 1 })],
41+
"",
42+
);
43+
44+
expect(skill?.revisions.map(({ operation }) => operation)).toEqual(["update", "update"]);
45+
});
46+
47+
it("groups applied revisions with deterministic order and recorded operations", () => {
48+
const proposals = [
49+
proposal({ key: "revision-a", updatedAt: 1 }),
50+
proposal({ key: "revision-c", updatedAt: 3 }),
51+
proposal({ key: "revision-b", kind: "create", updatedAt: 2 }),
52+
proposal({ key: "revision-d", updatedAt: 3 }),
53+
];
54+
55+
expect(filterSkillWorkshopProposals(proposals, "applied", "").map((item) => item.key)).toEqual([
56+
"revision-d",
57+
]);
58+
const [skill] = filterSkillWorkshopAppliedSkills(proposals, "");
59+
expect(
60+
skill?.revisions.map(({ proposal: revisionProposal, operation, version }) => ({
61+
key: revisionProposal.key,
62+
operation,
63+
version,
64+
})),
65+
).toEqual([
66+
{ key: "revision-d", operation: "update", version: 4 },
67+
{ key: "revision-c", operation: "update", version: 3 },
68+
{ key: "revision-b", operation: "create", version: 2 },
69+
{ key: "revision-a", operation: "update", version: 1 },
70+
]);
71+
});
72+
73+
it("searches every revision while returning the grouped skill row", () => {
74+
const proposals = [
75+
proposal({ key: "new", description: "Current release checks", updatedAt: 2 }),
76+
proposal({ key: "old", description: "Legacy rollback phrase", updatedAt: 1 }),
77+
];
78+
79+
expect(
80+
filterSkillWorkshopProposals(proposals, "applied", "legacy rollback").map((item) => item.key),
81+
).toEqual(["new"]);
82+
});
83+
84+
it("keeps non-applied filters and the all view proposal-based", () => {
85+
const proposals = [
86+
proposal({ key: "pending", status: "pending" }),
87+
proposal({ key: "rejected", status: "rejected" }),
88+
proposal({ key: "quarantined", status: "quarantined" }),
89+
proposal({ key: "stale", status: "stale" }),
90+
proposal({ key: "applied-a" }),
91+
proposal({ key: "applied-b" }),
92+
];
93+
94+
for (const status of ["pending", "rejected", "quarantined", "stale"] as const) {
95+
expect(filterSkillWorkshopProposals(proposals, status, "").map((item) => item.key)).toEqual([
96+
status,
97+
]);
98+
}
99+
expect(filterSkillWorkshopProposals(proposals, "all", "")).toEqual(proposals);
100+
});
101+
});

‎ui/src/lib/skill-workshop/index.ts‎

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export type SkillWorkshopEvaluation = {
5252

5353
export type SkillWorkshopProposal = {
5454
key: string;
55+
kind: "create" | "update";
5556
slug: string;
5657
name: string;
5758
oneLine: string;
@@ -89,21 +90,86 @@ export type SkillWorkshopActionNotice = {
8990
slug: string;
9091
};
9192

93+
type SkillWorkshopAppliedRevision = {
94+
proposal: SkillWorkshopProposal;
95+
version: number;
96+
operation: SkillWorkshopProposal["kind"];
97+
};
98+
99+
export type SkillWorkshopAppliedSkill = {
100+
slug: string;
101+
latest: SkillWorkshopProposal;
102+
revisions: SkillWorkshopAppliedRevision[];
103+
};
104+
105+
function compareWorkshopProposals(
106+
left: SkillWorkshopProposal,
107+
right: SkillWorkshopProposal,
108+
): number {
109+
const timeDifference = (right.updatedAt ?? right.createdAt) - (left.updatedAt ?? left.createdAt);
110+
if (timeDifference !== 0) {
111+
return timeDifference;
112+
}
113+
if (left.key === right.key) {
114+
return 0;
115+
}
116+
return left.key < right.key ? 1 : -1;
117+
}
118+
119+
function matchesWorkshopQuery(proposal: SkillWorkshopProposal, query: string): boolean {
120+
return `${proposal.name} ${proposal.oneLine} ${proposal.slug}`.toLowerCase().includes(query);
121+
}
122+
123+
function groupSkillWorkshopAppliedSkills(
124+
proposals: SkillWorkshopProposal[],
125+
): SkillWorkshopAppliedSkill[] {
126+
const revisionsBySlug = new Map<string, [SkillWorkshopProposal, ...SkillWorkshopProposal[]]>();
127+
const applied = proposals
128+
.filter((proposal) => proposal.status === "applied")
129+
.toSorted(compareWorkshopProposals);
130+
for (const proposal of applied) {
131+
const revisions = revisionsBySlug.get(proposal.slug);
132+
if (revisions) {
133+
revisions.push(proposal);
134+
} else {
135+
revisionsBySlug.set(proposal.slug, [proposal]);
136+
}
137+
}
138+
return Array.from(revisionsBySlug, ([slug, proposalsForSkill]) => ({
139+
slug,
140+
latest: proposalsForSkill[0],
141+
revisions: proposalsForSkill.map((proposal, index) => {
142+
const version = proposalsForSkill.length - index;
143+
return { proposal, version, operation: proposal.kind };
144+
}),
145+
}));
146+
}
147+
148+
export function filterSkillWorkshopAppliedSkills(
149+
proposals: SkillWorkshopProposal[],
150+
query: string,
151+
): SkillWorkshopAppliedSkill[] {
152+
const q = query.trim().toLowerCase();
153+
return groupSkillWorkshopAppliedSkills(proposals).filter(
154+
(skill) => !q || skill.revisions.some(({ proposal }) => matchesWorkshopQuery(proposal, q)),
155+
);
156+
}
157+
92158
export function filterSkillWorkshopProposals(
93159
proposals: SkillWorkshopProposal[],
94160
statusFilter: SkillWorkshopStatusFilter,
95161
query: string,
96162
): SkillWorkshopProposal[] {
97163
const q = query.trim().toLowerCase();
164+
if (statusFilter === "applied") {
165+
return filterSkillWorkshopAppliedSkills(proposals, query).map((skill) => skill.latest);
166+
}
98167
return proposals.filter((p) => {
99168
if (statusFilter !== "all" && p.status !== statusFilter) {
100169
return false;
101170
}
102-
if (q) {
103-
const hay = `${p.name} ${p.oneLine} ${p.slug}`.toLowerCase();
104-
if (!hay.includes(q)) {
105-
return false;
106-
}
171+
if (q && !matchesWorkshopQuery(p, q)) {
172+
return false;
107173
}
108174
return true;
109175
});
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { html } from "lit";
2+
import { t } from "../../i18n/index.ts";
3+
import type { SkillWorkshopAppliedSkill } from "../../lib/skill-workshop/index.ts";
4+
import type { SkillWorkshopProps } from "./view-types.ts";
5+
6+
export function renderAppliedHistory(props: SkillWorkshopProps, skill: SkillWorkshopAppliedSkill) {
7+
return html`
8+
<section class="sw-section sw-applied-history">
9+
<h3 class="sw-section__label">${t("skillWorkshop.applied.history")}</h3>
10+
<div class="sw-applied-history__list">
11+
${skill.revisions.map(({ proposal, operation, version }) => {
12+
const selected = proposal.key === props.selectedKey;
13+
return html`
14+
<button
15+
class="sw-applied-history__item ${selected ? "is-selected" : ""}"
16+
aria-current=${selected ? "true" : "false"}
17+
@click=${() => props.onSelect(proposal.key)}
18+
>
19+
<span class="sw-applied-history__operation">
20+
${t(`skillWorkshop.applied.${operation}`)}
21+
</span>
22+
<span class="sw-applied-history__age">${proposal.ageLabel}</span>
23+
<span class="sw-applied-history__version">
24+
${t("skillWorkshop.applied.version", { version: String(version) })}
25+
</span>
26+
</button>
27+
`;
28+
})}
29+
</div>
30+
</section>
31+
`;
32+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { html } from "lit";
2+
import { until } from "lit/directives/until.js";
3+
import { t } from "../../i18n/index.ts";
4+
import {
5+
filterSkillWorkshopAppliedSkills,
6+
type SkillWorkshopAppliedSkill,
7+
type SkillWorkshopProposal,
8+
} from "../../lib/skill-workshop/index.ts";
9+
import type { SkillWorkshopProps } from "./view-types.ts";
10+
11+
type AppliedHistoryRenderer = typeof import("./applied-history.runtime.ts").renderAppliedHistory;
12+
13+
let appliedHistoryRenderer: AppliedHistoryRenderer | undefined;
14+
let appliedHistoryRuntime: Promise<AppliedHistoryRenderer> | undefined;
15+
16+
function loadAppliedHistoryRenderer(): Promise<AppliedHistoryRenderer> {
17+
return (appliedHistoryRuntime ??= import("./applied-history.runtime.ts").then((runtime) => {
18+
appliedHistoryRenderer = runtime.renderAppliedHistory;
19+
return appliedHistoryRenderer;
20+
}));
21+
}
22+
23+
export function resolveAppliedHistory(
24+
proposals: SkillWorkshopProposal[],
25+
query: string,
26+
selectedKey: string | null,
27+
) {
28+
const skills = filterSkillWorkshopAppliedSkills(proposals, query);
29+
const selectedSkill =
30+
skills.find((skill) => skill.revisions.some(({ proposal }) => proposal.key === selectedKey)) ??
31+
skills[0];
32+
const selectedProposal =
33+
selectedSkill?.revisions.find(({ proposal }) => proposal.key === selectedKey)?.proposal ??
34+
selectedSkill?.latest;
35+
return { skills, selectedSkill, selectedProposal };
36+
}
37+
38+
export function renderLazyAppliedHistory(
39+
props: SkillWorkshopProps,
40+
skill: SkillWorkshopAppliedSkill,
41+
) {
42+
if (appliedHistoryRenderer) {
43+
return appliedHistoryRenderer(props, skill);
44+
}
45+
return until(
46+
loadAppliedHistoryRenderer().then((renderer) => renderer(props, skill)),
47+
html`<p class="sw-muted" aria-busy="true">${t("common.loading")}</p>`,
48+
);
49+
}

‎ui/src/pages/skill-workshop/evaluation.browser.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ const evaluation: SkillWorkshopEvaluation = {
7070

7171
const proposal: SkillWorkshopProposal = {
7272
key: "proposal-1",
73+
kind: "update",
7374
slug: "inbox-cleaner",
7475
name: "Inbox Cleaner",
7576
oneLine: "Clean inbox triage",

0 commit comments

Comments
 (0)