* Set `metadata.cursorMigrationState='in_progress'` on the session row * with a single retry on version-mismatch. Returns true if the flag was * persisted (so the caller knows the finally-cleanup is required), false * if the write failed entirely — in which case the banner never appea
(sessionId: string, namespace: string)
| 991 | * banner; see maybeAutoMigrateLegacyCursorSession. |
| 992 | */ |
| 993 | private setCursorMigrationStateInProgress(sessionId: string, namespace: string): boolean { |
| 994 | for (let attempt = 0; attempt < 2; attempt += 1) { |
| 995 | const latest = this.sessionCache.getSessionByNamespace(sessionId, namespace) |
| 996 | ?? this.sessionCache.refreshSession(sessionId) |
| 997 | if (!latest?.metadata) return false |
| 998 | if (latest.metadata.cursorMigrationState === 'in_progress') return true |
| 999 | const nextMetadata = { ...latest.metadata, cursorMigrationState: 'in_progress' as const } |
| 1000 | const result = this.store.sessions.updateSessionMetadata( |
| 1001 | sessionId, |
| 1002 | nextMetadata, |
| 1003 | latest.metadataVersion, |
| 1004 | namespace, |
| 1005 | { touchUpdatedAt: false } |
| 1006 | ) |
| 1007 | if (result.result === 'success') { |
| 1008 | this.sessionCache.refreshSession(sessionId) |
| 1009 | return true |
| 1010 | } |
| 1011 | if (result.result === 'version-mismatch') { |
| 1012 | this.sessionCache.refreshSession(sessionId) |
| 1013 | continue |
| 1014 | } |
| 1015 | return false |
| 1016 | } |
| 1017 | return false |
| 1018 | } |
| 1019 | |
| 1020 | /** |
| 1021 | * Clear `metadata.cursorMigrationState` (failure / exception cleanup). |
no test coverage detected