feat: support numbered resume selection in cli and gateway

This commit is contained in:
daizhonggeng
2026-05-24 16:22:48 -07:00
committed by Teknium
parent 4f4e337c47
commit fef733d56b
5 changed files with 164 additions and 21 deletions
+44
View File
@@ -88,6 +88,9 @@ class TestHandleResumeCommand:
assert "Research" in result
assert "Coding" in result
assert "Named Sessions" in result
assert "1." in result
assert "2." in result
assert "/resume 1" in result
db.close()
@pytest.mark.asyncio
@@ -104,6 +107,47 @@ class TestHandleResumeCommand:
assert "/title" in result
db.close()
@pytest.mark.asyncio
async def test_resume_by_index(self, tmp_path):
"""Numeric argument resumes the indexed titled session from the list."""
from hermes_state import SessionDB
db = SessionDB(db_path=tmp_path / "state.db")
db.create_session("sess_001", "telegram")
db.create_session("sess_002", "telegram")
db.set_session_title("sess_001", "Research")
db.set_session_title("sess_002", "Coding")
db.create_session("current_session_001", "telegram")
event = _make_event(text="/resume 2")
runner = _make_runner(session_db=db, current_session_id="current_session_001",
event=event)
result = await runner._handle_resume_command(event)
assert "Resumed" in result
runner.session_store.switch_session.assert_called_once()
call_args = runner.session_store.switch_session.call_args
assert call_args[0][1] == "sess_001"
db.close()
@pytest.mark.asyncio
async def test_resume_index_out_of_range(self, tmp_path):
"""Out-of-range numeric arguments show a helpful error."""
from hermes_state import SessionDB
db = SessionDB(db_path=tmp_path / "state.db")
db.create_session("sess_001", "telegram")
db.set_session_title("sess_001", "Research")
db.create_session("current_session_001", "telegram")
event = _make_event(text="/resume 9")
runner = _make_runner(session_db=db, current_session_id="current_session_001",
event=event)
result = await runner._handle_resume_command(event)
assert "out of range" in result.lower()
assert "/resume" in result
runner.session_store.switch_session.assert_not_called()
db.close()
@pytest.mark.asyncio
async def test_resume_by_name(self, tmp_path):
"""Resolves a title and switches to that session."""