mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
fix(state): reclaim kanban worker rows already on disk
Retag pre-tag `cli` rows whose cwd sits under the board's workspaces root, gated once per database via state_meta.
This commit is contained in:
parent
1d58e7d231
commit
9fe36aecb1
1 changed files with 34 additions and 0 deletions
|
|
@ -7748,6 +7748,40 @@ class SessionDB(SessionSearchMixin, SessionSchemaMixin, SessionPortabilityMixin)
|
|||
)
|
||||
self._execute_write(_do)
|
||||
|
||||
def retag_kanban_worker_sessions(self, workspaces_root: str) -> int:
|
||||
"""Retag legacy kanban worker rows from ``cli`` to ``kanban``.
|
||||
|
||||
Workers used to spawn without ``HERMES_SESSION_SOURCE``, so their runs
|
||||
landed as untitled ``cli`` rows and the sidebar rendered one per attempt
|
||||
labeled with the worker's own prompt. New workers tag themselves; this
|
||||
reclaims the rows already on disk so they drop out of the session lists
|
||||
too. Identified by cwd under the board's workspaces root — a path only
|
||||
the dispatcher ever runs a session in.
|
||||
|
||||
Runs once per database (``state_meta`` gate) and returns the number of
|
||||
rows retagged.
|
||||
"""
|
||||
if self.get_meta("kanban_worker_source_retagged") == "1":
|
||||
return 0
|
||||
|
||||
prefix = str(workspaces_root).rstrip("/\\")
|
||||
if not prefix:
|
||||
return 0
|
||||
|
||||
def _do(conn):
|
||||
cursor = conn.execute(
|
||||
"UPDATE sessions SET source = 'kanban' "
|
||||
"WHERE source = 'cli' AND (cwd = ? OR cwd LIKE ? ESCAPE '\\')",
|
||||
(prefix, prefix.replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_") + "/%"),
|
||||
)
|
||||
# Read rowcount before set_meta reuses this cursor for its INSERT,
|
||||
# which would otherwise overwrite it with the meta write's count.
|
||||
retagged = cursor.rowcount or 0
|
||||
self.set_meta("kanban_worker_source_retagged", "1", cursor=cursor)
|
||||
return retagged
|
||||
|
||||
return self._execute_write(_do)
|
||||
|
||||
def apply_telegram_topic_migration(self) -> None:
|
||||
"""Create Telegram DM topic-mode tables on explicit /topic opt-in.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue