← Back to task

Commit 83d8bb59

commit 83d8bb59d7c5f9177f486c0487e02499205aeda2
Author: Ben Sima <ben@bensima.com>
Date:   Thu Jan 1 12:00:45 2026

    Add /ready command to show tasks ready for work (t-280.2.5)
    
    Added handleReadyCommand that responds to:
    - /ready
    - ready
    - show ready
    - what's ready
    
    Shows up to 10 ready tasks with ID, priority, and truncated title.
    Formatted with markdown for Telegram display.
    
    Task-Id: t-280.2.5

diff --git a/Omni/Agent/Telegram.hs b/Omni/Agent/Telegram.hs
index 8767a987..3be4ebdd 100644
--- a/Omni/Agent/Telegram.hs
+++ b/Omni/Agent/Telegram.hs
@@ -61,6 +61,7 @@ module Omni.Agent.Telegram
     recordUserChat,
     lookupChatId,
     handleRemindersCommand,
+    handleReadyCommand,
 
     -- * System Prompt
     telegramSystemPrompt,
@@ -112,6 +113,7 @@ import qualified Omni.Agent.Tools.Outreach as Outreach
 import qualified Omni.Agent.Tools.Pdf as Pdf
 import qualified Omni.Agent.Tools.Python as Python
 import qualified Omni.Agent.Tools.Tasks as Tasks
+import qualified Omni.Task.Core as Task
 import qualified Omni.Agent.Tools.Todos as Todos
 import qualified Omni.Agent.Tools.WebReader as WebReader
 import qualified Omni.Agent.Tools.WebSearch as WebSearch
@@ -810,8 +812,9 @@ handleAuthorizedMessage tgConfig provider engineCfg msg uid userName chatId = do
   -- Check for special commands before LLM processing
   outreachHandled <- handleOutreachCommand tgConfig chatId threadId msgText
   remindersHandled <- if outreachHandled then pure True else handleRemindersCommand uid chatId threadId msgText
+  readyHandled <- if remindersHandled then pure True else handleReadyCommand chatId threadId msgText
 
-  unless remindersHandled <| handleAuthorizedMessageContinued tgConfig provider engineCfg msg uid userName chatId
+  unless readyHandled <| handleAuthorizedMessageContinued tgConfig provider engineCfg msg uid userName chatId
 
 handleAuthorizedMessageContinued ::
   Types.TelegramConfig ->
@@ -996,8 +999,9 @@ handleAuthorizedMessageBatch tgConfig provider engineCfg msg uid userName chatId
   -- Check for special commands before LLM processing
   outreachHandled <- handleOutreachCommand tgConfig chatId threadId batchedText
   remindersHandled <- if outreachHandled then pure True else handleRemindersCommand uid chatId threadId batchedText
+  readyHandled <- if remindersHandled then pure True else handleReadyCommand chatId threadId batchedText
 
-  unless remindersHandled <| handleAuthorizedMessageBatchContinued tgConfig provider engineCfg msg uid userName chatId batchedText
+  unless readyHandled <| handleAuthorizedMessageBatchContinued tgConfig provider engineCfg msg uid userName chatId batchedText
 
 handleAuthorizedMessageBatchContinued ::
   Types.TelegramConfig ->
@@ -1749,6 +1753,32 @@ formatDraftForReview draft =
 -- | Handle /reminders commands
 -- Commands:
 --   /reminders              - List active reminders
+-- | Handle /ready command - show tasks ready for work
+handleReadyCommand :: Int -> Maybe Int -> Text -> IO Bool
+handleReadyCommand chatId mThreadId cmd
+  | cmd == "/ready" || cmd == "/ready " || cmd == "ready" || cmd == "show ready" || cmd == "what's ready" = do
+      readyTasks <- Task.getReadyTasks
+      let msg = if null readyTasks
+            then "No tasks ready right now."
+            else formatReadyTasks (take 10 readyTasks)
+      _ <- Messages.enqueueImmediate Nothing chatId mThreadId msg (Just "system") Nothing
+      pure True
+  | otherwise = pure False
+  where
+    formatReadyTasks :: [Task.Task] -> Text
+    formatReadyTasks tasks =
+      "📋 *Ready tasks:*\n\n"
+        <> Text.intercalate "\n" (map formatTask tasks)
+        <> "\n\n_Reply with a task ID to start work._"
+    
+    formatTask :: Task.Task -> Text
+    formatTask t =
+      "• `" <> Task.taskId t <> "` [" <> tshow (Task.taskPriority t) <> "] "
+        <> Text.take 50 (Task.taskTitle t)
+        <> if Text.length (Task.taskTitle t) > 50 then "..." else ""
+
+-- | Handle /reminders commands
+--   /reminders              - List active reminders
 --   /reminders add <time> <message> - Add new reminder
 --   /reminders delete <id>  - Delete a reminder
 --   /reminders edit <id> <new message> - Edit reminder text