summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax <[email protected]>2026-02-24 23:15:11 -0500
committerGitHub <[email protected]>2026-02-25 04:15:11 +0000
commit637059a515a6afd983a8a615f90650d997a821ce (patch)
tree3f6867041ec1496ba1a620f6a277effbfdcc2676
parentfa559b0385374222b933ba8f86dc3cd92f53c0de (diff)
downloadopencode-637059a515a6afd983a8a615f90650d997a821ce.tar.gz
opencode-637059a515a6afd983a8a615f90650d997a821ce.zip
feat: show LSP errors for apply_patch tool (#14715)
-rw-r--r--packages/opencode/src/cli/cmd/tui/routes/session/index.tsx58
1 files changed, 26 insertions, 32 deletions
diff --git a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
index f5a7f6f6c..365eb3314 100644
--- a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
+++ b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
@@ -1762,11 +1762,6 @@ function Write(props: ToolProps<typeof WriteTool>) {
return props.input.content
})
- const diagnostics = createMemo(() => {
- const filePath = Filesystem.normalizePath(props.input.filePath ?? "")
- return props.metadata.diagnostics?.[filePath] ?? []
- })
-
return (
<Switch>
<Match when={props.metadata.diagnostics !== undefined}>
@@ -1780,15 +1775,7 @@ function Write(props: ToolProps<typeof WriteTool>) {
content={code()}
/>
</line_number>
- <Show when={diagnostics().length}>
- <For each={diagnostics()}>
- {(diagnostic) => (
- <text fg={theme.error}>
- Error [{diagnostic.range.start.line}:{diagnostic.range.start.character}]: {diagnostic.message}
- </text>
- )}
- </For>
- </Show>
+ <Diagnostics diagnostics={props.metadata.diagnostics} filePath={props.input.filePath ?? ""} />
</BlockTool>
</Match>
<Match when={true}>
@@ -1972,12 +1959,6 @@ function Edit(props: ToolProps<typeof EditTool>) {
const diffContent = createMemo(() => props.metadata.diff)
- const diagnostics = createMemo(() => {
- const filePath = Filesystem.normalizePath(props.input.filePath ?? "")
- const arr = props.metadata.diagnostics?.[filePath] ?? []
- return arr.filter((x) => x.severity === 1).slice(0, 3)
- })
-
return (
<Switch>
<Match when={props.metadata.diff !== undefined}>
@@ -2003,18 +1984,7 @@ function Edit(props: ToolProps<typeof EditTool>) {
removedLineNumberBg={theme.diffRemovedLineNumberBg}
/>
</box>
- <Show when={diagnostics().length}>
- <box>
- <For each={diagnostics()}>
- {(diagnostic) => (
- <text fg={theme.error}>
- Error [{diagnostic.range.start.line + 1}:{diagnostic.range.start.character + 1}]{" "}
- {diagnostic.message}
- </text>
- )}
- </For>
- </box>
- </Show>
+ <Diagnostics diagnostics={props.metadata.diagnostics} filePath={props.input.filePath ?? ""} />
</BlockTool>
</Match>
<Match when={true}>
@@ -2086,6 +2056,7 @@ function ApplyPatch(props: ToolProps<typeof ApplyPatchTool>) {
}
>
<Diff diff={file.diff} filePath={file.filePath} />
+ <Diagnostics diagnostics={props.metadata.diagnostics} filePath={file.movePath ?? file.filePath} />
</Show>
</BlockTool>
)}
@@ -2163,6 +2134,29 @@ function Skill(props: ToolProps<typeof SkillTool>) {
)
}
+function Diagnostics(props: { diagnostics?: Record<string, Record<string, any>[]>; filePath: string }) {
+ const { theme } = useTheme()
+ const errors = createMemo(() => {
+ const normalized = Filesystem.normalizePath(props.filePath)
+ const arr = props.diagnostics?.[normalized] ?? []
+ return arr.filter((x) => x.severity === 1).slice(0, 3)
+ })
+
+ return (
+ <Show when={errors().length}>
+ <box>
+ <For each={errors()}>
+ {(diagnostic) => (
+ <text fg={theme.error}>
+ Error [{diagnostic.range.start.line + 1}:{diagnostic.range.start.character + 1}] {diagnostic.message}
+ </text>
+ )}
+ </For>
+ </box>
+ </Show>
+ )
+}
+
function normalizePath(input?: string) {
if (!input) return ""
if (path.isAbsolute(input)) {