* Clear `metadata.cursorMigrationState` (failure / exception cleanup). * Idempotent; safe to call when the flag was never set. UX A++ helper.
(sessionId: string, namespace: string)
| 1022 | * Idempotent; safe to call when the flag was never set. UX A++ helper. |
| 1023 | */ |
| 1024 | private clearCursorMigrationState(sessionId: string, namespace: string): void { |
| 1025 | for (let attempt = 0; attempt < 2; attempt += 1) { |
| 1026 | const latest = this.sessionCache.getSessionByNamespace(sessionId, namespace) |
| 1027 | ?? this.sessionCache.refreshSession(sessionId) |
| 1028 | if (!latest?.metadata) return |
| 1029 | if (latest.metadata.cursorMigrationState === undefined) return |
| 1030 | const nextMetadata: typeof latest.metadata = { ...latest.metadata } |
| 1031 | delete nextMetadata.cursorMigrationState |
| 1032 | const result = this.store.sessions.updateSessionMetadata( |
| 1033 | sessionId, |
| 1034 | nextMetadata, |
| 1035 | latest.metadataVersion, |
| 1036 | namespace, |
| 1037 | { touchUpdatedAt: false } |
| 1038 | ) |
| 1039 | if (result.result === 'success') { |
| 1040 | this.sessionCache.refreshSession(sessionId) |
| 1041 | return |
| 1042 | } |
| 1043 | if (result.result === 'version-mismatch') { |
| 1044 | this.sessionCache.refreshSession(sessionId) |
| 1045 | continue |
| 1046 | } |
| 1047 | return |
| 1048 | } |
| 1049 | } |
| 1050 | |
| 1051 | /** Inactive session with directory path but no agent thread and no prior user turn. */ |
| 1052 | private canFreshSpawnNeverStartedSession(session: Session, sessionId: string, namespace: string): boolean { |
no test coverage detected