mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-18 04:41:56 +00:00
fix(kanban): route gateway create auto-subscribe to explicit board
This commit is contained in:
parent
64145a1996
commit
f6d4f3c37d
2 changed files with 72 additions and 2 deletions
|
|
@ -8329,6 +8329,7 @@ class GatewayRunner:
|
|||
"""
|
||||
import asyncio
|
||||
import re
|
||||
import shlex
|
||||
from hermes_cli.kanban import run_slash
|
||||
|
||||
text = (event.text or "").strip()
|
||||
|
|
@ -8338,7 +8339,26 @@ class GatewayRunner:
|
|||
if text.startswith("kanban"):
|
||||
text = text[len("kanban"):].lstrip()
|
||||
|
||||
is_create = text.split(None, 1)[:1] == ["create"]
|
||||
tokens = shlex.split(text) if text else []
|
||||
requested_board = None
|
||||
action = None
|
||||
i = 0
|
||||
while i < len(tokens):
|
||||
tok = tokens[i]
|
||||
if tok == "--board":
|
||||
if i + 1 >= len(tokens):
|
||||
break
|
||||
requested_board = tokens[i + 1]
|
||||
i += 2
|
||||
continue
|
||||
if tok.startswith("--board="):
|
||||
requested_board = tok.split("=", 1)[1]
|
||||
i += 1
|
||||
continue
|
||||
action = tok
|
||||
break
|
||||
|
||||
is_create = action == "create"
|
||||
|
||||
try:
|
||||
output = await asyncio.to_thread(run_slash, text)
|
||||
|
|
@ -8365,7 +8385,7 @@ class GatewayRunner:
|
|||
if platform_str and chat_id:
|
||||
def _sub():
|
||||
from hermes_cli import kanban_db as _kb
|
||||
conn = _kb.connect()
|
||||
conn = _kb.connect(board=requested_board)
|
||||
try:
|
||||
_kb.add_notify_sub(
|
||||
conn, task_id=task_id,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import asyncio
|
|||
import pytest
|
||||
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from hermes_cli import kanban_db as kb
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
|
|
@ -429,3 +430,52 @@ async def test_notifier_delivers_subscription_owned_by_current_profile(kanban_ho
|
|||
finally:
|
||||
conn.close()
|
||||
assert subs == []
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_gateway_create_autosubscribes_on_explicit_board(kanban_home):
|
||||
"""`/kanban --board <slug> create ...` must subscribe on that board.
|
||||
|
||||
The gateway handler currently auto-subscribes after `/kanban create`,
|
||||
but the create detection must still work when the shared `--board`
|
||||
flag appears before the subcommand, and the subscription must land in
|
||||
that board's DB rather than the ambient/default board.
|
||||
"""
|
||||
from gateway.run import GatewayRunner
|
||||
from gateway.config import Platform
|
||||
|
||||
kb.create_board("projx")
|
||||
|
||||
runner = object.__new__(GatewayRunner)
|
||||
source = SimpleNamespace(
|
||||
platform=Platform.TELEGRAM,
|
||||
chat_id="chat1",
|
||||
thread_id="th1",
|
||||
user_id="u1",
|
||||
)
|
||||
event = SimpleNamespace(
|
||||
text='/kanban --board projx create "hello" --assignee alice',
|
||||
source=source,
|
||||
)
|
||||
|
||||
out = await GatewayRunner._handle_kanban_command(runner, event)
|
||||
|
||||
assert "subscribed" in out.lower()
|
||||
|
||||
conn = kb.connect(board="projx")
|
||||
try:
|
||||
subs = kb.list_notify_subs(conn)
|
||||
tasks = kb.list_tasks(conn)
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
assert [t.title for t in tasks] == ["hello"]
|
||||
assert len(subs) == 1
|
||||
assert subs[0]["chat_id"] == "chat1"
|
||||
assert subs[0]["thread_id"] == "th1"
|
||||
|
||||
conn = kb.connect(board="default")
|
||||
try:
|
||||
assert kb.list_notify_subs(conn) == []
|
||||
finally:
|
||||
conn.close()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue