Skip to content

Commit f3c1ae4

Browse files
fix(skills): preserve picked files through provider dispatch
1 parent 4d3a3b5 commit f3c1ae4

20 files changed

Lines changed: 397 additions & 261 deletions

‎apps/mobile/src/features/threads/use-composer-command-menu.test.ts‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,41 @@ describe("workspace command discovery retry", () => {
180180
vi.unstubAllGlobals();
181181
});
182182

183+
it("offers and inserts each same-name skill from both mobile menus", async () => {
184+
const skills = [
185+
{ name: "review.v2", path: "/repo/my skills/100%/SKILL.md", enabled: true },
186+
{ name: "review.v2", path: "/home/me/review/SKILL.md", enabled: true },
187+
];
188+
const changed = vi.fn();
189+
const menus: ReturnType<typeof useComposerCommandMenu>[] = [];
190+
function SkillMenu({ prefix }: { prefix: string }) {
191+
menus.push(
192+
useComposerCommandMenu({
193+
draftMessage: prefix,
194+
ownerKey: null,
195+
environmentId: null,
196+
projectCwd: null,
197+
selectedProviderStatus: { ...provider, skills },
198+
hasThread: false,
199+
hasCompactableConversation: false,
200+
onChangeDraftMessage: changed,
201+
}),
202+
);
203+
return null;
204+
}
205+
for (const prefix of ["$", "/"]) {
206+
await act(async () => root.render(createElement(SkillMenu, { prefix, key: prefix })));
207+
const menu = menus.at(-1)!;
208+
const items = menu.items.filter((item) => item.type === "skill");
209+
expect(items.map((item) => item.description)).toEqual(skills.map((skill) => skill.path));
210+
expect(new Set(items.map((item) => item.id)).size).toBe(2);
211+
await act(async () => menu.onSelect(items[0]!));
212+
expect(changed).toHaveBeenLastCalledWith("[$review.v2](/repo/my%20skills/100%25/SKILL.md) ");
213+
await act(async () => menu.onSelect(items[1]!));
214+
expect(changed).toHaveBeenLastCalledWith("[$review.v2](/home/me/review/SKILL.md) ");
215+
}
216+
});
217+
183218
it("retries partial commands after the cooldown without editing the draft", async () => {
184219
const recovered = {
185220
...provider,

‎apps/mobile/src/features/threads/use-composer-command-menu.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
scoreQueryMatch,
3838
} from "@t3tools/shared/searchRanking";
3939
import {
40-
dedupeProviderSkillsByPath,
40+
dedupeProviderSkills,
4141
formatProviderSkillMention,
4242
formatProviderSkillMenuDescription,
4343
getProviderSkillsForSlashMenu,
@@ -136,7 +136,6 @@ export function resolveComposerCommandSelection(input: {
136136
readonly draftMessage: string;
137137
readonly trigger: Pick<ComposerTrigger, "rangeStart" | "rangeEnd">;
138138
readonly item: ComposerCommandItem;
139-
/** The provider's skills, to bind a pick to its file when another skill shares its name. */
140139
readonly skills?: ReadonlyArray<ServerProviderSkill>;
141140
readonly allowInteractionMode: boolean;
142141
}): {
@@ -416,7 +415,7 @@ export function useComposerCommandMenu({
416415
}
417416

418417
if (trigger.kind === "skill") {
419-
const enabledSkills = dedupeProviderSkillsByPath(skills.filter(isProviderSkillUserInvocable));
418+
const enabledSkills = dedupeProviderSkills(skills.filter(isProviderSkillUserInvocable));
420419
const normalizedQuery = normalizeSearchQuery(trigger.query, {
421420
trimLeadingPattern: /^\p{Sc}+/u,
422421
});

‎apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts‎

Lines changed: 73 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,15 +1473,6 @@ describe("CodexAdapterV2 skill mentions", () => {
14731473
assert.equal(CodexAdapterV2.codexSkillMentionText(text), expected, text);
14741474
}
14751475
});
1476-
1477-
it("sends a linked skill as a structured input for its exact file", () => {
1478-
const path = String.raw`C:\Users\Jane Doe\skills (old)\review\SKILL.md`;
1479-
const link = String.raw`[$review](C:\Users\Jane%20Doe\skills%20%28old%29\review\SKILL.md)`;
1480-
assert.deepEqual(CodexAdapterV2.codexSkillInputs(`Run ${link} then ${link} and €lint`), {
1481-
text: "Run $review then $review and $lint",
1482-
skills: [{ type: "skill", name: "review", path }],
1483-
});
1484-
});
14851476
});
14861477

14871478
describe("CodexAdapterV2 background command detail", () => {
@@ -1617,6 +1608,7 @@ function codexReplayPreamble(input: {
16171608
readonly nativeTurnId: string;
16181609
readonly prompt: string;
16191610
readonly sentPrompt?: string;
1611+
readonly skills?: ReadonlyArray<{ type: "skill"; name: string; path: string }>;
16201612
}): Array<CodexReplay.CodexAppServerReplayEntry> {
16211613
return [
16221614
{
@@ -1707,7 +1699,10 @@ function codexReplayPreamble(input: {
17071699
method: "turn/start",
17081700
params: {
17091701
threadId: input.nativeThreadId,
1710-
input: [{ type: "text", text: input.sentPrompt ?? input.prompt }],
1702+
input: [
1703+
{ type: "text", text: input.sentPrompt ?? input.prompt },
1704+
...(input.skills ?? []),
1705+
],
17111706
cwd: "/workspace",
17121707
model: "gpt-5.4",
17131708
approvalPolicy: "never",
@@ -2567,68 +2562,78 @@ describe("CodexAdapterV2 post-settle continuation", () => {
25672562
),
25682563
);
25692564

2570-
it.effect("sends currency-sigil skill mentions to Codex as $ mentions", () =>
2571-
Effect.gen(function* () {
2572-
const nativeThreadId = "skill-sigil-thread";
2573-
const nativeTurnId = "skill-sigil-turn";
2574-
const transcript = makeCodexReplayTranscript({
2575-
scenario: "skill-sigil-canonicalized",
2576-
entries: [
2577-
...codexReplayPreamble({
2578-
nativeThreadId,
2579-
nativeTurnId,
2580-
prompt: "€review do it",
2581-
sentPrompt: "$review do it",
2582-
}),
2583-
{
2584-
type: "expect_outbound",
2585-
label: "turn/steer",
2586-
frame: {
2587-
id: 4,
2588-
method: "turn/steer",
2589-
params: {
2590-
expectedTurnId: nativeTurnId,
2591-
input: [{ type: "text", text: "then $ship it" }],
2592-
threadId: nativeThreadId,
2565+
it.effect(
2566+
"binds picked skill files in Codex start and steer while retaining plain mentions",
2567+
() =>
2568+
Effect.gen(function* () {
2569+
const nativeThreadId = "skill-sigil-thread";
2570+
const nativeTurnId = "skill-sigil-turn";
2571+
const firstPath = String.raw`C:\Users\Jane Doe\100% (old)\review\SKILL.md`;
2572+
const first = String.raw`[$review.v2](C:\Users\Jane%20Doe\100%25%20%28old%29\review\SKILL.md)`;
2573+
const secondPath = "/repo/skills/review/SKILL.md";
2574+
const second = `[$review.v2](${secondPath})`;
2575+
const transcript = makeCodexReplayTranscript({
2576+
scenario: "skill-sigil-canonicalized",
2577+
entries: [
2578+
...codexReplayPreamble({
2579+
nativeThreadId,
2580+
nativeTurnId,
2581+
prompt: `${first} then ${first} and €lint`,
2582+
sentPrompt: "$review.v2 then $review.v2 and $lint",
2583+
skills: [{ type: "skill", name: "review.v2", path: firstPath }],
2584+
}),
2585+
{
2586+
type: "expect_outbound",
2587+
label: "turn/steer",
2588+
frame: {
2589+
id: 4,
2590+
method: "turn/steer",
2591+
params: {
2592+
expectedTurnId: nativeTurnId,
2593+
input: [
2594+
{ type: "text", text: "then $ship and $review.v2" },
2595+
{ type: "skill", name: "review.v2", path: secondPath },
2596+
],
2597+
threadId: nativeThreadId,
2598+
},
25932599
},
25942600
},
2601+
{
2602+
type: "emit_inbound",
2603+
label: "turn/steer",
2604+
frame: { id: 4, result: { turnId: nativeTurnId } },
2605+
},
2606+
],
2607+
});
2608+
const harness = yield* makeCodexReplayHarness(transcript);
2609+
const turnInput = makeCodexTestTurnInput({
2610+
threadId: harness.threadId,
2611+
providerThread: harness.providerThread,
2612+
now: yield* DateTime.now,
2613+
attemptId: RunAttemptId.make("skill-sigil-attempt"),
2614+
text: `${first} then ${first} and €lint`,
2615+
});
2616+
yield* harness.runtime.startTurn(turnInput);
2617+
yield* harness.runtime.steerTurn({
2618+
threadId: harness.threadId,
2619+
runId: turnInput.runId,
2620+
providerThread: harness.providerThread,
2621+
providerTurnId: (yield* IdAllocator.IdAllocatorV2).derive.providerTurn({
2622+
driver: CodexAdapterV2.CODEX_DRIVER_KIND,
2623+
nativeTurnId,
2624+
}),
2625+
message: {
2626+
...turnInput.message,
2627+
messageId: MessageId.make("message-skill-sigil-steer"),
2628+
text: `then £ship and ${second}`,
25952629
},
2596-
{
2597-
type: "emit_inbound",
2598-
label: "turn/steer",
2599-
frame: { id: 4, result: { turnId: nativeTurnId } },
2600-
},
2601-
],
2602-
});
2603-
const harness = yield* makeCodexReplayHarness(transcript);
2604-
const turnInput = makeCodexTestTurnInput({
2605-
threadId: harness.threadId,
2606-
providerThread: harness.providerThread,
2607-
now: yield* DateTime.now,
2608-
attemptId: RunAttemptId.make("skill-sigil-attempt"),
2609-
text: "€review do it",
2610-
});
2611-
yield* harness.runtime.startTurn(turnInput);
2612-
yield* harness.runtime.steerTurn({
2613-
threadId: harness.threadId,
2614-
runId: turnInput.runId,
2615-
providerThread: harness.providerThread,
2616-
providerTurnId: (yield* IdAllocator.IdAllocatorV2).derive.providerTurn({
2617-
driver: CodexAdapterV2.CODEX_DRIVER_KIND,
2618-
nativeTurnId,
2619-
}),
2620-
message: {
2621-
...turnInput.message,
2622-
messageId: MessageId.make("message-skill-sigil-steer"),
2623-
text: "then £ship it",
2624-
},
2625-
});
2626-
}).pipe(
2627-
Effect.scoped,
2628-
Effect.provide(
2629-
Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
2630+
});
2631+
}).pipe(
2632+
Effect.scoped,
2633+
Effect.provide(
2634+
Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
2635+
),
26302636
),
2631-
),
26322637
);
26332638

26342639
const assistantMessages = (events: ReadonlyArray<ProviderAdapter.ProviderAdapterV2Event>) =>

‎apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -420,13 +420,8 @@ export function codexSkillMentionText(text: string): string {
420420
return text.replace(SKILL_MENTION_PATTERN, "$1$$$2");
421421
}
422422

423-
/**
424-
* A skill picked from a shared name arrives as a link to its SKILL.md. Codex
425-
* gets it as a structured skill input, which binds that exact file; the link
426-
* in the text becomes `$name`, which Codex does not resolve again once a
427-
* structured input selected that name.
428-
*/
429-
export function codexSkillInputs(text: string) {
423+
// Codex skips name resolution for names already selected by structured input.
424+
function codexSkillInputs(text: string) {
430425
const mentions = collectLinkedSkillMentions(text);
431426
return {
432427
text: codexSkillMentionText(

0 commit comments

Comments
 (0)