From 44f6a7567adde5a2cb5db9b356f49fa56396d8ae Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Mon, 24 Nov 2025 22:25:45 -0500 Subject: fix(agent): round credits to 2 decimal places and use totalCredits Amp-Thread-ID: https://ampcode.com/threads/T-ac41b9b6-d117-46de-9e4f-842887a22f1d Co-authored-by: Amp --- Omni/Agent/Log.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Omni/Agent/Log.hs b/Omni/Agent/Log.hs index 2942563..e0e05a1 100644 --- a/Omni/Agent/Log.hs +++ b/Omni/Agent/Log.hs @@ -16,6 +16,7 @@ import qualified Data.Text.IO as TIO import qualified System.Console.ANSI as ANSI import qualified System.IO as IO import System.IO.Unsafe (unsafePerformIO) +import Text.Printf (printf) -- | Status of the agent for the UI data Status = Status @@ -113,7 +114,8 @@ render = do ANSI.hCursorDown IO.stderr 1 ANSI.hSetCursorColumn IO.stderr 0 ANSI.hClearLine IO.stderr - TIO.hPutStr IO.stderr ("Files: " <> tshow statusFiles <> " | Credits: $" <> tshow statusCredits) + let creditsStr = Text.pack (printf "%.2f" statusCredits) + TIO.hPutStr IO.stderr ("Files: " <> tshow statusFiles <> " | Credits: $" <> creditsStr) -- Line 4: Time ANSI.hCursorDown IO.stderr 1 @@ -166,7 +168,7 @@ updateFromEntry :: LogEntry -> Status -> Status updateFromEntry LogEntry {..} s = s { statusThread = leThreadId <|> statusThread s, - statusCredits = maybe (statusCredits s) (/ 100.0) (leTotalCredits <|> leCredits), + statusCredits = maybe (statusCredits s) (/ 100.0) leTotalCredits, -- Only update if totalCredits is present statusTime = maybe (statusTime s) formatTime leTimestamp } -- cgit v1.2.3