@devries-cameron20 / t3code-1 / commits / 11f40556de
Fork 0

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

feat(web): render skill calls as inline chips (#2572)

maria committed May 7, 2026 at 17:43 UTC 11f40556de8a37c7f16486c23fb6bce058275557
6 files changed +134 -8
apps/web/src/components/ChatMarkdown.tsx
+18 -1
@@ -1,5 +1,6 @@
1 import { DiffsHighlighter, getSharedHighlighter, SupportedLanguages } from "@pierre/diffs";
2 import { CheckIcon, CopyIcon } from "lucide-react";
3 +import type { ServerProviderSkill } from "@t3tools/contracts";
4 import React, {
5 Children,
6 Suspense,
@@ -19,6 +20,7 @@ import ReactMarkdown from "react-markdown";
20 import { defaultUrlTransform } from "react-markdown";
21 import remarkGfm from "remark-gfm";
22 import { VscodeEntryIcon } from "./chat/VscodeEntryIcon";
23 +import { renderSkillInlineMarkdownChildren } from "./chat/SkillInlineText";
24 import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
25 import { stackedThreadToast, toastManager } from "./ui/toast";
26 import { openInPreferredEditor } from "../editorPreferences";
@@ -59,8 +61,11 @@ interface ChatMarkdownProps {
61 text: string;
62 cwd: string | undefined;
63 isStreaming?: boolean;
64 + skills?: ReadonlyArray<Pick<ServerProviderSkill, "name" | "displayName">>;
65 }
66
67 +const EMPTY_MARKDOWN_SKILLS: ReadonlyArray<Pick<ServerProviderSkill, "name" | "displayName">> = [];
68 +
69 const CODE_FENCE_LANGUAGE_REGEX = /(?:^|\s)language-([^\s]+)/;
70 const MAX_HIGHLIGHT_CACHE_ENTRIES = 500;
71 const MAX_HIGHLIGHT_CACHE_MEMORY_BYTES = 50 * 1024 * 1024;
@@ -507,7 +512,12 @@ function areMarkdownFileLinkPropsEqual(
512 );
513 }
514
510 -function ChatMarkdown({ text, cwd, isStreaming = false }: ChatMarkdownProps) {
515 +function ChatMarkdown({
516 + text,
517 + cwd,
518 + isStreaming = false,
519 + skills = EMPTY_MARKDOWN_SKILLS,
520 +}: ChatMarkdownProps) {
521 const { resolvedTheme } = useTheme();
522 const diffThemeName = resolveDiffThemeName(resolvedTheme);
523 const markdownFileLinkMetaByHref = useMemo(() => {
@@ -534,6 +544,12 @@ function ChatMarkdown({ text, cwd, isStreaming = false }: ChatMarkdownProps) {
544 }, []);
545 const markdownComponents = useMemo<Components>(
546 () => ({
547 + p({ node: _node, children, ...props }) {
548 + return <p {...props}>{renderSkillInlineMarkdownChildren(children, skills)}</p>;
549 + },
550 + li({ node: _node, children, ...props }) {
551 + return <li {...props}>{renderSkillInlineMarkdownChildren(children, skills)}</li>;
552 + },
553 a({ node: _node, href, ...props }) {
554 const normalizedHref = href ? normalizeMarkdownLinkHrefKey(href) : "";
555 const fileLinkMeta = normalizedHref ? markdownFileLinkMetaByHref.get(normalizedHref) : null;
@@ -592,6 +608,7 @@ function ChatMarkdown({ text, cwd, isStreaming = false }: ChatMarkdownProps) {
608 isStreaming,
609 markdownFileLinkMetaByHref,
610 resolvedTheme,
611 + skills,
612 ],
613 );
614
apps/web/src/components/ChatView.tsx
+2
@@ -195,6 +195,7 @@ const IMAGE_ONLY_BOOTSTRAP_PROMPT =
195 const EMPTY_ACTIVITIES: OrchestrationThreadActivity[] = [];
196 const EMPTY_PROPOSED_PLANS: Thread["proposedPlans"] = [];
197 const EMPTY_PROVIDERS: ServerProvider[] = [];
198 +const EMPTY_PROVIDER_SKILLS: ServerProvider["skills"] = [];
199 const EMPTY_PENDING_USER_INPUT_ANSWERS: Record<string, PendingUserInputDraftAnswer> = {};
200 type EnvironmentUnavailableState = {
201 readonly environmentId: EnvironmentId;
@@ -3574,6 +3575,7 @@ export default function ChatView(props: ChatViewProps) {
3575 resolvedTheme={resolvedTheme}
3576 timestampFormat={timestampFormat}
3577 workspaceRoot={activeWorkspaceRoot}
3578 + skills={activeProviderStatus?.skills ?? EMPTY_PROVIDER_SKILLS}
3579 onIsAtEndChange={onIsAtEndChange}
3580 />
3581
apps/web/src/components/ComposerPromptEditor.tsx
+1 -2
@@ -72,6 +72,7 @@ import {
72 COMPOSER_INLINE_CHIP_ICON_CLASS_NAME,
73 COMPOSER_INLINE_CHIP_LABEL_CLASS_NAME,
74 COMPOSER_INLINE_SKILL_CHIP_CLASS_NAME,
75 + SKILL_CHIP_ICON_SVG,
76 } from "./composerInlineChip";
77 import { ComposerPendingTerminalContextChip } from "./chat/ComposerPendingTerminalContexts";
78 import { formatProviderSkillDisplayName } from "~/providerSkillPresentation";
@@ -216,8 +217,6 @@ function $createComposerMentionNode(path: string): ComposerMentionNode {
217 return $applyNodeReplacement(new ComposerMentionNode(path));
218 }
219
219 -const SKILL_CHIP_ICON_SVG = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.85" stroke-linecap="round" stroke-linejoin="round"><path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="m3.3 7 8.7 5 8.7-5"/><path d="M12 22V12"/></svg>`;
220 -
220 function resolveSkillDescription(
221 skill: Pick<ServerProviderSkill, "shortDescription" | "description">,
222 ): string | null {
apps/web/src/components/chat/MessagesTimeline.tsx
+24 -5
@@ -1,4 +1,9 @@
1 -import { type EnvironmentId, type MessageId, type TurnId } from "@t3tools/contracts";
1 +import {
2 + type EnvironmentId,
3 + type MessageId,
4 + type ServerProviderSkill,
5 + type TurnId,
6 +} from "@t3tools/contracts";
7 import {
8 createContext,
9 memo,
@@ -60,6 +65,7 @@ import {
65 formatInlineTerminalContextLabel,
66 textContainsInlineTerminalContextLabels,
67 } from "./userMessageTerminalContexts";
68 +import { SkillInlineText } from "./SkillInlineText";
69 import { formatWorkspaceRelativePath } from "../../filePathDisplay";
70
71 // ---------------------------------------------------------------------------
@@ -75,6 +81,7 @@ interface TimelineRowSharedState {
81 markdownCwd: string | undefined;
82 resolvedTheme: "light" | "dark";
83 workspaceRoot: string | undefined;
84 + skills: ReadonlyArray<Pick<ServerProviderSkill, "name" | "displayName">>;
85 activeThreadEnvironmentId: EnvironmentId;
86 onRevertUserMessage: (messageId: MessageId) => void;
87 onImageExpand: (preview: ExpandedImagePreview) => void;
@@ -93,6 +100,7 @@ const TimelineRowCtx = createContext<TimelineRowSharedState>(null!);
100 const TimelineRowActivityCtx = createContext<TimelineRowActivityState>(null!);
101 const TIMELINE_LIST_HEADER = <div className="h-3 sm:h-4" />;
102 const TIMELINE_LIST_FOOTER = <div className="h-3 sm:h-4" />;
103 +const EMPTY_TIMELINE_SKILLS: ReadonlyArray<Pick<ServerProviderSkill, "name" | "displayName">> = [];
104
105 // ---------------------------------------------------------------------------
106 // Props (public API)
@@ -119,6 +127,7 @@ interface MessagesTimelineProps {
127 resolvedTheme: "light" | "dark";
128 timestampFormat: TimestampFormat;
129 workspaceRoot: string | undefined;
130 + skills?: ReadonlyArray<Pick<ServerProviderSkill, "name" | "displayName">>;
131 onIsAtEndChange: (isAtEnd: boolean) => void;
132 }
133
@@ -147,6 +156,7 @@ export const MessagesTimeline = memo(function MessagesTimeline({
156 resolvedTheme,
157 timestampFormat,
158 workspaceRoot,
159 + skills = EMPTY_TIMELINE_SKILLS,
160 onIsAtEndChange,
161 }: MessagesTimelineProps) {
162 const rawRows = useMemo(
@@ -202,6 +212,7 @@ export const MessagesTimeline = memo(function MessagesTimeline({
212 markdownCwd,
213 resolvedTheme,
214 workspaceRoot,
215 + skills,
216 activeThreadEnvironmentId,
217 onRevertUserMessage,
218 onImageExpand,
@@ -213,6 +224,7 @@ export const MessagesTimeline = memo(function MessagesTimeline({
224 markdownCwd,
225 resolvedTheme,
226 workspaceRoot,
227 + skills,
228 activeThreadEnvironmentId,
229 onRevertUserMessage,
230 onImageExpand,
@@ -357,6 +369,7 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
369 <UserMessageBody
370 text={displayedUserMessage.visibleText}
371 terminalContexts={terminalContexts}
372 + skills={ctx.skills}
373 />
374 )}
375 <div className="mt-1.5 flex items-center justify-end gap-2">
@@ -405,6 +418,7 @@ function AssistantTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "mess
418 text={messageText}
419 cwd={ctx.markdownCwd}
420 isStreaming={Boolean(row.message.streaming)}
421 + skills={ctx.skills}
422 />
423 <AssistantChangedFilesSection
424 turnSummary={row.assistantTurnDiffSummary}
@@ -744,6 +758,7 @@ const UserMessageTerminalContextInlineLabel = memo(
758 const UserMessageBody = memo(function UserMessageBody(props: {
759 text: string;
760 terminalContexts: ParsedTerminalContextEntry[];
761 + skills: ReadonlyArray<Pick<ServerProviderSkill, "name" | "displayName">>;
762 }) {
763 if (props.terminalContexts.length > 0) {
764 const hasEmbeddedInlineLabels = textContainsInlineTerminalContextLabels(
@@ -766,7 +781,7 @@ const UserMessageBody = memo(function UserMessageBody(props: {
781 if (matchIndex > cursor) {
782 inlineNodes.push(
783 <span key={`user-terminal-context-inline-before:${context.header}:${cursor}`}>
769 - {props.text.slice(cursor, matchIndex)}
784 + <SkillInlineText text={props.text.slice(cursor, matchIndex)} skills={props.skills} />
785 </span>,
786 );
787 }
@@ -783,7 +798,7 @@ const UserMessageBody = memo(function UserMessageBody(props: {
798 if (cursor < props.text.length) {
799 inlineNodes.push(
800 <span key={`user-message-terminal-context-inline-rest:${cursor}`}>
786 - {props.text.slice(cursor)}
801 + <SkillInlineText text={props.text.slice(cursor)} skills={props.skills} />
802 </span>,
803 );
804 }
@@ -811,7 +826,11 @@ const UserMessageBody = memo(function UserMessageBody(props: {
826 }
827
828 if (props.text.length > 0) {
814 - inlineNodes.push(<span key="user-message-terminal-context-inline-text">{props.text}</span>);
829 + inlineNodes.push(
830 + <span key="user-message-terminal-context-inline-text">
831 + <SkillInlineText text={props.text} skills={props.skills} />
832 + </span>,
833 + );
834 } else if (inlinePrefix.length === 0) {
835 return null;
836 }
@@ -829,7 +848,7 @@ const UserMessageBody = memo(function UserMessageBody(props: {
848
849 return (
850 <div className="whitespace-pre-wrap wrap-break-word text-sm leading-relaxed text-foreground">
832 - {props.text}
851 + <SkillInlineText text={props.text} skills={props.skills} />
852 </div>
853 );
854 });
apps/web/src/components/chat/SkillInlineText.tsx new
+87
@@ -0,0 +1,87 @@
1 +import { Children, cloneElement, isValidElement, type ReactNode } from "react";
2 +import type { ServerProviderSkill } from "@t3tools/contracts";
3 +
4 +import { formatProviderSkillDisplayName } from "../../providerSkillPresentation";
5 +import {
6 + COMPOSER_INLINE_CHIP_ICON_CLASS_NAME,
7 + COMPOSER_INLINE_CHIP_LABEL_CLASS_NAME,
8 + COMPOSER_INLINE_SKILL_CHIP_CLASS_NAME,
9 + SKILL_CHIP_ICON_SVG,
10 +} from "../composerInlineChip";
11 +
12 +const SKILL_TOKEN_REGEX = /(^|\s)\$([a-zA-Z][a-zA-Z0-9:_-]*)(?=\s|$)/g;
13 +
14 +type InlineSkill = Pick<ServerProviderSkill, "name" | "displayName">;
15 +
16 +export function SkillInlineText(props: { text: string; skills: ReadonlyArray<InlineSkill> }) {
17 + const nodes: ReactNode[] = [];
18 + let cursor = 0;
19 +
20 + for (const match of props.text.matchAll(SKILL_TOKEN_REGEX)) {
21 + const prefix = match[1] ?? "";
22 + const name = match[2] ?? "";
23 + const start = (match.index ?? 0) + prefix.length;
24 + const rawText = `$${name}`;
25 + const skill = props.skills.find((candidate) => candidate.name === name);
26 + if (!skill) {
27 + continue;
28 + }
29 +
30 + if (start > cursor) {
31 + nodes.push(props.text.slice(cursor, start));
32 + }
33 + nodes.push(<SkillChip key={`${start}:${name}`} skill={skill} rawText={rawText} />);
34 + cursor = start + rawText.length;
35 + }
36 +
37 + if (cursor === 0) {
38 + return <>{props.text}</>;
39 + }
40 + if (cursor < props.text.length) {
41 + nodes.push(props.text.slice(cursor));
42 + }
43 + return <>{nodes}</>;
44 +}
45 +
46 +export function renderSkillInlineMarkdownChildren(
47 + children: ReactNode,
48 + skills: ReadonlyArray<InlineSkill>,
49 +): ReactNode {
50 + return Children.map(children, (child) => {
51 + if (typeof child === "string") {
52 + return <SkillInlineText text={child} skills={skills} />;
53 + }
54 + if (!isValidElement<{ children?: ReactNode }>(child)) {
55 + return child;
56 + }
57 + if (child.type === "code" || child.type === "a") {
58 + return child;
59 + }
60 + if (!("children" in child.props)) {
61 + return child;
62 + }
63 + return cloneElement(
64 + child,
65 + undefined,
66 + renderSkillInlineMarkdownChildren(child.props.children, skills),
67 + );
68 + });
69 +}
70 +
71 +function SkillChip(props: { skill: InlineSkill; rawText: string }) {
72 + return (
73 + <span className="inline-flex align-middle leading-none">
74 + <span className="sr-only">{props.rawText}</span>
75 + <span aria-hidden="true" className={COMPOSER_INLINE_SKILL_CHIP_CLASS_NAME}>
76 + <span
77 + aria-hidden="true"
78 + className={COMPOSER_INLINE_CHIP_ICON_CLASS_NAME}
79 + dangerouslySetInnerHTML={{ __html: SKILL_CHIP_ICON_SVG }}
80 + />
81 + <span className={COMPOSER_INLINE_CHIP_LABEL_CLASS_NAME}>
82 + {formatProviderSkillDisplayName(props.skill)}
83 + </span>
84 + </span>
85 + </span>
86 + );
87 +}
apps/web/src/components/composerInlineChip.ts
+2
@@ -8,5 +8,7 @@ export const COMPOSER_INLINE_CHIP_LABEL_CLASS_NAME = "truncate select-none leadi
8 export const COMPOSER_INLINE_SKILL_CHIP_CLASS_NAME =
9 "inline-flex max-w-full select-none items-center gap-1 rounded-md border border-fuchsia-500/25 bg-fuchsia-500/12 px-1.5 py-px font-medium text-[12px] leading-[1.1] text-fuchsia-700 align-middle dark:text-fuchsia-300";
10
11 +export const SKILL_CHIP_ICON_SVG = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.85" stroke-linecap="round" stroke-linejoin="round"><path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="m3.3 7 8.7 5 8.7-5"/><path d="M12 22V12"/></svg>`;
12 +
13 export const COMPOSER_INLINE_CHIP_DISMISS_BUTTON_CLASS_NAME =
14 "ml-0.5 inline-flex size-3.5 shrink-0 cursor-pointer items-center justify-center rounded-sm text-muted-foreground/72 transition-colors hover:bg-foreground/6 hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring";