SSH + chat deletion fix
fix for chat file removal fix for ssh banners
frdel committed
Oct 19, 2024 at 09:39 UTC
ba2d5c7a674f97ff38261f2d9c09ff4d61b09037
4 files changed
+13
-4
agent.py
+3
@@ -44,6 +44,9 @@ class AgentContext:
44
AgentContext._counter += 1
45
self.no = AgentContext._counter
46
47
+ existing = self._contexts.get(self.id, None)
48
+ if existing:
49
+ AgentContext.remove(self.id)
50
self._contexts[self.id] = self
51
52
@staticmethod
python/helpers/persist_chat.py
+2
-1
@@ -33,6 +33,7 @@ def load_json_chats(jsons: list[str]):
33
ctxids = []
34
for js in jsons:
35
data = json.loads(js)
36
+ if "id" in data: del data["id"] # remove id to get new
37
ctx = _deserialize_context(data)
38
ctxids.append(ctx.id)
39
return ctxids
@@ -102,7 +103,7 @@ def _deserialize_context(data):
103
104
context = AgentContext(
105
config=config,
105
- # id=data.get("id", None), #get new id
106
+ id=data.get("id", None), #get new id
107
name=data.get("name", None),
108
log=log,
109
paused=False,
python/helpers/shell_ssh.py
+6
-1
@@ -33,7 +33,12 @@ class SSHInteractiveSession:
33
while True:
34
try:
35
self.client.connect(
36
- self.hostname, self.port, self.username, self.password
36
+ self.hostname,
37
+ self.port,
38
+ self.username,
39
+ self.password,
40
+ allow_agent=False,
41
+ look_for_keys=False,
42
)
43
self.shell = self.client.invoke_shell(width=160, height=48)
44
# self.shell.send(f'PS1="{SSHInteractiveSession.ps1_label}"'.encode())
run_ui.py
+2
-2
@@ -204,7 +204,7 @@ async def load_chats():
204
return jsonify(response)
205
206
207
-# load chats from json
207
+# save chats to json
208
@app.route("/exportChat", methods=["POST"])
209
async def export_chat():
210
try:
@@ -219,7 +219,7 @@ async def export_chat():
219
220
response = {
221
"ok": True,
222
- "message": "Chats loaded.",
222
+ "message": "Chats exported.",
223
"ctxid": context.id,
224
"content": content,
225
}