Fix agentd top TUI dashboard - multiple issues with current implementation.
getRunningAgents returns completed/failed agents too. Should default to running only, with --all flag to show everything.
Uses B.padRight (B.Pad 2) which adds 2 spaces after variable-length content. Columns don't line up.
run-abc123 Running 5 iterations - 1.23¢
run-xyz Completed 42 iterations - 15.67¢
Should use B.hLimit for fixed-width columns:
run-abc123 Running 5 iters - 1.23¢
run-xyz Completed 42 iters - 15.67¢
The TUI loads agents once at startup and never refreshes. Should poll every few seconds or use file watching.
Pressing Enter on a selected agent should switch to log-tailing view (like agentd watch). Currently does nothing.
getRunningAgents workspace showAll = do
...
let filtered = if showAll
then results
else filter (\a -> aiStatus a == "Running") results
pure filtered
Add --all flag to topParser.
renderAgent selected agent =
style <|
B.hBox
[ B.hLimit 24 <| B.padRight B.Max (B.txt <| aiRunId agent),
B.hLimit 10 <| B.padRight B.Max (B.txt <| aiStatus agent),
B.hLimit 14 <| B.padRight B.Max (B.txt <| aiDuration agent),
B.hLimit 10 <| B.padRight B.Max (B.txt <| fromMaybe "-" (aiTokens agent)),
B.hLimit 10 <| B.padRight B.Max (B.txt <| fromMaybe "-" (aiCost agent)),
B.txt <| fromMaybe "-" (aiCurrentActivity agent)
]
Same for header row.
Use Brick's BChan for custom events with a background thread:
runTop workspace = do
chan <- BChan.newBChan 10
-- Background thread polls every 2 seconds
_ <- forkIO <| forever <| do
threadDelay 2000000
agents <- getRunningAgents workspace False
BChan.writeBChan chan (AgentsUpdated agents)
let app = B.App
{ ...
B.appHandleEvent = handleTopEvent workspace chan,
...
}
let buildVty = Vty.mkVty Vty.defaultConfig
initialVty <- buildVty
_ <- B.customMain initialVty buildVty (Just chan) app initialState
pure ()
handleTopEvent workspace event = do
case event of
B.VtyEvent (VtyEvents.EvKey VtyEvents.KEnter []) -> do
state <- B.get
case BList.listSelectedElement (tsAgents state) of
Nothing -> pure ()
Just (_, agent) -> do
-- Switch to watch mode for this agent
B.suspendAndResume <| do
runWatch (Text.unpack <| aiRunId agent) False
pure state
...
Or switch to a split view with list on top, logs on bottom.
--all flag shows completed/failed too