agent: dogfood polish 2026/04/19 — Linux native chrome + History redesign + mic picker cleanup
Second dogfood sprint. Headline fix: Linux now uses native KWin/Mutter decorations instead of fragile frameless `startResizeDragging`, which collapsed diagonal corner resize to a single axis and made drag feel laggy. macOS / Windows keep custom chrome via `useCustomChrome` gate. Other changes: - Cross-window preferences sync via `kon:preferences-changed` Tauri event — theme and font changes propagate live to float/viewer. - Hotkey recorder rewritten to use capture-phase document listener gated by $effect; button focus was unreliable in webkit2gtk. - History page redesigned for cognitive-load hygiene: title-first compact row, inline title input, Edit popout opening /viewer in edit mode, clipboard export as .md with YAML frontmatter, manual tag chips + + Add tag input, header tag filter (cap 7), global Starred filter, `tag:xyz` search syntax. - `deriveAutoTags` kept as empty hook for post-Task-7 LLM topic tags; research found all previous auto-tag chips redundant with row UI. - Viewer window adds edit mode with debounced-save textarea; native title renamed to "Kon - Transcription Editor". - Window minimums updated per GNOME HIG + WCAG reflow research: main 960x600, float 360x480, editor 560x520. - Microphone picker filters raw ALSA strings (hw:, plughw:, front:, sysdefault:, null) and dedupes by CARD=X. New `description` field on DeviceInfo reads /proc/asound/cards so Blue Yeti shows as "Blue Microphones" instead of the short "Microphones" card name. - GPU reporting fixed: get_runtime_capabilities now returns accelerators=[cpu,vulkan] and whisper.supports_gpu=true, matching the transcribe-rs whisper-vulkan feature linked unconditionally. - ResizeHandles kept for macOS/Windows frameless: 12px edges, 20px corners via CSS vars, pointerdown + setPointerCapture, corners above edges in z-order, rendered as sibling (not child) of the animated layout root so `position: fixed` is viewport-relative. - Dueling drag-region handlers removed — `data-tauri-drag-region` and manual `startDragging()` were stacked on the same elements; kept the manual handler which has the button/input early-return logic. See HANDOVER.md for the full session log and deferred items. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -42,6 +42,11 @@ pub struct DeviceInfo {
|
||||
pub is_likely_monitor: bool,
|
||||
/// True if cpal reports this as the host's default input device.
|
||||
pub is_default: bool,
|
||||
/// Human-readable product description, if known (Linux: from
|
||||
/// `/proc/asound/cards`). Empty string when unavailable or on
|
||||
/// platforms that don't expose one.
|
||||
#[serde(default)]
|
||||
pub description: String,
|
||||
}
|
||||
|
||||
/// A non-fatal capture-time error emitted by the cpal stream callback after
|
||||
@@ -97,6 +102,12 @@ impl MicrophoneCapture {
|
||||
.input_devices()
|
||||
.map_err(|e| KonError::AudioCaptureFailed(format!("input_devices: {e}")))?;
|
||||
|
||||
// Load ALSA card descriptions once per enumeration. These are the
|
||||
// "real" product names (e.g. "Blue Microphones") that cpal's
|
||||
// short card name (e.g. "Microphones") alone can't convey. Empty
|
||||
// map on non-Linux or if the file is missing.
|
||||
let card_descriptions = load_alsa_card_descriptions();
|
||||
|
||||
let mut out = Vec::new();
|
||||
for device in devices {
|
||||
let name = device.name().unwrap_or_else(|_| "<unnamed>".to_string());
|
||||
@@ -106,12 +117,16 @@ impl MicrophoneCapture {
|
||||
};
|
||||
let is_likely_monitor = is_monitor_name(&name);
|
||||
let is_default = !default_name.is_empty() && name == default_name;
|
||||
let description = extract_card_id(&name)
|
||||
.and_then(|card| card_descriptions.get(card).cloned())
|
||||
.unwrap_or_default();
|
||||
out.push(DeviceInfo {
|
||||
name,
|
||||
sample_rate,
|
||||
channels,
|
||||
is_likely_monitor,
|
||||
is_default,
|
||||
description,
|
||||
});
|
||||
}
|
||||
Ok(out)
|
||||
@@ -252,6 +267,71 @@ fn is_monitor_name(name: &str) -> bool {
|
||||
|| lower.contains("loopback")
|
||||
}
|
||||
|
||||
/// Pull the CARD= value from an ALSA device string.
|
||||
///
|
||||
/// `sysdefault:CARD=Microphones` → `Some("Microphones")`
|
||||
/// `hw:CARD=C920,DEV=0` → `Some("C920")`
|
||||
/// `pipewire` / `default` → `None`
|
||||
fn extract_card_id(name: &str) -> Option<&str> {
|
||||
let rest = name.split("CARD=").nth(1)?;
|
||||
Some(rest.split(|c: char| c == ',' || c == ';').next().unwrap_or(rest))
|
||||
}
|
||||
|
||||
/// Read `/proc/asound/cards` and return a map from ALSA card short name
|
||||
/// (e.g. "Microphones") to the richer product string (e.g. "Blue
|
||||
/// Microphones"). Empty map on non-Linux or if the file is missing.
|
||||
///
|
||||
/// Format of `/proc/asound/cards`:
|
||||
/// ```text
|
||||
/// 2 [Microphones ]: USB-Audio - Blue Microphones
|
||||
/// Blue Microphones at usb-...
|
||||
/// 3 [C920 ]: USB-Audio - HD Pro Webcam C920
|
||||
/// HD Pro Webcam C920 at usb-...
|
||||
/// ```
|
||||
/// The bracket contains the short name that cpal reports; the text
|
||||
/// after the colon on that same line is the description we want. The
|
||||
/// next indented line is a longer location string we ignore.
|
||||
fn load_alsa_card_descriptions() -> std::collections::HashMap<String, String> {
|
||||
use std::collections::HashMap;
|
||||
let mut map = HashMap::new();
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
let Ok(contents) = std::fs::read_to_string("/proc/asound/cards") else {
|
||||
return map;
|
||||
};
|
||||
for line in contents.lines() {
|
||||
// Header lines start with an optional leading space plus a
|
||||
// digit (the card ID, right-aligned to 2 chars for readable
|
||||
// formatting). Continuation lines are indented beyond that.
|
||||
let trimmed = line.trim_start();
|
||||
if !trimmed.chars().next().map(|c| c.is_ascii_digit()).unwrap_or(false) {
|
||||
continue;
|
||||
}
|
||||
let Some(open) = trimmed.find('[') else { continue };
|
||||
let Some(close) = trimmed[open..].find(']') else { continue };
|
||||
let short_name = trimmed[open + 1..open + close].trim().to_string();
|
||||
if short_name.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let after_bracket = &trimmed[open + close + 1..];
|
||||
let Some(colon) = after_bracket.find(':') else { continue };
|
||||
// Format: "USB-Audio - Blue Microphones"
|
||||
// We keep everything after the " - " if present, otherwise
|
||||
// the whole post-colon fragment.
|
||||
let raw = after_bracket[colon + 1..].trim();
|
||||
let description = raw
|
||||
.split(" - ")
|
||||
.nth(1)
|
||||
.map(|s| s.trim().to_string())
|
||||
.unwrap_or_else(|| raw.to_string());
|
||||
if !description.is_empty() {
|
||||
map.insert(short_name, description);
|
||||
}
|
||||
}
|
||||
}
|
||||
map
|
||||
}
|
||||
|
||||
/// Open the given device and validate it produces non-silent audio.
|
||||
/// If `require_audio` is false, accept any data (used for monitor fallback).
|
||||
fn open_and_validate(
|
||||
|
||||
Reference in New Issue
Block a user