mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 20:11:08 +00:00
* fix(#3339): automated AI fix * fix: address Codex review on PR #3340 * fix: address Codex review on PR #3340 * fix: address Codex review on PR #3340 * fix: address Codex review on PR #3340 * fix: address Codex review on PR #3340 * fix: address Codex review on PR #3340 * fix: address Codex review on PR #3340 * fix(tabs): guard complete batch close and verify editor safety --------- Co-authored-by: netcatty-bot <308658023+netcatty-bot@users.noreply.github.com> Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com>
56 lines
2.0 KiB
TypeScript
56 lines
2.0 KiB
TypeScript
/**
|
|
* Maps live SFTP connection ids to the top-level tab that owns the panel
|
|
* hosting them (a terminal/workspace tab for SftpSidePanel instances).
|
|
*
|
|
* Editor tabs record the SFTP `connection.id` as their `sessionId` — not the
|
|
* owning terminal session id — so batch-close logic that wants to keep an
|
|
* editor's owning tab open after a cancelled dirty-save prompt must resolve
|
|
* the owner through this registry instead of comparing `editorTab.sessionId`
|
|
* against terminal session ids.
|
|
*
|
|
* Each mounted SftpSidePanel registers a resolver that reports the connection
|
|
* ids it currently owns plus its host tab id; the top-level SftpView either
|
|
* registers nothing (its owner is not a closable terminal tab) or registers
|
|
* with a non-terminal owner id that simply never matches.
|
|
*/
|
|
export interface EditorSftpOwnerSnapshot {
|
|
connectionIds: readonly string[];
|
|
/**
|
|
* Stable SFTP pane tab ids (pane.id) hosted by this panel. Unlike connection
|
|
* ids these survive browse reconnects that regenerate connection ids, so
|
|
* owner resolution can fall back to them when an editor still references a
|
|
* pre-reconnect connection id.
|
|
*/
|
|
paneTabIds?: readonly string[];
|
|
ownerTabId: string | null;
|
|
}
|
|
|
|
type EditorSftpOwnerResolver = () => EditorSftpOwnerSnapshot;
|
|
|
|
const resolvers = new Set<EditorSftpOwnerResolver>();
|
|
|
|
export const registerEditorSftpOwnerResolver = (resolver: EditorSftpOwnerResolver): (() => void) => {
|
|
resolvers.add(resolver);
|
|
return () => {
|
|
resolvers.delete(resolver);
|
|
};
|
|
};
|
|
|
|
export const findEditorSftpOwnerTabId = (
|
|
connectionId: string | undefined,
|
|
paneTabId?: string,
|
|
): string | null => {
|
|
if (!connectionId && !paneTabId) return null;
|
|
for (const resolve of resolvers) {
|
|
const snapshot = resolve();
|
|
if (!snapshot.ownerTabId) continue;
|
|
if (connectionId && snapshot.connectionIds.includes(connectionId)) {
|
|
return snapshot.ownerTabId;
|
|
}
|
|
if (paneTabId && snapshot.paneTabIds?.includes(paneTabId)) {
|
|
return snapshot.ownerTabId;
|
|
}
|
|
}
|
|
return null;
|
|
};
|