feat(kon): add first-run hardware probe and model recommendation wizard

- New probe_system command: returns RAM, CPU, OS info
- New rank_models command: scores models against detected hardware
- FirstRunPage.svelte: hardware summary, ranked model list with
  "Recommended" badge on top pick, download progress bar, skip option
- First-run detection in layout: checks list_models + list_parakeet_models,
  shows wizard if both empty
- Sidebar hidden during first-run for clean wizard experience
- clippy clean

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
jake
2026-03-16 22:02:01 +00:00
parent 57eccaf373
commit 904d5fdb95
6 changed files with 266 additions and 4 deletions

View File

@@ -0,0 +1,69 @@
use serde::Serialize;
use kon_core::hardware::{self, Os};
use kon_core::recommendation;
#[derive(Serialize)]
pub struct SystemInfo {
pub ram_mb: u64,
pub cpu_brand: String,
pub cpu_cores: usize,
pub os: String,
pub gpu: Option<String>,
}
#[derive(Serialize)]
pub struct ModelRecommendation {
pub id: String,
pub display_name: &'static str,
pub disk_size_mb: u64,
pub ram_required_mb: u64,
pub description: &'static str,
pub score: f64,
pub reason: String,
pub is_downloaded: bool,
}
/// Probe system hardware and return a summary.
#[tauri::command]
pub fn probe_system() -> Result<SystemInfo, String> {
let profile = hardware::probe_system();
Ok(SystemInfo {
ram_mb: profile.ram.0,
cpu_brand: profile.cpu.brand,
cpu_cores: profile.cpu.core_count,
os: match profile.os {
Os::Windows => "Windows",
Os::Linux => "Linux",
Os::MacOs => "macOS",
Os::Ios => "iOS",
Os::Android => "Android",
}
.to_string(),
gpu: profile.gpu.map(|g| format!("{:?}", g.vendor)),
})
}
/// Rank models for the current system and return recommendations.
#[tauri::command]
pub fn rank_models() -> Result<Vec<ModelRecommendation>, String> {
let profile = hardware::probe_system();
let ranked = recommendation::rank_recommendations(&profile);
Ok(ranked
.into_iter()
.map(|scored| {
let downloaded = kon_transcription::is_downloaded(&scored.entry.id);
ModelRecommendation {
id: scored.entry.id.as_str().to_string(),
display_name: scored.entry.display_name,
disk_size_mb: scored.entry.disk_size.0,
ram_required_mb: scored.entry.ram_required.0,
description: scored.entry.description,
score: scored.score,
reason: scored.reason,
is_downloaded: downloaded,
}
})
.collect())
}

View File

@@ -1,5 +1,6 @@
pub mod audio;
pub mod clipboard;
pub mod hardware;
pub mod llm;
pub mod models;
pub mod transcription;

View File

@@ -70,6 +70,9 @@ pub fn run() {
commands::windows::open_viewer_window,
// Clipboard
commands::clipboard::copy_to_clipboard,
// Hardware
commands::hardware::probe_system,
commands::hardware::rank_models,
// LLM stubs
commands::llm::download_llm_model,
commands::llm::check_llm_model,

View File

@@ -0,0 +1,170 @@
<script>
import { invoke } from "@tauri-apps/api/core";
import { listen } from "@tauri-apps/api/event";
import { page, settings } from "$lib/stores/page.svelte.js";
import UnicodeSpinner from "$lib/components/UnicodeSpinner.svelte";
let systemInfo = $state(null);
let models = $state([]);
let probing = $state(true);
let downloading = $state(false);
let downloadProgress = $state(0);
let downloadingModel = $state("");
let error = $state("");
let ready = $state(false);
async function probe() {
try {
systemInfo = await invoke("probe_system");
models = await invoke("rank_models");
probing = false;
} catch (e) {
error = `Hardware probe failed: ${e}`;
probing = false;
}
}
async function downloadAndGo(modelId) {
downloading = true;
downloadingModel = modelId;
downloadProgress = 0;
const unlisten = await listen("model-download-progress", (event) => {
downloadProgress = event.payload.percent;
});
const unlistenParakeet = await listen("parakeet-download-progress", (event) => {
downloadProgress = event.payload.percent;
});
try {
if (modelId.startsWith("whisper-")) {
const sizeMap = {
"whisper-tiny-en": "tiny",
"whisper-base-en": "base",
"whisper-small-en": "small",
"whisper-medium-en": "medium",
};
await invoke("download_model", { size: sizeMap[modelId] || modelId });
await invoke("load_model", { size: sizeMap[modelId] || modelId });
settings.engine = "whisper";
settings.modelSize = (sizeMap[modelId] || modelId).charAt(0).toUpperCase() + (sizeMap[modelId] || modelId).slice(1);
} else if (modelId.startsWith("parakeet-")) {
await invoke("download_parakeet_model", { name: "ctc-int8" });
await invoke("load_parakeet_model", { name: "ctc-int8" });
settings.engine = "parakeet";
}
ready = true;
setTimeout(() => {
page.current = "dictation";
}, 1500);
} catch (e) {
error = `Download failed: ${e}`;
downloading = false;
} finally {
unlisten();
unlistenParakeet();
}
}
function skipSetup() {
page.current = "dictation";
}
// Start probing on mount
probe();
</script>
<div class="flex flex-col items-center justify-center h-full px-8 py-12 max-w-xl mx-auto">
{#if probing}
<div class="text-center">
<UnicodeSpinner type="dots" speed={80} classes="text-2xl text-accent" />
<h2 class="text-xl font-medium text-text mt-4">Setting up Kon</h2>
<p class="text-sm text-text-secondary mt-2">Detecting your hardware...</p>
</div>
{:else if ready}
<div class="text-center">
<span class="text-4xl">&#3559;</span>
<h2 class="text-xl font-medium text-text mt-4">Ready to go</h2>
<p class="text-sm text-text-secondary mt-2">Starting Kon...</p>
</div>
{:else if downloading}
<div class="text-center w-full">
<h2 class="text-xl font-medium text-text">Downloading model</h2>
<p class="text-sm text-text-secondary mt-2">{downloadingModel}</p>
<div class="w-full bg-bg-input rounded-full h-2 mt-6">
<div
class="bg-accent h-2 rounded-full transition-all duration-300"
style="width: {downloadProgress}%"
></div>
</div>
<p class="text-xs text-text-tertiary mt-2">{downloadProgress}%</p>
</div>
{:else}
<div class="w-full">
<h2 class="text-2xl font-medium text-text text-center">Welcome to Kon</h2>
<p class="text-sm text-text-secondary text-center mt-2">Think out loud</p>
{#if error}
<div class="mt-4 p-3 rounded-lg bg-red-500/10 text-red-400 text-sm">{error}</div>
{/if}
{#if systemInfo}
<div class="mt-8 p-4 rounded-lg bg-bg-input border border-border">
<h3 class="text-xs font-medium text-text-tertiary uppercase tracking-wider mb-3">Your system</h3>
<div class="grid grid-cols-2 gap-2 text-sm">
<span class="text-text-secondary">RAM</span>
<span class="text-text">{Math.round(systemInfo.ram_mb / 1024)} GB</span>
<span class="text-text-secondary">CPU</span>
<span class="text-text truncate" title={systemInfo.cpu_brand}>{systemInfo.cpu_brand}</span>
<span class="text-text-secondary">Cores</span>
<span class="text-text">{systemInfo.cpu_cores}</span>
<span class="text-text-secondary">OS</span>
<span class="text-text">{systemInfo.os}</span>
</div>
</div>
{/if}
{#if models.length > 0}
<div class="mt-6">
<h3 class="text-xs font-medium text-text-tertiary uppercase tracking-wider mb-3">Recommended models</h3>
<div class="space-y-2">
{#each models as model, i}
<button
class="w-full text-left p-3 rounded-lg border transition-colors
{i === 0 ? 'border-accent bg-accent/5 hover:bg-accent/10' : 'border-border bg-bg-input hover:bg-hover'}"
onclick={() => downloadAndGo(model.id)}
disabled={model.is_downloaded}
>
<div class="flex items-center justify-between">
<div>
<span class="text-sm font-medium text-text">{model.display_name}</span>
{#if i === 0}
<span class="ml-2 text-[10px] px-1.5 py-0.5 rounded-full bg-accent/15 text-accent font-medium">Recommended</span>
{/if}
{#if model.is_downloaded}
<span class="ml-2 text-[10px] px-1.5 py-0.5 rounded-full bg-green-500/15 text-green-400 font-medium">Downloaded</span>
{/if}
</div>
<span class="text-xs text-text-tertiary">{model.disk_size_mb} MB</span>
</div>
<p class="text-xs text-text-secondary mt-1">{model.description}</p>
</button>
{/each}
</div>
</div>
{/if}
<button
class="mt-6 text-xs text-text-tertiary hover:text-text-secondary underline"
onclick={skipSetup}
>
Skip setup — I'll configure later
</button>
</div>
{/if}
</div>

View File

@@ -1,6 +1,7 @@
<script>
import "../app.css";
import { onDestroy } from "svelte";
import { onMount, onDestroy } from "svelte";
import { invoke } from "@tauri-apps/api/core";
import Sidebar from "$lib/Sidebar.svelte";
import TaskSidebar from "$lib/components/TaskSidebar.svelte";
import Titlebar from "$lib/components/Titlebar.svelte";
@@ -66,6 +67,19 @@
document.documentElement.style.setProperty("--font-size-transcript", `${settings.fontSize}px`);
});
// First-run detection: check if any models are downloaded
onMount(async () => {
try {
const whisper = await invoke("list_models");
const parakeet = await invoke("list_parakeet_models");
if (whisper.length === 0 && parakeet.length === 0) {
page.current = "first-run";
}
} catch {
// If commands fail, skip first-run check
}
});
onDestroy(() => {
if (registeredHotkey) {
import("@tauri-apps/plugin-global-shortcut")
@@ -87,11 +101,13 @@
<div class="flex flex-col h-screen w-screen overflow-hidden grain">
<Titlebar />
<div class="flex flex-1 min-h-0">
<Sidebar />
{#if page.current !== "first-run"}
<Sidebar />
{/if}
<div class="flex-1 overflow-hidden bg-bg">
{@render children()}
</div>
{#if page.taskSidebarOpen}
{#if page.taskSidebarOpen && page.current !== "first-run"}
<TaskSidebar />
{/if}
</div>

View File

@@ -5,6 +5,7 @@
import TasksPage from "$lib/pages/TasksPage.svelte";
import HistoryPage from "$lib/pages/HistoryPage.svelte";
import SettingsPage from "$lib/pages/SettingsPage.svelte";
import FirstRunPage from "$lib/pages/FirstRunPage.svelte";
// Redirect legacy "profiles" page to settings
$effect(() => {
@@ -13,7 +14,9 @@
</script>
<div class="h-full overflow-hidden">
{#if page.current === "dictation"}
{#if page.current === "first-run"}
<FirstRunPage />
{:else if page.current === "dictation"}
<DictationPage />
{:else if page.current === "files"}
<FilesPage />