Skip to content

Commit b59f041

Browse files
juliusmarmingefloklein
authored andcommitted
fix(web): show a sent same-name skill pick as its skill chip
A picked same-name skill is sent as [$name](…/SKILL.md), which the message renderer showed as a plain link. Render it as the skill chip for that file, with its details and View instructions. AI-assisted; verified with the tests and tools listed above.
1 parent 57505ef commit b59f041

2 files changed

Lines changed: 57 additions & 1 deletion

File tree

‎apps/web/src/components/ChatMarkdown.browser.test.tsx‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,38 @@ describe("ChatMarkdown skill chips", () => {
466466
expect(openFile).toHaveBeenCalledExactlyOnceWith(threadRef, "/skills/review/SKILL.md");
467467
});
468468

469+
it("shows a picked same-name skill as that file's chip", async () => {
470+
setup();
471+
const threadRef = {
472+
environmentId: EnvironmentId.make("workspace"),
473+
threadId: ThreadId.make("thread"),
474+
};
475+
const review = { name: "review", enabled: true };
476+
await using screen = await renderText("Run [$review](/repo/my%20skills/review/SKILL.md) now", {
477+
threadRef,
478+
skills: [
479+
{ ...review, displayName: "User review", path: "/home/me/skills/review/SKILL.md" },
480+
{
481+
...review,
482+
displayName: "Project review",
483+
description: "Reviews the project.",
484+
path: "/repo/my skills/review/SKILL.md",
485+
},
486+
],
487+
});
488+
using openFile = vi
489+
.spyOn(useRightPanelStore.getState(), "openFile")
490+
.mockImplementation(() => {});
491+
492+
await userEvent.click(
493+
screen.getByRole("button", { name: "Skill Project review. Show details" }),
494+
);
495+
await expect.element(page.getByText("Reviews the project.")).toBeVisible();
496+
await userEvent.click(page.getByRole("button", { name: "View instructions" }));
497+
498+
expect(openFile).toHaveBeenCalledExactlyOnceWith(threadRef, "/repo/my skills/review/SKILL.md");
499+
});
500+
469501
it("names a mentioned model as its provider does, without a thread", async () => {
470502
setup();
471503
await using screen = await renderText("Ask (model:codex/gpt-6.1), not model:openai/gpt-4o.", {

‎apps/web/src/components/ChatMarkdown.tsx‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { clientHostEnvironmentAtom } from "../state/clientHostEnvironment";
22
import { buildFileLinkParentSuffixByPath, fileLinkLabel } from "@t3tools/shared/fileLinks";
3+
import { collectComposerInlineTokens } from "@t3tools/shared/composerInlineTokens";
4+
import { formatProviderSkillDisplayName } from "@t3tools/shared/inlineSkills";
35
import {
46
isWindowsDrivePathHref,
57
normalizeMarkdownLinkDestination,
@@ -104,7 +106,12 @@ import {
104106
artifactTemplateFromHastProperties,
105107
renderCodexInlineDirectivesAsMarkdown,
106108
} from "@t3tools/shared/codexMarkdownDirectives";
107-
import { renderSkillInlineMarkdownChildren } from "./chat/SkillInlineText";
109+
import {
110+
renderSkillInlineMarkdownChildren,
111+
SkillChipPopover,
112+
skillInstructionsOpener,
113+
skillPopoverDescription,
114+
} from "./chat/SkillInlineText";
108115
import { MarkdownMath } from "./chat/MarkdownMath";
109116
import {
110117
resolveMarkdownMediaPreview,
@@ -1105,6 +1112,7 @@ const CHAT_MARKDOWN_COMPONENTS = {
11051112
updateThreadPullRequestLink,
11061113
fileLinkChip,
11071114
renderContextReference,
1115+
skills,
11081116
} = use(ChatMarkdownRendererContext);
11091117
const text = use(ChatMarkdownTextContext);
11101118
const citation = href ? parseAssistantCitationHref(href) : null;
@@ -1129,6 +1137,22 @@ const CHAT_MARKDOWN_COMPONENTS = {
11291137
<span>{label}</span>
11301138
);
11311139
}
1140+
// A picked same-name skill is sent as `[$name](…/SKILL.md)`; show it as that file's chip.
1141+
const linkedSkill = href
1142+
? collectComposerInlineTokens(`[${hastPlainTextDeep(node)}](${href}) `)[0]
1143+
: undefined;
1144+
if (linkedSkill?.type === "skill" && linkedSkill.path !== undefined) {
1145+
const skillPath = linkedSkill.path;
1146+
const skill = skills.find((candidate) => candidate.path === skillPath);
1147+
return (
1148+
<SkillChipPopover
1149+
label={skill ? formatProviderSkillDisplayName(skill) : linkedSkill.value}
1150+
description={skill ? skillPopoverDescription(skill) : null}
1151+
copyMarkdown={linkedSkill.source}
1152+
onViewInstructions={skillInstructionsOpener(threadRef, { path: skillPath })}
1153+
/>
1154+
);
1155+
}
11321156
const normalizedHref = href ? normalizeMarkdownLinkHrefKey(href) : "";
11331157
const fileLinkMeta = normalizedHref
11341158
? (markdownFileLinkMetaByHref.get(normalizedHref) ??

0 commit comments

Comments
 (0)