* Execute the push and track its lifecycle. * Push is read-only on disk (delta+probe, no merge writes), so no event * suppression is needed — edits arriving mid-push hit schedulePush() and * the debounce re-arms after this push completes.
()
| 84 | * the debounce re-arms after this push completes. |
| 85 | */ |
| 86 | async function executePush(): Promise<void> { |
| 87 | if (!syncState) { |
| 88 | return |
| 89 | } |
| 90 | pushInProgress = true |
| 91 | try { |
| 92 | const result = await pushTeamMemory(syncState) |
| 93 | if (result.success) { |
| 94 | hasPendingChanges = false |
| 95 | } |
| 96 | if (result.success && result.filesUploaded > 0) { |
| 97 | logForDebugging( |
| 98 | `team-memory-watcher: pushed ${result.filesUploaded} files`, |
| 99 | { level: 'info' }, |
| 100 | ) |
| 101 | } else if (!result.success) { |
| 102 | logForDebugging(`team-memory-watcher: push failed: ${result.error}`, { |
| 103 | level: 'warn', |
| 104 | }) |
| 105 | if (isPermanentFailure(result) && pushSuppressedReason === null) { |
| 106 | pushSuppressedReason = |
| 107 | result.httpStatus !== undefined |
| 108 | ? `http_${result.httpStatus}` |
| 109 | : (result.errorType ?? 'unknown') |
| 110 | logForDebugging( |
| 111 | `team-memory-watcher: suppressing retry until next unlink or session restart (${pushSuppressedReason})`, |
| 112 | { level: 'warn' }, |
| 113 | ) |
| 114 | logEvent('tengu_team_mem_push_suppressed', { |
| 115 | reason: |
| 116 | pushSuppressedReason as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS, |
| 117 | ...(result.httpStatus && { status: result.httpStatus }), |
| 118 | }) |
| 119 | } |
| 120 | } |
| 121 | } catch (e) { |
| 122 | logForDebugging(`team-memory-watcher: push error: ${errorMessage(e)}`, { |
| 123 | level: 'warn', |
| 124 | }) |
| 125 | } finally { |
| 126 | pushInProgress = false |
| 127 | currentPushPromise = null |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Debounced push: waits for writes to settle, then pushes once. |
no test coverage detected