feat: show LSP errors for apply_patch tool (#14715)

This commit is contained in:
Dax
2026-02-24 23:15:11 -05:00
committed by GitHub
parent fa559b0385
commit 637059a515

View File

@@ -1762,11 +1762,6 @@ function Write(props: ToolProps<typeof WriteTool>) {
return props.input.content return props.input.content
}) })
const diagnostics = createMemo(() => {
const filePath = Filesystem.normalizePath(props.input.filePath ?? "")
return props.metadata.diagnostics?.[filePath] ?? []
})
return ( return (
<Switch> <Switch>
<Match when={props.metadata.diagnostics !== undefined}> <Match when={props.metadata.diagnostics !== undefined}>
@@ -1780,15 +1775,7 @@ function Write(props: ToolProps<typeof WriteTool>) {
content={code()} content={code()}
/> />
</line_number> </line_number>
<Show when={diagnostics().length}> <Diagnostics diagnostics={props.metadata.diagnostics} filePath={props.input.filePath ?? ""} />
<For each={diagnostics()}>
{(diagnostic) => (
<text fg={theme.error}>
Error [{diagnostic.range.start.line}:{diagnostic.range.start.character}]: {diagnostic.message}
</text>
)}
</For>
</Show>
</BlockTool> </BlockTool>
</Match> </Match>
<Match when={true}> <Match when={true}>
@@ -1972,12 +1959,6 @@ function Edit(props: ToolProps<typeof EditTool>) {
const diffContent = createMemo(() => props.metadata.diff) 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 ( return (
<Switch> <Switch>
<Match when={props.metadata.diff !== undefined}> <Match when={props.metadata.diff !== undefined}>
@@ -2003,18 +1984,7 @@ function Edit(props: ToolProps<typeof EditTool>) {
removedLineNumberBg={theme.diffRemovedLineNumberBg} removedLineNumberBg={theme.diffRemovedLineNumberBg}
/> />
</box> </box>
<Show when={diagnostics().length}> <Diagnostics diagnostics={props.metadata.diagnostics} filePath={props.input.filePath ?? ""} />
<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>
</BlockTool> </BlockTool>
</Match> </Match>
<Match when={true}> <Match when={true}>
@@ -2086,6 +2056,7 @@ function ApplyPatch(props: ToolProps<typeof ApplyPatchTool>) {
} }
> >
<Diff diff={file.diff} filePath={file.filePath} /> <Diff diff={file.diff} filePath={file.filePath} />
<Diagnostics diagnostics={props.metadata.diagnostics} filePath={file.movePath ?? file.filePath} />
</Show> </Show>
</BlockTool> </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) { function normalizePath(input?: string) {
if (!input) return "" if (!input) return ""
if (path.isAbsolute(input)) { if (path.isAbsolute(input)) {