diff options
| author | Ben Sima <ben@bensima.com> | 2025-11-24 22:25:45 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-11-24 22:25:45 -0500 |
| commit | 44f6a7567adde5a2cb5db9b356f49fa56396d8ae (patch) | |
| tree | ee005c81721f9f26093032d229602581e34ca1ab | |
| parent | e896b3ca80ca3916a8b5d1fdf7447446d6fa3ad7 (diff) | |
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 <amp@ampcode.com>
| -rw-r--r-- | Omni/Agent/Log.hs | 6 |
1 files 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 } |
