← Whispering

fix: Use webview module directly for file dialog

a7de9b891e35c3417ccee67dc215720017f33ae9 · Claude · Jan 26, 2026 07:06

Access webview.windows directly and use webview.OPEN_DIALOG constant.
Make function async to handle potential coroutine returns.

+9 −7 · 1 file changed

  • src/whispering_ui/components/sidebar.py +9 −7
diff --git a/src/whispering_ui/components/sidebar.py b/src/whispering_ui/components/sidebar.py
index eb23486..170bbb6 100644
--- a/src/whispering_ui/components/sidebar.py
+++ b/src/whispering_ui/components/sidebar.py
@@ -123,15 +123,17 @@ def create_sidebar(state: AppState, bridge: ProcessingBridge, output_container=N
                 duration_label.text = ''
 
         # File selection using system native dialog
-        def on_add_files_click():
+        async def on_add_files_click():
             """Handle file selection using system native dialog - no copying."""
             try:
-                # Use pywebview's native file dialog
-                window = getattr(app.native, 'main_window', None)
-                if window:
-                    file_types = ('Audio files (*.mp3;*.wav;*.flac;*.ogg;*.m4a;*.wma;*.aac;*.opus)',)
+                import webview
+                # Get the active webview window
+                windows = webview.windows
+                if windows:
+                    window = windows[0]
+                    file_types = ('Audio files (*.mp3;*.wav;*.flac;*.ogg;*.m4a;*.wma;*.aac;*.opus)', 'All files (*.*)')
                     result = window.create_file_dialog(
-                        dialog_type=20,  # OPEN_DIALOG with multiple selection
+                        webview.OPEN_DIALOG,
                         allow_multiple=True,
                         file_types=file_types
                     )
@@ -146,7 +148,7 @@ def create_sidebar(state: AppState, bridge: ProcessingBridge, output_container=N
                         if added > 0:
                             ui.notify(f"Added {added} file(s)", type='positive')
                 else:
-                    ui.notify("Native file dialog not available", type='warning')
+                    ui.notify("No webview window available", type='warning')
             except Exception as ex:
                 ui.notify(f"Error: {ex}", type='negative')