summaryrefslogtreecommitdiff
path: root/continuedev/src/continuedev/server
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-06-11 12:26:42 -0400
committerNate Sesti <sestinj@gmail.com>2023-06-11 12:26:42 -0400
commit2070fee3a47cf1e8d566ad3452ee64f0fc03dd5c (patch)
tree8254fc7bc2fa984949fe45c97fdec74b38f3d7b2 /continuedev/src/continuedev/server
parent8303a2a5eb0724cc4224998cef9008b16898a7fb (diff)
downloadsncontinue-2070fee3a47cf1e8d566ad3452ee64f0fc03dd5c.tar.gz
sncontinue-2070fee3a47cf1e8d566ad3452ee64f0fc03dd5c.tar.bz2
sncontinue-2070fee3a47cf1e8d566ad3452ee64f0fc03dd5c.zip
Step to decide next step form user input
Diffstat (limited to 'continuedev/src/continuedev/server')
-rw-r--r--continuedev/src/continuedev/server/state_manager.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/continuedev/src/continuedev/server/state_manager.py b/continuedev/src/continuedev/server/state_manager.py
new file mode 100644
index 00000000..c9bd760b
--- /dev/null
+++ b/continuedev/src/continuedev/server/state_manager.py
@@ -0,0 +1,21 @@
+from typing import Any, List, Tuple, Union
+from fastapi import WebSocket
+from pydantic import BaseModel
+from ..core.main import FullState
+
+# State updates represented as (path, replacement) pairs
+StateUpdate = Tuple[List[Union[str, int]], Any]
+
+
+class StateManager:
+ """
+ A class that acts as the source of truth for state, ingesting changes to the entire object and streaming only the updated portions to client.
+ """
+
+ def __init__(self, ws: WebSocket):
+ self.ws = ws
+
+ def _send_update(self, updates: List[StateUpdate]):
+ self.ws.send_json(
+ [update.dict() for update in updates]
+ )