Skip to content

Commit b5d8b28

Browse files
committed
Redesign "Refresh network hosts" function
- Remove button that didn't match the app design - Add ⌘R shortcut - Add nice footer
1 parent a018a3e commit b5d8b28

6 files changed

Lines changed: 77 additions & 8 deletions

File tree

apps/desktop/src/lib/commands/command-registry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ export const commands: Command[] = [
303303
name: 'Refresh network hosts',
304304
scope: 'Main window/Network',
305305
showInPalette: true,
306-
shortcuts: [],
306+
shortcuts: ['⌘R'],
307307
},
308308

309309
// ============================================================================

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

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,32 @@
137137
scrollToIndex(cursorIndex)
138138
}
139139
140+
/** Refresh all shares (used by ⌘R shortcut). */
141+
export function refresh() {
142+
handleRefreshClick()
143+
}
144+
140145
/** Find a host by name, returns its index or -1. */
141146
// noinspection JSUnusedGlobalSymbols -- used dynamically
142147
export function findItemIndex(name: string): number {
143148
return hosts.findIndex((h) => h.name.toLowerCase() === name.toLowerCase())
144149
}
145150
151+
/** Check for ⌘R refresh shortcut */
152+
function isRefreshShortcut(e: KeyboardEvent): boolean {
153+
return e.key === 'r' && e.metaKey && !e.shiftKey && !e.altKey && !e.ctrlKey
154+
}
155+
146156
// Handle keyboard navigation
147157
// noinspection JSUnusedGlobalSymbols -- used dynamically
148158
export function handleKeyDown(e: KeyboardEvent): boolean {
159+
// ⌘R to refresh — works regardless of host count
160+
if (isRefreshShortcut(e)) {
161+
e.preventDefault()
162+
handleRefreshClick()
163+
return true
164+
}
165+
149166
if (hosts.length === 0) return false
150167
151168
// Try centralized navigation shortcuts first (PageUp, PageDown, Home, End, Option+arrows)
@@ -408,9 +425,10 @@
408425
</div>
409426

410427
{#if hosts.length > 0}
411-
<div class="refresh-section">
412-
<Button variant="secondary" onclick={handleRefreshClick}>🔄 Refresh</Button>
413-
</div>
428+
<button class="network-status-bar" onclick={handleRefreshClick} aria-label="Refresh network hosts">
429+
<span class="status-text">{hosts.length} {hosts.length === 1 ? 'host' : 'hosts'}</span>
430+
<span class="refresh-hint">Press ⌘R or click here to refresh</span>
431+
</button>
414432
{/if}
415433
</div>
416434

@@ -549,10 +567,35 @@
549567
cursor: help;
550568
}
551569
552-
.refresh-section {
570+
.network-status-bar {
553571
display: flex;
554-
justify-content: center;
555-
padding: var(--spacing-lg) var(--spacing-sm);
556-
border-top: 1px solid var(--color-border-subtle);
572+
align-items: center;
573+
gap: 8px;
574+
width: 100%;
575+
padding: var(--spacing-xs) var(--spacing-sm);
576+
font-family: var(--font-system), sans-serif;
577+
font-size: calc(var(--font-size-sm) * 0.95);
578+
color: var(--color-text-secondary);
579+
background-color: var(--color-bg-secondary);
580+
border: none;
581+
border-top: 1px solid var(--color-border-strong);
582+
min-height: 1.5em;
583+
text-align: left;
584+
}
585+
586+
.status-text {
587+
flex: 1 1 0;
588+
min-width: 0;
589+
white-space: nowrap;
590+
overflow: hidden;
591+
text-overflow: ellipsis;
592+
}
593+
594+
.refresh-hint {
595+
flex-shrink: 0;
596+
margin-left: auto;
597+
padding-left: var(--spacing-md);
598+
color: var(--color-text-tertiary);
599+
white-space: nowrap;
557600
}
558601
</style>

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,6 +1808,13 @@
18081808
paneRef?.refreshView?.()
18091809
}
18101810
1811+
/** Refresh network hosts in the focused pane (used by ⌘R shortcut). */
1812+
export function refreshNetworkHosts() {
1813+
const paneRef = getPaneRef(focusedPane)
1814+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
1815+
paneRef?.refreshNetworkHosts?.()
1816+
}
1817+
18111818
/**
18121819
* Handle unified select command from MCP.
18131820
* @param pane - Which pane to select in

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,12 @@
253253
return isNetworkView
254254
}
255255
256+
/** Refresh network hosts (used by ⌘R shortcut). */
257+
export function refreshNetworkHosts(): void {
258+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
259+
networkMountViewRef?.refreshNetworkHosts()
260+
}
261+
256262
export function getSelectedIndices(): number[] {
257263
return selection.getSelectedIndices()
258264
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@
157157
return (networkBrowserRef?.findItemIndex(name) as number | undefined) ?? -1
158158
}
159159
160+
/** Refresh network hosts (used by ⌘R shortcut). */
161+
export function refreshNetworkHosts() {
162+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call -- Svelte bind:this ref
163+
networkBrowserRef?.refresh()
164+
}
165+
160166
export function setNetworkHost(host: NetworkHost | null) {
161167
currentNetworkHost = host
162168
mountError = null

apps/desktop/src/routes/(main)/+page.svelte

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
moveCursor: (pane: 'left' | 'right', to: number | string) => Promise<void>
7676
scrollTo: (pane: 'left' | 'right', index: number) => void
7777
refreshPane: () => void
78+
refreshNetworkHosts: () => void
7879
newTab: () => boolean
7980
closeActiveTab: () => 'closed' | 'last-tab'
8081
closeActiveTabWithConfirmation: () => Promise<'closed' | 'last-tab' | 'cancelled'>
@@ -797,6 +798,12 @@
797798
explorerRef?.refocus()
798799
return
799800
801+
// === Network commands ===
802+
case 'network.refresh':
803+
explorerRef?.refreshNetworkHosts()
804+
explorerRef?.refocus()
805+
return
806+
800807
// === Sort commands ===
801808
case 'sort.byName':
802809
explorerRef?.setSortColumn('name')

0 commit comments

Comments
 (0)