Skip to content

Commit fe4de4f

Browse files
fix: show catalog skill labels after a turn
Wire mounts keep the FQN on name, which the chips render. Restore the catalog label on reconcile, and stop copying that FQN onto id at load. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 547bc4c commit fe4de4f

3 files changed

Lines changed: 28 additions & 9 deletions

File tree

‎packages/trueforge-ui/src/atoms/draft/DraftSpecPreferenceBridge.tsx‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,20 @@ function skillAvailableKeys(skills: AgentSkill[]): Set<string> {
5252
return keys;
5353
}
5454

55+
/** Chips render `name`. A post-turn mount stores the FQN there; swap in the catalog label. */
56+
function labelSkillMounts(mounts: object[] | undefined, skills: readonly AgentSkill[]): object[] | undefined {
57+
if (mounts === undefined) return undefined;
58+
let changed = false;
59+
const next = mounts.map(mount => {
60+
const name = mountName(mount);
61+
const catalog = skills.find(skill => skill.id === name);
62+
if (catalog === undefined || name === catalog.name) return mount;
63+
changed = true;
64+
return { ...mount, id: catalog.id, name: catalog.name };
65+
});
66+
return changed ? next : mounts;
67+
}
68+
5569
export function reconcileDraftSpecPreferences({
5670
agentSpec,
5771
models,
@@ -90,8 +104,10 @@ export function reconcileDraftSpecPreferences({
90104
update.skills = [];
91105
}
92106
} else {
93-
// Catalog `name` is display; wire/session mounts use FQN on `name` (and optional `id`).
94-
const nextSkills = filterMounts(agentSpec.skills, skillAvailableKeys(skills), { matchFamily: true });
107+
const nextSkills = labelSkillMounts(
108+
filterMounts(agentSpec.skills, skillAvailableKeys(skills), { matchFamily: true }),
109+
skills,
110+
);
95111
if (nextSkills !== agentSpec.skills) {
96112
update.skills = nextSkills;
97113
}

‎packages/trueforge-ui/src/plugins/trueforge-agent-server-adapter/chatServer.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ function toUiMcpServer(server: TrueForgeApi.McpServer): HarnessMcpServerMount {
4444
}
4545

4646
function toUiSkill(skill: TrueForgeApi.Skill): HarnessSkillMount {
47-
// Wire Skill is name-only (FQN). Restore picker `id` so family matching survives load.
48-
return { id: skill.name, name: skill.name, preload: skill.preload === true };
47+
// Wire Skill is name-only. Catalog reconcile restores picker id + display name.
48+
return { name: skill.name, preload: skill.preload === true };
4949
}
5050

5151
function toHarnessSkill(skill: HarnessSkillMount): TrueForgeApi.Skill {

‎packages/trueforge-ui/test/atoms/draft/DraftCatalogProvider.test.tsx‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,20 +174,21 @@ describe('DraftCatalogProvider', () => {
174174
expect(update.skills).toEqual([]);
175175
});
176176

177-
it('keeps post-turn FQN skill mounts that match catalog attach keys', () => {
178-
const skills = [{ name: 'agent-skill:acme/team/echo:3' }];
177+
it('restores the catalog display name for post-turn FQN skill mounts', () => {
179178
const update = reconcileDraftSpecPreferences({
180179
agentSpec: {
181180
model: { name: 'live/model' },
182-
skills,
181+
skills: [{ name: 'agent-skill:acme/team/echo:3', preload: false }],
183182
},
184183
models: [{ id: 'live/model', name: 'live/model', provider: { name: 'Live' }, properties: {} }],
185184
skills: [{ id: 'agent-skill:acme/team/echo:3', name: 'echo' }],
186185
connectors: [],
187186
skillsEnabled: true,
188187
});
189188

190-
expect(update).toEqual({});
189+
expect(update).toEqual({
190+
skills: [{ id: 'agent-skill:acme/team/echo:3', name: 'echo', preload: false }],
191+
});
191192
});
192193

193194
it('keeps skill mounts when only the version suffix differs from the catalog', () => {
@@ -218,7 +219,9 @@ describe('DraftCatalogProvider', () => {
218219
skillsEnabled: true,
219220
});
220221

221-
expect(update).toEqual({ skills: [{ name: 'agent-skill:acme/team/echo:3' }] });
222+
expect(update).toEqual({
223+
skills: [{ id: 'agent-skill:acme/team/echo:3', name: 'echo' }],
224+
});
222225
});
223226

224227
it('does not re-clear an already empty skills list when skills are unavailable', () => {

0 commit comments

Comments
 (0)