Skip to content

Commit 0cdbfef

Browse files
committed
fix: restore license expiration dashboard navigation on hotkey press
- Show and focus main window when license check fails - Auto-navigate to Account section for license management - Display clear error toast with license status - Fix AI test assertions to match refactored prompt structure
1 parent 132a2ce commit 0cdbfef

File tree

3 files changed

+34
-28
lines changed

3 files changed

+34
-28
lines changed

src-tauri/src/ai/tests.rs

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ mod tests {
107107
let prompt = build_enhancement_prompt("hello world", None, &options);
108108

109109
assert!(prompt.contains("hello world"));
110-
assert!(prompt.contains("APPLY THESE CORRECTIONS"));
110+
assert!(prompt.contains("THEN clean up this voice transcription"));
111111

112112
// Test with context
113113
let prompt_with_context =
@@ -132,7 +132,7 @@ mod tests {
132132
// Test Default preset
133133
let default_options = EnhancementOptions::default();
134134
let default_prompt = build_enhancement_prompt(text, None, &default_options);
135-
assert!(default_prompt.contains("APPLY THESE CORRECTIONS"));
135+
assert!(default_prompt.contains("THEN clean up this voice transcription"));
136136

137137
// Test Prompts preset
138138
let mut prompts_options = EnhancementOptions::default();
@@ -178,15 +178,10 @@ mod tests {
178178

179179
// All prompts should include self-correction rules
180180
assert!(
181-
prompt.contains("handle natural speech self-corrections"),
181+
prompt.contains("handle self-corrections"),
182182
"Preset {:?} should include self-correction rules",
183183
preset
184184
);
185-
assert!(
186-
prompt.contains("Immediate replacement"),
187-
"Preset {:?} should include immediate replacement pattern",
188-
preset
189-
);
190185
}
191186
}
192187

@@ -211,14 +206,14 @@ mod tests {
211206

212207
// All should include self-correction rules
213208
assert!(
214-
prompt.contains("handle natural speech self-corrections"),
209+
prompt.contains("handle self-corrections"),
215210
"Preset {:?} should include self-correction rules",
216211
preset
217212
);
218213

219214
// All should include default processing
220215
assert!(
221-
prompt.contains("APPLY THESE CORRECTIONS"),
216+
prompt.contains("THEN clean up this voice transcription"),
222217
"Preset {:?} should include default processing",
223218
preset
224219
);
@@ -245,29 +240,18 @@ mod tests {
245240
// Test that Default prompt includes all comprehensive features
246241

247242
// 1. Speech artifacts removal
248-
assert!(prompt.contains("Filler words"), "Should include filler word removal");
243+
assert!(prompt.contains("Remove filler words"), "Should include filler word removal");
249244
assert!(prompt.contains("stutters"), "Should handle stutters");
250245

251-
// 2. Homophone correction
252-
assert!(prompt.contains("Homophones"), "Should handle homophones");
253-
assert!(prompt.contains("there/their/they're"), "Should include common homophone examples");
246+
// 2. Error correction
247+
assert!(prompt.contains("Fix all errors"), "Should fix errors");
248+
assert!(prompt.contains("grammar, spelling, punctuation"), "Should handle grammar and spelling");
254249

255250
// 3. Number and time formatting
256-
assert!(prompt.contains("Times:"), "Should format times");
257-
assert!(prompt.contains("Dates:"), "Should format dates");
258-
assert!(prompt.contains("Numbers:"), "Should format numbers");
259-
260-
// 4. Spoken punctuation
261-
assert!(prompt.contains("spoken punctuation"), "Should handle spoken punctuation");
262-
assert!(prompt.contains("comma"), "Should handle spoken comma");
263-
assert!(prompt.contains("question mark"), "Should handle spoken question mark");
264-
265-
// 5. List detection
266-
assert!(prompt.contains("Format lists"), "Should format detected lists");
251+
assert!(prompt.contains("Format numbers, dates, times"), "Should format numbers and dates");
267252

268-
// 6. Technical terms
269-
assert!(prompt.contains("Technical terms"), "Should preserve technical terms");
270-
assert!(prompt.contains("JavaScript"), "Should correct JavaScript");
253+
// 4. Technical terms
254+
assert!(prompt.contains("Correct technical terms"), "Should preserve technical terms");
271255
}
272256

273257
#[test]

src-tauri/src/commands/audio.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ async fn validate_recording_requirements(app: &AppHandle) -> Result<(), String>
8787
Ok(status) => {
8888
if matches!(status.status, LicenseState::Expired | LicenseState::None) {
8989
log::error!("Invalid license");
90+
91+
// Show and focus the main window
92+
if let Some(window) = app.get_webview_window("main") {
93+
let _ = window.show();
94+
let _ = window.set_focus();
95+
}
96+
9097
// Emit error event with guidance
9198
let _ = emit_to_window(
9299
app,

src/components/AppContainer.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ export function AppContainer() {
8989
toast.error(event.payload as string);
9090
});
9191

92+
// Listen for license-required event and navigate to Account section
93+
registerEvent<{ title: string; message: string; action?: string }>(
94+
"license-required",
95+
(data) => {
96+
console.log("License required event received in AppContainer:", data);
97+
// Navigate to Account section to show license management
98+
setActiveSection("account");
99+
// Show a toast to inform the user
100+
toast.error(data.title || "License Required", {
101+
description: data.message || "Please purchase or restore a license to continue",
102+
duration: 5000
103+
});
104+
}
105+
);
106+
92107
// Listen for no models error (when trying to record without any models)
93108
registerEvent<ErrorEventPayload>("no-models-error", (data) => {
94109
console.error("No models available:", data);

0 commit comments

Comments
 (0)