From e733b42ceb547015cba5c99a612857727b31d3c8 Mon Sep 17 00:00:00 2001 From: Omni Worker Date: Sat, 22 Nov 2025 04:53:03 -0500 Subject: feat(agent): responsive 4-line status bar with thread ID Amp-Thread-ID: https://ampcode.com/threads/T-79499d9e-f4f4-40de-893c-524c32a45483 Co-authored-by: Amp --- Omni/Agent/Log.hs | 63 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 29 deletions(-) (limited to 'Omni/Agent/Log.hs') diff --git a/Omni/Agent/Log.hs b/Omni/Agent/Log.hs index afaf1da..1f2746d 100644 --- a/Omni/Agent/Log.hs +++ b/Omni/Agent/Log.hs @@ -16,6 +16,7 @@ import System.IO.Unsafe (unsafePerformIO) data Status = Status { statusWorker :: Text, statusTask :: Maybe Text, + statusThreadId :: Maybe Text, statusFiles :: Int, statusCredits :: Double, statusTime :: Text, -- formatted time string @@ -28,6 +29,7 @@ emptyStatus workerName = Status { statusWorker = workerName, statusTask = Nothing, + statusThreadId = Nothing, statusFiles = 0, statusCredits = 0.0, statusTime = "00:00", @@ -44,10 +46,9 @@ init :: Text -> IO () init workerName = do IO.hSetBuffering IO.stderr IO.LineBuffering writeIORef currentStatus (emptyStatus workerName) - -- Reserve 2 lines at bottom - IO.hPutStrLn IO.stderr "" - IO.hPutStrLn IO.stderr "" - ANSI.hCursorUp IO.stderr 2 + -- Reserve 4 lines at bottom + replicateM_ 4 (IO.hPutStrLn IO.stderr "") + ANSI.hCursorUp IO.stderr 4 -- | Update the status update :: (Status -> Status) -> IO () @@ -62,50 +63,54 @@ updateActivity msg = update (\s -> s {statusActivity = msg}) -- | Log a scrolling message (appears above status bars) log :: Text -> IO () log msg = do - -- Clear status bars + -- Clear status bars (4 lines) ANSI.hClearLine IO.stderr ANSI.hCursorDown IO.stderr 1 ANSI.hClearLine IO.stderr - ANSI.hCursorUp IO.stderr 1 - + ANSI.hCursorDown IO.stderr 1 + ANSI.hClearLine IO.stderr + ANSI.hCursorDown IO.stderr 1 + ANSI.hClearLine IO.stderr + ANSI.hCursorUp IO.stderr 3 + -- Print message (scrolls screen) TIO.hPutStrLn IO.stderr msg - + -- Re-render status bars at bottom -- (Since we scrolled, we are now on the line above where the first status line should be) render --- | Render the two status lines +-- | Render the 4 status lines (Vertical Layout) render :: IO () render = do Status {..} <- readIORef currentStatus - - -- Line 1: Meta - -- [Worker: name] Task: t-123 | Files: 3 | Credits: $0.45 | Time: 05:23 + let taskStr = maybe "None" identity statusTask - meta = - "[Worker: " - <> statusWorker - <> "] Task: " - <> taskStr - <> " | Files: " - <> tshow statusFiles - <> " | Credits: $" - <> tshow statusCredits - <> " | Time: " - <> statusTime + threadStr = maybe "None" identity statusThreadId + + -- Line 1: Worker + Time + ANSI.hSetCursorColumn IO.stderr 0 + ANSI.hClearLine IO.stderr + TIO.hPutStr IO.stderr <| "Worker: " <> statusWorker <> " | Time: " <> statusTime + -- Line 2: Task + ANSI.hCursorDown IO.stderr 1 ANSI.hSetCursorColumn IO.stderr 0 ANSI.hClearLine IO.stderr - TIO.hPutStr IO.stderr meta + TIO.hPutStr IO.stderr <| "Task: " <> taskStr - -- Line 2: Activity - -- [14:05:22] > Thinking... + -- Line 3: Thread + Credits ANSI.hCursorDown IO.stderr 1 ANSI.hSetCursorColumn IO.stderr 0 ANSI.hClearLine IO.stderr - TIO.hPutStr IO.stderr ("> " <> statusActivity) + TIO.hPutStr IO.stderr <| "Thread: " <> threadStr <> " | Credits: $" <> tshow statusCredits - -- Return cursor to line 1 - ANSI.hCursorUp IO.stderr 1 + -- Line 4: Activity + ANSI.hCursorDown IO.stderr 1 + ANSI.hSetCursorColumn IO.stderr 0 + ANSI.hClearLine IO.stderr + TIO.hPutStr IO.stderr ("> " <> statusActivity) + + -- Return cursor to Line 1 + ANSI.hCursorUp IO.stderr 3 IO.hFlush IO.stderr -- cgit v1.2.3 From 8b9a184260b5dfc563b884071d10511602606ccf Mon Sep 17 00:00:00 2001 From: Omni Worker Date: Sat, 22 Nov 2025 04:55:40 -0500 Subject: style: fix linting Amp-Thread-ID: https://ampcode.com/threads/T-79499d9e-f4f4-40de-893c-524c32a45483 Co-authored-by: Amp --- Omni/Agent/Log.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Omni/Agent/Log.hs') diff --git a/Omni/Agent/Log.hs b/Omni/Agent/Log.hs index 1f2746d..084052b 100644 --- a/Omni/Agent/Log.hs +++ b/Omni/Agent/Log.hs @@ -72,10 +72,10 @@ log msg = do ANSI.hCursorDown IO.stderr 1 ANSI.hClearLine IO.stderr ANSI.hCursorUp IO.stderr 3 - + -- Print message (scrolls screen) TIO.hPutStrLn IO.stderr msg - + -- Re-render status bars at bottom -- (Since we scrolled, we are now on the line above where the first status line should be) render @@ -84,10 +84,10 @@ log msg = do render :: IO () render = do Status {..} <- readIORef currentStatus - + let taskStr = maybe "None" identity statusTask threadStr = maybe "None" identity statusThreadId - + -- Line 1: Worker + Time ANSI.hSetCursorColumn IO.stderr 0 ANSI.hClearLine IO.stderr @@ -110,7 +110,7 @@ render = do ANSI.hSetCursorColumn IO.stderr 0 ANSI.hClearLine IO.stderr TIO.hPutStr IO.stderr ("> " <> statusActivity) - + -- Return cursor to Line 1 ANSI.hCursorUp IO.stderr 3 IO.hFlush IO.stderr -- cgit v1.2.3 From e4aaed813097dc880556ff8abc01af279b85f325 Mon Sep 17 00:00:00 2001 From: Omni Worker Date: Sat, 22 Nov 2025 05:10:23 -0500 Subject: feat: split thread and credits lines in worker status bar Amp-Thread-ID: https://ampcode.com/threads/T-5a2ca80d-5cba-409f-a262-6b5c652c257d Co-authored-by: Amp --- Omni/Agent/Log.hs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'Omni/Agent/Log.hs') diff --git a/Omni/Agent/Log.hs b/Omni/Agent/Log.hs index 084052b..2e26272 100644 --- a/Omni/Agent/Log.hs +++ b/Omni/Agent/Log.hs @@ -46,9 +46,9 @@ init :: Text -> IO () init workerName = do IO.hSetBuffering IO.stderr IO.LineBuffering writeIORef currentStatus (emptyStatus workerName) - -- Reserve 4 lines at bottom - replicateM_ 4 (IO.hPutStrLn IO.stderr "") - ANSI.hCursorUp IO.stderr 4 + -- Reserve 5 lines at bottom + replicateM_ 5 (IO.hPutStrLn IO.stderr "") + ANSI.hCursorUp IO.stderr 5 -- | Update the status update :: (Status -> Status) -> IO () @@ -63,7 +63,9 @@ updateActivity msg = update (\s -> s {statusActivity = msg}) -- | Log a scrolling message (appears above status bars) log :: Text -> IO () log msg = do - -- Clear status bars (4 lines) + -- Clear status bars (5 lines) + ANSI.hClearLine IO.stderr + ANSI.hCursorDown IO.stderr 1 ANSI.hClearLine IO.stderr ANSI.hCursorDown IO.stderr 1 ANSI.hClearLine IO.stderr @@ -71,7 +73,7 @@ log msg = do ANSI.hClearLine IO.stderr ANSI.hCursorDown IO.stderr 1 ANSI.hClearLine IO.stderr - ANSI.hCursorUp IO.stderr 3 + ANSI.hCursorUp IO.stderr 4 -- Print message (scrolls screen) TIO.hPutStrLn IO.stderr msg @@ -80,7 +82,7 @@ log msg = do -- (Since we scrolled, we are now on the line above where the first status line should be) render --- | Render the 4 status lines (Vertical Layout) +-- | Render the 5 status lines (Vertical Layout) render :: IO () render = do Status {..} <- readIORef currentStatus @@ -99,18 +101,24 @@ render = do ANSI.hClearLine IO.stderr TIO.hPutStr IO.stderr <| "Task: " <> taskStr - -- Line 3: Thread + Credits + -- Line 3: Thread ANSI.hCursorDown IO.stderr 1 ANSI.hSetCursorColumn IO.stderr 0 ANSI.hClearLine IO.stderr - TIO.hPutStr IO.stderr <| "Thread: " <> threadStr <> " | Credits: $" <> tshow statusCredits + TIO.hPutStr IO.stderr <| "Thread: " <> threadStr - -- Line 4: Activity + -- Line 4: Credits + ANSI.hCursorDown IO.stderr 1 + ANSI.hSetCursorColumn IO.stderr 0 + ANSI.hClearLine IO.stderr + TIO.hPutStr IO.stderr <| "Credits: $" <> tshow statusCredits + + -- Line 5: Activity ANSI.hCursorDown IO.stderr 1 ANSI.hSetCursorColumn IO.stderr 0 ANSI.hClearLine IO.stderr TIO.hPutStr IO.stderr ("> " <> statusActivity) -- Return cursor to Line 1 - ANSI.hCursorUp IO.stderr 3 + ANSI.hCursorUp IO.stderr 4 IO.hFlush IO.stderr -- cgit v1.2.3