@@ -13,6 +13,7 @@ import { parseDiff, SessionResponseLogChunk, toFileLabel } from '../../common/se
1313import { vscode } from '../common/message' ;
1414import { CodeView } from './codeView' ;
1515import './index.css' ; // Create this file for styling
16+ import { convertIssueReferencesToLinks } from './issueLinker' ;
1617import { PullInfo } from './messages' ;
1718import { type SessionInfo , type SessionSetupStepResponse } from './sessionsApi' ;
1819
@@ -30,7 +31,7 @@ export const SessionView: React.FC<SessionViewProps> = (props) => {
3031 { props . logs . length === 0 && props . setupSteps && props . setupSteps . length > 0 && (
3132 < SetupStageLog setupSteps = { props . setupSteps } />
3233 ) }
33- < SessionLog logs = { props . logs } />
34+ < SessionLog logs = { props . logs } pullInfo = { props . pullInfo } />
3435 { props . info . state === 'in_progress' && ! ( props . logs . length === 0 && props . setupSteps && props . setupSteps . length > 0 ) && (
3536 < div className = "session-in-progress-indicator" >
3637 < span className = "icon" > < i className = "codicon codicon-loading" > </ i > </ span >
@@ -102,9 +103,10 @@ const SessionHeader: React.FC<SessionHeaderProps> = ({ info, pullInfo }) => {
102103// Session Log component
103104interface SessionLogProps {
104105 readonly logs : readonly SessionResponseLogChunk [ ] ;
106+ readonly pullInfo : PullInfo | undefined ;
105107}
106108
107- const SessionLog : React . FC < SessionLogProps > = ( { logs } ) => {
109+ const SessionLog : React . FC < SessionLogProps > = ( { logs, pullInfo } ) => {
108110 const components = logs . flatMap ( x => x . choices ) . map ( ( choice , index ) => {
109111 if ( ! choice . delta . content ) {
110112 return ;
@@ -129,6 +131,7 @@ const SessionLog: React.FC<SessionLogProps> = ({ logs }) => {
129131 < MarkdownContent
130132 key = { `markdown-${ index } ` }
131133 content = { choice . delta . content }
134+ pullInfo = { pullInfo }
132135 />
133136 ) ;
134137 }
@@ -224,9 +227,10 @@ const SessionLog: React.FC<SessionLogProps> = ({ logs }) => {
224227// Custom component for rendering markdown content
225228interface MarkdownContentProps {
226229 content : string ;
230+ pullInfo : PullInfo | undefined ;
227231}
228232
229- const MarkdownContent : React . FC < MarkdownContentProps > = ( { content } ) => {
233+ const MarkdownContent : React . FC < MarkdownContentProps > = ( { content, pullInfo } ) => {
230234 const containerRef = React . useRef < HTMLDivElement > ( null ) ;
231235 const md = React . useMemo ( ( ) => {
232236 const mdInstance = new MarkdownIt ( ) ;
@@ -245,27 +249,36 @@ const MarkdownContent: React.FC<MarkdownContentProps> = ({ content }) => {
245249 React . useEffect ( ( ) => {
246250 if ( ! containerRef . current ) return ;
247251
248- // Render markdown
249- containerRef . current . innerHTML = md . render ( content ) ;
252+ // Process issue references and convert to clickable links
253+ const processContent = async ( ) => {
254+ const processedContent = await convertIssueReferencesToLinks ( content , pullInfo ) ;
255+
256+ // Render markdown
257+ if ( containerRef . current ) {
258+ containerRef . current . innerHTML = md . render ( processedContent ) ;
250259
251- // Find all code blocks and render them using CodeView
252- const codeBlocks = containerRef . current . querySelectorAll ( '.markdown-code-block' ) ;
253- codeBlocks . forEach ( ( block ) => {
254- const code = decodeURIComponent ( block . getAttribute ( 'data-code' ) || '' ) ;
255- const lang = block . getAttribute ( 'data-lang' ) || 'plaintext' ;
260+ // Find all code blocks and render them using CodeView
261+ const codeBlocks = containerRef . current . querySelectorAll ( '.markdown-code-block' ) ;
262+ codeBlocks . forEach ( ( block ) => {
263+ const code = decodeURIComponent ( block . getAttribute ( 'data-code' ) || '' ) ;
264+ const lang = block . getAttribute ( 'data-lang' ) || 'plaintext' ;
256265
257- const codeViewElement = document . createElement ( 'div' ) ;
258- block . replaceWith ( codeViewElement ) ;
266+ const codeViewElement = document . createElement ( 'div' ) ;
267+ block . replaceWith ( codeViewElement ) ;
259268
260- ReactDOM . render (
261- < CodeView
262- label = "Code Block"
263- content = { { value : code , lang } }
264- /> ,
265- codeViewElement
266- ) ;
267- } ) ;
268- } , [ content ] ) ;
269+ ReactDOM . render (
270+ < CodeView
271+ label = "Code Block"
272+ content = { { value : code , lang } }
273+ /> ,
274+ codeViewElement
275+ ) ;
276+ } ) ;
277+ }
278+ } ;
279+
280+ processContent ( ) ;
281+ } , [ content , pullInfo , md ] ) ;
269282
270283 return < div className = "markdown-content" ref = { containerRef } /> ;
271284} ;
0 commit comments