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

Commit 3d1e61d

Browse files
committed
Show command details before execution in ToolExecutor
Added RenderPreExecutionCommand to display command, working directory, and session info before executing 'execute_command' tool calls. This improves user visibility into what is about to be run.
1 parent cd9ed0b commit 3d1e61d

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

LogiQCLI/Presentation/Console/Components/Services/ToolExecutor.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ private async Task<Message> ExecuteSingleToolAsync(ToolCall toolCall, bool inter
7070
};
7171
}
7272

73+
if (toolCall.Function.Name?.ToLowerInvariant() == "execute_command" && !string.IsNullOrEmpty(toolCall.Function.Arguments))
74+
{
75+
RenderPreExecutionCommand(toolCall.Function.Arguments);
76+
}
77+
7378
if (interactive)
7479
{
7580
await AnsiConsole.Status()
@@ -169,6 +174,47 @@ private void RenderToolExecutionComplete()
169174
AnsiConsole.WriteLine();
170175
}
171176

177+
private void RenderPreExecutionCommand(string arguments)
178+
{
179+
try
180+
{
181+
var args = JsonSerializer.Deserialize<Dictionary<string, object>>(arguments);
182+
var command = args?.GetValueOrDefault("command")?.ToString();
183+
var workingDir = args?.GetValueOrDefault("cwd")?.ToString();
184+
var sessionId = args?.GetValueOrDefault("session_id")?.ToString();
185+
186+
if (string.IsNullOrEmpty(command)) return;
187+
188+
AnsiConsole.WriteLine();
189+
190+
var commandInfo = new List<string>();
191+
commandInfo.Add($"[cyan]$ {Markup.Escape(command)}[/]");
192+
193+
if (!string.IsNullOrEmpty(workingDir))
194+
{
195+
commandInfo.Add($"[dim]Working Directory: {Markup.Escape(workingDir)}[/]");
196+
}
197+
198+
if (!string.IsNullOrEmpty(sessionId))
199+
{
200+
commandInfo.Add($"[dim]Session: {Markup.Escape(sessionId)}[/]");
201+
}
202+
203+
var panel = new Panel(string.Join("\n", commandInfo))
204+
.Header("[blue]💻 Executing Command[/]")
205+
.HeaderAlignment(Justify.Center)
206+
.Border(BoxBorder.Rounded)
207+
.BorderColor(Color.Blue)
208+
.Padding(1, 0)
209+
.Expand();
210+
211+
AnsiConsole.Write(panel);
212+
}
213+
catch
214+
{
215+
}
216+
}
217+
172218

173219
}
174220
}

0 commit comments

Comments
 (0)