Files
magpie/internal/sessions/testdata/codex-app
yetone d5eac64f23 sessions: a deleted Codex session leaves the Codex app's list too
zhuddan (Discord, Codex app 26.1023): a Codex conversation deleted in
magpie went on showing in the Codex app. The app lists threads from its
own catalog, <CODEX_HOME>/sqlite/codex.db (codex-dev.db for a non-prod
build), table local_thread_catalog, and drops a row only on the
app-server's thread/deleted or thread/archived. After its first full
sweep it takes in only threads newer than its watermark, so a row of a
thread whose rollout magpie moved to its trash stayed.

Delete now does what the app does on thread/deleted: the local host's
rows of threads whose rollout is gone from that Codex folder's sessions
and archived_sessions (as Codex's state database names them; neither
the file nor its packed twin there, and a file that can't be looked at
counts as there) are deleted and catalog_revision raised, in one
BEGIN IMMEDIATE transaction that waits for the app's own. The rows go
into the trash note (codex_catalog) and Restore puts them back, since
the app wouldn't take in a thread that old by itself.
/api/sessions/manage does the same once a run (TidyCodexCatalog) for
threads deleted before this release.

Run (Windows, win-run, go1.26.8):
- go test -count=1 -v -timeout 25m ./internal/sessions/: 339 PASS,
  including TestDeleteForgetsCodexAppCatalog,
  TestTidyCodexCatalogForgetsEarlierDeletes and
  TestTidyCodexCatalogKeepsWhatItCantJudge. Red: TestAgySessions,
  TestAgyRowOnly (#4115), TestOneListing and TestShareListing hanging
  the package (#4114). The same four are red at origin/main bc247a8cc
  on the same box, run alone. A second run also had TestPurgeOne,
  TestPurgeAll, TestUnchangedPackedNotReadAgain red and
  TestReadNotHeldByAnotherRead hanging, and internal/gui
  TestGatewaySessionHistoryAndCalendar red; all the same at
  bc247a8cc (#4177).
After the rebase onto origin/main (mote, go test -count=1 ./internal/sessions/ ./internal/gui/): sessions ok; gui red only in ten AppKit window tests killed at 30s (TestPanelCloseHidesIt, TestMainWindowCorners and others), mote's pboard being down (#4125).
Broken by hand: forgetCodexCatalog returning nothing turns
TestDeleteForgetsCodexAppCatalog and
TestTidyCodexCatalogForgetsEarlierDeletes red.
Not tried: the real Codex app (its catalog is in the owner's live
~/.codex, which sessions never touch); the schemas in testdata are
Codex 26.1023's.
2026-10-29 13:17:17 +08:00
..