mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-27 07:58:01 +01:00
The ready panel always said Apple Intelligence while notes were being written, even where OpenCode writes them. Share the pane's writer rule through rune_ui::notes_writer so the pane and capsule use one label.
66 lines
2.4 KiB
Rust
66 lines
2.4 KiB
Rust
//! What writes a meeting's notes now, and the progress line that names it:
|
||
//! one rule for the Meetings pane and the finished-meeting capsule, which
|
||
//! both say notes are being written (#2062, #1151).
|
||
|
||
use crate::app_settings::MeetingSummaries;
|
||
use crate::desktop::i18n::tr;
|
||
|
||
/// The notes writer, as `meeting::generator` picks it: Apple Intelligence
|
||
/// where it can write, otherwise OpenCode.
|
||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||
pub(super) enum NotesWriter {
|
||
AppleIntelligence,
|
||
OpenCode,
|
||
}
|
||
|
||
impl NotesWriter {
|
||
/// The writer for a Summaries choice on a computer with (or without)
|
||
/// Apple Intelligence. Summaries › OpenCode always uses OpenCode.
|
||
pub(super) fn for_choice(summaries: MeetingSummaries, apple_intelligence: bool) -> Self {
|
||
if summaries != MeetingSummaries::OpenCode && apple_intelligence {
|
||
Self::AppleIntelligence
|
||
} else {
|
||
Self::OpenCode
|
||
}
|
||
}
|
||
|
||
/// What a pane or capsule says while this writer writes the notes.
|
||
pub(super) fn running_label(self) -> &'static str {
|
||
match self {
|
||
Self::AppleIntelligence => tr("Writing a title and summary with Apple Intelligence…"),
|
||
Self::OpenCode => tr("Writing a title and summary with OpenCode…"),
|
||
}
|
||
}
|
||
}
|
||
|
||
#[cfg(test)]
|
||
mod tests {
|
||
use super::*;
|
||
use MeetingSummaries::{Mac, Off, OpenCode};
|
||
|
||
/// The progress line names the writer the generator picks: Apple
|
||
/// Intelligence where it can write, unless Summaries sends notes to
|
||
/// OpenCode.
|
||
#[test]
|
||
fn the_progress_line_names_the_writer_the_generator_picks() {
|
||
for summaries in [Mac, Off] {
|
||
let writer = NotesWriter::for_choice(summaries, true);
|
||
assert_eq!(writer, NotesWriter::AppleIntelligence, "{summaries:?}");
|
||
assert!(writer.running_label().contains("Apple Intelligence"));
|
||
}
|
||
for (summaries, apple_intelligence) in [
|
||
(Mac, false),
|
||
(Off, false),
|
||
(OpenCode, false),
|
||
(OpenCode, true),
|
||
] {
|
||
let writer = NotesWriter::for_choice(summaries, apple_intelligence);
|
||
assert_eq!(
|
||
writer,
|
||
NotesWriter::OpenCode,
|
||
"{summaries:?}, Apple Intelligence {apple_intelligence}"
|
||
);
|
||
assert!(writer.running_label().contains("OpenCode"));
|
||
}
|
||
}
|
||
}
|