mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-17 13:01:24 +00:00
* fix(#2727): automated Cursor CLI fix * fix(sftp): drop external-edit retainers when browse sessions close closeSftp already deletes registered temps on disconnect/reconnect; clear the matching renderer retainers so hasActiveWork cannot stick on a gone file. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(sftp): clear external-edit retainers when watches force-stop When the temp file disappears, fileWatcherBridge force-stops the watch with localPath; drop the matching retainer so hasActiveWork cannot stick. Co-authored-by: Cursor <cursoragent@cursor.com> * fix: address Codex review on PR #2730 --------- Co-authored-by: netcatty-bot <308658023+netcatty-bot@users.noreply.github.com> Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
/**
|
|
* Renderer-side retainers for remote temps opened in external editors.
|
|
* closeSftp deletes those files; forget matching retainers so park/auto-connect
|
|
* checks do not keep treating a deleted temp as active work.
|
|
*/
|
|
export type ExternalEditTempRetention = {
|
|
remember(sftpId: string, localPath: string): boolean;
|
|
forgetPath(localPath: string): boolean;
|
|
forgetSftp(sftpId: string): boolean;
|
|
clear(): boolean;
|
|
readonly size: number;
|
|
};
|
|
|
|
export function createExternalEditTempRetention(): ExternalEditTempRetention {
|
|
const bySftp = new Map<string, Set<string>>();
|
|
|
|
const recount = (): number => {
|
|
let total = 0;
|
|
for (const paths of bySftp.values()) total += paths.size;
|
|
return total;
|
|
};
|
|
|
|
return {
|
|
remember(sftpId, localPath) {
|
|
if (!sftpId || !localPath) return false;
|
|
let paths = bySftp.get(sftpId);
|
|
if (!paths) {
|
|
paths = new Set();
|
|
bySftp.set(sftpId, paths);
|
|
}
|
|
if (paths.has(localPath)) return false;
|
|
paths.add(localPath);
|
|
return true;
|
|
},
|
|
forgetPath(localPath) {
|
|
if (!localPath) return false;
|
|
let changed = false;
|
|
for (const [sftpId, paths] of bySftp) {
|
|
if (!paths.delete(localPath)) continue;
|
|
changed = true;
|
|
if (paths.size === 0) bySftp.delete(sftpId);
|
|
}
|
|
return changed;
|
|
},
|
|
forgetSftp(sftpId) {
|
|
if (!sftpId || !bySftp.has(sftpId)) return false;
|
|
bySftp.delete(sftpId);
|
|
return true;
|
|
},
|
|
clear() {
|
|
if (bySftp.size === 0) return false;
|
|
bySftp.clear();
|
|
return true;
|
|
},
|
|
get size() {
|
|
return recount();
|
|
},
|
|
};
|
|
}
|