Skip to content

Commit 8d7c2c8

Browse files
[autofix.ci] apply automated fixes
1 parent 15649f9 commit 8d7c2c8

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

ee/tabby-ui/lib/utils/chat.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ import {
2525
PLACEHOLDER_FILE_REGEX,
2626
PLACEHOLDER_SYMBOL_REGEX
2727
} from '../constants/regex'
28-
import { convertContextBlockToPlaceholder, formatObjectToMarkdownBlock } from './markdown'
28+
import {
29+
convertContextBlockToPlaceholder,
30+
formatObjectToMarkdownBlock
31+
} from './markdown'
2932

3033
export const isCodeSourceContext = (kind: ContextSourceKind) => {
3134
return [
@@ -326,7 +329,7 @@ export async function processingPlaceholder(
326329
): Promise<string> {
327330
let processedMessage = message
328331
if (hasChangesCommand(processedMessage) && options.getChanges) {
329-
try {
332+
try {
330333
const changes = await options.getChanges({})
331334
const gitChanges = convertChangeItemsToContextContent(changes)
332335
processedMessage = processedMessage.replaceAll(
@@ -380,7 +383,11 @@ export async function processingPlaceholder(
380383
})
381384
let replacement = ''
382385
if (content) {
383-
replacement = formatObjectToMarkdownBlock('symbol', symbolInfo, content)
386+
replacement = formatObjectToMarkdownBlock(
387+
'symbol',
388+
symbolInfo,
389+
content
390+
)
384391
}
385392
processedMessage = processedMessage.replace(match[0], replacement)
386393
tempMessage = tempMessage.replace(match[0], replacement)

ee/tabby-ui/lib/utils/markdown.ts

+16-17
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Parent, Root, RootContent } from 'mdast'
22
import { remark } from 'remark'
3-
import remarkStringify from 'remark-stringify'
4-
import { Options } from 'remark-stringify'
3+
import remarkStringify, { Options } from 'remark-stringify'
54

65
const REMARK_STRINGIFY_OPTIONS: Options = {
76
bullet: '*',
@@ -13,12 +12,11 @@ const REMARK_STRINGIFY_OPTIONS: Options = {
1312
placeholder: (node: PlaceholderNode) => {
1413
return node.value
1514
}
16-
} as any
15+
} as any
1716
}
1817

1918
function createRemarkProcessor() {
20-
return remark()
21-
.use(remarkStringify, REMARK_STRINGIFY_OPTIONS)
19+
return remark().use(remarkStringify, REMARK_STRINGIFY_OPTIONS)
2220
}
2321

2422
/**
@@ -31,7 +29,6 @@ export function customAstToString(ast: Root): string {
3129
return processor.stringify(ast).trim()
3230
}
3331

34-
3532
/**
3633
* Process code blocks with labels and convert them to placeholders
3734
*/
@@ -71,12 +68,16 @@ export function processCodeBlocksWithLabel(ast: Root): RootContent[] {
7168
switch (metas['label']) {
7269
case 'changes':
7370
finalCommandText = 'contextCommand:changes'
74-
placeholderNode = createPlaceholderNode(`[[contextCommand:${finalCommandText}]]`) as unknown as RootContent
71+
placeholderNode = createPlaceholderNode(
72+
`[[contextCommand:${finalCommandText}]]`
73+
) as unknown as RootContent
7574
break
7675
case 'file':
7776
if (metas['object']) {
7877
try {
79-
placeholderNode = createPlaceholderNode(`[[file:${metas['object']}]]`) as unknown as RootContent
78+
placeholderNode = createPlaceholderNode(
79+
`[[file:${metas['object']}]]`
80+
) as unknown as RootContent
8081
if (!placeholderNode) {
8182
shouldProcessNode = false
8283
newChildren.push(node)
@@ -90,7 +91,9 @@ export function processCodeBlocksWithLabel(ast: Root): RootContent[] {
9091
case 'symbol':
9192
if (metas['object']) {
9293
try {
93-
placeholderNode = createPlaceholderNode(`[[symbol:${metas['object']}]]`) as unknown as RootContent
94+
placeholderNode = createPlaceholderNode(
95+
`[[symbol:${metas['object']}]]`
96+
) as unknown as RootContent
9497
if (!placeholderNode) {
9598
shouldProcessNode = false
9699
newChildren.push(node)
@@ -201,20 +204,16 @@ export function formatObjectToMarkdownBlock(
201204
} as RootContent
202205
]
203206
}
204-
207+
205208
const processor = createRemarkProcessor()
206-
209+
207210
const res = '\n' + processor.stringify(codeNode).trim() + '\n'
208-
return res;
211+
return res
209212
} catch (error) {
210213
return `\n*Error formatting ${label}*\n`
211214
}
212215
}
213216

214-
215-
216-
217-
218217
export interface PlaceholderNode extends Node {
219218
type: 'placeholder'
220219
value: string
@@ -223,6 +222,6 @@ export interface PlaceholderNode extends Node {
223222
export function createPlaceholderNode(value: string): PlaceholderNode {
224223
return {
225224
type: 'placeholder',
226-
value: value,
225+
value: value
227226
} as PlaceholderNode
228227
}

0 commit comments

Comments
 (0)