返回 DeepSeek-Reasonix
desktop_persistence_state.go
根目录 / desktop / desktop_persistence_state.go
1 package main
2
3 import (
4 "log/slog"
5 "sync/atomic"
6
7 "reasonix/desktop/internal/draftstate"
8 "reasonix/desktop/internal/legacycleanup"
9 "reasonix/internal/config"
10 )
11
12 // desktopPersistenceState groups process-lifetime stores and their recovery
13 // coordinator so App does not expose each lifecycle field independently.
14 type desktopPersistenceState struct {
15 desktopSessions desktopSessionState
16 desktopDrafts *draftstate.Store
17 legacyCleanup *legacycleanup.Store
18 desktopMigrationDone chan struct{}
19 desktopMigrationFailed atomic.Bool
20 beforeSavedTabMigrationWait func()
21 legacyCleanupWorker legacyCleanupWorkerState
22 historicalImports historicalImportCoordinator
23 }
24
25 func newDesktopPersistenceState() desktopPersistenceState {
26 return desktopPersistenceState{
27 desktopSessions: newDesktopSessionState(),
28 desktopDrafts: draftstate.New(config.DesktopDraftStatePath()),
29 legacyCleanup: legacycleanup.New(config.DesktopLegacyEmptySessionCleanupPath()),
30 desktopMigrationDone: make(chan struct{}),
31 }
32 }
33
34 func (a *App) registerLegacyCleanupUpgradeBatch() {
35 if err := a.initializeLegacyEmptySessionCleanupBatch(); err != nil {
36 slog.Warn("desktop: legacy empty session cleanup registration unavailable", "err", err)
37 }
38 }
39
40 func (a *App) startDesktopPersistenceReconciliation() {
41 a.goSafe("reconcileDraftSubmissions", func() {
42 a.reconcileDraftSubmissionOperations()
43 })
44 }
45
45 lines GO