Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 6c1a1a7

Browse files
committed
fix: strip parentheses from file paths generated by llm
1 parent 2e21c62 commit 6c1a1a7

4 files changed

Lines changed: 18 additions & 6 deletions

File tree

.opencode/bun.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.opencode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"dependencies": {
33
"@octokit/rest": "^22.0.1",
4-
"@opencode-ai/plugin": "0.0.0-dev-202512160508"
4+
"@opencode-ai/plugin": "1.0.162"
55
}
66
}

packages/ui/src/components/markdown.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ function strip(text: string): string {
77
return match ? match[2] : text
88
}
99

10+
function removeParensAroundFileRefs(text: string): string {
11+
// Remove parentheses around inline code that looks like a file reference
12+
// Matches: (`path/to/file.ext`) or (`path/to/file.ext:1-10`) or (`file.ext:42`)
13+
return text.replace(/\(\s*(`[^`]+\.[a-zA-Z0-9]+(?::\d+(?:-\d+)?)?`)\s*\)/g, "$1")
14+
}
15+
1016
export function Markdown(
1117
props: ComponentProps<"div"> & {
1218
text: string
@@ -17,7 +23,7 @@ export function Markdown(
1723
const [local, others] = splitProps(props, ["text", "class", "classList"])
1824
const marked = useMarked()
1925
const [html] = createResource(
20-
() => strip(local.text),
26+
() => removeParensAroundFileRefs(strip(local.text)),
2127
async (markdown) => {
2228
return marked.parse(markdown)
2329
},

packages/web/src/components/share/content-markdown.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ interface Props {
2929
}
3030
export function ContentMarkdown(props: Props) {
3131
const [html] = createResource(
32-
() => strip(props.text),
32+
() => removeParensAroundFileRefs(strip(props.text)),
3333
async (markdown) => {
3434
return markedWithShiki.parse(markdown)
3535
},
@@ -65,3 +65,9 @@ function strip(text: string): string {
6565
const match = text.match(wrappedRe)
6666
return match ? match[2] : text
6767
}
68+
69+
function removeParensAroundFileRefs(text: string): string {
70+
// Remove parentheses around inline code that looks like a file reference
71+
// Matches: (`path/to/file.ext`) or (`path/to/file.ext:1-10`) or (`file.ext:42`)
72+
return text.replace(/\(\s*(`[^`]+\.[a-zA-Z0-9]+(?::\d+(?:-\d+)?)?`)\s*\)/g, "$1")
73+
}

0 commit comments

Comments
 (0)