feat(ocm-move): plan worktree mirror targets and stream move progress (#345)

* feat(ocm-move): plan worktree mirror targets and stream move progress

- Plan/ensure mirror targets per branch via new internal endpoints, creating a worktree repo when the target branch is not checked out in the source repo
- Skip branches checked out in other worktrees during bundle import and reset/clean before checkout on both server and CLI
- Rewrite workspace paths in message.updated events when replaying moved sessions
- Stream live move progress (bundle, upload, import, patch, replay) in the TUI
- Prefer branch-matched repos when moving sessions and share push-divergence descriptions

* chore(ocm-cli): bump version to 0.2.7

* fix(ocm): harden worktree mirror synchronization

* fix(ocm): protect active branch during branchless pull
This commit is contained in:
Chris Scott authored and GitHub committed 2026-09-01 22:14:48 -04:00
1 parent 4ed3460759
commit 68d586f183
23 files changed
+2026 -158

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
import type { MirrorUpFastPhase } from './mirror.js'
import { formatBytes, SPINNER_FRAMES } from './progress.js'
export interface MoveProgress {
label: string
fraction: number | null
}
const BAR_WIDTH = 12
export function renderProgressBar(fraction: number, width = BAR_WIDTH): string {
const clamped = Math.min(1, Math.max(0, fraction))
const filled = Math.round(clamped * width)
return `${'█'.repeat(filled)}${'░'.repeat(width - filled)} ${Math.round(clamped * 100)}%`
}
export function formatMoveProgress(progress: MoveProgress, frame: number): string {
const spinner = SPINNER_FRAMES[frame % SPINNER_FRAMES.length]
const bar = progress.fraction === null ? '' : ` ${renderProgressBar(progress.fraction)}`
return `${spinner} ocm-move: ${progress.label}${bar}`
}
export function pushPhaseProgress(phase: MirrorUpFastPhase): MoveProgress {
switch (phase.kind) {
case 'bundling':
return { label: 'creating git bundle', fraction: null }
case 'uploading':
return {
label: `uploading ${formatBytes(phase.bytesSent)} / ${formatBytes(phase.totalBytes)}`,
fraction: phase.totalBytes > 0 ? phase.bytesSent / phase.totalBytes : null,
}
case 'processing':
return { label: 'server importing bundle', fraction: null }
case 'patching':
return { label: 'applying local changes', fraction: null }
}
}
export function replayProgress(replayed: number, total: number): MoveProgress {
return { label: `replaying session ${replayed}/${total} events`, fraction: total > 0 ? replayed / total : null }
}