diff --git a/haiku_rag_slim/haiku/rag/chat/app.py b/haiku_rag_slim/haiku/rag/chat/app.py index a40f7e03..6d7e3a48 100644 --- a/haiku_rag_slim/haiku/rag/chat/app.py +++ b/haiku_rag_slim/haiku/rag/chat/app.py @@ -401,7 +401,19 @@ class ChatApp(App): """Show the current session state.""" from haiku.skills.chat.app import StateScreen - self.push_screen(StateScreen(self._state)) + self.push_screen(StateScreen(self._state, on_save=self._apply_state_edit)) + + def _apply_state_edit(self, new_state: dict[str, Any]) -> None: + if self._toolset is None: + return + if not isinstance(new_state, dict): + raise ValueError("state must be a JSON object") + for namespace, data in new_state.items(): + current = self._toolset.get_namespace(namespace) + if current is not None: + type(current).model_validate(data) + self._toolset.restore_state_snapshot(new_state) + self._state = self._toolset.build_state_snapshot() def on_citation_widget_selected(self, event: CitationWidget.Selected) -> None: """Handle citation selection.""" diff --git a/haiku_rag_slim/pyproject.toml b/haiku_rag_slim/pyproject.toml index 538cbd23..85c71c31 100644 --- a/haiku_rag_slim/pyproject.toml +++ b/haiku_rag_slim/pyproject.toml @@ -23,7 +23,7 @@ classifiers = [ dependencies = [ "docling-core>=2.71.0,<2.72", - "haiku.skills>=0.15.0", + "haiku.skills>=0.16.0", "httpx>=0.28.1", "jinja2>=3.1.0", "jsonpatch>=1.33", diff --git a/tests/skills/test_analysis.py b/tests/skills/test_analysis.py index 6935eec8..54a8dd5b 100644 --- a/tests/skills/test_analysis.py +++ b/tests/skills/test_analysis.py @@ -273,10 +273,10 @@ class TestAnalysisLifespan: from pydantic_ai.models.test import TestModel from haiku.rag.skills.analysis import create_skill - from haiku.skills.agent import _run_skill + from haiku.skills.agent import run_skill skill = create_skill(db_path=rag_db) - result, *_ = await _run_skill(TestModel(), skill, "Print the document count.") + result, *_ = await run_skill(TestModel(), skill, "Print the document count.") assert result async def test_lifespan_clears_executions_citations_searches(self, rag_db): diff --git a/tests/skills/test_rag.py b/tests/skills/test_rag.py index 808c0603..7e4d7b7d 100644 --- a/tests/skills/test_rag.py +++ b/tests/skills/test_rag.py @@ -366,10 +366,10 @@ class TestLifespan: from pydantic_ai.models.test import TestModel from haiku.rag.skills.rag import create_skill - from haiku.skills.agent import _run_skill + from haiku.skills.agent import run_skill skill = create_skill(db_path=rag_db) - result, *_ = await _run_skill(TestModel(), skill, "List the documents.") + result, *_ = await run_skill(TestModel(), skill, "List the documents.") assert result async def test_lifespan_clears_citations_and_searches_but_keeps_index(self, rag_db): diff --git a/uv.lock b/uv.lock index e7607d23..e9edf4eb 100644 --- a/uv.lock +++ b/uv.lock @@ -1570,7 +1570,7 @@ requires-dist = [ { name = "cohere", marker = "extra == 'cohere'", specifier = ">=5.21.1" }, { name = "docling", marker = "extra == 'docling'", specifier = ">=2.84.0" }, { name = "docling-core", specifier = ">=2.71.0,<2.72" }, - { name = "haiku-skills", specifier = ">=0.15.0" }, + { name = "haiku-skills", specifier = ">=0.16.0" }, { name = "httpx", specifier = ">=0.28.1" }, { name = "jinja2", specifier = ">=3.1.0" }, { name = "jsonpatch", specifier = ">=1.33" }, @@ -1604,7 +1604,7 @@ provides-extras = ["docling", "voyageai", "mxbai", "cohere", "zeroentropy", "jin [[package]] name = "haiku-skills" -version = "0.15.0" +version = "0.16.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "ag-ui-protocol" }, @@ -1614,9 +1614,9 @@ dependencies = [ { name = "pyyaml" }, { name = "skills-ref" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/86/a1/e2bd00a72d002f9db1c53c068167ed436a457dae0f8996399f116c087f6a/haiku_skills-0.15.0.tar.gz", hash = "sha256:ce93e6846e05397f5d96c144f956edd395b9e7308cb5cef6213c49c183a08bbc", size = 252030, upload-time = "2026-04-22T09:00:13.775Z" } +sdist = { url = "https://files.pythonhosted.org/packages/8c/12/98ea5ee4ca14d4053019b4ec4b22e39af8ae1bc054aea107c87f5ecb025e/haiku_skills-0.16.0.tar.gz", hash = "sha256:e7bfa8141523912f3eb4469bf0b611408fa1e1e54707c9b475d0b3e04ea7ffbc", size = 256020, upload-time = "2026-04-28T08:44:23.347Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/9b/68/3df2c9761fc0b0592b60f4723c87adeda5f335ea0835b4cf77ca07784379/haiku_skills-0.15.0-py3-none-any.whl", hash = "sha256:a1771b16e0ffe7da775f28d38c704e029f8e8757791616d7f27e73feb2c16fd0", size = 32041, upload-time = "2026-04-22T09:00:12.824Z" }, + { url = "https://files.pythonhosted.org/packages/55/ca/4cc0b026ee3e25d4b7f85267a210d1248988079fcac73649a09e9f9a5873/haiku_skills-0.16.0-py3-none-any.whl", hash = "sha256:50dec4e24594dceadc781242cafb20ced3b1fe743fdb7035a081756fbb402aa1", size = 32794, upload-time = "2026-04-28T08:44:21.855Z" }, ] [[package]]