From 066ed78b37c7d0d2d441c7a98ca12555bcece574 Mon Sep 17 00:00:00 2001 From: Matt McKenna Date: Thu, 5 Feb 2026 10:02:24 -0500 Subject: [PATCH 1/2] Include task ID and command in status line messages When a task was promoted from waiting to running, the status line only showed the task ID number instead of the command name. This made it hard to identify which task was running when multiple tasks were queued. All status line messages now include the task ID and a truncated command preview (max 50 chars) for better visibility. Co-Authored-By: Claude Opus 4.5 --- task_queue.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/task_queue.py b/task_queue.py index f5003cb..c4b5f5c 100644 --- a/task_queue.py +++ b/task_queue.py @@ -263,8 +263,9 @@ async def wait_for_turn(queue_name: str, command: str | None = None) -> int: queued_at = time.time() if ctx: + cmd_preview = (command[:50] + "...") if command and len(command) > 50 else command await ctx.info( - log_fmt(f"Request #{task_id} received. Entering '{queue_name}' queue.") + log_fmt(f"Task #{task_id} queued ({cmd_preview}). Entering '{queue_name}' queue.") ) last_pos = -1 @@ -293,12 +294,12 @@ async def wait_for_turn(queue_name: str, command: str | None = None) -> int: if pos != last_pos: if ctx: - await ctx.info(log_fmt(f"Position #{pos} in queue. Waiting...")) + await ctx.info(log_fmt(f"Task #{task_id} is position #{pos} in queue. Waiting...")) last_pos = pos elif wait_ticks % 10 == 0 and ctx: # Update every ~10 polls await ctx.info( log_fmt( - f"Still waiting... Position #{pos} ({int(wait_ticks * POLL_INTERVAL_WAITING)}s elapsed)" + f"Task #{task_id} still waiting... Position #{pos} ({int(wait_ticks * POLL_INTERVAL_WAITING)}s elapsed)" ) ) @@ -329,7 +330,9 @@ async def wait_for_turn(queue_name: str, command: str | None = None) -> int: wait_time_seconds=round(wait_time, 2), ) if ctx: - await ctx.info(log_fmt("Lock ACQUIRED. Starting execution.")) + # Include task ID and truncated command for visibility + cmd_preview = (command[:50] + "...") if command and len(command) > 50 else command + await ctx.info(log_fmt(f"Task #{task_id} lock ACQUIRED. Running: {cmd_preview}")) return task_id await asyncio.sleep(POLL_INTERVAL_READY) @@ -368,7 +371,7 @@ async def release_lock(task_id: int): pass if ctx: - await ctx.info(log_fmt("Task complete. Queue slot released.")) + await ctx.info(log_fmt(f"Task #{task_id} complete. Queue slot released.")) # --- The Tool --- From 7e925dd09de8ae7914cb30d98d2db55ca3b175e0 Mon Sep 17 00:00:00 2001 From: Matt McKenna Date: Thu, 5 Feb 2026 10:20:41 -0500 Subject: [PATCH 2/2] Address PR review feedback: DRY and None handling - Compute cmd_preview once at function start instead of twice - Handle None command gracefully by omitting from message instead of showing "(None)" or "Running: None" Co-Authored-By: Claude Opus 4.5 --- task_queue.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/task_queue.py b/task_queue.py index c4b5f5c..211cb29 100644 --- a/task_queue.py +++ b/task_queue.py @@ -248,6 +248,9 @@ async def wait_for_turn(queue_name: str, command: str | None = None) -> int: except LookupError: pass # Running outside request context (e.g., in tests) + # Compute command preview once for status messages (truncate long commands) + cmd_preview = (command[:50] + "...") if command and len(command) > 50 else command + with get_db() as conn: cursor = conn.execute( "INSERT INTO queue (queue_name, status, pid, server_id, command) VALUES (?, ?, ?, ?, ?)", @@ -263,9 +266,11 @@ async def wait_for_turn(queue_name: str, command: str | None = None) -> int: queued_at = time.time() if ctx: - cmd_preview = (command[:50] + "...") if command and len(command) > 50 else command await ctx.info( - log_fmt(f"Task #{task_id} queued ({cmd_preview}). Entering '{queue_name}' queue.") + log_fmt( + f"Task #{task_id} queued{f' ({cmd_preview})' if cmd_preview else ''}. " + f"Entering '{queue_name}' queue." + ) ) last_pos = -1 @@ -330,9 +335,8 @@ async def wait_for_turn(queue_name: str, command: str | None = None) -> int: wait_time_seconds=round(wait_time, 2), ) if ctx: - # Include task ID and truncated command for visibility - cmd_preview = (command[:50] + "...") if command and len(command) > 50 else command - await ctx.info(log_fmt(f"Task #{task_id} lock ACQUIRED. Running: {cmd_preview}")) + msg = f"Task #{task_id} lock ACQUIRED.{f' Running: {cmd_preview}' if cmd_preview else ''}" + await ctx.info(log_fmt(msg)) return task_id await asyncio.sleep(POLL_INTERVAL_READY)