Skip to content
This repository was archived by the owner on Aug 13, 2025. It is now read-only.

Commit cd9ed0b

Browse files
committed
feat: enhance command execution visibility with pre-execution display
- Show command details before execution in a blue panel - Display full command output (up to 70 lines) instead of truncating to 100 chars - Add dedicated formatting for execute_command tool with command, working directory, and session info - Split display into two phases: "Executing Command" (before) and "Command Output" (after) - Improve user experience by providing clear visibility of what commands are being run This follows the conventional commit format used in the repository and clearly describes the enhancement to command execution visibility.
1 parent 6c7c57b commit cd9ed0b

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

LogiQCLI/Presentation/Common/Formatting/ToolDisplayFormatter.cs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ public static void RenderEnhancedToolResult(string toolName, string arguments, s
4747
case "move_file":
4848
RenderMoveFileResult(arguments, result);
4949
break;
50+
case "execute_command":
51+
RenderExecuteCommandResult(arguments, result);
52+
break;
5053
default:
5154
RenderBasicToolResult(toolName, result, hasError);
5255
break;
@@ -318,6 +321,71 @@ private static void RenderMoveFileResult(string arguments, string result)
318321
}
319322
}
320323

324+
private static void RenderExecuteCommandResult(string arguments, string result)
325+
{
326+
try
327+
{
328+
var args = JsonSerializer.Deserialize<Dictionary<string, object>>(arguments);
329+
var command = args?.GetValueOrDefault("command")?.ToString() ?? "Unknown command";
330+
var workingDir = args?.GetValueOrDefault("cwd")?.ToString();
331+
var sessionId = args?.GetValueOrDefault("session_id")?.ToString();
332+
var timeout = args?.GetValueOrDefault("timeout")?.ToString();
333+
334+
if (result.StartsWith("Error:"))
335+
{
336+
RenderBasicToolResult("execute_command", result, true);
337+
return;
338+
}
339+
340+
// Extract session ID from result if present
341+
var sessionIdFromResult = string.Empty;
342+
if (!string.IsNullOrEmpty(sessionId) && result.StartsWith("Session ID: "))
343+
{
344+
var lines = result.Split('\n');
345+
if (lines.Length > 0)
346+
{
347+
sessionIdFromResult = lines[0].Replace("Session ID: ", "").Trim();
348+
result = string.Join('\n', lines.Skip(1));
349+
}
350+
}
351+
var outputLines = result.Split('\n');
352+
var truncated = outputLines.Length > MaxDisplayLines;
353+
var displayLines = outputLines.Take(MaxDisplayLines).ToArray();
354+
355+
var outputDisplay = string.Join("\n", displayLines.Select(line =>
356+
{
357+
var trimmedLine = line.TrimEnd();
358+
return trimmedLine.Length > MaxLineLength
359+
? Markup.Escape(trimmedLine.Substring(0, MaxLineLength - 3)) + "..."
360+
: Markup.Escape(trimmedLine);
361+
}));
362+
363+
if (truncated)
364+
{
365+
outputDisplay += $"\n[dim]... and {outputLines.Length - MaxDisplayLines} more lines (output truncated)[/]";
366+
}
367+
368+
var outputContent = string.IsNullOrWhiteSpace(result)
369+
? "[dim]<no output>[/]"
370+
: outputDisplay;
371+
372+
var panel = new Panel(new Markup(outputContent))
373+
.Header("[green]📤 Command Output[/]")
374+
.HeaderAlignment(Justify.Center)
375+
.Border(BoxBorder.Rounded)
376+
.BorderColor(Color.Green)
377+
.Padding(1, 0)
378+
.Expand();
379+
380+
AnsiConsole.Write(panel);
381+
AnsiConsole.WriteLine();
382+
}
383+
catch
384+
{
385+
RenderBasicToolResult("execute_command", result, false);
386+
}
387+
}
388+
321389
private static void RenderBasicToolResult(string toolName, string result, bool hasError = false)
322390
{
323391
var displayResult = TruncateResult(result);

0 commit comments

Comments
 (0)