From 6c7382be0580be7b13baa4e17381e0a1a6f0a635 Mon Sep 17 00:00:00 2001 From: agata Date: Wed, 15 Oct 2025 23:08:33 +0900 Subject: [PATCH] Remove diff logging dependency --- Cargo.lock | 7 ------- Cargo.toml | 1 - src/core/postprocess.rs | 39 ++++----------------------------------- 3 files changed, 4 insertions(+), 43 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3254efb..b901bb1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2073,7 +2073,6 @@ dependencies = [ "serde_json", "serde_yaml", "signal-hook", - "similar", "sys-locale", "toml", "tracing", @@ -4083,12 +4082,6 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" -[[package]] -name = "similar" -version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" - [[package]] name = "slab" version = "0.4.11" diff --git a/Cargo.toml b/Cargo.toml index c8d4853..f23f928 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,6 @@ serde_json = "1.0" toml = "0.8" serde_yaml = "0.9" image = { version = "0.24", default-features = false, features = ["png", "jpeg"] } -similar = "2.6" # GUI egui = "0.32" diff --git a/src/core/postprocess.rs b/src/core/postprocess.rs index a3d862f..5686142 100644 --- a/src/core/postprocess.rs +++ b/src/core/postprocess.rs @@ -3,7 +3,6 @@ use crate::llm::{ history_file_path, record_history, LlmPostProcessSettings, LlmPostProcessor, MAX_HISTORY_ENTRIES, }; -use similar::{ChangeTag, TextDiff}; use std::sync::{Arc, Mutex}; pub struct PostProcessResult { @@ -66,7 +65,7 @@ impl PostProcessEngine { let mut final_text = base_text.to_string(); let mut llm_latency_secs = 0.0f32; - let mut llm_output_for_diff: Option = None; + let mut llm_output_for_log: Option = None; let mut history_payload: Option<(String, bool, u128)> = None; match self @@ -93,7 +92,7 @@ impl PostProcessEngine { &format!("[llm] Completed in {:.2}s.", llm_latency_secs), ); log_message(log, &format!("[llm][output] {}", content)); - llm_output_for_diff = Some(content.clone()); + llm_output_for_log = Some(content.clone()); if snapshot.apply_to_autopaste { final_text = content.clone(); } else { @@ -144,41 +143,11 @@ impl PostProcessEngine { } } - if let Some(output_text) = llm_output_for_diff.as_ref() { + if let Some(output_text) = llm_output_for_log.as_ref() { if output_text == base_text { log_message(log, "[llm] Output identical to Whisper text."); } else { - let diff = TextDiff::from_lines(base_text, output_text); - let mut diff_lines = Vec::new(); - let mut truncated = false; - for change in diff.iter_all_changes() { - let prefix = match change.tag() { - ChangeTag::Delete => "-", - ChangeTag::Insert => "+", - ChangeTag::Equal => continue, - }; - if diff_lines.len() >= 120 { - truncated = true; - break; - } - let mut line = change.value().trim_end_matches('\n').to_string(); - if line.chars().count() > 200 { - let mut truncated = String::with_capacity(201); - truncated.extend(line.chars().take(200)); - truncated.push_str("…"); - line = truncated; - } - diff_lines.push(format!("{}{}", prefix, line)); - } - - if diff_lines.is_empty() { - log_message(log, "[llm] Output identical to Whisper text."); - } else { - if truncated { - diff_lines.push("... (diff truncated)".to_string()); - } - log_message(log, &format!("[llm][diff]\n{}", diff_lines.join("\n"))); - } + log_message(log, "[llm] Output differs from Whisper text."); } }