MCPcopy Create free account
hub / github.com/tiann/hapi / setCursorMigrationStateInProgress

Method setCursorMigrationStateInProgress

hub/src/sync/syncEngine.ts:993–1018  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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).

Calls 3

refreshSessionMethod · 0.80
updateSessionMetadataMethod · 0.80
getSessionByNamespaceMethod · 0.45

Tested by

no test coverage detected