Fix formatting for multi-line command output and delete tasks after completion.

This commit is contained in:
Jakob Friedl
2025-05-23 16:02:16 +02:00
parent 5ab9cd302c
commit a8a32668d1
6 changed files with 33 additions and 21 deletions

View File

@@ -1,4 +1,4 @@
import terminal, strformat, strutils, sequtils, tables, json, times
import terminal, strformat, strutils, sequtils, tables, json, times, base64
import ./interact
import ../[types, globals, utils]
import ../db/database
@@ -163,8 +163,15 @@ proc handleResult*(listener, agent, task: string, taskResult: Task) =
{.cast(gcsafe).}:
cq.writeLine(fgBlack, styleBright, fmt"[*] [{task}] ", resetStyle, "Task execution finished.")
cq.writeLine(taskResult.result)
if taskResult.result != "":
cq.writeLine(fgBlack, styleBright, fmt"[*] [{task}] ", resetStyle, "Output:")
# TODO: Remove completed task from the queue
# Split result string on newline to keep formatting
for line in decode(taskResult.result).split("\n"):
cq.writeLine(line)
# Update task queue to include all tasks, except the one that was just completed
cq.agents[agent].tasks = cq.agents[agent].tasks.filterIt(it.id != task)
return