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
commit0827135d561a327002c8078d52f071f134a5c23b (patch)
treedb178a105ea515dc7b3cdce173dbfee6d7e0e3dd /continuedev/src/continuedev/server
parentd7fad7f55aa9fc5eee908bc1e77b7d976a506c9d (diff)
downloadsncontinue-0827135d561a327002c8078d52f071f134a5c23b.tar.gz
sncontinue-0827135d561a327002c8078d52f071f134a5c23b.tar.bz2
sncontinue-0827135d561a327002c8078d52f071f134a5c23b.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]
+ )