[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:
66
application/state/sftp/transferCancelLatch.ts
Normal file
66
application/state/sftp/transferCancelLatch.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Process-wide cancel flags for SFTP transfers.
|
||||
*
|
||||
* Directory walks and stream arms check these so Cancel from the global
|
||||
* transfer center still stops work after the React owner unmounts.
|
||||
*/
|
||||
|
||||
const cancelledIds = new Set<string>();
|
||||
const childIdsByRoot = new Map<string, Set<string>>();
|
||||
|
||||
export function markTransferCancelled(taskId: string): void {
|
||||
cancelledIds.add(taskId);
|
||||
}
|
||||
|
||||
export function markTransferCancelledTree(rootTaskId: string, childIds: readonly string[] = []): void {
|
||||
cancelledIds.add(rootTaskId);
|
||||
if (childIds.length === 0) return;
|
||||
const recordedChildren = childIdsByRoot.get(rootTaskId) ?? new Set<string>();
|
||||
for (const id of childIds) {
|
||||
cancelledIds.add(id);
|
||||
recordedChildren.add(id);
|
||||
}
|
||||
childIdsByRoot.set(rootTaskId, recordedChildren);
|
||||
}
|
||||
|
||||
export function clearTransferCancelled(taskId: string): void {
|
||||
cancelledIds.delete(taskId);
|
||||
}
|
||||
|
||||
export function clearTransferCancelledTree(rootTaskId: string, childIds: readonly string[] = []): void {
|
||||
cancelledIds.delete(rootTaskId);
|
||||
for (const id of childIdsByRoot.get(rootTaskId) ?? []) cancelledIds.delete(id);
|
||||
for (const id of childIds) cancelledIds.delete(id);
|
||||
childIdsByRoot.delete(rootTaskId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Release cancellation state after the transfer has fully settled.
|
||||
* Returns every related child id, including children no longer present in UI
|
||||
* history, so sibling control state can be released from the same tree.
|
||||
*/
|
||||
export function settleTransferCancelTree(
|
||||
rootTaskId: string,
|
||||
childIds: readonly string[] = [],
|
||||
): string[] {
|
||||
const relatedChildIds = [...new Set([
|
||||
...(childIdsByRoot.get(rootTaskId) ?? []),
|
||||
...childIds,
|
||||
])];
|
||||
clearTransferCancelledTree(rootTaskId, relatedChildIds);
|
||||
return relatedChildIds;
|
||||
}
|
||||
|
||||
export function isTransferCancelledFlag(taskId: string): boolean {
|
||||
return cancelledIds.has(taskId);
|
||||
}
|
||||
|
||||
export function isTransferOrRootCancelled(rootTaskId: string, taskId?: string): boolean {
|
||||
return cancelledIds.has(rootTaskId) || (!!taskId && cancelledIds.has(taskId));
|
||||
}
|
||||
|
||||
/** Test helper. */
|
||||
export function resetTransferCancelLatchesForTests(): void {
|
||||
cancelledIds.clear();
|
||||
childIdsByRoot.clear();
|
||||
}
|
||||
Reference in New Issue
Block a user