[Init] Initial commit - NetMesh terminal manager
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
This commit is contained in:
121
application/state/sftp/pauseTransferOutcome.ts
Normal file
121
application/state/sftp/pauseTransferOutcome.ts
Normal file
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
* Shared pause-result classification for panel + global transfer center.
|
||||
* Keep panel and store pause UX consistent.
|
||||
*/
|
||||
|
||||
export type PauseBridgeResult = {
|
||||
success: boolean;
|
||||
reason?: string;
|
||||
checkpointBytes?: number;
|
||||
resumeStage?: string;
|
||||
downloadCheckpointBytes?: number;
|
||||
uploadCheckpointBytes?: number;
|
||||
sourceFingerprint?: string;
|
||||
};
|
||||
|
||||
/** Backend miss that means "nothing to pause" — not a hard failure. */
|
||||
export function isBenignPauseMiss(reason?: string): boolean {
|
||||
return /no longer active|not found|session/i.test(reason || "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Bridge reports the live stream is gone. For a single top-level file this is
|
||||
* not a successful pause — Resume must hard-reconnect rather than soft-unpause
|
||||
* a dead row painted as "paused".
|
||||
*/
|
||||
export function isDeadTransferPauseMiss(reason?: string): boolean {
|
||||
return /no longer active|not found/i.test(reason || "");
|
||||
}
|
||||
|
||||
export function isHardPauseFailure(result: PauseBridgeResult | undefined): boolean {
|
||||
if (!result) return true;
|
||||
if (result.success) return false;
|
||||
return !isBenignPauseMiss(result.reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a multi-id pause (directory children or single+children) fully
|
||||
* succeeded: every targeted id paused or was already gone.
|
||||
*/
|
||||
export function allPauseResultsBenignOrSuccess(
|
||||
results: readonly PauseBridgeResult[],
|
||||
): boolean {
|
||||
if (results.length === 0) return true;
|
||||
return results.every((result) => result.success || isBenignPauseMiss(result.reason));
|
||||
}
|
||||
|
||||
/** True when every bridge pause miss means the stream is already dead. */
|
||||
export function allPauseResultsDeadTransfer(
|
||||
results: readonly PauseBridgeResult[],
|
||||
): boolean {
|
||||
if (results.length === 0) return false;
|
||||
return results.every((result) => !result.success && isDeadTransferPauseMiss(result.reason));
|
||||
}
|
||||
|
||||
export type DirectoryPauseParentOutcome =
|
||||
| { kind: "paused"; reason?: string }
|
||||
| { kind: "still_transferring"; reason?: string };
|
||||
|
||||
/**
|
||||
* Parent directory pause outcome after per-child bridge results.
|
||||
*
|
||||
* Folder pause is latch-first: stop admitting new files even when some child
|
||||
* streams refuse pause ("cannot be paused yet", checkpoint verify races).
|
||||
* Rolling the parent back to transferring was worse — soft-drained children
|
||||
* finished and the queue claimed the next file under a "failed" pause.
|
||||
*
|
||||
* `reason` may still surface a soft warning on the parent row.
|
||||
*/
|
||||
export function resolveDirectoryPauseParentOutcome(
|
||||
results: readonly PauseBridgeResult[],
|
||||
): DirectoryPauseParentOutcome {
|
||||
if (allPauseResultsBenignOrSuccess(results)) {
|
||||
return { kind: "paused" };
|
||||
}
|
||||
const hard = results.find((result) => isHardPauseFailure(result));
|
||||
return { kind: "paused", reason: hard?.reason };
|
||||
}
|
||||
|
||||
/** Soft/transient pause misses — keep retrying or tolerate for folder latch. */
|
||||
export function isTransientPauseFailure(reason?: string): boolean {
|
||||
return /cannot be paused yet|Could not verify the saved transfer checkpoint|Could not verify that the source is safe to resume/i
|
||||
.test(reason || "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether pauseTransfer should latch waiters (pausedTasksRef).
|
||||
* Only latch on true pause success so workers do not soft-deadlock.
|
||||
*/
|
||||
export function shouldLatchPauseWaiters(params: {
|
||||
pauseSucceeded: boolean;
|
||||
}): boolean {
|
||||
return params.pauseSucceeded;
|
||||
}
|
||||
|
||||
/**
|
||||
* After a multi-id pause attempt fails overall, which ids must be unpaused so
|
||||
* work can continue (scheduler jobs + successfully bridge-paused streams).
|
||||
*
|
||||
* `activeIds` — every id we attempted to pause
|
||||
* `backendIds` — ids sent to the bridge (scheduler.pause returned false)
|
||||
* `bridgeResults` — bridge pause outcomes for backendIds (same order)
|
||||
*/
|
||||
export function planPartialPauseRollback(params: {
|
||||
activeIds: readonly string[];
|
||||
backendIds: readonly string[];
|
||||
bridgeResults: readonly PauseBridgeResult[];
|
||||
}): {
|
||||
schedulerIdsToResume: string[];
|
||||
bridgeIdsToResume: string[];
|
||||
} {
|
||||
const backendSet = new Set(params.backendIds);
|
||||
const schedulerIdsToResume = params.activeIds.filter((id) => !backendSet.has(id));
|
||||
const bridgeIdsToResume: string[] = [];
|
||||
for (let i = 0; i < params.backendIds.length; i += 1) {
|
||||
const result = params.bridgeResults[i];
|
||||
if (result?.success) {
|
||||
bridgeIdsToResume.push(params.backendIds[i]!);
|
||||
}
|
||||
}
|
||||
return { schedulerIdsToResume, bridgeIdsToResume };
|
||||
}
|
||||
Reference in New Issue
Block a user