feat: deliver installable local alpha sessions
Some checks failed
tamq-ci / test (push) Failing after 6s
Some checks failed
tamq-ci / test (push) Failing after 6s
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a03397-4d51-7fd1-8ff2-946eb22ea2bc
This commit is contained in:
parent
d56bd3c79f
commit
5774fbd548
18 changed files with 890 additions and 94 deletions
|
|
@ -57,6 +57,11 @@ class Store:
|
|||
|
||||
def register_endpoint(self, endpoint_id: str, pid: int, session: str, repos: list[str]) -> None:
|
||||
import json
|
||||
self.db.execute(
|
||||
"UPDATE endpoints SET disconnected_at=strftime('%s','now') "
|
||||
"WHERE pid=? AND session=? AND endpoint_id<>? AND disconnected_at IS NULL",
|
||||
(pid, session, endpoint_id),
|
||||
)
|
||||
self.db.execute(
|
||||
"INSERT INTO endpoints(endpoint_id,pid,session,repos,connected_at,disconnected_at) VALUES(?,?,?,?,strftime('%s','now'),NULL) "
|
||||
"ON CONFLICT(endpoint_id) DO UPDATE SET pid=excluded.pid, session=excluded.session, repos=excluded.repos, connected_at=excluded.connected_at, disconnected_at=NULL",
|
||||
|
|
@ -73,17 +78,21 @@ class Store:
|
|||
self.db.commit()
|
||||
|
||||
def endpoints(self) -> list[sqlite3.Row]:
|
||||
return list(self.db.execute("SELECT * FROM endpoints ORDER BY endpoint_id"))
|
||||
return list(
|
||||
self.db.execute(
|
||||
"SELECT * FROM endpoints WHERE disconnected_at IS NULL ORDER BY endpoint_id"
|
||||
)
|
||||
)
|
||||
|
||||
def endpoint(self, endpoint_id: str) -> sqlite3.Row | None:
|
||||
row = self.db.execute("SELECT * FROM endpoints WHERE endpoint_id=? AND disconnected_at IS NULL", (endpoint_id,)).fetchone()
|
||||
if row is not None:
|
||||
return row
|
||||
if endpoint_id.startswith("tmux-amq-"):
|
||||
try:
|
||||
pid = int(endpoint_id.removeprefix("tmux-amq-").split("-", 1)[0])
|
||||
except ValueError:
|
||||
visible_pid = endpoint_id.removeprefix("tmux-amq-")
|
||||
if not visible_pid.isdigit():
|
||||
return None
|
||||
pid = int(visible_pid)
|
||||
return self.db.execute("SELECT * FROM endpoints WHERE pid=? AND disconnected_at IS NULL ORDER BY connected_at DESC LIMIT 1", (pid,)).fetchone()
|
||||
return None
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue