refactor: LangGraph gateway layer for UI-agnostic graph and thread access (#295)
* feat(gateway): graph gateway protocol * refactor(cli): wire gateway in cli/tui * refactor(gateway): centralize runtime gateway init * chore(gateway): restrict RunRequest message type * feat(gateway): add langgraph server gateway * chore(cli): tighten serve runtime state typing * refactor(cli): route async task state reads through graph gateway * refactor(gateway): support graph targets in server gateway * refactor(cli): route session commands through graph gateway * refactor(cli): fold thread store under graph gateway * refactor(gateway): route graph state access through gateway * refactor(channels): wire graph gateway * refactor(memory): preserve graph threads for cloning * feat(gateway): add thread cloning * fix(tui): pass effective workspace for thread creation * chore(memory): add workspare dir to memory worker metadata * fix(sessions): filter preloaded UUID registy entries by the current scope * test(fakes): use https * refactor(consumer): consolidate imports * fix(stream): optional summarization event * fix(gateway): resolve abbreviated thread IDs by search * fix(gateway): page server thread listings * fix(gateway): emit pending interrupt events * style: fmt * feat(gateway): persist workspace_dir & model in thread metadata * fix(gateway): page server thread prefix resolution * fix(gateway): expose server thread list metadata * refactor: add back type def * refactor: tighten types * revert: add back worker thread deletion The worker thread forking changes are out of scope for now, so to maintain parity with the existing behavior we'll leave this intact. * fix(gateway): apply compaction to server thread history * refactor(stream): restore direct summary replay suppression * fix(gateway): preserve compaction state and server stream output * fix(gateway): close local stream generator on cancellation --------- Co-authored-by: Xi Zhang <106144707+X-iZhang@users.noreply.github.com>
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
"""Tests for the /threads command."""
|
||||
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from rich.table import Table
|
||||
|
||||
from tests.conftest import run_async as _run
|
||||
from tests.fakes import FakeGraphGateway, FakeThreadStore
|
||||
|
||||
|
||||
def _ctx(**overrides):
|
||||
@@ -12,11 +13,13 @@ def _ctx(**overrides):
|
||||
|
||||
ui = MagicMock()
|
||||
ui.supports_interactive = overrides.pop("supports_interactive", True)
|
||||
store = overrides.pop("thread_store", FakeThreadStore())
|
||||
return CommandContext(
|
||||
agent=None,
|
||||
thread_id=overrides.pop("thread_id", "tid-1"),
|
||||
ui=ui,
|
||||
workspace_dir=overrides.pop("workspace_dir", "/ws"),
|
||||
graph_gateway=FakeGraphGateway(thread_store=store),
|
||||
), ui
|
||||
|
||||
|
||||
@@ -25,11 +28,7 @@ class TestThreadsCommand:
|
||||
from EvoScientist.commands.implementation.session import ThreadsCommand
|
||||
|
||||
ctx, ui = _ctx()
|
||||
with patch(
|
||||
"EvoScientist.sessions.list_threads",
|
||||
new=AsyncMock(return_value=[]),
|
||||
):
|
||||
_run(ThreadsCommand().execute(ctx, []))
|
||||
_run(ThreadsCommand().execute(ctx, []))
|
||||
ui.append_system.assert_called_once()
|
||||
assert "No saved sessions" in ui.append_system.call_args.args[0]
|
||||
|
||||
@@ -53,11 +52,9 @@ class TestThreadsCommand:
|
||||
"updated_at": None,
|
||||
},
|
||||
]
|
||||
with patch(
|
||||
"EvoScientist.sessions.list_threads",
|
||||
new=AsyncMock(return_value=threads),
|
||||
):
|
||||
_run(ThreadsCommand().execute(ctx, []))
|
||||
store = FakeThreadStore(threads=threads)
|
||||
ctx.graph_gateway = FakeGraphGateway(thread_store=store)
|
||||
_run(ThreadsCommand().execute(ctx, []))
|
||||
ui.mount_renderable.assert_called_once()
|
||||
table = ui.mount_renderable.call_args.args[0]
|
||||
assert isinstance(table, Table)
|
||||
@@ -81,11 +78,9 @@ class TestThreadsCommand:
|
||||
"updated_at": None,
|
||||
}
|
||||
]
|
||||
with patch(
|
||||
"EvoScientist.sessions.list_threads",
|
||||
new=AsyncMock(return_value=threads),
|
||||
):
|
||||
_run(ThreadsCommand().execute(ctx, []))
|
||||
store = FakeThreadStore(threads=threads)
|
||||
ctx.graph_gateway = FakeGraphGateway(thread_store=store)
|
||||
_run(ThreadsCommand().execute(ctx, []))
|
||||
ui.append_system.assert_not_called()
|
||||
|
||||
def test_channel_mode_drops_model_column(self):
|
||||
@@ -102,11 +97,9 @@ class TestThreadsCommand:
|
||||
"updated_at": None,
|
||||
}
|
||||
]
|
||||
with patch(
|
||||
"EvoScientist.sessions.list_threads",
|
||||
new=AsyncMock(return_value=threads),
|
||||
):
|
||||
_run(ThreadsCommand().execute(ctx, []))
|
||||
store = FakeThreadStore(threads=threads)
|
||||
ctx.graph_gateway = FakeGraphGateway(thread_store=store)
|
||||
_run(ThreadsCommand().execute(ctx, []))
|
||||
# Channel mode: no Model column. 4 columns: ID, Preview, Msgs, Last Used.
|
||||
table = ui.mount_renderable.call_args.args[0]
|
||||
column_headers = [col.header for col in table.columns]
|
||||
|
||||
Reference in New Issue
Block a user