Skip to content

Commit c4d5318

Browse files
committed
fix(history): preserve actual model timing attribution
1 parent 0fcb8fc commit c4d5318

3 files changed

Lines changed: 171 additions & 45 deletions

File tree

‎openless-all/app/src-tauri/src/coordinator.rs‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,6 +1763,7 @@ impl Coordinator {
17631763
&[],
17641764
// repolish 不回写历史的模型/耗时字段,调用快照就地丢弃。
17651765
&mut None,
1766+
&mut None,
17661767
)
17671768
.await
17681769
.map_err(|e| e.to_string())
@@ -1774,25 +1775,36 @@ impl Coordinator {
17741775
&self,
17751776
pcm: Vec<u8>,
17761777
) -> Result<(String, AsrCallLabel), String> {
1777-
self.retranscribe_pcm_inner(pcm, false).await
1778+
self.retranscribe_pcm_inner(pcm, false, None).await
17781779
}
17791780

17801781
pub(super) async fn retranscribe_pcm_until_cancelled(
17811782
&self,
17821783
pcm: Vec<u8>,
1783-
) -> Result<String, String> {
1784-
// 自动静默重试沿用 begin_session 已存的会话快照,这里的构建标签不再需要。
1785-
self.retranscribe_pcm_inner(pcm, true).await.map(|(text, _)| text)
1784+
) -> (Result<String, String>, Option<AsrCallLabel>) {
1785+
// 自动静默重试会重新读取当前设置并构建一条全新的 ASR 会话,因此必须把这次
1786+
// 实际构建的标签交还给调用方。即使请求最终失败,也保留“本次尝试了谁”,让
1787+
// 彻底失败的历史不会退回首次会话的旧归因。
1788+
let mut attempted_label = None;
1789+
let result = self
1790+
.retranscribe_pcm_inner(pcm, true, Some(&mut attempted_label))
1791+
.await
1792+
.map(|(text, _)| text);
1793+
(result, attempted_label)
17861794
}
17871795

17881796
async fn retranscribe_pcm_inner(
17891797
&self,
17901798
pcm: Vec<u8>,
17911799
cancel_on_drop: bool,
1800+
attempted_label: Option<&mut Option<AsrCallLabel>>,
17921801
) -> Result<(String, AsrCallLabel), String> {
17931802
let inner = &self.inner;
17941803
let active_asr = CredentialsVault::get_active_asr();
17951804
let (start, asr_call_label) = build_qa_asr_start(inner, &active_asr).await?;
1805+
if let Some(label_slot) = attempted_label {
1806+
*label_slot = Some(asr_call_label.clone());
1807+
}
17961808
let retry_guard = if cancel_on_drop {
17971809
Some(CancellableRetranscribeGuard::new(
17981810
Arc::clone(inner),

0 commit comments

Comments
 (0)