feat #14740: delete transcribed calls

Transcribed (Done) calls get a "Löschen" button next to the upload
control, with a confirmation dialog in the app's style instead of
window.confirm. Deleting reuses discard_call (not a parallel path),
which now also refuses while the call's transcript is being uploaded,
consistent with the existing refusals for recording/processing/
CleanupPending.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
hauke
2026-11-09 14:45:17 +01:00
co-authored by Claude Opus 5.5
parent 697f13e13a
commit 36cefaab5f
2 changed files with 211 additions and 16 deletions
+75 -8
View File
@@ -37,6 +37,7 @@ const MANUAL_APP: &str = "Manuell";
const TEST_DURATION: Duration = Duration::from_secs(5);
const TEST_POLL: Duration = Duration::from_millis(50);
const ALREADY_PROCESSING: &str = "Wird bereits verarbeitet";
const ALREADY_UPLOADING: &str = "Wird bereits hochgeladen";
/// Why [`AppState::discard_call`] refused.
#[derive(Debug, Clone, PartialEq)]
@@ -362,7 +363,7 @@ impl AppState {
pub fn claim_upload(&self, id: CallId) -> Result<UploadClaim<'_>, String> {
let mut uploading = lock(&self.uploading);
if uploading.contains(&id) {
return Err("Wird bereits hochgeladen".to_string());
return Err(ALREADY_UPLOADING.to_string());
}
if lock(&self.upload_confirmed_unsaved).contains(&id) {
return Err("Bereits hochgeladen".to_string());
@@ -712,11 +713,15 @@ impl AppState {
.ok_or_else(|| "Gespräch nicht gefunden".to_string())
}
/// Deletes a finished call: both audio files and the row, and takes it
/// out of the prompt queue. Returns how many calls still wait for the
/// prompt. A call that is being processed, or whose DeepScript jobs
/// are still on record ([`DiscardError::CleanupPending`]), is not
/// deleted.
/// Deletes a finished (or still undecided/failed) call: both audio files
/// and the row, cascading to its segments, speaker names, merges and
/// recorded remote jobs — this is also how a transcribed (`Done`) call's
/// "Löschen" removes it. Takes it out of the prompt queue and returns how
/// many calls still wait for it. Refused while the call is being
/// recorded, processed ([`AppState::claim_processing`]/
/// [`AppState::reserve_processing`] or status `Processing`), uploaded
/// ([`AppState::claim_upload`]), or while its DeepScript jobs are still
/// on record ([`DiscardError::CleanupPending`]).
pub fn discard_call(&self, id: CallId) -> Result<usize, DiscardError> {
if lock(&self.current)
.as_ref()
@@ -724,11 +729,17 @@ impl AppState {
{
return Err("Das Gespräch wird gerade aufgenommen".to_string().into());
}
// Held until the call is gone, so no run can claim it meanwhile.
// Both held until the call is gone, so neither a pipeline run nor an
// upload can claim it meanwhile (same uploading -> store lock order
// as `claim_upload`, so this can never deadlock against it).
let processing = lock(&self.processing);
if processing.contains(&id) {
return Err(ALREADY_PROCESSING.to_string().into());
}
let uploading = lock(&self.uploading);
if uploading.contains(&id) {
return Err(ALREADY_UPLOADING.to_string().into());
}
let call = self
.store
.get_call(id)
@@ -742,7 +753,8 @@ impl AppState {
return Err(DiscardError::CleanupPending);
}
// Files first: if one cannot be deleted, the row stays so the user
// can try again instead of leaving orphaned audio behind.
// can try again instead of leaving orphaned audio behind. Already
// gone (e.g. removed by retention) is not an error.
for path in [&call.mic_path, &call.out_path] {
if path.as_os_str().is_empty() {
continue;
@@ -768,6 +780,7 @@ impl AppState {
}
return Err(format!("Gespräch konnte nicht gelöscht werden: {e}").into());
}
drop(uploading);
drop(processing);
Ok(self.prompts_waiting())
}
@@ -1147,6 +1160,60 @@ mod tests {
assert!(f.state.reserve_processing(id));
}
#[test]
fn a_transcribed_call_is_deleted_like_any_other() {
let f = fixture();
let (id, mic, out) = finished_call(&f, "a");
f.state
.store
.set_status(id, CallStatus::Done, None)
.unwrap();
assert_eq!(f.state.discard_call(id), Ok(0));
assert!(!mic.exists());
assert!(!out.exists());
assert_eq!(f.state.store.get_call(id).unwrap(), None);
}
#[test]
fn a_call_being_uploaded_is_not_discarded() {
let f = fixture();
let (id, mic, out) = finished_call(&f, "a");
f.state
.store
.set_status(id, CallStatus::Done, None)
.unwrap();
let claim = f.state.claim_upload(id).unwrap();
assert_eq!(
f.state.discard_call(id),
Err(DiscardError::Other("Wird bereits hochgeladen".to_string()))
);
assert!(mic.exists());
assert!(out.exists());
assert!(f.state.store.get_call(id).unwrap().is_some());
// Once the upload is done, the delete goes through.
drop(claim);
assert_eq!(f.state.discard_call(id), Ok(0));
}
#[test]
fn a_call_already_uploaded_here_is_deleted_without_touching_the_crm() {
let f = fixture();
let (id, mic, out) = finished_call(&f, "a");
f.state
.store
.set_status(id, CallStatus::Done, None)
.unwrap();
f.state.mark_uploaded(id, "4711").unwrap();
assert_eq!(f.state.discard_call(id), Ok(0));
assert!(!mic.exists());
assert!(!out.exists());
assert_eq!(f.state.store.get_call(id).unwrap(), None);
}
#[test]
fn a_cleanup_reserves_a_call_of_any_status() {
let f = fixture();