From d3acbdec5c04f27d33d7b2023b544a640a611947 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Fri, 14 Nov 2025 15:52:28 -0500 Subject: Fix concurrent terminal update issues - Remove [+] display from reserveLine (was causing mangled output from concurrent writes) - Add [+] display in analyze function where it's single-threaded - Simplify cleanup to just move cursor down without clearing lines - This eliminates race conditions and terminal clearing issues --- Omni/Bild.hs | 1 + Omni/Log/Concurrent.hs | 20 ++------------------ 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/Omni/Bild.hs b/Omni/Bild.hs index 1bb42db..704a47d 100755 --- a/Omni/Bild.hs +++ b/Omni/Bild.hs @@ -542,6 +542,7 @@ analyze hmap ns = case Map.lookup ns hmap of let quapath = path user <- Env.getEnv "USER" /> Text.pack host <- HostName.getHostName /> Text.pack + Log.wipe >> Log.info ["+", nschunk namespace] contentLines <- withFile abspath ReadMode <| \h -> IO.hSetEncoding h IO.utf8_bom diff --git a/Omni/Log/Concurrent.hs b/Omni/Log/Concurrent.hs index 391fcff..204e497 100644 --- a/Omni/Log/Concurrent.hs +++ b/Omni/Log/Concurrent.hs @@ -89,11 +89,7 @@ withLineManager maxLines action = do result <- action mgr - forM_ [0 .. maxLines - 1] <| \_ -> do - ANSI.hCursorDown IO.stderr 1 - ANSI.hSetCursorColumn IO.stderr 0 - ANSI.hClearLine IO.stderr - + ANSI.hCursorDown IO.stderr maxLines writeIORef currentLineManager Nothing writeIORef namespaceLines Map.empty pure result @@ -122,19 +118,7 @@ reserveLine LineManager {..} ns = linesMap' = Map.insert lineNum (Just status) linesMap in (linesMap', Just lineNum) case mLine of - Just lineNum -> do - modifyIORef' namespaceLines (Map.insert ns lineNum) - currentLine <- readIORef lmCurrentLine - ANSI.hSaveCursor IO.stderr - ANSI.hSetCursorColumn IO.stderr 0 - let linesToMove = currentLine - lineNum - when (linesToMove > 0) <| ANSI.hCursorUp IO.stderr linesToMove - when (linesToMove < 0) <| ANSI.hCursorDown IO.stderr (abs linesToMove) - ANSI.hClearLine IO.stderr - let nsText = Text.pack (Namespace.toPath ns) - IO.hPutStr IO.stderr (Text.unpack <| "[+] " <> nsText) - IO.hFlush IO.stderr - ANSI.hRestoreCursor IO.stderr + Just lineNum -> modifyIORef' namespaceLines (Map.insert ns lineNum) Nothing -> pure () pure mLine where -- cgit v1.2.3