Skip to content

Commit 20067c9

Browse files
ozgesolidkeyclaude
andcommitted
Disconnect SSH connection when remote folder is removed
Clicking × on an SSH folder now calls liveDisconnect + liveRemove on the connection that was created for it, freeing the slot and closing the SSH session. The connectionId is threaded through addSshFolderToPanel and stored on FolderState. Folders using an already-active connection (no connectionId) are unaffected. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 6eefe62 commit 20067c9

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/renderer/renderer.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ interface FolderState {
158158
collapsed: boolean;
159159
isRemote?: boolean;
160160
sshHost?: string;
161+
connectionId?: string; // live connection ID to disconnect when folder is removed
161162
}
162163

163164
// Column visibility state
@@ -4290,6 +4291,12 @@ async function openFolder(): Promise<void> {
42904291
}
42914292

42924293
function removeFolder(folderPath: string): void {
4294+
const folder = state.folders.find((f) => f.path === folderPath);
4295+
// Disconnect the SSH connection if one was created exclusively for this folder
4296+
if (folder?.connectionId) {
4297+
window.api.liveDisconnect(folder.connectionId).catch(() => {});
4298+
window.api.liveRemove(folder.connectionId).catch(() => {});
4299+
}
42934300
state.folders = state.folders.filter((f) => f.path !== folderPath);
42944301
renderFolderTree();
42954302
updateFolderSearchState();
@@ -6972,7 +6979,7 @@ async function showSshConnectModal(): Promise<void> {
69726979
return;
69736980
}
69746981
const files = result.files || [];
6975-
addSshFolderToPanel(`${username || 'user'}@${host}`, remotePath, files);
6982+
addSshFolderToPanel(`${username || 'user'}@${host}`, remotePath, files, connResult.connectionId);
69766983
cleanup();
69776984
}
69786985
} catch (err) {
@@ -6988,16 +6995,16 @@ async function showSshConnectModal(): Promise<void> {
69886995
});
69896996
}
69906997

6991-
function addSshFolderToPanel(hostLabel: string, remotePath: string, files: any[]): void {
6998+
function addSshFolderToPanel(hostLabel: string, remotePath: string, files: any[], connectionId?: string): void {
69926999
const folderName = `${hostLabel}:${remotePath}`;
69937000

6994-
// Reuse existing openSshFolder logic for adding to state
69957001
state.folders.push({
69967002
name: folderName,
69977003
path: remotePath,
69987004
files: mapFolderEntries(files),
69997005
collapsed: false,
70007006
isRemote: true,
7007+
connectionId, // stored so removeFolder can disconnect it
70017008
});
70027009
renderFolderTree();
70037010
// Open folders panel if not already open

0 commit comments

Comments
 (0)