@devries-cameron20 / t3code Mirror · read-only / commits / 278588a61a
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 15:45 UTC

fix(web): skill chips in chat open the same details popover as the composer (#25432)

oliver committed Oct 26, 2026 at 13:04 UTC 278588a61a3a3c0cd7f18760ebed1bbd75e64acf
10 files changed +132 -70
apps/web/src/components/ChatMarkdown.browser.test.tsx
+32
@@ -2,6 +2,7 @@ import { EnvironmentId, ThreadId } from "@t3tools/contracts";
2 import { AsyncResult } from "effect/reactivity";
3 import { type ReactElement } from "react";
4 import { describe, expect, it, vi } from "vite-plus/test";
5 +import { page, userEvent } from "vite-plus/test/browser";
6
7 import { act, render } from "../../test/render";
8 import "../index.css";
@@ -260,6 +261,37 @@ describe("ChatMarkdown workspace file opens", () => {
261 });
262 });
263
264 +describe("ChatMarkdown skill chips", () => {
265 + it("shows the skill's details and opens its instructions", async () => {
266 + setup();
267 + const threadRef = {
268 + environmentId: EnvironmentId.make("workspace"),
269 + threadId: ThreadId.make("thread"),
270 + };
271 + await using screen = await renderText("Run $review now", {
272 + threadRef,
273 + skills: [
274 + {
275 + name: "review",
276 + displayName: "Review",
277 + description: "Reviews the current branch.",
278 + path: "/skills/review/SKILL.md",
279 + enabled: true,
280 + },
281 + ],
282 + });
283 + using openFile = vi
284 + .spyOn(useRightPanelStore.getState(), "openFile")
285 + .mockImplementation(() => {});
286 +
287 + await userEvent.click(screen.getByRole("button", { name: "Skill Review. Show details" }));
288 + await expect.element(page.getByText("Reviews the current branch.")).toBeVisible();
289 + await userEvent.click(page.getByRole("button", { name: "View instructions" }));
290 +
291 + expect(openFile).toHaveBeenCalledExactlyOnceWith(threadRef, "/skills/review/SKILL.md");
292 + });
293 +});
294 +
295 describe("ChatMarkdown headings", () => {
296 it("never gives two headings the same id, even when a suffix matches another heading", async () => {
297 setup();
apps/web/src/components/ChatMarkdown.tsx
+6 -6
@@ -227,7 +227,7 @@ interface ChatMarkdownProps {
227 environmentId?: EnvironmentId | undefined;
228 onTaskListChange?: ((input: { markerOffset: number; checked: boolean }) => void) | undefined;
229 isStreaming?: boolean;
230 - skills?: ReadonlyArray<Pick<ServerProviderSkill, "name" | "displayName">>;
230 + skills?: ReadonlyArray<ServerProviderSkill>;
231 className?: string;
232 lineBreaks?: boolean;
233 parseRawHtml?: boolean;
@@ -250,7 +250,7 @@ export interface ChatMarkdownContextReference {
250 label: string;
251 }
252
253 -const EMPTY_MARKDOWN_SKILLS: ReadonlyArray<Pick<ServerProviderSkill, "name" | "displayName">> = [];
253 +const EMPTY_MARKDOWN_SKILLS: ReadonlyArray<ServerProviderSkill> = [];
254 const EMPTY_REMARK_PLUGINS: NonNullable<ReactMarkdownOptions["remarkPlugins"]> = [];
255
256 const ARTIFACT_TEMPLATE_ICON_BY_KIND = {
@@ -958,8 +958,8 @@ const CHAT_MARKDOWN_COMPONENTS = {
958 return <div {...props}>{children}</div>;
959 },
960 p: function MarkdownParagraph({ node: _node, children, ...props }) {
961 - const { skills } = use(ChatMarkdownRendererContext);
962 - return <p {...props}>{renderSkillInlineMarkdownChildren(children, skills)}</p>;
961 + const { skills, threadRef } = use(ChatMarkdownRendererContext);
962 + return <p {...props}>{renderSkillInlineMarkdownChildren(children, skills, threadRef)}</p>;
963 },
964 blockquote: function MarkdownBlockquote({ node: _node, children, ...props }) {
965 const alert =
@@ -994,12 +994,12 @@ const CHAT_MARKDOWN_COMPONENTS = {
994 );
995 },
996 li: function MarkdownListItem({ node, children, ...props }) {
997 - const { skills } = use(ChatMarkdownRendererContext);
997 + const { skills, threadRef } = use(ChatMarkdownRendererContext);
998 // Resolve checkbox markers by offset to avoid rerendering list items on every streamed token.
999 const isTaskItem = String(props.className ?? "").includes("task-list-item");
1000 return (
1001 <li {...props} data-list-item-offset={isTaskItem ? node?.position?.start.offset : undefined}>
1002 - {renderSkillInlineMarkdownChildren(children, skills)}
1002 + {renderSkillInlineMarkdownChildren(children, skills, threadRef)}
1003 </li>
1004 );
1005 },
apps/web/src/components/ComposerPromptEditorTiptap.tsx
+7 -21
@@ -108,11 +108,9 @@ import { cn, isMacPlatform } from "~/lib/utils";
108 import { basenameOfPath } from "~/pierre-icons";
109 import { WorkspaceEntryTooltip } from "./chat/WorkspaceEntryIcon";
110 import { FileTagChipContent } from "./chat/FileTagChip";
111 -import { SkillChipIcon } from "./chat/SkillInlineText";
111 +import { SkillChipPopover, skillPopoverDescription } from "./chat/SkillInlineText";
112 import { AssistantCitationChip } from "./chat/AssistantCitationChip";
113 import { getTimelinePageScrollKey } from "./chat/pageScrollController";
114 -import { ContextChipPopover } from "./contextChipParts";
115 -import { Button } from "./ui/button";
114 import { ContextChip } from "./ContextChip";
115 import {
116 ComposerContextActionsContext,
@@ -348,31 +346,19 @@ function ComposerSkillNodeView({ node }: NodeViewProps) {
346 const skill = skills.find(
347 (candidate) => candidate.name === skillName && isProviderSkillUserInvocable(candidate),
348 );
351 - const description = skill
352 - ? skill.description?.trim() || skill.shortDescription?.trim()
353 - : skillDescription;
349 // The node outlives a provider switch, so its stored label can be another provider's.
350 const skillLabel = skill
351 ? formatProviderSkillDisplayName(skill)
352 : (node.attrs.skillLabel as string) || skillName;
353 return (
354 <NodeViewWrapper as="span" className={CHIP_NODE_SELECTION_CLASS_NAME}>
360 - <ContextChipPopover
361 - kind="skill"
362 - icon={<SkillChipIcon />}
355 + <SkillChipPopover
356 label={skillLabel}
364 - accessibleLabel={`Skill ${skillLabel}`}
365 - >
366 - <div className="space-y-3 p-2 text-sm">
367 - <p className="font-medium">{skillLabel}</p>
368 - <p>{description || "No description is available for this skill."}</p>
369 - {skill?.path && actions.environmentId ? (
370 - <Button variant="outline" size="sm" onClick={() => actions.openMention(skill.path)}>
371 - View instructions
372 - </Button>
373 - ) : null}
374 - </div>
375 - </ContextChipPopover>
357 + description={skill ? skillPopoverDescription(skill) : skillDescription}
358 + onViewInstructions={
359 + skill?.path && actions.environmentId ? () => actions.openMention(skill.path) : undefined
360 + }
361 + />
362 </NodeViewWrapper>
363 );
364 }
apps/web/src/components/chat/MessagesTimeline.tsx
+2 -2
@@ -157,7 +157,7 @@ function TimelineListFooter({
157 );
158 }
159
160 -const EMPTY_TIMELINE_SKILLS: ReadonlyArray<Pick<ServerProviderSkill, "name" | "displayName">> = [];
160 +const EMPTY_TIMELINE_SKILLS: ReadonlyArray<ServerProviderSkill> = [];
161 const TIMELINE_MAINTAIN_SCROLL_AT_END = {
162 animated: false,
163 on: {
@@ -253,7 +253,7 @@ interface MessagesTimelineProps {
253 resolvedTheme: "light" | "dark";
254 timestampFormat: TimestampFormat;
255 workspaceRoot: string | undefined;
256 - skills?: ReadonlyArray<Pick<ServerProviderSkill, "name" | "displayName">>;
256 + skills?: ReadonlyArray<ServerProviderSkill>;
257 runs: ReadonlyArray<HandoffTimelineRun>;
258 anchorMessageId: MessageId | null;
259 onAnchorReady: (messageId: MessageId, anchorIndex: number) => void;
apps/web/src/components/chat/SkillInlineText.tsx
+61 -13
@@ -1,11 +1,18 @@
1 +import type { ScopedThreadRef, ServerProviderSkill } from "@t3tools/contracts";
2 import { formatProviderSkillDisplayName } from "@t3tools/shared/inlineSkills";
3 import { Children, cloneElement, isValidElement, type ReactNode } from "react";
3 -import { matchInlineSkills, type InlineSkill } from "@t3tools/shared/inlineSkills";
4 +import { matchInlineSkills } from "@t3tools/shared/inlineSkills";
5
6 +import { useRightPanelStore } from "~/rightPanelStore";
7 import { SKILL_CHIP_ICON_SVG } from "../composerInlineChip";
6 -import { ContextChip, ContextChipLabel } from "../ContextChip";
8 +import { ContextChipPopover } from "../contextChipParts";
9 +import { Button } from "../ui/button";
10
8 -function SkillInlineText(props: { text: string; skills: ReadonlyArray<InlineSkill> }) {
11 +function SkillInlineText(props: {
12 + text: string;
13 + skills: ReadonlyArray<ServerProviderSkill>;
14 + threadRef: ScopedThreadRef | undefined;
15 +}) {
16 const nodes: ReactNode[] = [];
17 let cursor = 0;
18
@@ -13,7 +20,15 @@ function SkillInlineText(props: { text: string; skills: ReadonlyArray<InlineSkil
20 if (start > cursor) {
21 nodes.push(props.text.slice(cursor, start));
22 }
16 - nodes.push(<SkillChip key={`${start}:${skill.name}`} skill={skill} rawText={rawText} />);
23 + nodes.push(
24 + <SkillChipPopover
25 + key={`${start}:${skill.name}`}
26 + label={formatProviderSkillDisplayName(skill)}
27 + description={skillPopoverDescription(skill)}
28 + copyMarkdown={rawText}
29 + onViewInstructions={skillInstructionsOpener(props.threadRef, skill)}
30 + />,
31 + );
32 cursor = end;
33 }
34
@@ -28,11 +43,12 @@ function SkillInlineText(props: { text: string; skills: ReadonlyArray<InlineSkil
43
44 export function renderSkillInlineMarkdownChildren(
45 children: ReactNode,
31 - skills: ReadonlyArray<InlineSkill>,
46 + skills: ReadonlyArray<ServerProviderSkill>,
47 + threadRef: ScopedThreadRef | undefined,
48 ): ReactNode {
49 return Children.map(children, (child) => {
50 if (typeof child === "string") {
35 - return <SkillInlineText text={child} skills={skills} />;
51 + return <SkillInlineText text={child} skills={skills} threadRef={threadRef} />;
52 }
53 if (!isValidElement<{ children?: ReactNode; node?: { tagName?: string } }>(child)) {
54 return child;
@@ -48,21 +64,53 @@ export function renderSkillInlineMarkdownChildren(
64 return cloneElement(
65 child,
66 undefined,
51 - renderSkillInlineMarkdownChildren(child.props.children, skills),
67 + renderSkillInlineMarkdownChildren(child.props.children, skills, threadRef),
68 );
69 });
70 }
71
56 -function SkillChip(props: { skill: InlineSkill; rawText: string }) {
72 +export function skillPopoverDescription(
73 + skill: Pick<ServerProviderSkill, "description" | "shortDescription">,
74 +) {
75 + return skill.description?.trim() || skill.shortDescription?.trim() || null;
76 +}
77 +
78 +export function skillInstructionsOpener(
79 + threadRef: ScopedThreadRef | null | undefined,
80 + skill: Pick<ServerProviderSkill, "path"> | undefined,
81 +) {
82 + if (!threadRef || !skill?.path) return undefined;
83 + return () => useRightPanelStore.getState().openFile(threadRef, skill.path);
84 +}
85 +
86 +export function SkillChipPopover(props: {
87 + label: string;
88 + description: string | null | undefined;
89 + copyMarkdown?: string | undefined;
90 + onViewInstructions: (() => void) | undefined;
91 +}) {
92 return (
58 - <ContextChip kind="skill" data-markdown-copy={props.rawText}>
59 - <SkillChipIcon />
60 - <ContextChipLabel>{formatProviderSkillDisplayName(props.skill)}</ContextChipLabel>
61 - </ContextChip>
93 + <ContextChipPopover
94 + kind="skill"
95 + icon={<SkillChipIcon />}
96 + label={props.label}
97 + accessibleLabel={`Skill ${props.label}`}
98 + copyMarkdown={props.copyMarkdown}
99 + >
100 + <div className="space-y-3 p-2 text-sm">
101 + <p className="font-medium">{props.label}</p>
102 + <p>{props.description || "No description is available for this skill."}</p>
103 + {props.onViewInstructions ? (
104 + <Button variant="outline" size="sm" onClick={props.onViewInstructions}>
105 + View instructions
106 + </Button>
107 + ) : null}
108 + </div>
109 + </ContextChipPopover>
110 );
111 }
112
65 -export function SkillChipIcon() {
113 +function SkillChipIcon() {
114 return (
115 <span
116 aria-hidden="true"
apps/web/src/components/chat/TimelineUserMessageRow.tsx
+2 -2
@@ -735,7 +735,7 @@ const COLLAPSED_USER_MESSAGE_FADE_MASK = `linear-gradient(to bottom, black calc(
735 const CollapsibleUserMessageBody = memo(function CollapsibleUserMessageBody(props: {
736 text: string;
737 renderContextReference: (reference: ChatMarkdownContextReference) => ReactNode;
738 - skills: ReadonlyArray<Pick<ServerProviderSkill, "name" | "displayName">>;
738 + skills: ReadonlyArray<ServerProviderSkill>;
739 markdownCwd: string | undefined;
740 collapsible?: boolean;
741 footer?: ReactNode;
@@ -811,7 +811,7 @@ const CollapsibleUserMessageBody = memo(function CollapsibleUserMessageBody(prop
811 const UserMessageBody = memo(function UserMessageBody(props: {
812 text: string;
813 renderContextReference?: (reference: ChatMarkdownContextReference) => ReactNode;
814 - skills: ReadonlyArray<Pick<ServerProviderSkill, "name" | "displayName">>;
814 + skills: ReadonlyArray<ServerProviderSkill>;
815 markdownCwd: string | undefined;
816 }) {
817 const ctx = use(TimelineRowCtx);
apps/web/src/components/chat/UserMessageContextChips.tsx
+16 -23
@@ -31,7 +31,6 @@ import { TerminalContextInlineChip } from "./TerminalContextInlineChip";
31 import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
32 import {
33 ContextChipPopover as UserMessageContextPopover,
34 - ContextChipShell,
34 FileChip,
35 ImageChipButton,
36 PULL_REQUEST_CHIP_KINDS,
@@ -48,7 +47,11 @@ import { formatComposerContextReference } from "@t3tools/shared/composerContextR
47 import { ContextChip, ContextChipLabel, type ContextChipKind } from "../ContextChip";
48 import { createContextPresentationRegistry } from "../contextPresentationRegistry";
49 import type { ChatMarkdownContextReference } from "../ChatMarkdown";
51 -import { SkillChipIcon } from "./SkillInlineText";
50 +import {
51 + SkillChipPopover,
52 + skillInstructionsOpener,
53 + skillPopoverDescription,
54 +} from "./SkillInlineText";
55 import { formatWorkspaceRelativePath } from "../../filePathDisplay";
56 import {
57 buildReviewCommentRenderablePatch,
@@ -99,22 +102,18 @@ function UserMessageMentionChip(props: {
102 );
103 }
104
102 -function UserMessageContextChip(props: {
103 - icon: ReactNode;
104 - label: string;
105 - kindLabel?: string;
105 +function UserMessageSkillChip(props: {
106 + record: Extract<KnownComposerContextRecord, { kind: "skill" }>;
107 copyMarkdown: string;
107 - tooltip?: string;
108 - kind: ContextChipKind;
108 }) {
109 + const { skills, threadRef } = use(TimelineRowCtx);
110 + const skill = skills.find((candidate) => candidate.name === props.record.name);
111 return (
111 - <ContextChipShell
112 - kind={props.kind}
113 - icon={props.icon}
114 - label={props.label}
115 - aria-label={props.kindLabel ? `${props.kindLabel}, ${props.label}` : undefined}
116 - data-markdown-copy={props.copyMarkdown}
117 - tooltip={props.tooltip}
112 + <SkillChipPopover
113 + label={props.record.label || props.record.name}
114 + description={skill ? skillPopoverDescription(skill) : null}
115 + copyMarkdown={props.copyMarkdown}
116 + onViewInstructions={skillInstructionsOpener(threadRef, skill)}
117 />
118 );
119 }
@@ -315,14 +314,7 @@ const userMessageContextPresentationRegistry = createContextPresentationRegistry
314 canRender: (record) => record.kind === "skill",
315 render: (record, context) =>
316 record.kind === "skill" ? (
318 - <UserMessageContextChip
319 - icon={<SkillChipIcon />}
320 - label={record.label || record.name}
321 - kindLabel="Skill"
322 - tooltip={`$${record.name}`}
323 - copyMarkdown={context.copyMarkdown}
324 - kind="skill"
325 - />
317 + <UserMessageSkillChip record={record} copyMarkdown={context.copyMarkdown} />
318 ) : (
319 <UnavailableUserMessageContextChip {...context} />
320 ),
@@ -562,6 +554,7 @@ function UserMessageReviewCommentCard({ comment }: { comment: ReviewCommentConte
554 <ChatMarkdown
555 text={comment.text}
556 cwd={ctx.markdownCwd}
557 + threadRef={ctx.threadRef ?? undefined}
558 skills={ctx.skills}
559 parseRawHtml={false}
560 lineBreaks
apps/web/src/components/chat/timelineRowContext.ts
+1 -1
@@ -45,7 +45,7 @@ export interface TimelineRowSharedState {
45 markdownCwd: string | undefined;
46 resolvedTheme: "light" | "dark";
47 workspaceRoot: string | undefined;
48 - skills: ReadonlyArray<Pick<ServerProviderSkill, "name" | "displayName">>;
48 + skills: ReadonlyArray<ServerProviderSkill>;
49 runs: ReadonlyArray<HandoffTimelineRun>;
50 activeThreadEnvironmentId: EnvironmentId;
51 onRevertToTurnCount: (targetTurnCount: number, messageId: MessageId) => void;
apps/web/src/components/contextChipParts.tsx
+1 -1
@@ -65,7 +65,7 @@ export function ContextChipPopover(props: {
65 kind: ContextChipKind;
66 icon: ReactNode;
67 label: string;
68 - copyMarkdown?: string;
68 + copyMarkdown?: string | undefined;
69 accessibleLabel: string;
70 children: ReactNode;
71 }) {
packages/shared/src/inlineSkills.ts
+4 -1
@@ -24,7 +24,10 @@ export function formatProviderSkillDisplayName(
24 const SKILL_TOKEN_REGEX =
25 /(^|\s)\p{Sc}(?![0-9][0-9_]*(?:[kKmMbBtT]|[eE][0-9]+)?(?:\s|$))(?=[a-zA-Z0-9:_-]*[a-zA-Z])([a-zA-Z0-9][a-zA-Z0-9:_-]*)(?=\s|$)/gu;
26
27 -export function* matchInlineSkills(text: string, skills: readonly InlineSkill[]) {
27 +export function* matchInlineSkills<Skill extends InlineSkill>(
28 + text: string,
29 + skills: readonly Skill[],
30 +) {
31 for (const match of text.matchAll(SKILL_TOKEN_REGEX)) {
32 const name = match[2] ?? "";
33 const skill = skills.find((candidate) => candidate.name === name);