Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/telegram_agent_bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5327,7 +5327,9 @@ async def text_handler(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
if not success:
await safe_reply(update.message, f"❌ {message}")
return
if not queued:
if queued:
await safe_reply(update.message, f"⏳ {message}")
else:
await mark_window_working(context.bot, user.id, wid, thread_id)

# Start background capture for ! bash command output
Expand Down
51 changes: 51 additions & 0 deletions tests/telegram_agent_bot/test_existing_window_binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,57 @@ async def test_bound_topic_does_not_block_on_background_confirmation(self):

safe_reply.assert_not_awaited()

@pytest.mark.asyncio
async def test_bound_topic_acknowledges_queued_text(self):
update = _make_text_update("hi")
context = _make_context()

fake_window = MagicMock()
fake_window.window_id = "@1"
fake_window.window_name = "Projects"
fake_window.cwd = "/tmp/project"

with (
patch("telegram_agent_bot.bot.is_user_allowed", return_value=True),
patch("telegram_agent_bot.bot._get_thread_id", return_value=42),
patch("telegram_agent_bot.bot.session_manager") as mock_sm,
patch("telegram_agent_bot.bot.tmux_manager") as mock_tmux,
patch(
"telegram_agent_bot.bot.enqueue_status_update", new_callable=AsyncMock
),
patch(
"telegram_agent_bot.bot.safe_reply", new_callable=AsyncMock
) as safe_reply,
patch(
"telegram_agent_bot.bot._send_or_queue_agent_input",
new_callable=AsyncMock,
return_value=(
True,
"Agent is busy; queued until ready (1/20)",
True,
),
),
patch(
"telegram_agent_bot.bot.mark_window_working",
new_callable=AsyncMock,
) as mark_working,
patch("telegram_agent_bot.bot._cancel_bash_capture"),
):
mock_sm.get_window_for_thread.return_value = "@1"
mock_sm.window_has_usage_limit_exceeded = AsyncMock(return_value=False)
mock_tmux.find_window_by_id = AsyncMock(return_value=fake_window)
mock_tmux.capture_pane = AsyncMock(return_value="")

from telegram_agent_bot.bot import text_handler

await text_handler(update, context)

safe_reply.assert_awaited_once_with(
update.message,
"⏳ Agent is busy; queued until ready (1/20)",
)
mark_working.assert_not_awaited()

@pytest.mark.asyncio
async def test_bound_topic_reports_when_direct_send_fails(self):
update = _make_text_update("hi")
Expand Down
Loading