From 6cd0b8b71e86acfa236969599b012d19c33fe167 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 25 Aug 2026 18:15:12 +0200 Subject: feat: persist loaded skills per session --- test_llamachat.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'test_llamachat.py') diff --git a/test_llamachat.py b/test_llamachat.py index ed990af..81a430b 100755 --- a/test_llamachat.py +++ b/test_llamachat.py @@ -3486,6 +3486,46 @@ def test_skill_tool_message(): print("ok skill tool message") +def test_skills_db(): + with tempfile.TemporaryDirectory() as tmp: + history = db.History(Path(tmp) / "history.db") + sid = history.create_session("chat", "m") + history.set_skills(sid, ["firefly-cli", "handoff"]) + session = history.get_session(sid) + assert json.loads(session["skills"]) == ["firefly-cli", "handoff"] + + history.set_skills(sid, []) + assert json.loads(history.get_session(sid)["skills"]) == [] + + # A fresh session has no skills stored. + sid2 = history.create_session("oneshot", "m") + assert history.get_session(sid2)["skills"] == "" + print("ok skills db") + + +def test_skills_column_migration(): + # A database created before the column existed gains it on open. + import sqlite3 as _sqlite3 + + with tempfile.TemporaryDirectory() as tmp: + path = Path(tmp) / "old.db" + conn = _sqlite3.connect(path) + conn.execute( + "CREATE TABLE sessions (id INTEGER PRIMARY KEY, mode TEXT NOT NULL," + " title TEXT, model TEXT, prompt_name TEXT NOT NULL DEFAULT ''," + " prompt_custom TEXT NOT NULL DEFAULT '', created_at INTEGER NOT NULL," + " updated_at INTEGER NOT NULL)" + ) + conn.commit() + conn.close() + + history = db.History(path) + sid = history.create_session("chat", "m") + history.set_skills(sid, ["firefly-cli"]) + assert json.loads(history.get_session(sid)["skills"]) == ["firefly-cli"] + print("ok skills column migration") + + if __name__ == "__main__": test_presets() test_real_presets() @@ -3553,4 +3593,6 @@ if __name__ == "__main__": test_skills_mentions() test_skills_parse_commands() test_skill_tool_message() + test_skills_db() + test_skills_column_migration() print("\nall checks passed") -- cgit v1.2.3