diff options
| author | Ben Sima <ben@bensima.com> | 2025-11-22 08:36:00 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-11-22 08:36:00 -0500 |
| commit | 4b9f6e6669eebc7edf61c223b71ffcc44a0ff1c8 (patch) | |
| tree | 21578ed55bf3768a541d0c9daeb27e637759304d /Omni/Agent/LogTest.hs | |
| parent | 3300f66017a009f6e4a83e4bc83a6ebb16fd528a (diff) | |
| parent | 0a3fc4d3991b6219abf9b6445e551f37f8d18db0 (diff) | |
Merge task t-rWclFp3vN: Improve Worker status bar activity formatting
Diffstat (limited to 'Omni/Agent/LogTest.hs')
| -rw-r--r-- | Omni/Agent/LogTest.hs | 78 |
1 files changed, 14 insertions, 64 deletions
diff --git a/Omni/Agent/LogTest.hs b/Omni/Agent/LogTest.hs index 518147e..97b558d 100644 --- a/Omni/Agent/LogTest.hs +++ b/Omni/Agent/LogTest.hs @@ -5,7 +5,6 @@ module Omni.Agent.LogTest where import Alpha -import qualified Data.Set as Set import Omni.Agent.Log import qualified Omni.Test as Test @@ -17,9 +16,7 @@ tests = Test.group "Omni.Agent.Log" [ Test.unit "Parse LogEntry" testParse, - Test.unit "Format LogEntry" testFormat, - Test.unit "Update Status" testUpdateStatus, - Test.unit "Render Status" testRenderStatus + Test.unit "Format LogEntry" testFormat ] testParse :: IO () @@ -27,13 +24,12 @@ testParse = do let json = "{\"message\": \"executing 1 tools in 1 batch(es)\", \"batches\": [[\"grep\"]]}" let expected = LogEntry - { leMessage = "executing 1 tools in 1 batch(es)", + { leMessage = Just "executing 1 tools in 1 batch(es)", leLevel = Nothing, leToolName = Nothing, leBatches = Just [["grep"]], leMethod = Nothing, - lePath = Nothing, - leTimestamp = Nothing + lePath = Nothing } parseLine json @?= Just expected @@ -41,84 +37,38 @@ testFormat :: IO () testFormat = do let entry = LogEntry - { leMessage = "executing 1 tools in 1 batch(es)", + { leMessage = Just "executing 1 tools in 1 batch(es)", leLevel = Nothing, leToolName = Nothing, leBatches = Just [["grep"]], leMethod = Nothing, - lePath = Nothing, - leTimestamp = Nothing + lePath = Nothing } - format entry @?= Just "🤖 THOUGHT: Planning tool execution (grep)" + -- Expect NO emoji + formatLogEntry entry @?= Just "THOUGHT: Planning tool execution (grep)" let entry2 = LogEntry - { leMessage = "some random log", + { leMessage = Just "some random log", leLevel = Nothing, leToolName = Nothing, leBatches = Nothing, leMethod = Nothing, - lePath = Nothing, - leTimestamp = Nothing + lePath = Nothing } - format entry2 @?= Nothing + formatLogEntry entry2 @?= Nothing let entry3 = LogEntry - { leMessage = "some error", + { leMessage = Just "some error", leLevel = Just "error", leToolName = Nothing, leBatches = Nothing, leMethod = Nothing, - lePath = Nothing, - leTimestamp = Nothing + lePath = Nothing } - format entry3 @?= Just "❌ ERROR: some error" - -testUpdateStatus :: IO () -testUpdateStatus = do - let s0 = initialStatus "worker-1" - let e1 = - LogEntry - { leMessage = "executing 1 tools in 1 batch(es)", - leLevel = Nothing, - leToolName = Nothing, - leBatches = Just [["grep"]], - leMethod = Nothing, - lePath = Nothing, - leTimestamp = Just "12:00:00" - } - let s1 = updateStatus e1 s0 - sLastActivity s1 @?= "🤖 THOUGHT: Planning tool execution (grep)" - sStartTime s1 @?= Just "12:00:00" - - let e2 = - LogEntry - { leMessage = "ide-fs", - leLevel = Nothing, - leToolName = Nothing, - leBatches = Nothing, - leMethod = Just "readFile", - lePath = Just "/path/to/file", - leTimestamp = Just "12:00:01" - } - let s2 = updateStatus e2 s1 - sLastActivity s2 @?= "📂 READ: /path/to/file" - Set.member "/path/to/file" (sFiles s2) @?= True - sStartTime s2 @?= Just "12:00:00" -- Should preserve start time - -testRenderStatus :: IO () -testRenderStatus = do - let s = - Status - { sWorkerName = "worker-1", - sTaskId = Just "t-123", - sFiles = Set.fromList ["file1", "file2"], - sStartTime = Just "12:00", - sLastActivity = "Running..." - } - let output = renderStatus s - output @?= "[Worker: worker-1] Task: t-123 | Files: 2\nRunning..." + -- Expect NO emoji + formatLogEntry entry3 @?= Just "ERROR: some error" (@?=) :: (Eq a, Show a) => a -> a -> IO () (@?=) = (Test.@?=) |
