feat: OpenWhispr-inspired transcription polish pass
Some checks failed
check / cargo check (macos-latest) (push) Has been cancelled
check / cargo check (ubuntu-22.04) (push) Has been cancelled
check / cargo check (windows-latest) (push) Has been cancelled
check / svelte build + lint (push) Has been cancelled

Major quality pass on top of Phase 2. Five substantive changes plus
cross-cutting touches across audio, hotkey, transcription, and Tauri
command layers.

  Transcription quality

  - Long-audio chunking in commands/transcription.rs: Parakeet and large
    file transcription now chunk-and-recompose with overlap trimming, so
    the live-path chunking advantage extends to file-based workflows.
  - Stateful live speech gate in commands/live.rs on top of the earlier
    duplicate-boundary filtering — distinguishes start-of-speech from
    mid-speech and holds state across chunks.

  Auto-learning corrections

  - New crates/ai-formatting/src/correction_learning.rs: extracts user
    text corrections from viewer edits and proposes additions to the
    active profile's vocabulary.
  - src-tauri/src/commands/profiles.rs bridge for frontend-driven
    confirmation of learned terms.
  - src/routes/viewer/+page.svelte hooks the learning path into the
    segment-edit flow so corrections feed profile_terms without a
    separate 'train this profile' UX.

  Transcript profile provenance

  - Migration v8 (crates/storage/src/migrations.rs) adds profile_id to
    transcripts, defaulting to DEFAULT_PROFILE_ID so existing rows stay
    valid.
  - crates/storage/src/database.rs: TranscriptRow + CRUD carry profile_id.
  - src-tauri/src/commands/transcripts.rs: add_transcript accepts and
    persists profile_id.
  - DictationPage.svelte + FilesPage.svelte send activeProfileId on
    capture so learned corrections are attributed to the right profile.

  Cleanup prompt contract

  - crates/ai-formatting/src/llm_client.rs hardened: the CLEANUP_PROMPT
    now specifies concrete do/do-not rules, ready for a real model-backed
    cleanup pass. The llm_client is still a stub — kon-llm remains unwired
    — but the prompt shape is final.

  Cross-cutting polish

  - Minor touches in audio (capture/decode/resample), hotkey (lib/linux/stub),
    core, transcription (concurrency/model_manager/local_engine/whisper_rs),
    and the rest of src-tauri/src/commands/*: error-path tightening, log
    clarity, TS-migration follow-ups (@ts-nocheck additions for incremental
    typing).

Verified locally: npm run check, cargo test -p kon-ai-formatting,
cargo test -p kon-storage, cargo test -p kon --lib commands::live::tests,
cargo check — all green.

Scope boundary: kon-llm crate is still a stub; task extraction remains
rule-based. Bundled local-LLM runtime is the next clean step and is not
in this commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-19 22:39:08 +01:00
parent 28acdcfa6d
commit 34fce3cf9e
39 changed files with 1581 additions and 554 deletions

View File

@@ -100,7 +100,9 @@ fn ensure_x11_on_wayland() {
// SAFETY: setting env vars before any threads spawn (we are
// pre-Tauri-Builder here). This block is the only place these
// are written.
unsafe { std::env::set_var(key, value); }
unsafe {
std::env::set_var(key, value);
}
eprintln!("[startup] Wayland workaround: {key}={value}");
}
};
@@ -130,10 +132,8 @@ pub fn run() {
// Initialise database (blocking in setup — runs once at startup)
let db_path = database_path();
let t0 = Instant::now();
let db = tauri::async_runtime::block_on(async {
init_db(&db_path).await
})
.map_err(|e| Box::new(e) as Box<dyn std::error::Error>)?;
let db = tauri::async_runtime::block_on(async { init_db(&db_path).await })
.map_err(|e| Box::new(e) as Box<dyn std::error::Error>)?;
eprintln!("[startup] DB init: {:?}", t0.elapsed());
// Load saved preferences for webview injection
@@ -158,37 +158,40 @@ pub fn run() {
// signal and grant audio capture requests automatically.
#[cfg(target_os = "linux")]
{
main_window.with_webview(|webview| {
use webkit2gtk::{
PermissionRequest, PermissionRequestExt,
SettingsExt, WebViewExt,
};
main_window
.with_webview(|webview| {
use webkit2gtk::{
PermissionRequest, PermissionRequestExt, SettingsExt, WebViewExt,
};
let wv: webkit2gtk::WebView = webview.inner().clone();
let wv: webkit2gtk::WebView = webview.inner().clone();
// Enable media stream in WebKit settings
if let Some(settings) = WebViewExt::settings(&wv) {
settings.set_enable_media_stream(true);
settings.set_enable_media_capabilities(true);
}
// Enable media stream in WebKit settings
if let Some(settings) = WebViewExt::settings(&wv) {
settings.set_enable_media_stream(true);
settings.set_enable_media_capabilities(true);
}
// Auto-grant all permission requests (audio/video capture)
WebViewExt::connect_permission_request(&wv, |_wv, request: &PermissionRequest| {
request.allow();
true
// Auto-grant all permission requests (audio/video capture)
WebViewExt::connect_permission_request(
&wv,
|_wv, request: &PermissionRequest| {
request.allow();
true
},
);
})
.unwrap_or_else(|e| {
// Non-fatal: WebKitGTK may already have media
// capture wired by some compositors, or the
// signal binding may fail on unusual builds.
// Falling back means getUserMedia() prompts (or
// silently denies) instead of auto-granting,
// which is degraded but recoverable.
eprintln!(
"[startup] failed to configure webview media permissions: {e}",
);
});
})
.unwrap_or_else(|e| {
// Non-fatal: WebKitGTK may already have media
// capture wired by some compositors, or the
// signal binding may fail on unusual builds.
// Falling back means getUserMedia() prompts (or
// silently denies) instead of auto-granting,
// which is degraded but recoverable.
eprintln!(
"[startup] failed to configure webview media permissions: {e}",
);
});
}
// Close-to-tray: hide window instead of exiting
@@ -209,12 +212,8 @@ pub fn run() {
app.manage(commands::live::LiveTranscriptionState::default());
app.manage(AppState {
whisper_engine: Arc::new(LocalEngine::new(
EngineName::new("whisper"),
)),
parakeet_engine: Arc::new(LocalEngine::new(
EngineName::new("parakeet"),
)),
whisper_engine: Arc::new(LocalEngine::new(EngineName::new("whisper"))),
parakeet_engine: Arc::new(LocalEngine::new(EngineName::new("parakeet"))),
db,
llm_engine: Arc::new(LlmEngine::new()),
});
@@ -273,6 +272,7 @@ pub fn run() {
commands::profiles::delete_profile_cmd,
commands::profiles::list_profile_terms_cmd,
commands::profiles::add_profile_term_cmd,
commands::profiles::learn_profile_terms_from_edit_cmd,
commands::profiles::delete_profile_term_cmd,
// Transcripts (canonical SQLite-backed history) — Day 4
commands::transcripts::add_transcript,