Skip to content

The agent that grows with you

fix(kanban): query show graph before closing database

cmoiccool5b4c03fa4b2e
diff --git a/hermes_cli/kanban.py b/hermes_cli/kanban.py
index ce51c15caa8..3dffbeeaf2c 100644
--- a/hermes_cli/kanban.py
+++ b/hermes_cli/kanban.py
@@ -1671,6 +1671,7 @@ def _cmd_show(args: argparse.Namespace) -> int:
file=sys.stderr,
)
return 2
+ graph = None
with kb.connect_closing() as conn:
task = kb.get_task(conn, args.task_id)
if not task:
@@ -1685,6 +1686,8 @@ def _cmd_show(args: argparse.Namespace) -> int:
# ``result=``. Surfacing the latest summary here keeps ``show`` from
# looking like a no-op when the worker actually did real work.
latest_summary = kb.latest_summary(conn, args.task_id)
+ if not getattr(args, "json", False):
+ graph = kb.task_graph_context(conn, task.id)
if getattr(args, "json", False):
payload = {
@@ -1762,9 +1765,7 @@ def _cmd_show(args: argparse.Namespace) -> int:
# of show output so CLI users see them before scrolling through
# comments / runs.
from hermes_cli import kanban_diagnostics as kd
- diags = kd.compute_task_diagnostics(
- task, events, runs, graph=kb.task_graph_context(conn, task.id)
- )
+ diags = kd.compute_task_diagnostics(task, events, runs, graph=graph)
if diags:
sev_marker = {"warning": "⚠", "error": "!!", "critical": "!!!"}
print(f"\n Diagnostics ({len(diags)}):")
diff --git a/tests/hermes_cli/test_kanban_cli.py b/tests/hermes_cli/test_kanban_cli.py
index c953a122e69..658bf2d8c8c 100644
--- a/tests/hermes_cli/test_kanban_cli.py
+++ b/tests/hermes_cli/test_kanban_cli.py
@@ -57,6 +57,19 @@ def test_kanban_list_json_includes_session_id(kanban_home):
)
+def test_kanban_show_text_renders_graph_with_open_connection(kanban_home):
+ with kb.connect_closing() as conn:
+ parent_id = kb.create_task(conn, title="parent task")
+ child_id = kb.create_task(conn, title="child task")
+ kb.link_tasks(conn, parent_id=parent_id, child_id=child_id)
+
+ output = kc.run_slash(f"show {child_id}")
+
+ assert f"Task {child_id}: child task" in output
+ assert f"parents: {parent_id}" in output
+ assert "Cannot operate on a closed database" not in output
+
+
def test_board_override_is_isolated_per_concurrent_call(kanban_home, monkeypatch):
kb.create_board("alpha")
kb.create_board("beta")