Skip to content

Commit

Permalink
feat: ✨ add eraseAnnotations to clean text in chat
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Oct 11, 2024
1 parent 643740c commit 860e082
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions packages/core/src/annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ export function parseAnnotations(text: string): Diagnostic[] {
return Array.from(annotations.values()) // Convert the set to an array
}

export function eraseAnnotations(text: string) {
return [
TYPESCRIPT_ANNOTATIONS_RX,
GITHUB_ANNOTATIONS_RX,
AZURE_DEVOPS_ANNOTATIONS_RX,
].reduce((t, rx) => t.replace(rx, ""), text)
}

/**
* Converts a `Diagnostic` to a GitHub Action command string.
*
Expand Down
8 changes: 6 additions & 2 deletions packages/vscode/src/chatparticipant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ExtensionState } from "./state"
import { TOOL_ID } from "../../core/src/constants"
import { Fragment } from "../../core/src/generation"
import { prettifyMarkdown } from "../../core/src/markdown"
import { eraseAnnotations } from "../../core/src/annotations"

export async function activateChatParticipant(state: ExtensionState) {
const { context } = state
Expand Down Expand Up @@ -52,9 +53,12 @@ export async function activateChatParticipant(state: ExtensionState) {

if (token.isCancellationRequested) return

const { text } = res || {}
const { text = "", annotations = [] } = res || {}
response.markdown(
new vscode.MarkdownString(prettifyMarkdown(text || ""), true)
new vscode.MarkdownString(
prettifyMarkdown(eraseAnnotations(text)),
true
)
)
}
)
Expand Down

0 comments on commit 860e082

Please sign in to comment.