chore: apply formatter updates

This commit is contained in:
Evandro committed 2026-06-11 01:19:07 -03:00
1 parent 8f754b3f00
commit b111ae0a76
5 files changed
+110 -97

No files matched your search

+4 -1
View File
@@ -18,7 +18,10 @@ serde_json = "1"
tauri = { version = "2", features = ["tray-icon", "image-png"] }
tauri-plugin-opener = "2"
tauri-plugin-global-shortcut = "2"
reqwest = { version = "0.12", default-features = false, features = ["blocking", "rustls-tls"] }
reqwest = { version = "0.12", default-features = false, features = [
"blocking",
"rustls-tls",
] }
cpal = "0.15.3"
hound = "3.5"
arboard = "3.6"
+9 -4
View File
@@ -87,7 +87,8 @@ pub fn status_for_path(path: &Path, expected_size: u64) -> ModelInstallStatus {
Ok(metadata) if metadata.len() >= expected_size => ModelInstallStatus::Ready,
Ok(metadata) => ModelInstallStatus::Error(format!(
"arquivo incompleto: {} de {} bytes",
metadata.len(), expected_size
metadata.len(),
expected_size
)),
Err(_) => ModelInstallStatus::NotInstalled,
}
@@ -132,7 +133,8 @@ pub fn download_default_model(model_dir: &Path) -> AppResult<ModelDownloadResult
bytes_written += read as u64;
}
file.flush().map_err(|error| AppError::Io(error.to_string()))?;
file.flush()
.map_err(|error| AppError::Io(error.to_string()))?;
if bytes_written < model.size_bytes {
let _ = fs::remove_file(&temp_path);
@@ -180,9 +182,12 @@ mod tests {
fs::write(&path, [1_u8, 2, 3, 4]).unwrap_or_else(|error| panic!("write model: {error}"));
assert_eq!(status_for_path(&path, 4), ModelInstallStatus::Ready);
assert!(matches!(status_for_path(&path, 5), ModelInstallStatus::Error(_)));
assert!(matches!(
status_for_path(&path, 5),
ModelInstallStatus::Error(_)
));
let _ = fs::remove_file(path);
let _ = fs::remove_dir(dir);
}
}
}
+82 -77
View File
@@ -1,98 +1,103 @@
import { beforeEach, describe, expect, it } from 'vitest';
import { beforeEach, describe, expect, it } from "vitest";
import { createTranscriptionApp, type AppSnapshot, type NativeClient } from './app';
import {
createTranscriptionApp,
type AppSnapshot,
type NativeClient,
} from "./app";
const baseSnapshot: AppSnapshot = {
recordingStatus: 'idle',
transcript: {
text: 'Texto inicial',
lastMessage: 'Revise o texto antes de inserir.',
},
settings: {
transcription: {
mode: 'localFirst',
modelId: 'parakeet-tdt-0.6b-v3-q8_0',
language: null,
openaiCompatible: {
endpoint: 'https://api.openai.com/v1/audio/transcriptions',
apiKeyConfigured: false,
model: 'whisper-1',
},
},
insertion: {
method: 'clipboardPaste',
restoreClipboard: true,
waylandManualFallback: true,
},
storage: {
keepAudio: false,
audioFormat: 'wav',
},
},
models: [
{
model: {
id: 'parakeet-tdt-0.6b-v3-q8_0',
displayName: 'Parakeet TDT 0.6B v3 Q8',
repository: 'cstr/parakeet-tdt-0.6b-v3-GGUF',
filename: 'parakeet-tdt-0.6b-v3-q8_0.gguf',
quantization: 'Q8_0',
sizeBytes: 745_121_600,
languages: ['pt'],
recommendedForSimplePc: true,
},
status: 'notInstalled',
},
],
recordingStatus: "idle",
transcript: {
text: "Texto inicial",
lastMessage: "Revise o texto antes de inserir.",
},
settings: {
transcription: {
mode: "localFirst",
modelId: "parakeet-tdt-0.6b-v3-q8_0",
language: null,
openaiCompatible: {
endpoint: "https://api.openai.com/v1/audio/transcriptions",
apiKeyConfigured: false,
model: "whisper-1",
},
},
insertion: {
method: "clipboardPaste",
restoreClipboard: true,
waylandManualFallback: true,
},
storage: {
keepAudio: false,
audioFormat: "wav",
},
},
models: [
{
model: {
id: "parakeet-tdt-0.6b-v3-q8_0",
displayName: "Parakeet TDT 0.6B v3 Q8",
repository: "cstr/parakeet-tdt-0.6b-v3-GGUF",
filename: "parakeet-tdt-0.6b-v3-q8_0.gguf",
quantization: "Q8_0",
sizeBytes: 745_121_600,
languages: ["pt"],
recommendedForSimplePc: true,
},
status: "notInstalled",
},
],
};
function createFakeClient(): NativeClient & { calls: string[] } {
const calls: string[] = [];
const calls: string[] = [];
return {
calls,
async invoke<T>(command: string): Promise<T> {
calls.push(command);
return baseSnapshot as T;
},
};
return {
calls,
async invoke<T>(command: string): Promise<T> {
calls.push(command);
return baseSnapshot as T;
},
};
}
async function flushPromises(): Promise<void> {
await new Promise((resolve) => window.setTimeout(resolve, 0));
await new Promise((resolve) => window.setTimeout(resolve, 0));
}
describe('createTranscriptionApp', () => {
beforeEach(() => {
document.body.textContent = '';
});
describe("createTranscriptionApp", () => {
beforeEach(() => {
document.body.textContent = "";
});
it('renders editable transcript modal with offline model details', async () => {
const mount = document.createElement('main');
const client = createFakeClient();
it("renders editable transcript modal with offline model details", async () => {
const mount = document.createElement("main");
const client = createFakeClient();
createTranscriptionApp(mount, client);
await flushPromises();
createTranscriptionApp(mount, client);
await flushPromises();
const editor = mount.querySelector<HTMLTextAreaElement>('#transcript-editor');
const editor =
mount.querySelector<HTMLTextAreaElement>("#transcript-editor");
expect(editor?.value).toBe('Texto inicial');
expect(mount.textContent).toContain('Parakeet TDT 0.6B v3 Q8');
expect(mount.textContent).toContain('Offline primeiro');
});
expect(editor?.value).toBe("Texto inicial");
expect(mount.textContent).toContain("Parakeet TDT 0.6B v3 Q8");
expect(mount.textContent).toContain("Offline primeiro");
});
it('calls native start command when record button is pressed', async () => {
const mount = document.createElement('main');
const client = createFakeClient();
it("calls native start command when record button is pressed", async () => {
const mount = document.createElement("main");
const client = createFakeClient();
createTranscriptionApp(mount, client);
await flushPromises();
createTranscriptionApp(mount, client);
await flushPromises();
const button = mount.querySelector<HTMLButtonElement>('.primary-button');
button?.click();
await flushPromises();
const button = mount.querySelector<HTMLButtonElement>(".primary-button");
button?.click();
await flushPromises();
expect(client.calls).toContain('get_app_snapshot');
expect(client.calls).toContain('start_recording');
});
expect(client.calls).toContain("get_app_snapshot");
expect(client.calls).toContain("start_recording");
});
});
+4 -4
View File
@@ -1,10 +1,10 @@
import './styles.css';
import { createTranscriptionApp } from './app';
import "./styles.css";
import { createTranscriptionApp } from "./app";
const app = document.querySelector<HTMLElement>('#app');
const app = document.querySelector<HTMLElement>("#app");
if (!app) {
throw new Error('Elemento #app não encontrado.');
throw new Error("Elemento #app não encontrado.");
}
createTranscriptionApp(app);
+11 -11
View File
@@ -1,14 +1,14 @@
import { defineConfig } from 'vitest/config';
import { defineConfig } from "vitest/config";
export default defineConfig({
clearScreen: false,
server: {
host: '127.0.0.1',
port: 1420,
strictPort: true,
},
envPrefix: ['VITE_', 'TAURI_'],
test: {
environment: 'jsdom',
},
clearScreen: false,
server: {
host: "127.0.0.1",
port: 1420,
strictPort: true,
},
envPrefix: ["VITE_", "TAURI_"],
test: {
environment: "jsdom",
},
});