diff options
Diffstat (limited to 'Omni/Agent/Worker.hs')
| -rw-r--r-- | Omni/Agent/Worker.hs | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/Omni/Agent/Worker.hs b/Omni/Agent/Worker.hs index dabf45c..50ad2ae 100644 --- a/Omni/Agent/Worker.hs +++ b/Omni/Agent/Worker.hs @@ -125,13 +125,17 @@ processTask worker task = do TaskCore.logActivity tid TaskCore.Failed (Just (toMetadata [("reason", "max_retries_exceeded")])) TaskCore.updateTaskStatus tid TaskCore.Open [] else do + let currentReason = "attempt " <> tshow attempt <> ": commit_failed: " <> commitErr + let accumulatedReason = case maybeCtx of + Nothing -> currentReason + Just ctx -> TaskCore.retryReason ctx <> "\n" <> currentReason TaskCore.setRetryContext TaskCore.RetryContext { TaskCore.retryTaskId = tid, TaskCore.retryOriginalCommit = "", TaskCore.retryConflictFiles = [], TaskCore.retryAttempt = attempt, - TaskCore.retryReason = "commit_failed: " <> commitErr, + TaskCore.retryReason = accumulatedReason, TaskCore.retryNotes = maybeCtx +> TaskCore.retryNotes } TaskCore.logActivity tid TaskCore.Retrying (Just (toMetadata [("attempt", tshow attempt)])) @@ -329,19 +333,24 @@ formatCommitMessage task ampOutput = else subject <> "\n\n" <> body <> "\n\nTask-Id: " <> tid where cleanSubject s = - let stripped = Text.dropWhileEnd (`elem` ['.', ':', '!', '?', ' ']) s - truncated = if Text.length stripped > 52 then Text.take 49 stripped <> "..." else stripped - capitalized = case Text.uncons truncated of + let trailingPunct = ['.', ':', '!', '?', ',', ';', ' ', '-'] + stripped = Text.dropWhileEnd (`elem` trailingPunct) s + truncated = Text.take 72 stripped + noPunct = Text.dropWhileEnd (`elem` trailingPunct) truncated + capitalized = case Text.uncons noPunct of Just (c, rest) -> Text.cons (toUpper c) rest - Nothing -> truncated + Nothing -> noPunct in capitalized cleanBody :: Text -> Text cleanBody output = let stripped = Text.strip output - lns = Text.lines stripped - cleaned = map (Text.take 72) lns - in Text.intercalate "\n" cleaned + in if Text.null stripped + then "" + else + let lns = Text.lines stripped + cleaned = [Text.take 72 ln | ln <- lns] + in Text.intercalate "\n" cleaned monitorLog :: FilePath -> Process.ProcessHandle -> IO () monitorLog path ph = do |
