feat #14740: done only once uploaded

A done call only shows "fertig" once its transcript reached this
build's backend (uploaded_here); otherwise it's "bereit zum
Hochladen". The list row gets a blue dot for anything needing action
(ready to upload or not transcribed yet), and the sidebar header shows
"Gespräche · N offen".

Adds ListState/needs_action to CallListItem, computed in
recorder-core so the UI doesn't re-implement the rule.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
hauke
2026-11-10 12:09:08 +01:00
co-authored by Claude Opus 5.5
parent 183c135b1d
commit 0ae6ed304f
5 changed files with 176 additions and 9 deletions
+113
View File
@@ -18,6 +18,15 @@ pub struct CallListItem {
/// Whole seconds from start to end; 0 while recording. /// Whole seconds from start to end; 0 while recording.
pub duration_secs: i64, pub duration_secs: i64,
pub status: CallStatus, pub status: CallStatus,
/// What the status pill shows and whether the row needs the user's
/// attention — see [`ListState`]. Computed from `status` and
/// [`uploaded_here`] so the UI does not re-implement the rule.
pub list_state: ListState,
/// Whether this row needs the user to act on it (the dot in
/// `CallList.svelte` and the sidebar header's "N offen" count). Equal
/// to `list_state.needs_action()`, kept as its own field so the UI
/// does not need to know `ListState`'s variants to filter by it.
pub needs_action: bool,
pub interrupted: bool, pub interrupted: bool,
/// The name the user gave the call, if any. /// The name the user gave the call, if any.
pub title: Option<String>, pub title: Option<String>,
@@ -35,12 +44,15 @@ impl CallListItem {
/// row. Nothing is deleted; the fields are just not shown as set. /// row. Nothing is deleted; the fields are just not shown as set.
pub fn of(call: &Call, backend_url: &str) -> Self { pub fn of(call: &Call, backend_url: &str) -> Self {
let uploaded = uploaded_here(call, backend_url); let uploaded = uploaded_here(call, backend_url);
let list_state = ListState::of(call.status, uploaded);
Self { Self {
id: call.id, id: call.id,
app: call.app.clone(), app: call.app.clone(),
started_at: call.started_at, started_at: call.started_at,
duration_secs: duration_secs(call), duration_secs: duration_secs(call),
status: call.status, status: call.status,
list_state,
needs_action: list_state.needs_action(),
interrupted: call.interrupted, interrupted: call.interrupted,
title: call.title.clone(), title: call.title.clone(),
crm_transcript_id: if uploaded { crm_transcript_id: if uploaded {
@@ -53,6 +65,45 @@ impl CallListItem {
} }
} }
/// What the call list row (and the detail header's pill) shows about a
/// call's status. Mirrors [`CallStatus`] one-to-one, except that `Done`
/// splits in two: a call is only ever shown as done ("fertig") once its
/// transcript has actually reached *this build's* backend ([`uploaded_here`]);
/// otherwise — never uploaded, or uploaded to a different backend — it is
/// `ReadyToUpload` ("bereit zum Hochladen"), because from this build's
/// point of view the CRM has not seen it yet.
#[derive(Serialize, Clone, Copy, Debug, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum ListState {
Recording,
AwaitingDecision,
Processing,
Failed,
Done,
ReadyToUpload,
}
impl ListState {
fn of(status: CallStatus, uploaded_here: bool) -> Self {
match status {
CallStatus::Recording => ListState::Recording,
CallStatus::AwaitingDecision => ListState::AwaitingDecision,
CallStatus::Processing => ListState::Processing,
CallStatus::Failed => ListState::Failed,
CallStatus::Done if uploaded_here => ListState::Done,
CallStatus::Done => ListState::ReadyToUpload,
}
}
/// Whether a row in this state needs the user to act on it: not yet
/// transcribed, or transcribed but not uploaded here. Excludes
/// `Failed` (already shown in red) and the transient
/// `Recording`/`Processing` states.
pub fn needs_action(self) -> bool {
matches!(self, ListState::AwaitingDecision | ListState::ReadyToUpload)
}
}
/// Whole seconds from `started_at` to `ended_at`; 0 while the call has not /// Whole seconds from `started_at` to `ended_at`; 0 while the call has not
/// ended (and never negative). /// ended (and never negative).
pub fn duration_secs(call: &Call) -> i64 { pub fn duration_secs(call: &Call) -> i64 {
@@ -318,6 +369,8 @@ mod tests {
started_at: at(10, 14, 0), started_at: at(10, 14, 0),
duration_secs: 60, duration_secs: 60,
status: CallStatus::AwaitingDecision, status: CallStatus::AwaitingDecision,
list_state: ListState::AwaitingDecision,
needs_action: true,
interrupted: true, interrupted: true,
title: None, title: None,
crm_transcript_id: None, crm_transcript_id: None,
@@ -351,6 +404,64 @@ mod tests {
assert!(uploaded_here(&c, BACKEND)); assert!(uploaded_here(&c, BACKEND));
} }
#[test]
fn done_is_fertig_only_once_uploaded_to_this_backend() {
let mut c = call(Some(at(10, 15, 0)));
c.status = CallStatus::Done;
// Never uploaded.
assert_eq!(
CallListItem::of(&c, BACKEND).list_state,
ListState::ReadyToUpload
);
// Uploaded, but to a different backend.
c.crm_transcript_id = Some("4711".into());
c.crm_base_url = Some(OTHER_BACKEND.into());
assert_eq!(
CallListItem::of(&c, BACKEND).list_state,
ListState::ReadyToUpload
);
// Uploaded to this build's backend.
c.crm_base_url = Some(BACKEND.into());
assert_eq!(CallListItem::of(&c, BACKEND).list_state, ListState::Done);
}
#[test]
fn needs_action_marks_awaiting_and_ready_to_upload_only() {
let mut c = call(Some(at(10, 15, 0)));
c.status = CallStatus::AwaitingDecision;
assert!(CallListItem::of(&c, BACKEND).needs_action, "awaiting");
c.status = CallStatus::Done;
assert!(
CallListItem::of(&c, BACKEND).needs_action,
"done, never uploaded"
);
for status in [
CallStatus::Processing,
CallStatus::Failed,
CallStatus::Recording,
] {
c.status = status;
assert!(
!CallListItem::of(&c, BACKEND).needs_action,
"{status:?} must not show the dot"
);
}
c.status = CallStatus::Done;
c.crm_transcript_id = Some("4711".into());
c.crm_base_url = Some(BACKEND.into());
assert!(
!CallListItem::of(&c, BACKEND).needs_action,
"done and uploaded here"
);
}
#[test] #[test]
fn an_upload_to_another_backend_is_hidden_from_the_list_item() { fn an_upload_to_another_backend_is_hidden_from_the_list_item() {
// Uploaded to OTHER_BACKEND; this build's backend is BACKEND: the // Uploaded to OTHER_BACKEND; this build's backend is BACKEND: the
@@ -503,6 +614,8 @@ mod tests {
"started_at": serde_json::to_value(at(10, 14, 0)).unwrap(), "started_at": serde_json::to_value(at(10, 14, 0)).unwrap(),
"duration_secs": 60, "duration_secs": 60,
"status": "failed", "status": "failed",
"list_state": "failed",
"needs_action": false,
"interrupted": false, "interrupted": false,
"title": "Reklamation", "title": "Reklamation",
"crm_transcript_id": null, "crm_transcript_id": null,
+17 -2
View File
@@ -28,12 +28,15 @@
aria-current={call.id === selectedId} aria-current={call.id === selectedId}
onclick={() => onselect(call.id)} onclick={() => onselect(call.id)}
> >
{#if call.needs_action}
<span class="dot" title="Offen" aria-label="Offen"></span>
{/if}
<span class="title">{call.title ?? appLine(call)}</span> <span class="title">{call.title ?? appLine(call)}</span>
<span class="meta"> <span class="meta">
<span class="muted"> <span class="muted">
{call.title ? `${appLine(call)} · ` : ''}{formatListTime(call.started_at)} {call.title ? `${appLine(call)} · ` : ''}{formatListTime(call.started_at)}
</span> </span>
<StatusPill status={call.status} interrupted={call.interrupted} /> <StatusPill state={call.list_state} interrupted={call.interrupted} />
</span> </span>
</button> </button>
</li> </li>
@@ -53,11 +56,12 @@
} }
.row { .row {
position: relative;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 3px; gap: 3px;
width: 100%; width: 100%;
padding: 9px 10px; padding: 9px 10px 9px 18px;
border: none; border: none;
border-radius: 8px; border-radius: 8px;
background: none; background: none;
@@ -67,6 +71,17 @@
cursor: pointer; cursor: pointer;
} }
.dot {
position: absolute;
left: 7px;
top: 50%;
transform: translateY(-50%);
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--primary);
}
.row:hover { .row:hover {
background: var(--bg); background: var(--bg);
} }
+11 -5
View File
@@ -1,21 +1,22 @@
<script lang="ts"> <script lang="ts">
import type { CallStatus } from './api' import type { ListState } from './api'
let { status, interrupted = false }: { status: CallStatus; interrupted?: boolean } = $props() let { state, interrupted = false }: { state: ListState; interrupted?: boolean } = $props()
const pills: Record<CallStatus, { text: string; kind: string }> = { const pills: Record<ListState, { text: string; kind: string }> = {
done: { text: 'fertig', kind: 'done' }, done: { text: 'fertig', kind: 'done' },
ready_to_upload: { text: 'bereit zum Hochladen', kind: 'ready' },
processing: { text: 'wird verarbeitet…', kind: 'processing' }, processing: { text: 'wird verarbeitet…', kind: 'processing' },
awaiting_decision: { text: 'nicht transkribiert', kind: 'awaiting' }, awaiting_decision: { text: 'nicht transkribiert', kind: 'awaiting' },
failed: { text: 'fehlgeschlagen', kind: 'failed' }, failed: { text: 'fehlgeschlagen', kind: 'failed' },
recording: { text: 'Aufnahme läuft', kind: 'recording' }, recording: { text: 'Aufnahme läuft', kind: 'recording' },
} }
let pill = $derived(pills[status]) let pill = $derived(pills[state])
</script> </script>
<span class="pill status {pill.kind}"> <span class="pill status {pill.kind}">
{pill.text}{#if interrupted && status === 'awaiting_decision'}, unterbrochen{/if} {pill.text}{#if interrupted && state === 'awaiting_decision'}, unterbrochen{/if}
</span> </span>
<style> <style>
@@ -28,6 +29,11 @@
color: var(--ok); color: var(--ok);
} }
.ready {
background: var(--primary-soft);
color: var(--primary);
}
.processing { .processing {
background: #fff4d6; background: #fff4d6;
color: #8a6100; color: #8a6100;
+16
View File
@@ -79,6 +79,18 @@ export interface PendingPrompt extends CallBrief {
export type CallStatus = 'recording' | 'awaiting_decision' | 'processing' | 'done' | 'failed' export type CallStatus = 'recording' | 'awaiting_decision' | 'processing' | 'done' | 'failed'
/** What the status pill shows and whether the row needs the user's
* attention. Mirrors `CallStatus`, except `done` splits into `done`
* (uploaded to this build's backend — "fertig") and `ready_to_upload`
* (not uploaded here yet — "bereit zum Hochladen"). */
export type ListState =
| 'recording'
| 'awaiting_decision'
| 'processing'
| 'failed'
| 'done'
| 'ready_to_upload'
/** A row of the main window's call list. Times are RFC 3339. */ /** A row of the main window's call list. Times are RFC 3339. */
export interface CallListItem { export interface CallListItem {
id: CallId id: CallId
@@ -87,6 +99,10 @@ export interface CallListItem {
/** 0 while recording. */ /** 0 while recording. */
duration_secs: number duration_secs: number
status: CallStatus status: CallStatus
list_state: ListState
/** Whether this row needs the user to act on it (the dot in the list,
* counted in the sidebar header's "N offen"). */
needs_action: boolean
interrupted: boolean interrupted: boolean
/** The name the user gave the call, if any. */ /** The name the user gave the call, if any. */
title: string | null title: string | null
+19 -2
View File
@@ -326,13 +326,17 @@
// A failed start (e.g. missing key) also marks the call failed; its // A failed start (e.g. missing key) also marks the call failed; its
// error is then shown once, in the failure box. // error is then shown once, in the failure box.
let shownActionError = $derived(actionError !== detail?.call.error ? actionError : '') let shownActionError = $derived(actionError !== detail?.call.error ? actionError : '')
// Calls that still need the user's attention (not transcribed, or
// transcribed but not uploaded here) — shown as "Gespräche · N offen".
let openCount = $derived(calls.filter((c) => c.needs_action).length)
</script> </script>
<main class="main"> <main class="main">
<UpdateBanner /> <UpdateBanner />
<aside class="sidebar"> <aside class="sidebar">
<header class="sidebar-header"> <header class="sidebar-header">
<h1>Gespräche</h1> <h1>Gespräche{#if openCount > 0} <span class="open-count">· {openCount} offen</span>{/if}</h1>
<div class="header-actions"> <div class="header-actions">
<button <button
class="btn small record-btn" class="btn small record-btn"
@@ -381,7 +385,7 @@
<button class="edit-title" title="Titel ändern" onclick={startTitleEdit}>✎</button> <button class="edit-title" title="Titel ändern" onclick={startTitleEdit}>✎</button>
</h1> </h1>
{/if} {/if}
<StatusPill status={call.status} interrupted={call.interrupted} /> <StatusPill state={call.list_state} interrupted={call.interrupted} />
</div> </div>
{#if editingTitle} {#if editingTitle}
<p class="muted subline">Enter speichert, Esc bricht ab. Leer = Standardtitel.</p> <p class="muted subline">Enter speichert, Esc bricht ab. Leer = Standardtitel.</p>
@@ -525,18 +529,31 @@
.sidebar-header { .sidebar-header {
display: flex; display: flex;
flex-wrap: wrap;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
gap: 4px 8px;
padding: 14px 12px 10px 16px; padding: 14px 12px 10px 16px;
border-bottom: 1px solid var(--border); border-bottom: 1px solid var(--border);
} }
.sidebar-header h1 { .sidebar-header h1 {
flex: 1 1 auto;
min-width: 0;
font-size: 16px; font-size: 16px;
overflow-wrap: break-word;
}
.open-count {
font-size: 13px;
font-weight: 600;
color: var(--primary);
white-space: nowrap;
} }
.header-actions { .header-actions {
display: flex; display: flex;
flex-shrink: 0;
align-items: center; align-items: center;
gap: 6px; gap: 6px;
} }