Compare commits

...

1 Commits

Author SHA1 Message Date
Dax Raad
4d81854149 feat: show LSP errors for apply_patch tool 2026-02-22 14:46:52 -05:00

View File

@@ -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 ?? ""} theme={theme} />
</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 ?? ""} theme={theme} />
</BlockTool>
</Match>
<Match when={true}>
@@ -2086,6 +2056,11 @@ function ApplyPatch(props: ToolProps<typeof ApplyPatchTool>) {
}
>
<Diff diff={file.diff} filePath={file.filePath} />
<Diagnostics
diagnostics={props.metadata.diagnostics}
filePath={file.movePath ?? file.filePath}
theme={theme}
/>
</Show>
</BlockTool>
)}
@@ -2163,6 +2138,32 @@ function Skill(props: ToolProps<typeof SkillTool>) {
)
}
function Diagnostics(props: {
diagnostics?: Record<string, Record<string, any>[]>
filePath: string
theme: { error: any }
}) {
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={props.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)) {