* Replace `cursorMigrationState='in_progress'` with `'ambiguous'` so * the web banner can switch from "Upgrading..." to "Manual resolution * needed". Returns true if the new flag persisted. tiann/hapi#872.
(sessionId: string, namespace: string)
| 956 | * needed". Returns true if the new flag persisted. tiann/hapi#872. |
| 957 | */ |
| 958 | private setCursorMigrationStateAmbiguous(sessionId: string, namespace: string): boolean { |
| 959 | for (let attempt = 0; attempt < 2; attempt += 1) { |
| 960 | const latest = this.sessionCache.getSessionByNamespace(sessionId, namespace) |
| 961 | ?? this.sessionCache.refreshSession(sessionId) |
| 962 | if (!latest?.metadata) return false |
| 963 | if (latest.metadata.cursorMigrationState === 'ambiguous') return true |
| 964 | const nextMetadata = { ...latest.metadata, cursorMigrationState: 'ambiguous' as const } |
| 965 | const result = this.store.sessions.updateSessionMetadata( |
| 966 | sessionId, |
| 967 | nextMetadata, |
| 968 | latest.metadataVersion, |
| 969 | namespace, |
| 970 | { touchUpdatedAt: false } |
| 971 | ) |
| 972 | if (result.result === 'success') { |
| 973 | this.sessionCache.refreshSession(sessionId) |
| 974 | return true |
| 975 | } |
| 976 | if (result.result === 'version-mismatch') { |
| 977 | this.sessionCache.refreshSession(sessionId) |
| 978 | continue |
| 979 | } |
| 980 | return false |
| 981 | } |
| 982 | return false |
| 983 | } |
| 984 | |
| 985 | /** |
| 986 | * Set `metadata.cursorMigrationState='in_progress'` on the session row |
no test coverage detected