feat(coding-agent): added language-specific file icons to tool output
- Added language-specific file icons to LSP diagnostics output for improved file type recognition. - Added language-specific file icon to edit tool header display for visual consistency.
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
|
||||
- Added language-specific file icons to LSP diagnostics output showing file locations
|
||||
- Added language-specific file icon to edit tool header display
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
import type { AgentToolResult, RenderResultOptions } from "@oh-my-pi/pi-agent-core";
|
||||
import { Text } from "@oh-my-pi/pi-tui";
|
||||
import { highlight, supportsLanguage } from "cli-highlight";
|
||||
import type { Theme } from "../../../modes/interactive/theme/theme";
|
||||
import { getLanguageFromPath, type Theme } from "../../../modes/interactive/theme/theme";
|
||||
import type { LspParams, LspToolDetails } from "./types";
|
||||
|
||||
// =============================================================================
|
||||
@@ -186,6 +186,12 @@ function highlightCode(codeText: string, language: string, theme: Theme): string
|
||||
// Diagnostics Rendering
|
||||
// =============================================================================
|
||||
|
||||
function formatDiagnosticLocation(file: string, line: string | number, col: string | number, theme: Theme): string {
|
||||
const lang = getLanguageFromPath(file);
|
||||
const icon = theme.fg("muted", theme.getLangIcon(lang));
|
||||
return `${icon} ${file}:${line}:${col}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render diagnostics with color-coded severity.
|
||||
*/
|
||||
@@ -230,7 +236,7 @@ function renderDiagnostics(
|
||||
continue;
|
||||
}
|
||||
const severityColor = severityToColor(item.severity);
|
||||
const location = `${item.file}:${item.line}:${item.col}`;
|
||||
const location = formatDiagnosticLocation(item.file, item.line, item.col, theme);
|
||||
output += `\n ${theme.fg("dim", branch)} ${theme.fg(severityColor, location)} ${theme.fg(
|
||||
"dim",
|
||||
`[${item.severity}]`,
|
||||
@@ -259,7 +265,7 @@ function renderDiagnostics(
|
||||
continue;
|
||||
}
|
||||
const severityColor = severityToColor(item.severity);
|
||||
const location = `${item.file}:${item.line}:${item.col}`;
|
||||
const location = formatDiagnosticLocation(item.file, item.line, item.col, theme);
|
||||
const message = item.message ? ` ${theme.fg("muted", trimTo(item.message, 80, theme))}` : "";
|
||||
output += `\n ${theme.fg("dim", branch)} ${theme.fg(severityColor, location)}${message}`;
|
||||
}
|
||||
|
||||
@@ -202,7 +202,9 @@ function formatDiagnostics(diag: { errored: boolean; summary: string; messages:
|
||||
const fileBranch = isLastFile ? theme.tree.last : theme.tree.branch;
|
||||
|
||||
// File header with icon
|
||||
output += `\n ${theme.fg("dim", fileBranch)} ${theme.fg("muted", theme.icon.file)} ${theme.fg("accent", filePath)}`;
|
||||
const fileLang = getLanguageFromPath(filePath);
|
||||
const fileIcon = theme.fg("muted", theme.getLangIcon(fileLang));
|
||||
output += `\n ${theme.fg("dim", fileBranch)} ${fileIcon} ${theme.fg("accent", filePath)}`;
|
||||
shown++;
|
||||
|
||||
// Render diagnostics for this file
|
||||
@@ -840,6 +842,8 @@ export class ToolExecutionComponent extends Container {
|
||||
} else if (this.toolName === "edit") {
|
||||
const rawPath = this.args?.file_path || this.args?.path || "";
|
||||
const path = shortenPath(rawPath);
|
||||
const editLanguage = getLanguageFromPath(rawPath) ?? "text";
|
||||
const editIcon = theme.fg("muted", theme.getLangIcon(editLanguage));
|
||||
|
||||
// Build path display, appending :line if we have diff info
|
||||
let pathDisplay = path ? theme.fg("accent", path) : theme.fg("toolOutput", theme.format.ellipsis);
|
||||
@@ -852,9 +856,8 @@ export class ToolExecutionComponent extends Container {
|
||||
pathDisplay += theme.fg("warning", `:${firstChangedLine}`);
|
||||
}
|
||||
|
||||
text = `${theme.fg("toolTitle", theme.bold("edit"))} ${pathDisplay}`;
|
||||
text = `${theme.fg("toolTitle", theme.bold("edit"))} ${editIcon} ${pathDisplay}`;
|
||||
|
||||
const editLanguage = getLanguageFromPath(rawPath) ?? "text";
|
||||
const editLineCount = countLines(this.args?.newText ?? this.args?.oldText ?? "");
|
||||
text += `\n${formatMetadataLine(editLineCount, editLanguage)}`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user