| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "log/slog" |
| 5 | |
| 6 | "reasonix/internal/control" |
| 7 | "reasonix/internal/session" |
| 8 | ) |
| 9 | |
| 10 | // archivedRuntimeCleanup owns post-commit joins. Keep removal/admission |
| 11 | // ownership until finish returns, but never hold title/index/App locks here: |
| 12 | // an in-flight autosave may need those locks before it can exit. |
| 13 | type archivedRuntimeCleanup struct { |
| 14 | app *App |
| 15 | removed []removedSessionRuntime |
| 16 | refs []session.SessionRef |
| 17 | } |
| 18 | |
| 19 | func (c *archivedRuntimeCleanup) finish() { |
| 20 | a := c.app |
| 21 | a.finalizeRemovedTopicRuntimes(c.removed) |
| 22 | a.closeRemainingRemovedSessionRuntimesAdmissionHeld(c.removed, map[control.SessionAPI]bool{}) |
| 23 | for _, ref := range c.refs { |
| 24 | if err := a.retireArchivedSessionRuntime(a.bootContext(), ref); err != nil { |
| 25 | // Archive is already durable; purge can retry retirement later. |
| 26 | slog.Warn("desktop: archived runtime retirement deferred", "err", err) |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 |