@@ -3,7 +3,12 @@ import * as Dialog from "../../components/ui/Dialog";
33import { useOpenPullRequest } from "../../native/useOpenPullRequest" ;
44import { ThreadMarkdownVideo , ThreadMediaVisibleContext } from "./ThreadMarkdownVideo" ;
55import { useMarkdownImageSource } from "../../native/useMarkdownImageSource" ;
6- import { enrichedContextLinkPresentation } from "../../lib/enrichedLinkPresentation" ;
6+ import {
7+ enrichedContextLinkPresentation ,
8+ enrichedSkillDisplayName ,
9+ enrichedSkillInstructionsPath ,
10+ enrichedSkillReference ,
11+ } from "../../lib/enrichedLinkPresentation" ;
712import { ThreadContextDivider } from "./thread-context-divider" ;
813import { ThreadHandoffDivider , ThreadHandoffRow } from "./thread-handoff-row" ;
914import { SecretRequestCard } from "./SecretRequestCard" ;
@@ -1788,6 +1793,14 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
17881793 const iconSubtleColor = theme [ "--color-icon-subtle" ] ;
17891794 const screenColor = theme [ "--color-screen" ] ;
17901795 const userBubbleColor = theme [ "--color-user-bubble" ] ;
1796+ const openSkillInstructions = ( path : string ) => {
1797+ void Haptics . selectionAsync ( ) ;
1798+ navigation . navigate ( "ThreadFile" , {
1799+ environmentId : String ( props . environmentId ) ,
1800+ threadId : String ( props . threadId ) ,
1801+ path : fileRoutePathSegments ( path ) ,
1802+ } ) ;
1803+ } ;
17911804 const resolveLinkedThread = ( href : string ) => {
17921805 const linkedThreadId = parseThreadLinkHref ( href ) ;
17931806 if ( ! linkedThreadId ) return null ;
@@ -1798,6 +1811,12 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
17981811 ) ;
17991812 } ;
18001813 const onMarkdownLinkPress = ( href : string , imageEmbed = false ) => {
1814+ const skill = enrichedSkillReference ( href , props . skills ) ;
1815+ if ( skill ) {
1816+ const instructionsPath = enrichedSkillInstructionsPath ( skill ) ;
1817+ if ( instructionsPath ) openSkillInstructions ( instructionsPath ) ;
1818+ return ;
1819+ }
18011820 const target = resolveLinkedThread ( href ) ;
18021821 if ( target ) {
18031822 navigation . navigate ( "Thread" , {
@@ -1868,6 +1887,20 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
18681887 onImagePress : ( href ) => onMarkdownLinkPress ( href , true ) ,
18691888 resolveImageSource,
18701889 fileContextMenu : ( href ) => {
1890+ const skill = enrichedSkillReference ( href , props . skills ) ;
1891+ if ( skill ) {
1892+ return {
1893+ title : enrichedSkillDisplayName ( skill ) ,
1894+ actions : [
1895+ {
1896+ id : "open-skill" ,
1897+ title : "View instructions" ,
1898+ disabled : ! enrichedSkillInstructionsPath ( skill ) ,
1899+ } ,
1900+ { id : "copy-skill" , title : "Copy skill" } ,
1901+ ] ,
1902+ } ;
1903+ }
18711904 const thread = resolveLinkedThread ( href ) ;
18721905 if ( thread ) {
18731906 return {
@@ -1883,6 +1916,13 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
18831916 return target ? fileChipMenu ( target ) : undefined ;
18841917 } ,
18851918 onFileContextMenuAction : ( href , actionId ) => {
1919+ const skill = enrichedSkillReference ( href , props . skills ) ;
1920+ if ( skill ) {
1921+ const instructionsPath = enrichedSkillInstructionsPath ( skill ) ;
1922+ if ( actionId === "open-skill" && instructionsPath ) openSkillInstructions ( instructionsPath ) ;
1923+ else if ( actionId === "copy-skill" ) copyTextWithHaptic ( `$${ skill . name } ` ) ;
1924+ return ;
1925+ }
18861926 if ( resolveLinkedThread ( href ) ) {
18871927 if ( actionId === "open-thread" ) onMarkdownLinkPress ( href ) ;
18881928 else if ( actionId === "copy-thread-link" ) copyTextWithHaptic ( href ) ;
0 commit comments