Skip to content

Commit f494e15

Browse files
committed
Tooling: Add awesome debug pane to app
- Can toggle light/dark mode - See back/forward history - Opens in separate window - Only appears in dev mode
1 parent d327cf4 commit f494e15

6 files changed

Lines changed: 414 additions & 3 deletions

File tree

CONTRIBUTING.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ pnpm dev
2121

2222
This starts both the Svelte frontend and the Rust backend with hot reload.
2323

24+
## Debug window
25+
26+
In dev mode, press **Cmd+D** to open a debug window. This window is only available in dev builds and provides:
27+
28+
- **Dark mode toggle**: Switch between light and dark themes without changing your system settings
29+
- **Navigation history**: Real-time view of back/forward history for both panes, showing current position and
30+
available history entries
31+
32+
The debug window is a separate, movable window that updates in real-time as you navigate.
33+
2434
## Logging
2535

2636
### Rust

apps/desktop/src-tauri/capabilities/default.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@
33
"identifier": "default",
44
"description": "Capability for the main window",
55
"windows": [
6-
"main"
6+
"main",
7+
"debug"
78
],
89
"permissions": [
910
"core:default",
1011
"core:window:allow-start-dragging",
12+
"core:window:allow-close",
13+
"core:window:allow-theme",
14+
"core:webview:allow-webview-close",
15+
"core:webview:allow-create-webview-window",
16+
"core:app:allow-set-app-theme",
17+
"core:event:default",
1118
"opener:default",
1219
{
1320
"identifier": "opener:allow-open-path",

apps/desktop/src-tauri/capabilities/desktop.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"linux"
77
],
88
"windows": [
9-
"main"
9+
"main",
10+
"debug"
1011
],
1112
"permissions": [
1213
"window-state:default"

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { onMount, onDestroy } from 'svelte'
2+
import { onMount, onDestroy, untrack } from 'svelte'
33
import FilePane from './FilePane.svelte'
44
import PaneResizer from './PaneResizer.svelte'
55
import LoadingIcon from '../LoadingIcon.svelte'
@@ -75,6 +75,21 @@
7575
let leftHistory = $state<NavigationHistory>(createHistory(DEFAULT_VOLUME_ID, '~'))
7676
let rightHistory = $state<NavigationHistory>(createHistory(DEFAULT_VOLUME_ID, '~'))
7777
78+
// Emit history state to debug window (dev mode only)
79+
$effect(() => {
80+
if (!import.meta.env.DEV) return
81+
// Read the reactive values
82+
const left = leftHistory
83+
const right = rightHistory
84+
const focused = focusedPane
85+
// Emit without tracking to avoid infinite loops
86+
untrack(() => {
87+
void import('@tauri-apps/api/event').then(({ emit }) => {
88+
void emit('debug-history', { left, right, focusedPane: focused })
89+
})
90+
})
91+
})
92+
7893
// Derived volume paths - handle 'network' virtual volume specially
7994
const leftVolumePath = $derived(
8095
leftVolumeId === 'network' ? 'smb://' : (volumes.find((v) => v.id === leftVolumeId)?.path ?? '/'),

apps/desktop/src/routes/+page.svelte

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,34 @@
6565
let unlistenCommandPalette: UnlistenFn | undefined
6666
let unlistenSwitchPane: UnlistenFn | undefined
6767
68+
/** Opens the debug window (dev mode only) */
69+
async function openDebugWindow() {
70+
try {
71+
const { WebviewWindow } = await import('@tauri-apps/api/webviewWindow')
72+
// Check if debug window already exists
73+
const existing = await WebviewWindow.getByLabel('debug')
74+
if (existing) {
75+
await existing.setFocus()
76+
return
77+
}
78+
// Create new debug window
79+
new WebviewWindow('debug', {
80+
url: '/debug',
81+
title: 'Debug',
82+
width: 480,
83+
height: 500,
84+
resizable: true,
85+
minimizable: false,
86+
maximizable: false,
87+
closable: true,
88+
focus: true,
89+
})
90+
} catch (error) {
91+
// eslint-disable-next-line no-console -- Debug window is dev-only
92+
console.error('Failed to open debug window:', error)
93+
}
94+
}
95+
6896
/** Start window drag when title bar is clicked */
6997
async function handleTitleBarMouseDown(e: MouseEvent) {
7098
if (e.buttons === 1) {
@@ -154,6 +182,13 @@
154182
return
155183
}
156184
185+
// Debug window: ⌘D (dev mode only)
186+
if (import.meta.env.DEV && e.metaKey && !e.shiftKey && !e.altKey && e.key.toLowerCase() === 'd') {
187+
e.preventDefault()
188+
void openDebugWindow()
189+
return
190+
}
191+
157192
// Suppress Cmd+A (select all) - always
158193
if (e.metaKey && e.key === 'a') {
159194
e.preventDefault()

0 commit comments

Comments
 (0)