Right-click / long-press → Pin to top. Pins are per user and follow you across devices (ui-state `ai-agent-pins`, keyed by session id); they lead the drawer in a Pinned section that ignores the time-interval filter but still obeys search, project, runner and owner — most recent activity first, with a pin by the card's cost. Pins older than the loaded pages are looked up by id. Archiving unpins; archive-old spares the pinned ones (`keep`). The fullscreen page lists them first too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
"""POST /api/conversations/archive-old — the drawer's bulk cleanup archives
|
|
everything that ended before yesterday, except the session ids it is told to
|
|
`keep` (the pinned conversations)."""
|
|
import types
|
|
import unittest
|
|
|
|
from conversations import routes
|
|
|
|
|
|
class FakeStore:
|
|
def __init__(self, summaries):
|
|
self._s = summaries
|
|
|
|
def all_summaries(self):
|
|
return self._s
|
|
|
|
|
|
class FakeMeta:
|
|
def __init__(self):
|
|
self.m = {}
|
|
|
|
def get(self, sid):
|
|
return self.m.get(sid, {})
|
|
|
|
def update(self, sid, patch):
|
|
self.m.setdefault(sid, {}).update(patch)
|
|
|
|
|
|
def summ(sid, ended):
|
|
return (f"/t/-home-x/{sid}.jsonl", {"sessionId": sid, "messages": 3, "endedAt": ended})
|
|
|
|
|
|
class ArchiveOldKeepTest(unittest.TestCase):
|
|
def setUp(self):
|
|
self.meta = FakeMeta()
|
|
self.deps = types.SimpleNamespace(
|
|
store=FakeStore([summ("old", "2020-01-01T00:00:00Z"),
|
|
summ("pinned", "2020-01-02T00:00:00Z"),
|
|
summ("new", "2999-01-01T00:00:00Z")]),
|
|
meta_store=self.meta,
|
|
hub=types.SimpleNamespace(publish=lambda ev: None))
|
|
|
|
def test_keeps_the_listed_sessions(self):
|
|
out = routes.archive_old_conversations(self.deps, routes.ArchiveOldBody(keep=["pinned"]))
|
|
self.assertEqual(out["archived"], 1)
|
|
self.assertTrue(self.meta.get("old").get("archived"))
|
|
self.assertFalse(self.meta.get("pinned").get("archived"))
|
|
self.assertFalse(self.meta.get("new").get("archived"))
|
|
|
|
def test_without_body_archives_every_old_one(self):
|
|
out = routes.archive_old_conversations(self.deps, None)
|
|
self.assertEqual(out["archived"], 2)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|