Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions apps/whispering/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/whispering/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ core-foundation-sys = "0.8.7"
tauri-plugin-global-shortcut = "2"
tauri-plugin-single-instance = "2"
tauri-plugin-updater = "2"
tauri-plugin-window-state = "2"

[profile.dev]
incremental = true # Compile your binary in smaller steps.
Expand Down
40 changes: 34 additions & 6 deletions apps/whispering/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,20 @@ pub async fn run() {

#[cfg(desktop)]
{
builder = builder.plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| {
let _ = app
.get_webview_window("main")
.expect("no main window")
.set_focus();
}));
builder = builder
.plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| {
let _ = app
.get_webview_window("main")
.expect("no main window")
.set_focus();
}))
.plugin(tauri_plugin_window_state::Builder::default().build());
}

// Register command handlers (same for all platforms now)
let builder = builder.invoke_handler(tauri::generate_handler![
write_text,
reset_window_size,
// Audio recorder commands
get_current_recording_id,
enumerate_recording_devices,
Expand Down Expand Up @@ -183,3 +186,28 @@ async fn write_text(app: tauri::AppHandle, text: String) -> Result<(), String> {
Ok(())
}

/// Resets window size by deleting the saved window state file
///
/// This command removes the `.window-state.json` file from the app's data directory,
/// allowing the window to reset to default dimensions on next launch or manual resize.
/// The frontend should immediately resize the window to defaults after calling this.
#[tauri::command]
async fn reset_window_size(app: tauri::AppHandle) -> Result<(), String> {
// Get app data directory
let app_dir = app
.path()
.app_data_dir()
.map_err(|e| format!("Failed to get app data directory: {}", e))?;

// Construct path to window state file (same name as used by tauri-plugin-window-state)
let state_file = app_dir.join(".window-state.json");

// Delete the file if it exists
if state_file.exists() {
std::fs::remove_file(&state_file)
.map_err(|e| format!("Failed to delete window state file: {}", e))?;
}

Ok(())
}

21 changes: 21 additions & 0 deletions apps/whispering/src/lib/components/NavItems.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
import * as DropdownMenu from '@repo/ui/dropdown-menu';
import { cn } from '@repo/ui/utils';
import { LogicalSize, getCurrentWindow } from '@tauri-apps/api/window';
import { invoke } from '@tauri-apps/api/core';
import { toast } from 'svelte-sonner';
import {
LayersIcon,
ListIcon,
Minimize2Icon,
MoonIcon,
MoreVerticalIcon,
RotateCcwIcon,
SettingsIcon,
SunIcon,
} from '@lucide/svelte';
Expand All @@ -21,6 +24,18 @@
collapsed = false,
}: { class?: string; collapsed?: boolean } = $props();

const resetWindowSize = async () => {
try {
await invoke('reset_window_size');
const window = getCurrentWindow();
await window.setSize(new LogicalSize(1080, 800));
toast.success('Window size reset to default');
} catch (error) {
console.error('Failed to reset window size:', error);
toast.error(`Failed to reset window size: ${error}`);
}
};

const navItems = [
{
label: 'Recordings',
Expand Down Expand Up @@ -62,6 +77,12 @@
type: 'button',
action: () => getCurrentWindow().setSize(new LogicalSize(72, 84)),
},
{
label: 'Reset window size',
icon: RotateCcwIcon,
type: 'button',
action: resetWindowSize,
},
] as const)
: []),
] satisfies NavItem[];
Expand Down
5 changes: 1 addition & 4 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
"workspaces": {
"": {
"name": "epicenter",
"dependencies": {
"wellcrafted": "catalog:",
},
"devDependencies": {
"@biomejs/biome": "^2.3.1",
"@eslint/compat": "^1.4.0",
Expand Down Expand Up @@ -148,7 +145,7 @@
},
"apps/whispering": {
"name": "@repo/whispering",
"version": "7.7.0",
"version": "7.7.1",
"dependencies": {
"@anthropic-ai/sdk": "^0.55.0",
"@aptabase/tauri": "^0.4.1",
Expand Down