Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ jobs:
run: |
node --check apps/desktop/ui/app.js
node --check apps/desktop/ui/overlay.js
node --check apps/desktop/ui/lexicon.js
- name: Validate Tauri configuration JSON
run: |
python3 -m json.tool apps/desktop/src-tauri/tauri.conf.json > /dev/null
Expand Down
5 changes: 3 additions & 2 deletions apps/desktop/src-tauri/src/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use serde_json::Value;
use tauri::{AppHandle, Manager, Runtime, State};

use crate::ipc::{CommandErrorDto, DesktopState, DictationReportDto};
use crate::text_rules::apply_text_rules;

const DEFAULT_HISTORY_LIMIT: u32 = 100;

Expand Down Expand Up @@ -62,7 +63,7 @@ impl HistoryService {
let result = report_history_metadata(report).and_then(|metadata| {
self.append(NewHistoryEntry {
created_at_unix_ms: unix_time_ms(),
transcript: report.text().to_owned(),
transcript: apply_text_rules(report.text()),
invocation_source: origin.into(),
engine_id: metadata.engine_id,
model_id: metadata.model_id,
Expand Down Expand Up @@ -90,7 +91,7 @@ impl HistoryService {
// Preserve it without inventing recognizer provenance.
let result = self.append(NewHistoryEntry {
created_at_unix_ms: unix_time_ms(),
transcript: text.to_owned(),
transcript: apply_text_rules(text),
invocation_source: origin.into(),
engine_id: "unknown".to_owned(),
model_id: "unknown".to_owned(),
Expand Down
5 changes: 4 additions & 1 deletion apps/desktop/src-tauri/src/insertion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use blcvoice_insertion_native::{NativeInserter, NativeInsertionOptions};
use blcvoice_insertion_x11::{X11Inserter, X11Options};
use blcvoice_platform::{DesktopEnvironment, current_desktop_environment};

use crate::text_rules::apply_text_rules;

struct InsertionState {
inserter: Option<Box<dyn TextInserter>>,
wayland_restore_token: Option<String>,
Expand Down Expand Up @@ -72,6 +74,7 @@ impl DesktopInsertionService {
}

pub fn insert_text(&self, text: &str) -> Result<InsertionReceipt, InsertionError> {
let processed_text = apply_text_rules(text);
let capability = self.capability()?;
let mut state = self.lock_state();
if state.inserter.is_none() {
Expand All @@ -82,7 +85,7 @@ impl DesktopInsertionService {
.inserter
.as_mut()
.expect("inserter must exist after connection")
.insert_text(text);
.insert_text(&processed_text);

if result.as_ref().is_err_and(|error| {
matches!(
Expand Down
11 changes: 11 additions & 0 deletions apps/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mod ipc;
mod models;
mod settings;
mod shortcut;
mod text_rules;

use coordinator::ShortcutDictationCoordinator;
use history::{
Expand All @@ -24,6 +25,9 @@ use shortcut::{ShortcutService, install_shortcut_backend, shortcut_capability};
use tauri::menu::{Menu, MenuItem};
use tauri::tray::TrayIconBuilder;
use tauri::{App, AppHandle, Manager, Runtime, WindowEvent};
use text_rules::{
dictionary_delete, dictionary_save, replacement_delete, replacement_save, text_rules_snapshot,
};

#[tauri::command]
fn core_status() -> String {
Expand Down Expand Up @@ -69,6 +73,8 @@ pub fn run() {
.setup(|app| {
let config_dir = app.path().app_config_dir()?;
let data_dir = app.path().app_data_dir()?;
text_rules::initialize(config_dir.clone())
.map_err(|error| std::io::Error::other(error.message().to_owned()))?;
let desktop = DesktopState::production(config_dir, data_dir.clone())
.map_err(std::io::Error::other)?;
app.manage(HistoryService::production(data_dir));
Expand Down Expand Up @@ -108,6 +114,11 @@ pub fn run() {
history_list,
history_delete,
shortcut_capability,
text_rules_snapshot,
dictionary_save,
dictionary_delete,
replacement_save,
replacement_delete,
])
.run(tauri::generate_context!())
.expect("failed to run BLCVoice desktop shell");
Expand Down
8 changes: 7 additions & 1 deletion apps/desktop/src-tauri/src/shortcut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub const SHORTCUT_DECISION_EVENT: &str = "blcvoice://shortcut-decision";
enum ShortcutRegistrationState {
Pending,
Registering,
#[cfg(any(target_os = "linux", test))]
ConfigurationRequired,
Registered,
Failed,
Expand All @@ -39,6 +40,7 @@ impl ShortcutRegistrationState {
match self {
Self::Pending => "pending",
Self::Registering => "registering",
#[cfg(any(target_os = "linux", test))]
Self::ConfigurationRequired => "configuration required",
Self::Registered => "registered",
Self::Failed => "failed",
Expand Down Expand Up @@ -102,6 +104,7 @@ impl ShortcutService {
}
}

#[cfg(any(target_os = "linux", test))]
fn mark_configuration_required(&self) {
let mut state = self.lock_state();
if state.backend.is_some() {
Expand Down Expand Up @@ -258,7 +261,9 @@ enum PortalShortcutEvent {
}

#[cfg(target_os = "linux")]
fn trigger_for_shortcut(shortcuts: &[ashpd::desktop::global_shortcuts::Shortcut]) -> Option<String> {
fn trigger_for_shortcut(
shortcuts: &[ashpd::desktop::global_shortcuts::Shortcut],
) -> Option<String> {
shortcuts
.iter()
.find(|shortcut| shortcut.id() == DICTATION_SHORTCUT_ID)
Expand Down Expand Up @@ -378,6 +383,7 @@ fn shortcut_capability_for(state: &ShortcutServiceState) -> ShortcutCapabilityDt
DesktopPlatform::Windows | DesktopPlatform::MacOs | DesktopPlatform::Other => None,
};
let registration_state = match state.registration_state {
#[cfg(any(target_os = "linux", test))]
ShortcutRegistrationState::ConfigurationRequired => {
"configuration required · KDE shortcut settings opened".to_owned()
}
Expand Down
Loading
Loading