2
2
3
3
import React , { useMemo } from 'react'
4
4
import { NodeViewProps , NodeViewWrapper } from '@tiptap/react'
5
+ import { Filepath } from 'tabby-chat-panel/index'
5
6
6
7
import {
7
8
MARKDOWN_COMMAND_REGEX ,
@@ -21,6 +22,8 @@ import {
21
22
IconGitLab
22
23
} from '@/components/ui/icons'
23
24
25
+ import { getFilepathStringByChatPanelFilePath } from './chat/form-editor/utils'
26
+
24
27
export function Mention ( {
25
28
kind,
26
29
label,
@@ -108,8 +111,10 @@ export function ThreadTitleWithMentions({
108
111
textPart = textPart . replace ( MARKDOWN_FILE_REGEX , ( match , content ) => {
109
112
try {
110
113
if ( content . startsWith ( '{' ) && content . endsWith ( '}' ) ) {
111
- const fileInfo = JSON . parse ( content )
112
- const filename = resolveFileNameForDisplay ( fileInfo . filepath )
114
+ const fileInfo = JSON . parse ( content ) as Filepath
115
+ const filepathString =
116
+ getFilepathStringByChatPanelFilePath ( fileInfo )
117
+ const filename = resolveFileNameForDisplay ( filepathString )
113
118
return `@${ filename } `
114
119
}
115
120
// Otherwise just use the content as is
@@ -127,7 +132,10 @@ export function ThreadTitleWithMentions({
127
132
if ( symbolInfo . label ) {
128
133
return `@${ symbolInfo . label } `
129
134
}
130
- const filename = resolveFileNameForDisplay ( symbolInfo . filepath )
135
+ const filepathString = getFilepathStringByChatPanelFilePath (
136
+ symbolInfo . filepath
137
+ )
138
+ const filename = resolveFileNameForDisplay ( filepathString )
131
139
const range = symbolInfo . range
132
140
? `:${ symbolInfo . range . start } -${ symbolInfo . range . end } `
133
141
: ''
@@ -143,6 +151,7 @@ export function ThreadTitleWithMentions({
143
151
return `@${ cmdPart . replace ( / " / g, '' ) } `
144
152
} )
145
153
} )
154
+
146
155
return finalContent
147
156
} , [ sources , message ] )
148
157
return < div className = { cn ( className ) } > { contentWithTags } </ div >
0 commit comments