Skip to content

Commit 0aec8fb

Browse files
committed
Bugfix: MCP open_under_cursor works on the Network view again
`openCursorItem` in `FilePane.svelte` only read from `briefList` / `fullList`, so on the Network volume — where the cursor lives in `NetworkBrowser` (host list) or `ShareBrowser` (share list) — it always threw "No entry under cursor". Regression from the May 2026 MCP ack-contract refactor (e12285d), which replaced the keyboard-event dispatch with a direct `handleNavigate(entry)` call that bypassed the network-view branch in `handleKeyDown`. - `NetworkBrowser`, `ShareBrowser`: new `openCursorItem()` method runs the same action Enter triggers (open host / open share / "Connect to server…"). - `NetworkMountView`: forwards to the active child (`shareBrowserRef` or `networkBrowserRef`). - `FilePane.openCursorItem`: routes to `networkMountViewRef.openCursorItem()` when `isNetworkView`, falls through to the file-list path otherwise. This unblocks the 3 SMB E2E tests on Linux that were red since the refactor (`smb.spec.ts:220`, `:240`, `:480`). Verified on Linux Docker (157/157) and macOS (145/145).
1 parent e21ca6d commit 0aec8fb

5 files changed

Lines changed: 36 additions & 0 deletions

File tree

apps/desktop/src/lib/file-explorer/network/NetworkBrowser.svelte

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,16 @@
205205
return hosts.findIndex((h) => h.name.toLowerCase() === name.toLowerCase())
206206
}
207207
208+
/** Opens the host (or "Connect to server…" row) under the cursor — same action Enter triggers. */
209+
// noinspection JSUnusedGlobalSymbols -- used dynamically by NetworkMountView / MCP
210+
export function openCursorItem(): void {
211+
if (isCursorOnConnectRow) {
212+
onConnectToServer?.()
213+
} else if (cursorIndex >= 0 && cursorIndex < hosts.length) {
214+
onHostSelect?.(hosts[cursorIndex])
215+
}
216+
}
217+
208218
/** Check for ⌘R refresh shortcut */
209219
function isRefreshShortcut(e: KeyboardEvent): boolean {
210220
return e.key === 'r' && e.metaKey && !e.shiftKey && !e.altKey && !e.ctrlKey

apps/desktop/src/lib/file-explorer/network/ShareBrowser.svelte

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,14 @@
317317
return sortedShares.findIndex((s) => s.name.toLowerCase() === name.toLowerCase())
318318
}
319319
320+
/** Opens the share under the cursor — same action Enter triggers. */
321+
// noinspection JSUnusedGlobalSymbols -- used dynamically by NetworkMountView / MCP
322+
export function openCursorItem(): void {
323+
if (cursorIndex >= 0 && cursorIndex < sortedShares.length) {
324+
onShareSelect?.(sortedShares[cursorIndex], authenticatedCredentials)
325+
}
326+
}
327+
320328
function handleShareClick(index: number) {
321329
cursorIndex = index
322330
}

apps/desktop/src/lib/file-explorer/pane/FilePane.svelte

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,12 @@
16461646
*/
16471647
// noinspection JSUnusedGlobalSymbols -- Used dynamically by DualPaneExplorer/MCP
16481648
export async function openCursorItem(): Promise<void> {
1649+
if (isNetworkView) {
1650+
// Network view: cursor lives in NetworkBrowser/ShareBrowser, not the file list.
1651+
// Delegate to NetworkMountView, which forwards to whichever child is active.
1652+
networkMountViewRef?.openCursorItem()
1653+
return
1654+
}
16491655
const entry = getEntryUnderCursor()
16501656
if (!entry) {
16511657
throw new Error('No entry under cursor')

apps/desktop/src/lib/file-explorer/pane/NetworkMountView.svelte

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,16 @@
184184
return networkBrowserRef?.findItemIndex(name) ?? -1
185185
}
186186
187+
/** Opens the host or share under the cursor — same action Enter triggers. */
188+
// noinspection JSUnusedGlobalSymbols -- used dynamically by FilePane / MCP
189+
export function openCursorItem(): void {
190+
if (currentNetworkHost) {
191+
shareBrowserRef?.openCursorItem()
192+
} else {
193+
networkBrowserRef?.openCursorItem()
194+
}
195+
}
196+
187197
/** Refresh network hosts (used by ⌘R shortcut). */
188198
export function refreshNetworkHosts() {
189199
networkBrowserRef?.refresh()

apps/desktop/src/lib/file-explorer/pane/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export interface BrowserAPI {
100100
handleKeyDown(e: KeyboardEvent): boolean
101101
setCursorIndex(index: number): void
102102
findItemIndex(name: string): number
103+
openCursorItem(): void
103104
}
104105

105106
/** Typed interface for NetworkBrowser's exported methods (extends BrowserAPI with refresh). */
@@ -112,6 +113,7 @@ export interface NetworkMountViewAPI {
112113
handleKeyDown(e: KeyboardEvent): void
113114
setCursorIndex(index: number): void
114115
findItemIndex(name: string): number
116+
openCursorItem(): void
115117
refreshNetworkHosts(): void
116118
setNetworkHost(host: NetworkHost | null): void
117119
}

0 commit comments

Comments
 (0)