mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-28 13:02:21 +01:00
* labs: delete transcript lines from a saved meeting A finished meeting's detail offers Select lines beside Copy when Labs › Delete transcript lines is on. Turns become checkable, Delete lines… asks once, and the confirmed request carries each line's source and span to one path on every OS. The final NDJSON and Markdown are replaced atomically, the rolling draft loses the same lines, and notes, provisional title, and chapters that were written from them are cleared. The user Markdown copy is rewritten only while Hex still wrote it. Refused while recording, transcribing, final-pending, or writing notes; the edit holds the notes claim. Tests cover reopening through the query library, the summary prompt after a fresh read, the hash-guarded export, rolling cleanup, the notes claim, and the pane's two-step request. Labs bookkeeping, translations, site catalog, feature maps, scenes, and goldens updated. * meetings: count selected turns and keep edits off the notes race The edit now takes the notes claim before reading the manifest, writes the cleared manifest before the transcript files, and writes them through the same publish function final publication uses. The selection bar counts turns with singular strings, drops a selection the pane no longer offers, and only warns about notes that exist. The summary regression test reads the transcript through the helper summarize_with uses. * tests: refresh labs and what is new goldens for the two new lab rows
1391 lines
49 KiB
Rust
1391 lines
49 KiB
Rust
//! The Meetings pane (macOS beta): recorded calls by day with their status,
|
||
//! search, a detail with notes, the live or final transcript as turns,
|
||
//! Copy transcript, Rename, an overflow menu (copy summary, reveal,
|
||
//! summarize, delete), and the two-step trash confirmation. Recording is
|
||
//! started and stopped from the header, whose `Recordings | Settings` switch
|
||
//! also shows the feature's settings (Call recording, Calendar, Detected
|
||
//! calls). With Meetings off, the pane is the opt-in card alone.
|
||
//!
|
||
//! The meetings store and controller are macOS-only, so the pane reads
|
||
//! [`Meeting`] values the host loads (formatted with `meeting::day_label`,
|
||
//! `meeting::clock`, and the coalesced transcript) and sends
|
||
//! [`MeetingRequest`]s back. Scenes feed [`MeetingsPane::fixture`].
|
||
|
||
use rune::{El, TextEdit, Tx, col, row, text};
|
||
use rune_kit::{
|
||
IconButton, IconButtonVariant, Loader, Menu as KitMenu, MenuItem, Placement, TextInput,
|
||
};
|
||
|
||
use super::controls::{
|
||
ButtonKind, DESCRIPTION, Paint, button, card, page, pulsing_dot, segmented_tx,
|
||
};
|
||
use super::list_detail::{self as ld, Item};
|
||
use super::lists::{Tone, dismissible_error_panel, error_panel, section_label, tone_tag};
|
||
use super::notes_writer::NotesWriter;
|
||
use super::platform::MeetingRequest;
|
||
use super::{Menu, Ui};
|
||
use crate::desktop::file_dialog::{Dialog, Filter, Pending, Target};
|
||
use crate::desktop::i18n::{tr, tr_fill, tr_named};
|
||
|
||
mod fixture;
|
||
mod selection;
|
||
|
||
pub(super) static MORE_ICON: rune::Icon = rune::Icon {
|
||
name: "hex-more",
|
||
view: 16.0,
|
||
body: r#"<circle cx="3.5" cy="8" r="1.25" fill="currentColor"/><circle cx="8" cy="8" r="1.25" fill="currentColor"/><circle cx="12.5" cy="8" r="1.25" fill="currentColor"/>"#,
|
||
};
|
||
|
||
// Only the macOS host reports the states fixtures do not show.
|
||
#[cfg_attr(not(target_os = "macos"), allow(dead_code))]
|
||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||
pub(super) enum Status {
|
||
Starting,
|
||
Recording,
|
||
Transcribing,
|
||
Complete,
|
||
Interrupted,
|
||
Failed,
|
||
}
|
||
|
||
impl Status {
|
||
pub(super) fn is_active(self) -> bool {
|
||
matches!(self, Self::Starting | Self::Recording | Self::Transcribing)
|
||
}
|
||
}
|
||
|
||
/// One speaker turn. `mine` is the microphone side ("You").
|
||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
pub(super) struct Turn {
|
||
pub(super) mine: bool,
|
||
pub(super) start_ms: u64,
|
||
pub(super) text: String,
|
||
/// A silence of 30 s or more before this turn.
|
||
pub(super) pause_before_ms: Option<u64>,
|
||
/// The published lines this displayed turn covers. Adjacent same-speaker
|
||
/// entries within three seconds coalesce here, so deleting the turn
|
||
/// deletes every line under it.
|
||
pub(super) entries: Vec<crate::meeting::TranscriptEntryKey>,
|
||
}
|
||
|
||
/// One topic of a meeting (Labs), from `start_ms` to
|
||
/// the next chapter's start.
|
||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
pub(super) struct Chapter {
|
||
pub(super) title: String,
|
||
pub(super) summary: String,
|
||
pub(super) start_ms: u64,
|
||
/// What Copy section copies, from the same transcript lines as the menu
|
||
/// bar and `hex meetings show --chapter`.
|
||
pub(super) markdown: String,
|
||
}
|
||
|
||
// Only the macOS host reports the states fixtures do not show.
|
||
#[cfg_attr(not(target_os = "macos"), allow(dead_code))]
|
||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
pub(super) enum Transcript {
|
||
Loaded(Vec<Turn>),
|
||
Unavailable(String),
|
||
}
|
||
|
||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||
pub(super) struct Meeting {
|
||
pub(super) id: String,
|
||
pub(super) title: String,
|
||
pub(super) status: Status,
|
||
/// `Today`, `Yesterday`, or a date, from `meeting::day_label`.
|
||
pub(super) day: String,
|
||
/// The start time, from `meeting::clock`.
|
||
pub(super) clock: String,
|
||
pub(super) duration_ms: u64,
|
||
pub(super) app: Option<String>,
|
||
pub(super) summary: Option<String>,
|
||
pub(super) notes_running: bool,
|
||
/// The exported Markdown while it still exists, which `Reveal Markdown`
|
||
/// selects and Trash takes too; otherwise the recording folder, which
|
||
/// only labels Trash.
|
||
pub(super) reveal: crate::meeting::RevealTarget,
|
||
/// The meeting's recording folder, which `Reveal files` always opens.
|
||
pub(super) folder: std::path::PathBuf,
|
||
pub(super) error: Option<String>,
|
||
pub(super) export_error: Option<String>,
|
||
pub(super) notes_error: Option<String>,
|
||
pub(super) live_error: Option<String>,
|
||
/// The microphone was digitally silent for part of this recording.
|
||
pub(super) microphone_warning: Option<crate::meeting::TrackWarning>,
|
||
pub(super) transcript: Transcript,
|
||
pub(super) chapters: Vec<Chapter>,
|
||
/// Imported from an audio file (Labs › Import audio): its one track is
|
||
/// labelled Speaker.
|
||
pub(super) imported: bool,
|
||
/// How long it is kept once finished, as `MeetingRetention::label`;
|
||
/// `None` when it is kept for good.
|
||
pub(super) kept_for: Option<&'static str>,
|
||
}
|
||
|
||
impl Meeting {
|
||
fn turns(&self) -> &[Turn] {
|
||
match &self.transcript {
|
||
Transcript::Loaded(turns) => turns,
|
||
Transcript::Unavailable(_) => &[],
|
||
}
|
||
}
|
||
|
||
fn searchable(&self) -> String {
|
||
let mut text = format!(
|
||
"{} {} {}",
|
||
self.title,
|
||
self.app.as_deref().unwrap_or_default(),
|
||
self.summary.as_deref().unwrap_or_default()
|
||
);
|
||
for turn in self.turns() {
|
||
text.push(' ');
|
||
text.push_str(&turn.text);
|
||
}
|
||
text.to_lowercase()
|
||
}
|
||
}
|
||
|
||
/// What the pane shows, picked in its header.
|
||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||
pub(super) enum View {
|
||
#[default]
|
||
Recordings,
|
||
Settings,
|
||
}
|
||
|
||
/// Meetings is on, so the pane lists recordings and settings instead of the
|
||
/// opt-in card (`MeetingSettings::available`; scenes leave `developer` off).
|
||
pub(super) fn available(ui: &Ui) -> bool {
|
||
crate::labs::Feature::Meetings.managed().is_none()
|
||
&& (ui.settings.meetings.enabled || ui.platform.developer)
|
||
}
|
||
|
||
/// Whether something can write a meeting's notes when asked: OpenCode once
|
||
/// Summaries chooses it, otherwise Apple Intelligence on a Mac that has it.
|
||
fn notes_available(ui: &Ui) -> bool {
|
||
ui.settings.meetings.summaries == crate::app_settings::MeetingSummaries::OpenCode
|
||
|| apple_intelligence_here(ui)
|
||
}
|
||
|
||
/// Whether this Mac has Apple Intelligence: the other half of the writer
|
||
/// choice, which [`NotesWriter`] makes with the Summaries setting.
|
||
fn apple_intelligence_here(ui: &Ui) -> bool {
|
||
ui.platform.caps.os == super::platform::Os::Macos && ui.platform.notes.is_available()
|
||
}
|
||
|
||
/// What writes the notes now, as the generator picks it.
|
||
fn notes_running_label(ui: &Ui) -> &'static str {
|
||
NotesWriter::for_choice(ui.settings.meetings.summaries, apple_intelligence_here(ui))
|
||
.running_label()
|
||
}
|
||
|
||
#[derive(Default)]
|
||
pub(super) struct MeetingsPane {
|
||
pub(super) view: View,
|
||
/// Newest first, as the store lists them.
|
||
pub(super) meetings: Vec<Meeting>,
|
||
error: Option<String>,
|
||
/// The last recording that could not start or finish.
|
||
pub(super) runtime_error: Option<String>,
|
||
/// The last audio file that could not be imported (Labs › Import audio).
|
||
pub(super) import_error: Option<String>,
|
||
/// The audio file dialog while it is open.
|
||
import_chooser: Option<Pending>,
|
||
pub(super) search: TextEdit,
|
||
pub(super) selected: Option<String>,
|
||
pub(super) renaming: Option<String>,
|
||
pub(super) rename: TextEdit,
|
||
pub(super) delete_armed: Option<String>,
|
||
/// The selected transcript lines (Labs › Delete transcript lines).
|
||
pub(super) selection: selection::Selection,
|
||
action_error: Option<String>,
|
||
/// The last transcript edit that failed.
|
||
pub(super) edit_error: Option<String>,
|
||
/// What was last copied, for the button's "Copied".
|
||
copied: Option<(String, String)>,
|
||
pub(super) start_pending: bool,
|
||
pub(super) stop_pending: bool,
|
||
/// Where Linux and Windows perform meeting requests.
|
||
#[cfg(not(target_os = "macos"))]
|
||
pub(super) local: super::meetings_host::LocalMeetings,
|
||
}
|
||
|
||
/// `42 min`, `1 h 05 min`, or `< 1 min`.
|
||
pub(super) fn length(milliseconds: u64) -> String {
|
||
let minutes = milliseconds / 60_000;
|
||
match minutes {
|
||
0 => tr("< 1 min").into(),
|
||
1..=59 => tr_fill("{} min", &minutes.to_string()),
|
||
_ => tr_named(
|
||
"{hours} h {minutes} min",
|
||
&[
|
||
("hours", &(minutes / 60).to_string()),
|
||
("minutes", &format!("{:02}", minutes % 60)),
|
||
],
|
||
),
|
||
}
|
||
}
|
||
|
||
/// Speaker turns as Markdown, delegating to the canonical meeting renderer.
|
||
fn transcript_markdown(turns: &[Turn], imported: bool) -> String {
|
||
crate::meeting::render_turns_markdown(
|
||
turns.iter().map(|turn| {
|
||
let source = if turn.mine {
|
||
crate::meeting::MeetingSource::Microphone
|
||
} else {
|
||
crate::meeting::MeetingSource::System
|
||
};
|
||
(source, turn.start_ms, turn.text.as_str())
|
||
}),
|
||
imported,
|
||
)
|
||
}
|
||
|
||
impl MeetingsPane {
|
||
fn meeting(&self, id: &str) -> Option<&Meeting> {
|
||
self.meetings.iter().find(|meeting| meeting.id == id)
|
||
}
|
||
|
||
fn active(&self) -> Option<&Meeting> {
|
||
self.meetings
|
||
.iter()
|
||
.find(|meeting| meeting.status.is_active())
|
||
}
|
||
|
||
fn visible(&self) -> Vec<&Meeting> {
|
||
let query = self.search.text.trim().to_lowercase();
|
||
self.meetings
|
||
.iter()
|
||
.filter(|meeting| query.is_empty() || meeting.searchable().contains(&query))
|
||
.collect()
|
||
}
|
||
|
||
/// Adopts a fresh listing: follows a recording that just started,
|
||
/// settles the Start/Stop buttons, and drops a selection that is gone.
|
||
pub(super) fn adopt(&mut self, listed: Result<Vec<Meeting>, String>) {
|
||
let meetings = match listed {
|
||
Ok(meetings) => meetings,
|
||
Err(error) => {
|
||
self.error = Some(error);
|
||
return;
|
||
}
|
||
};
|
||
let active = meetings.iter().find(|meeting| meeting.status.is_active());
|
||
let previous = self.active().map(|meeting| meeting.id.clone());
|
||
if let Some(active) = active {
|
||
self.start_pending = false;
|
||
if previous.as_deref() != Some(active.id.as_str()) {
|
||
self.select(active.id.clone());
|
||
}
|
||
}
|
||
if active.is_none_or(|meeting| meeting.status == Status::Transcribing) {
|
||
self.stop_pending = false;
|
||
}
|
||
if let Some(selected) = &self.selected
|
||
&& !meetings.iter().any(|meeting| &meeting.id == selected)
|
||
{
|
||
self.selected = None;
|
||
self.selection.stop();
|
||
}
|
||
self.meetings = meetings;
|
||
self.error = None;
|
||
}
|
||
|
||
pub(super) fn select(&mut self, id: String) {
|
||
if self.selected.as_deref() != Some(id.as_str()) {
|
||
self.renaming = None;
|
||
self.delete_armed = None;
|
||
self.action_error = None;
|
||
self.selection.stop();
|
||
}
|
||
self.selected = Some(id);
|
||
}
|
||
}
|
||
|
||
/// Sends `request` where it is carried out (on Linux and Windows, the
|
||
/// window's own meetings, not the OS host, which ignores meeting requests).
|
||
pub(super) fn ask(ui: &mut Ui, request: MeetingRequest) -> bool {
|
||
match ui.send_meeting(request) {
|
||
Ok(()) => true,
|
||
Err(error) => {
|
||
ui.meetings.action_error = Some(error);
|
||
false
|
||
}
|
||
}
|
||
}
|
||
|
||
fn start(ui: &mut Ui) {
|
||
ui.meetings.start_pending = ask(ui, MeetingRequest::Start);
|
||
}
|
||
|
||
fn stop(ui: &mut Ui) {
|
||
ui.meetings.stop_pending = ask(ui, MeetingRequest::Stop);
|
||
}
|
||
|
||
fn start_rename(ui: &mut Ui, id: String) {
|
||
let Some(meeting) = ui.meetings.meeting(&id) else {
|
||
return;
|
||
};
|
||
ui.meetings.rename = TextEdit::new(meeting.title.clone());
|
||
ui.meetings.renaming = Some(id);
|
||
ui.open = None;
|
||
}
|
||
|
||
fn finish_rename(ui: &mut Ui) {
|
||
let Some(id) = ui.meetings.renaming.take() else {
|
||
return;
|
||
};
|
||
let title = ui.meetings.rename.text.trim().to_string();
|
||
if title.is_empty() {
|
||
return;
|
||
}
|
||
if ask(
|
||
ui,
|
||
MeetingRequest::Rename {
|
||
id: id.clone(),
|
||
title: title.clone(),
|
||
},
|
||
) && ui.host.is_fixture()
|
||
&& let Some(meeting) = ui.meetings.meetings.iter_mut().find(|m| m.id == id)
|
||
{
|
||
meeting.title = title;
|
||
}
|
||
}
|
||
|
||
/// The first press arms the confirmation; the confirmation trashes.
|
||
fn trash(ui: &mut Ui, id: String) {
|
||
ui.open = None;
|
||
if ui.meetings.delete_armed.as_deref() != Some(id.as_str()) {
|
||
ui.meetings.delete_armed = Some(id);
|
||
return;
|
||
}
|
||
ui.meetings.delete_armed = None;
|
||
if ask(ui, MeetingRequest::Trash(id.clone())) && ui.host.is_fixture() {
|
||
ui.meetings.meetings.retain(|meeting| meeting.id != id);
|
||
ui.meetings.selected = None;
|
||
}
|
||
}
|
||
|
||
fn copy(ui: &mut Ui, tx: &mut Tx, id: String, what: impl Into<String>, text: String) {
|
||
tx.copy(text);
|
||
ui.meetings.copied = Some((id, what.into()));
|
||
}
|
||
|
||
/// The status tag; `Ready` only in the detail header, so the list stays
|
||
/// quiet for finished meetings.
|
||
/// The detail's status, while it is one worth a tag.
|
||
pub(super) fn status_tag(p: Paint, status: Status, stop_pending: bool) -> Option<El> {
|
||
let (label, tone) = match status {
|
||
Status::Recording if stop_pending => (tr("Transcribing"), Tone::Accent),
|
||
Status::Starting | Status::Recording => (tr("Recording"), Tone::Danger),
|
||
Status::Transcribing => (tr("Transcribing"), Tone::Accent),
|
||
Status::Complete => return None,
|
||
Status::Interrupted => (tr("Interrupted"), Tone::Neutral),
|
||
Status::Failed => (tr("Failed"), Tone::Danger),
|
||
};
|
||
Some(tone_tag(p, "status", label, tone))
|
||
}
|
||
|
||
/// Escape in the Meetings pane: the selection's confirmation or selection
|
||
/// itself, a rename, or a meeting delete's confirmation. False when none is
|
||
/// waiting.
|
||
pub(super) fn cancel_edit(ui: &mut Ui) -> bool {
|
||
if ui.meetings.selection.escape() {
|
||
return true;
|
||
}
|
||
let renaming = ui.meetings.renaming.take().is_some();
|
||
let deleting = ui.meetings.delete_armed.take().is_some();
|
||
renaming || deleting
|
||
}
|
||
|
||
/// The opt-in card while Meetings is off; otherwise the header's view
|
||
/// switch and Start/Stop, then the recordings or the settings.
|
||
pub(super) fn pane(ui: &Ui, p: Paint, layer: &mut Vec<El>) -> (Vec<El>, El) {
|
||
if !available(ui) {
|
||
let content = page("content").child(card(
|
||
p,
|
||
"enable",
|
||
vec![super::platform_settings::meetings_toggle(ui, p)],
|
||
));
|
||
return (Vec::new(), super::scroll_body(p.k, "scroll", content));
|
||
}
|
||
let action = recording_action(ui, p);
|
||
if ui.meetings.view == View::Settings {
|
||
let content =
|
||
page("content").children(super::platform_settings::meetings_settings(ui, p, layer));
|
||
return (
|
||
vec![action],
|
||
super::scroll_body(p.k, "settings-scroll", content),
|
||
);
|
||
}
|
||
recordings(ui, p, layer, action)
|
||
}
|
||
|
||
/// The header's `Recordings | Settings` switch, beside the title so it stays
|
||
/// put whichever view shows; none while the opt-in card does.
|
||
pub(super) fn view_switch(ui: &Ui, p: Paint) -> Option<El> {
|
||
if !available(ui) {
|
||
return None;
|
||
}
|
||
let views = [tr("Recordings"), tr("Settings")];
|
||
let selected = match ui.meetings.view {
|
||
View::Recordings => 0,
|
||
View::Settings => 1,
|
||
};
|
||
Some(segmented_tx(
|
||
p,
|
||
"meetings-view",
|
||
&views,
|
||
selected,
|
||
|ui: &mut Ui, index: usize, tx: &mut Tx| {
|
||
let view = if index == 0 {
|
||
View::Recordings
|
||
} else {
|
||
View::Settings
|
||
};
|
||
if ui.meetings.view != view {
|
||
tx.settle();
|
||
ui.flush_drafts();
|
||
ui.open = None;
|
||
ui.meetings.view = view;
|
||
ui.meetings.renaming = None;
|
||
ui.meetings.delete_armed = None;
|
||
}
|
||
},
|
||
))
|
||
}
|
||
|
||
fn search(ui: &Ui, p: Paint) -> El {
|
||
TextInput::new(&ui.meetings.search)
|
||
.placeholder(tr("Search meetings"))
|
||
.width(None)
|
||
.leading_icon(p.k.glyph.search)
|
||
.on_edit(|ui: &mut Ui| &mut ui.meetings.search)
|
||
.build(p.k)
|
||
.key("meetings-search")
|
||
}
|
||
|
||
/// Start recording, or the active recording's elapsed time and Stop.
|
||
fn recording_action(ui: &Ui, p: Paint) -> El {
|
||
let pane = &ui.meetings;
|
||
let busy = |label: &str| {
|
||
text(label)
|
||
.key("meeting-busy")
|
||
.font(DESCRIPTION)
|
||
.color(p.muted())
|
||
};
|
||
let active = pane.active();
|
||
let action = match active.map(|meeting| meeting.status) {
|
||
_ if pane.stop_pending => busy(tr("Finalizing…")),
|
||
Some(Status::Transcribing) => busy(tr("Finalizing…")),
|
||
Some(Status::Starting) => busy(tr("Starting…")),
|
||
// Recording is a state, not the screen's main action.
|
||
Some(Status::Recording) => row()
|
||
.key("stop-meeting-control")
|
||
.gap(12.0)
|
||
.center_y()
|
||
.child(
|
||
row()
|
||
.key("elapsed-group")
|
||
.gap(6.0)
|
||
.center_y()
|
||
.child(pulsing_dot(p.danger()))
|
||
.children(active.map(|meeting| {
|
||
text(crate::meeting::format_duration(meeting.duration_ms))
|
||
.key("elapsed")
|
||
.font(p.k.ty.mono)
|
||
.color(p.muted())
|
||
})),
|
||
)
|
||
.child(button(
|
||
p,
|
||
"stop-meeting",
|
||
tr("Stop & transcribe"),
|
||
ButtonKind::Secondary,
|
||
|ui: &mut Ui, _| stop(ui),
|
||
)),
|
||
_ if pane.start_pending => busy(tr("Starting…")),
|
||
_ => button(
|
||
p,
|
||
"start-meeting",
|
||
tr("Start recording"),
|
||
ButtonKind::Primary,
|
||
|ui: &mut Ui, _| start(ui),
|
||
),
|
||
};
|
||
// Importing is a second way in, never a competing main action.
|
||
if crate::labs::meeting_import() && active.is_none() && !pane.start_pending {
|
||
return row()
|
||
.key("meeting-actions")
|
||
.gap(8.0)
|
||
.center_y()
|
||
.child(button(
|
||
p,
|
||
"import-meeting",
|
||
tr("Import audio…"),
|
||
ButtonKind::Secondary,
|
||
|ui: &mut Ui, _| choose_import(ui),
|
||
))
|
||
.child(action);
|
||
}
|
||
action
|
||
}
|
||
|
||
/// The Labs › Import audio file dialog: one supported audio file.
|
||
fn choose_import(ui: &mut Ui) {
|
||
if ui.meetings.import_chooser.is_some() {
|
||
return;
|
||
}
|
||
ui.meetings.action_error = None;
|
||
let waker = ui.modes.waker.clone();
|
||
let wake = move || {
|
||
if let Some(waker) = &waker {
|
||
waker();
|
||
}
|
||
};
|
||
ui.meetings.import_chooser = Some(crate::desktop::file_dialog::open(
|
||
Dialog {
|
||
title: tr("Import audio").into(),
|
||
target: Target::File(vec![Filter {
|
||
label: tr("Audio files").into(),
|
||
extensions: &["wav", "m4a", "mp3", "aiff", "aif", "caf"],
|
||
}]),
|
||
directory: dirs::audio_dir(),
|
||
},
|
||
wake,
|
||
));
|
||
}
|
||
|
||
/// The audio file dialog's answer: a chosen file is imported where meetings
|
||
/// are carried out. True when the answer changed what the pane shows.
|
||
pub(super) fn poll_import(ui: &mut Ui) -> bool {
|
||
let Some(choice) = ui.meetings.import_chooser.as_ref().and_then(Pending::poll) else {
|
||
return false;
|
||
};
|
||
ui.meetings.import_chooser = None;
|
||
match choice {
|
||
Ok(Some(path)) => {
|
||
ask(ui, MeetingRequest::Import(path));
|
||
}
|
||
Ok(None) => {}
|
||
Err(error) => ui.meetings.action_error = Some(error),
|
||
}
|
||
true
|
||
}
|
||
|
||
/// An audio file could not be imported; the Meetings pane says why.
|
||
pub(crate) fn meeting_import_failed(ui: &mut Ui, error: String) {
|
||
ui.meetings.import_error = Some(error);
|
||
}
|
||
|
||
/// A row's state line: what went wrong or is happening, else the app and
|
||
/// length.
|
||
fn row_meta(pane: &MeetingsPane, meeting: &Meeting, p: Paint) -> (String, Option<rune::Color>) {
|
||
let (state, ink) = match meeting.status {
|
||
Status::Recording if pane.stop_pending => (Some(tr("Transcribing")), None),
|
||
Status::Starting | Status::Recording => (Some(tr("Recording")), Some(p.danger())),
|
||
Status::Transcribing => (Some(tr("Transcribing")), None),
|
||
Status::Failed => (Some(tr("Failed")), Some(p.danger())),
|
||
Status::Interrupted => (Some(tr("Interrupted")), None),
|
||
Status::Complete if meeting.notes_running => (Some(tr("Summarizing…")), None),
|
||
Status::Complete => (None, None),
|
||
};
|
||
let mut parts: Vec<String> = state.map(String::from).into_iter().collect();
|
||
parts.extend(meeting.app.clone());
|
||
if !meeting.status.is_active() {
|
||
parts.push(length(meeting.duration_ms));
|
||
}
|
||
(parts.join(" · "), ink)
|
||
}
|
||
|
||
/// The icon before a row's title: the call service's when its app names
|
||
/// one and a neutral one otherwise (another app, or a meeting started by
|
||
/// hand).
|
||
fn platform_icon(meeting: &Meeting) -> &'static rune::Icon {
|
||
match meeting
|
||
.app
|
||
.as_deref()
|
||
.and_then(crate::calendar::CallProvider::from_meeting_app)
|
||
{
|
||
Some(provider) => super::platform_settings::provider_icon(provider),
|
||
None => &super::icons::CALL,
|
||
}
|
||
}
|
||
|
||
/// Copy transcript as an icon: a completed row's hover action, or the
|
||
/// card's.
|
||
fn copy_action(p: Paint, pane: &MeetingsPane, meeting: &Meeting, what: &'static str) -> El {
|
||
let copied = pane
|
||
.copied
|
||
.as_ref()
|
||
.is_some_and(|(id, copied)| id == &meeting.id && copied == what);
|
||
let glyph = if copied {
|
||
p.k.glyph.check_small
|
||
} else {
|
||
ld::COPY_ICON
|
||
};
|
||
let id = meeting.id.clone();
|
||
let press = move |ui: &mut Ui, tx: &mut Tx| {
|
||
if let Some(meeting) = ui.meetings.meeting(&id) {
|
||
let markdown = transcript_markdown(meeting.turns(), meeting.imported);
|
||
copy(ui, tx, id.clone(), what, markdown);
|
||
}
|
||
};
|
||
if what == "row" {
|
||
ld::row_action(p, "row-copy", glyph, tr("Copy transcript"), press)
|
||
} else {
|
||
ld::ghost_icon(
|
||
p,
|
||
"meeting-copy-transcript",
|
||
glyph,
|
||
tr("Copy transcript"),
|
||
press,
|
||
)
|
||
}
|
||
}
|
||
|
||
/// The day-grouped list and the selected meeting's card.
|
||
fn recordings(ui: &Ui, p: Paint, layer: &mut Vec<El>, action: El) -> (Vec<El>, El) {
|
||
let pane = &ui.meetings;
|
||
let mut notices = Vec::new();
|
||
if let Some(error) = &pane.error {
|
||
notices.push(error_panel(
|
||
p,
|
||
"meetings-error",
|
||
tr("Meetings could not be loaded."),
|
||
error,
|
||
Tone::Danger,
|
||
));
|
||
}
|
||
if let Some(error) = &pane.runtime_error {
|
||
notices.push(dismissible_error_panel(
|
||
p,
|
||
"meeting-runtime-error",
|
||
tr("Meeting could not be recorded."),
|
||
error,
|
||
|ui: &mut Ui| ui.meetings.runtime_error = None,
|
||
));
|
||
}
|
||
if let Some(error) = &pane.import_error {
|
||
notices.push(dismissible_error_panel(
|
||
p,
|
||
"meeting-import-error",
|
||
tr("Audio could not be imported."),
|
||
error,
|
||
|ui: &mut Ui| ui.meetings.import_error = None,
|
||
));
|
||
}
|
||
if let Some(error) = &pane.edit_error {
|
||
notices.push(dismissible_error_panel(
|
||
p,
|
||
"meeting-edit-error",
|
||
tr("Lines could not be deleted."),
|
||
error,
|
||
|ui: &mut Ui| ui.meetings.edit_error = None,
|
||
));
|
||
}
|
||
let body = if pane.meetings.is_empty() {
|
||
ld::empty_state(
|
||
p,
|
||
"meetings-empty",
|
||
ld::HISTORY_ICON,
|
||
tr("No meetings yet."),
|
||
Some(tr("Record a call to see its notes and transcript here.")),
|
||
)
|
||
} else {
|
||
let mut list = col().key("meetings-list").label(tr("Meetings"));
|
||
let mut day: Option<&str> = None;
|
||
let visible = pane.visible();
|
||
let count = visible.len();
|
||
for (index, meeting) in visible.into_iter().enumerate() {
|
||
if day != Some(meeting.day.as_str()) {
|
||
list = list.child(ld::group(
|
||
p,
|
||
&format!("day{index}"),
|
||
day_label(&meeting.day),
|
||
day.is_none(),
|
||
));
|
||
day = Some(&meeting.day);
|
||
}
|
||
let (meta, meta_ink) = row_meta(pane, meeting, p);
|
||
let completed = meeting.status == Status::Complete && !meeting.turns().is_empty();
|
||
let id = meeting.id.clone();
|
||
list = list.child(
|
||
ld::item_with_icon(
|
||
p,
|
||
Item {
|
||
key: format!("meeting-{}", meeting.id),
|
||
title: meeting.title.clone(),
|
||
meta,
|
||
meta_ink,
|
||
time: meeting.clock.clone(),
|
||
hover: completed
|
||
.then(|| copy_action(p, pane, meeting, "row"))
|
||
.into_iter()
|
||
.collect(),
|
||
selected: pane.selected.as_deref() == Some(meeting.id.as_str()),
|
||
},
|
||
Some(platform_icon(meeting)),
|
||
move |ui: &mut Ui| ui.meetings.select(id.clone()),
|
||
)
|
||
.position_in_set(index + 1, count),
|
||
);
|
||
}
|
||
let detail = match pane.selected.as_deref().and_then(|id| pane.meeting(id)) {
|
||
Some(meeting) => detail(ui, p, meeting, layer),
|
||
None if pane.visible().is_empty() => ld::empty_state(
|
||
p,
|
||
"meetings-empty",
|
||
ld::SEARCH_ICON,
|
||
tr("No meetings match."),
|
||
None,
|
||
),
|
||
None => ld::empty_state(
|
||
p,
|
||
"meeting-detail",
|
||
ld::HISTORY_ICON,
|
||
tr("Select a meeting."),
|
||
None,
|
||
),
|
||
};
|
||
let column = ld::list_column(p, search(ui, p), "meetings-scroll", list);
|
||
ld::body(p, "meetings-body", column, detail)
|
||
};
|
||
(
|
||
vec![action],
|
||
col()
|
||
.key("meetings-pane")
|
||
.grow(1.0)
|
||
.shrink()
|
||
.children((!notices.is_empty()).then(|| ld::notices(notices)))
|
||
.child(body),
|
||
)
|
||
}
|
||
|
||
/// Whether the pane offers selection for this meeting: the lab is on, and
|
||
/// the meeting is a finished transcript with turns and no summary running.
|
||
fn selectable(ui: &Ui, meeting: &Meeting) -> bool {
|
||
available(ui)
|
||
&& crate::labs::Feature::TranscriptEdits.on(&ui.settings)
|
||
&& crate::labs::Feature::TranscriptEdits.managed().is_none()
|
||
&& meeting.status == Status::Complete
|
||
&& !meeting.notes_running
|
||
&& !meeting.turns().is_empty()
|
||
}
|
||
|
||
/// Drops a selection the pane no longer offers, before it is drawn: the lab
|
||
/// went off, the selected meeting left Complete, or its notes started
|
||
/// running. Returns whether anything was dropped.
|
||
pub(super) fn settle_selection(ui: &mut Ui) -> bool {
|
||
if !ui.meetings.selection.active() {
|
||
return false;
|
||
}
|
||
let offered = ui
|
||
.meetings
|
||
.selected
|
||
.as_deref()
|
||
.and_then(|id| ui.meetings.meeting(id))
|
||
.is_some_and(|meeting| selectable(ui, meeting));
|
||
if offered {
|
||
return false;
|
||
}
|
||
ui.meetings.selection.stop();
|
||
true
|
||
}
|
||
|
||
fn day_label(day: &str) -> &str {
|
||
match day {
|
||
"Today" => tr("Today"),
|
||
"Yesterday" => tr("Yesterday"),
|
||
other => other,
|
||
}
|
||
}
|
||
|
||
fn detail(ui: &Ui, p: Paint, meeting: &Meeting, layer: &mut Vec<El>) -> El {
|
||
let pane = &ui.meetings;
|
||
let active = meeting.status.is_active();
|
||
let copied = |what: &str| {
|
||
pane.copied
|
||
.as_ref()
|
||
.is_some_and(|(id, copied)| id == &meeting.id && copied == what)
|
||
};
|
||
let armed = pane.delete_armed.as_deref() == Some(meeting.id.as_str());
|
||
let renaming = pane.renaming.as_deref() == Some(meeting.id.as_str());
|
||
let can_select = selectable(ui, meeting);
|
||
let selecting = can_select && pane.selection.active();
|
||
let mut actions = Vec::new();
|
||
let mut confirm = None;
|
||
if armed && !active && !meeting.notes_running {
|
||
// The confirmation sits under the title until it is answered.
|
||
let id = meeting.id.clone();
|
||
confirm = Some(
|
||
row()
|
||
.key("delete-confirm")
|
||
.gap(8.0)
|
||
.pt(14.0)
|
||
.child(
|
||
button(
|
||
p,
|
||
"meeting-confirm-delete",
|
||
if meeting.reveal.is_markdown() {
|
||
tr("Trash recording & Markdown")
|
||
} else {
|
||
tr("Trash recording")
|
||
},
|
||
ButtonKind::Danger,
|
||
move |ui: &mut Ui, _| trash(ui, id.clone()),
|
||
)
|
||
.default_button(),
|
||
)
|
||
.child(button(
|
||
p,
|
||
"meeting-cancel-delete",
|
||
tr("Cancel"),
|
||
ButtonKind::Secondary,
|
||
|ui: &mut Ui, _| ui.meetings.delete_armed = None,
|
||
)),
|
||
);
|
||
} else if !renaming && !selecting {
|
||
// The title field brings its own Save and Cancel.
|
||
if can_select {
|
||
actions.push(selection::action(p));
|
||
}
|
||
if !meeting.turns().is_empty() {
|
||
actions.push(copy_action(p, pane, meeting, "transcript"));
|
||
}
|
||
if !active {
|
||
let id = meeting.id.clone();
|
||
actions.push(ld::ghost_icon(
|
||
p,
|
||
"meeting-rename",
|
||
ld::EDIT_ICON,
|
||
tr("Rename"),
|
||
move |ui: &mut Ui, _| start_rename(ui, id.clone()),
|
||
));
|
||
}
|
||
actions.extend(overflow(ui, p, meeting, layer));
|
||
}
|
||
|
||
let title = if renaming {
|
||
row()
|
||
.key("rename")
|
||
.w_full()
|
||
.gap(8.0)
|
||
.center_y()
|
||
.child(
|
||
TextInput::new(&pane.rename)
|
||
.label(tr("Name"))
|
||
.width(Some(220.0))
|
||
.on_edit(|ui: &mut Ui| &mut ui.meetings.rename)
|
||
.on_submit(|ui: &mut Ui, _| finish_rename(ui))
|
||
.build(p.k)
|
||
.key("rename-field"),
|
||
)
|
||
.child(button(
|
||
p,
|
||
"meeting-save-title",
|
||
tr("Save"),
|
||
ButtonKind::Secondary,
|
||
|ui: &mut Ui, _| finish_rename(ui),
|
||
))
|
||
.child(button(
|
||
p,
|
||
"meeting-cancel-title",
|
||
tr("Cancel"),
|
||
ButtonKind::Secondary,
|
||
|ui: &mut Ui, _| ui.meetings.renaming = None,
|
||
))
|
||
} else {
|
||
ld::card_title(p, &meeting.title)
|
||
};
|
||
let mut meta_line = vec![
|
||
day_label(&meeting.day).to_string(),
|
||
meeting.clock.clone(),
|
||
crate::meeting::format_duration(meeting.duration_ms),
|
||
];
|
||
meta_line.extend(meeting.app.clone());
|
||
let retention = meeting
|
||
.kept_for
|
||
.filter(|_| !meeting.status.is_active())
|
||
.map(|kept_for| ld::meta_note(p, "retention", &tr_fill("Deleted after {}", tr(kept_for))));
|
||
let mut meta: Vec<El> = status_tag(p, meeting.status, pane.stop_pending)
|
||
.into_iter()
|
||
.collect();
|
||
meta.push(ld::meta_text(p, &meta_line.join(" · ")));
|
||
|
||
let errors = [
|
||
pane.action_error
|
||
.as_deref()
|
||
.map(|error| ("action-error", tr("Meeting could not be updated."), error)),
|
||
meeting
|
||
.error
|
||
.as_deref()
|
||
.map(|error| ("recording-error", tr("Recording failed."), error)),
|
||
meeting
|
||
.export_error
|
||
.as_deref()
|
||
.map(|error| ("export-error", tr("Markdown not saved."), error)),
|
||
meeting
|
||
.notes_error
|
||
.as_deref()
|
||
.filter(|_| !meeting.notes_running)
|
||
.map(|error| ("notes-error", tr("Notes could not be written."), error)),
|
||
meeting
|
||
.live_error
|
||
.as_deref()
|
||
.filter(|_| active)
|
||
.map(|error| ("live-error", tr("Live transcript unavailable."), error)),
|
||
];
|
||
let mut body = col().key("detail-body").gap(24.0).pb(8.0);
|
||
for (key, title, error) in errors.into_iter().flatten() {
|
||
body = body.child(error_panel(p, key, title, error, Tone::Danger));
|
||
}
|
||
if !active && meeting.microphone_warning == Some(crate::meeting::TrackWarning::DigitalSilence) {
|
||
body = body.child(error_panel(
|
||
p,
|
||
"microphone-silence",
|
||
tr("Microphone is silent"),
|
||
tr("Your microphone was silent for part of this call. Another app may have been using it with voice processing, so your side may be missing."),
|
||
Tone::Warning,
|
||
));
|
||
}
|
||
if meeting.notes_running || meeting.summary.is_some() {
|
||
let mut notes =
|
||
col()
|
||
.key("notes")
|
||
.gap(6.0)
|
||
.child(section_label(p, "summary-label", tr("Summary")));
|
||
if meeting.notes_running {
|
||
// Writing or regenerating: the spinner and the writer's line
|
||
// above whatever summary is already shown (#2556).
|
||
notes = notes.child(
|
||
row()
|
||
.key("notes-running")
|
||
.gap(8.0)
|
||
.center_y()
|
||
.child(Loader::new().build(p.k))
|
||
.child(
|
||
text(notes_running_label(ui))
|
||
.font(DESCRIPTION)
|
||
.color(p.faint()),
|
||
),
|
||
);
|
||
}
|
||
if let Some(summary) = &meeting.summary {
|
||
let summary = summary.trim();
|
||
notes = notes.child(
|
||
text(if summary.is_empty() {
|
||
tr("Nothing to summarize.")
|
||
} else {
|
||
summary
|
||
})
|
||
.key("summary")
|
||
.font(p.k.ty.body)
|
||
.color(if summary.is_empty() {
|
||
p.faint()
|
||
} else {
|
||
p.text()
|
||
})
|
||
.wrap(),
|
||
);
|
||
}
|
||
body = body.child(notes);
|
||
}
|
||
if !meeting.chapters.is_empty() {
|
||
body = body.child(chapters(p, meeting, &copied));
|
||
}
|
||
let transcript_label = match meeting.status {
|
||
Status::Starting | Status::Recording if !pane.stop_pending => tr("Live transcript"),
|
||
Status::Starting | Status::Recording | Status::Transcribing => tr("Draft transcript"),
|
||
Status::Complete => tr("Transcript"),
|
||
Status::Interrupted | Status::Failed => tr("Recovered draft"),
|
||
};
|
||
body = body.child(
|
||
col()
|
||
.key("transcript-block")
|
||
.gap(10.0)
|
||
.child(section_label(p, "transcript-label", transcript_label))
|
||
.children(selecting.then(|| selection::bar(ui, p, meeting)))
|
||
.child(transcript(ui, p, meeting, pane.stop_pending, selecting)),
|
||
);
|
||
col()
|
||
.key("meeting-detail")
|
||
.grow(1.0)
|
||
.shrink()
|
||
.child(ld::card_header(title, meta, actions))
|
||
.children(retention)
|
||
.children(confirm)
|
||
.child(ld::card_scroll_sticky(
|
||
p,
|
||
"meeting-transcript",
|
||
body,
|
||
follows_live_transcript(ui, meeting),
|
||
))
|
||
}
|
||
|
||
/// A recording meeting's transcript keeps its newest line in view while
|
||
/// scrolled to the bottom. Any meeting not recording scrolls only by hand.
|
||
fn follows_live_transcript(ui: &Ui, meeting: &Meeting) -> bool {
|
||
matches!(meeting.status, Status::Starting | Status::Recording) && !ui.meetings.stop_pending
|
||
}
|
||
|
||
/// The meeting's chapters, each with its start, name, line, and Copy
|
||
/// section.
|
||
fn chapters(p: Paint, meeting: &Meeting, copied: &dyn Fn(&str) -> bool) -> El {
|
||
let mut list = col()
|
||
.key("chapters")
|
||
.gap(10.0)
|
||
.pb(16.0)
|
||
.child(section_label(p, "chapters-label", tr("Chapters")));
|
||
for (index, chapter) in meeting.chapters.iter().enumerate() {
|
||
let what = format!("chapter{index}");
|
||
let id = meeting.id.clone();
|
||
let mut words = col().key("words").gap(2.0).grow(1.0).shrink().child(
|
||
text(chapter.title.clone())
|
||
.key("title")
|
||
.font(p.k.ty.body_medium)
|
||
.color(p.text())
|
||
.wrap(),
|
||
);
|
||
if !chapter.summary.trim().is_empty() {
|
||
words = words.child(
|
||
text(chapter.summary.trim())
|
||
.key("summary")
|
||
.font(DESCRIPTION)
|
||
.color(p.muted())
|
||
.wrap(),
|
||
);
|
||
}
|
||
list = list.child(
|
||
row()
|
||
.key(format!("chapter{index}"))
|
||
.gap(12.0)
|
||
.child(
|
||
text(crate::meeting::format_duration(chapter.start_ms))
|
||
.key("clock")
|
||
.font(p.k.ty.mono)
|
||
.color(p.faint())
|
||
.pt(1.0),
|
||
)
|
||
.child(words)
|
||
.child(
|
||
ld::ghost_icon(
|
||
p,
|
||
"copy-section",
|
||
if copied(&what) {
|
||
p.k.glyph.check_small
|
||
} else {
|
||
ld::COPY_ICON
|
||
},
|
||
tr("Copy section"),
|
||
move |ui: &mut Ui, tx: &mut Tx| {
|
||
if let Some(markdown) = ui
|
||
.meetings
|
||
.meeting(&id)
|
||
.and_then(|meeting| meeting.chapters.get(index))
|
||
.map(|chapter| chapter.markdown.clone())
|
||
{
|
||
copy(ui, tx, id.clone(), what.clone(), markdown);
|
||
}
|
||
},
|
||
)
|
||
.mt(-4.0),
|
||
),
|
||
);
|
||
}
|
||
list
|
||
}
|
||
|
||
/// Less common actions behind the ellipsis, Delete last.
|
||
fn overflow(ui: &Ui, p: Paint, meeting: &Meeting, layer: &mut Vec<El>) -> Option<El> {
|
||
let active = meeting.status.is_active();
|
||
let mut menu = KitMenu::new("meeting-actions")
|
||
.placement(Placement::BottomEnd)
|
||
.gutter(4.0)
|
||
.min_width(200.0)
|
||
.open(ui.open == Some(Menu::MeetingActions))
|
||
.on_close(|ui: &mut Ui| ui.open = None);
|
||
let mut items = 0;
|
||
if let Some(summary) = meeting.summary.clone() {
|
||
let id = meeting.id.clone();
|
||
let copied = ui
|
||
.meetings
|
||
.copied
|
||
.as_ref()
|
||
.is_some_and(|(copied, what)| copied == &meeting.id && what == "notes");
|
||
// Stays open so "Copied" confirms the copy.
|
||
menu = menu.item(
|
||
MenuItem::new(if copied {
|
||
tr("Copied")
|
||
} else {
|
||
tr("Copy summary")
|
||
})
|
||
.on_select_tx(move |ui: &mut Ui, tx: &mut Tx| {
|
||
copy(ui, tx, id.clone(), "notes", summary.trim().to_string());
|
||
ui.open = Some(Menu::MeetingActions);
|
||
}),
|
||
);
|
||
items += 1;
|
||
}
|
||
if !active {
|
||
// Reveal Markdown appears only while the export exists; the
|
||
// recording folder stays one item away either way.
|
||
if meeting.reveal.is_markdown() {
|
||
let reveal = meeting.reveal.clone();
|
||
menu = menu.item(
|
||
MenuItem::new(tr("Reveal Markdown")).on_select(move |ui: &mut Ui| {
|
||
ui.open = None;
|
||
ask(ui, MeetingRequest::Reveal(reveal.clone()));
|
||
}),
|
||
);
|
||
items += 1;
|
||
}
|
||
let folder = meeting.folder.clone();
|
||
menu = menu.item(
|
||
MenuItem::new(tr("Reveal files")).on_select(move |ui: &mut Ui| {
|
||
ui.open = None;
|
||
ask(
|
||
ui,
|
||
MeetingRequest::Reveal(crate::meeting::RevealTarget::Folder(folder.clone())),
|
||
);
|
||
}),
|
||
);
|
||
items += 1;
|
||
}
|
||
if meeting.status == Status::Complete && notes_available(ui) {
|
||
if meeting.notes_running {
|
||
menu = menu.item(MenuItem::new(tr("Summarizing…")).disabled(true));
|
||
} else {
|
||
let id = meeting.id.clone();
|
||
menu = menu.item(
|
||
MenuItem::new(if meeting.summary.is_some() {
|
||
tr("Regenerate summary")
|
||
} else {
|
||
tr("Summarize")
|
||
})
|
||
.on_select(move |ui: &mut Ui| {
|
||
ui.open = None;
|
||
ask(ui, MeetingRequest::Summarize(id.clone()));
|
||
}),
|
||
);
|
||
}
|
||
items += 1;
|
||
}
|
||
if !active && !meeting.notes_running {
|
||
if items > 0 {
|
||
menu = menu.separator();
|
||
}
|
||
let id = meeting.id.clone();
|
||
menu = menu
|
||
.item(MenuItem::new(tr("Delete…")).on_select(move |ui: &mut Ui| trash(ui, id.clone())));
|
||
items += 1;
|
||
}
|
||
if items == 0 {
|
||
return None;
|
||
}
|
||
let trigger = IconButton::new(&MORE_ICON)
|
||
.variant(IconButtonVariant::Ghost)
|
||
.control_size(rune_kit::ControlSize::Small)
|
||
.label(tr("More"))
|
||
.on_press(|ui: &mut Ui| {
|
||
ui.open = (ui.open != Some(Menu::MeetingActions)).then_some(Menu::MeetingActions);
|
||
})
|
||
.build(p.k)
|
||
.key("meeting-more");
|
||
Some(menu.trigger(trigger).build(p.k, layer))
|
||
}
|
||
|
||
fn transcript(ui: &Ui, p: Paint, meeting: &Meeting, stop_pending: bool, selecting: bool) -> El {
|
||
let empty = |copy: &str| {
|
||
text(copy)
|
||
.key("transcript-empty")
|
||
.font(DESCRIPTION)
|
||
.color(p.faint())
|
||
.wrap()
|
||
};
|
||
let turns = match &meeting.transcript {
|
||
Transcript::Unavailable(error) => {
|
||
return error_panel(
|
||
p,
|
||
"transcript-error",
|
||
tr("Transcript unavailable."),
|
||
error,
|
||
Tone::Danger,
|
||
);
|
||
}
|
||
Transcript::Loaded(turns) => turns,
|
||
};
|
||
if turns.is_empty() {
|
||
return empty(match meeting.status {
|
||
Status::Starting => tr("Preparing local audio capture…"),
|
||
Status::Recording if meeting.live_error.is_some() => {
|
||
tr("Live transcription is unavailable. Audio is still recording safely.")
|
||
}
|
||
Status::Recording if stop_pending => tr("Building the final transcript…"),
|
||
Status::Recording => tr("Listening for speech…"),
|
||
Status::Transcribing => tr("Building the final transcript…"),
|
||
Status::Complete => tr("No speech was transcribed."),
|
||
Status::Interrupted | Status::Failed => tr("No recoverable transcript is available."),
|
||
});
|
||
}
|
||
let mut lines = col().key("turns").gap(14.0);
|
||
for (index, turn) in turns.iter().enumerate() {
|
||
if selecting {
|
||
lines = lines.child(selection::turn_row(
|
||
p,
|
||
index,
|
||
turn,
|
||
meeting.imported,
|
||
ui.meetings.selection.contains(turn),
|
||
));
|
||
} else {
|
||
lines = lines.children(turn_line(p, index, turn, meeting.imported));
|
||
}
|
||
}
|
||
if meeting.status == Status::Recording && !stop_pending {
|
||
lines = lines.child(
|
||
text(tr("Listening…"))
|
||
.key("listening")
|
||
.font(p.k.ty.small)
|
||
.color(p.faint()),
|
||
);
|
||
}
|
||
lines
|
||
}
|
||
|
||
/// One turn of a transcript: the pause before it, if any, then the speaker,
|
||
/// the time, and the words. An imported meeting has one track: Speaker.
|
||
pub(super) fn turn_line(p: Paint, index: usize, turn: &Turn, imported: bool) -> Vec<El> {
|
||
let mut els = Vec::new();
|
||
if let Some(pause) = turn.pause_before_ms {
|
||
els.push(
|
||
text(tr_fill("{} pause", &length(pause)))
|
||
.key(format!("pause{index}"))
|
||
.font(p.k.ty.small)
|
||
.color(p.faint()),
|
||
);
|
||
}
|
||
els.push(
|
||
col()
|
||
.key(format!("turn{index}"))
|
||
.gap(2.0)
|
||
.child(
|
||
row()
|
||
.key("speaker")
|
||
.gap(8.0)
|
||
.child(
|
||
text(if imported {
|
||
tr("Speaker")
|
||
} else if turn.mine {
|
||
tr("You")
|
||
} else {
|
||
tr("Them")
|
||
})
|
||
.key("name")
|
||
.font(p.k.ty.small_medium)
|
||
.color(if turn.mine && !imported {
|
||
p.text()
|
||
} else {
|
||
p.faint()
|
||
}),
|
||
)
|
||
.child(
|
||
text(crate::meeting::format_duration(turn.start_ms))
|
||
.key("clock")
|
||
.font(p.k.ty.small)
|
||
.color(p.faint()),
|
||
),
|
||
)
|
||
.child(
|
||
text(turn.text.clone())
|
||
.key("text")
|
||
.font(p.k.ty.body)
|
||
.color(p.text())
|
||
.wrap(),
|
||
),
|
||
);
|
||
els
|
||
}
|
||
|
||
#[cfg(all(test, not(target_os = "macos")))]
|
||
mod tests {
|
||
use super::*;
|
||
use crate::rune_ui::Service;
|
||
use crate::rune_ui::platform::PlatformHost;
|
||
|
||
/// An imported meeting has one track: every turn is Speaker, not Them.
|
||
#[test]
|
||
fn an_imported_meeting_labels_its_one_track_speaker() {
|
||
let turn = |mine| Turn {
|
||
mine,
|
||
start_ms: 1_000,
|
||
text: "Hi.".into(),
|
||
pause_before_ms: None,
|
||
entries: Vec::new(),
|
||
};
|
||
assert!(transcript_markdown(&[turn(false)], true).contains("**Speaker** · 00:01"));
|
||
assert!(transcript_markdown(&[turn(true)], true).contains("**Speaker**"));
|
||
assert!(transcript_markdown(&[turn(true)], false).contains("**You**"));
|
||
assert!(transcript_markdown(&[turn(false)], false).contains("**Them**"));
|
||
}
|
||
|
||
/// Linux and Windows carry meeting requests out in the window's own
|
||
/// process; the OS host ignored them, so Stop, Rename, and Trash from
|
||
/// the pane did nothing and reported nothing (#566).
|
||
#[test]
|
||
fn pane_requests_reach_the_window_s_own_meetings() {
|
||
let mut ui = Ui::with(
|
||
crate::app_settings::AppSettings::default(),
|
||
Service::Fixture(Vec::new()),
|
||
);
|
||
assert!(matches!(ui.host, PlatformHost::Local(_)));
|
||
ui.meetings = MeetingsPane::fixture();
|
||
// No meeting controller runs in tests, so the request is refused
|
||
// rather than silently accepted.
|
||
stop(&mut ui);
|
||
assert!(!ui.meetings.stop_pending);
|
||
assert!(ui.meetings.action_error.is_some());
|
||
}
|
||
|
||
/// A known call service's icon, and the neutral one for any other or
|
||
/// no app (#1290).
|
||
#[test]
|
||
fn platform_icons_fall_back_to_a_neutral_one() {
|
||
let pane = MeetingsPane::platforms_fixture();
|
||
let name = |id: &str| platform_icon(pane.meeting(id).unwrap()).name;
|
||
assert_eq!(name("preview-live"), "hex-provider-zoom");
|
||
assert_eq!(name("preview-meet"), "hex-provider-meet");
|
||
assert_eq!(name("preview-teams"), "hex-provider-teams");
|
||
assert_eq!(name("preview-huddle"), "hex-provider-slack");
|
||
assert_eq!(name("preview-design"), "hex-row-call");
|
||
assert_eq!(name("preview-failed"), "hex-row-call");
|
||
}
|
||
|
||
/// Only a recording meeting's transcript follows its newest line (#1332).
|
||
#[test]
|
||
fn only_a_recording_transcript_follows() {
|
||
let settings = crate::app_settings::AppSettings::default();
|
||
let pane = MeetingsPane::fixture();
|
||
let live = pane.meeting("preview-live").unwrap();
|
||
let finished = pane.meeting("preview-notes").unwrap();
|
||
let mut ui = Ui::with(settings, Service::Fixture(Vec::new()));
|
||
assert!(follows_live_transcript(&ui, live));
|
||
assert!(!follows_live_transcript(&ui, finished));
|
||
ui.meetings.stop_pending = true;
|
||
assert!(!follows_live_transcript(&ui, live));
|
||
}
|
||
|
||
/// Off a Mac the notes are written by OpenCode, so the progress line
|
||
/// names it, never Apple Intelligence (#1151).
|
||
#[test]
|
||
fn notes_progress_names_opencode_off_a_mac() {
|
||
let ui = Ui::with(
|
||
crate::app_settings::AppSettings::default(),
|
||
Service::Fixture(Vec::new()),
|
||
);
|
||
let label = notes_running_label(&ui);
|
||
assert!(label.contains("OpenCode"), "{label}");
|
||
assert!(!label.contains("Apple Intelligence"), "{label}");
|
||
}
|
||
}
|