use anyhow::Result;
#[cfg(feature = "whisper")]
use minutes_core::live_transcript::{
LiveTranscriptDisabled, SessionStatus, TranscriptLine, TranscriptSource,
};
#[cfg(feature = "whisper")]
use minutes_core::markdown::RemoteAudioStatus;
#[cfg(feature = "whisper")]
use std::io::{self, IsTerminal, Write};
#[cfg(feature = "whisper")]
use std::sync::atomic::{AtomicBool, Ordering};
#[cfg(feature = "whisper")]
use std::time::Duration;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FollowFormat {
Text,
Json,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum InitialWindow {
All,
SinceLine(usize),
SinceDurationMs(u64),
}
#[cfg(feature = "whisper")]
#[derive(Debug, Clone, Copy)]
pub struct FollowOptions {
pub format: FollowFormat,
pub initial: InitialWindow,
pub poll_interval: Duration,
pub use_color: bool,
}
#[cfg(feature = "whisper")]
impl FollowOptions {
pub fn for_cli(format: FollowFormat, initial: InitialWindow) -> Self {
let use_color = should_use_color(
io::stdout().is_terminal() && io::stderr().is_terminal(),
std::env::var_os("NO_COLOR").is_some(),
std::env::var("TERM").ok().as_deref(),
);
Self {
format,
initial,
poll_interval: Duration::from_millis(250),
use_color,
}
}
}
pub fn effective_transcript_format(format: Option<&str>, follow: bool) -> &str {
format.unwrap_or(if follow { "text" } else { "json" })
}
pub fn should_use_color(is_terminal: bool, no_color: bool, term: Option<&str>) -> bool {
is_terminal && !no_color && term != Some("dumb")
}
pub fn parse_since_window(since: Option<&str>) -> Result<InitialWindow> {
match since {
None => Ok(InitialWindow::All),
Some(s) if s.ends_with('m') || s.ends_with('s') => {
let (num_str, unit) = s.split_at(s.len() - 1);
let num: u64 = num_str
.parse()
.map_err(|_| anyhow::anyhow!("invalid duration: {}", s))?;
let ms = match unit {
"m" => num
.checked_mul(60_000)
.ok_or_else(|| anyhow::anyhow!("duration too large: {}", s))?,
"s" => num
.checked_mul(1000)
.ok_or_else(|| anyhow::anyhow!("duration too large: {}", s))?,
_ => anyhow::bail!("invalid duration unit: {}", unit),
};
Ok(InitialWindow::SinceDurationMs(ms))
}
Some(s) => {
let n: usize = s.parse().map_err(|_| {
anyhow::anyhow!(
"invalid --since value: '{}'. Use a line number (42) or duration (5m, 30s)",
s
)
})?;
Ok(InitialWindow::SinceLine(n))
}
}
}
#[cfg(feature = "whisper")]
pub trait FollowSource {
fn status(&self) -> SessionStatus;
fn read_since_line(&self, since_line: usize) -> Result<Vec<TranscriptLine>>;
fn read_since_duration(&self, duration_ms: u64) -> Result<Vec<TranscriptLine>>;
}
#[cfg(feature = "whisper")]
pub struct LiveTranscriptSource;
#[cfg(feature = "whisper")]
impl FollowSource for LiveTranscriptSource {
fn status(&self) -> SessionStatus {
minutes_core::live_transcript::session_status()
}
fn read_since_line(&self, since_line: usize) -> Result<Vec<TranscriptLine>> {
Ok(minutes_core::live_transcript::read_since_line(since_line)?)
}
fn read_since_duration(&self, duration_ms: u64) -> Result<Vec<TranscriptLine>> {
Ok(minutes_core::live_transcript::read_since_duration(
duration_ms,
)?)
}
}
#[cfg(feature = "whisper")]
#[derive(Debug, Clone, PartialEq, Eq)]
struct SessionIdentity {
session_id: Option<String>,
pid: Option<u32>,
}
#[cfg(feature = "whisper")]
impl SessionIdentity {
fn from_status(status: &SessionStatus) -> Self {
Self {
session_id: status.session_id.clone(),
pid: status.pid,
}
}
fn changed_from(&self, other: &Self) -> bool {
if let (Some(a), Some(b)) = (&self.session_id, &other.session_id) {
if a != b {
return true;
}
}
if let (Some(a), Some(b)) = (self.pid, other.pid) {
if a != b {
return true;
}
}
false
}
}
fn is_bidi_control(ch: char) -> bool {
matches!(
ch,
'\u{061C}'
| '\u{200E}'
| '\u{200F}'
| '\u{202A}'..='\u{202E}'
| '\u{2066}'..='\u{2069}'
)
}
pub fn sanitize_terminal_text(input: &str) -> String {
let mut out = String::with_capacity(input.len());
for ch in input.chars() {
match ch {
'\n' | '\r' | '\t' => out.push(' '),
c if c.is_control() || is_bidi_control(c) => {}
c => out.push(c),
}
}
out.trim().to_string()
}
#[cfg(feature = "whisper")]
pub fn format_text_line(line: &TranscriptLine, use_color: bool) -> String {
let ts = line.ts.format("%H:%M:%S");
let text = sanitize_terminal_text(&line.text);
let speaker = line
.speaker
.as_deref()
.map(sanitize_terminal_text)
.filter(|s| !s.is_empty());
match (speaker, use_color) {
(Some(speaker), true) => format!("\x1b[2m{ts}\x1b[0m \x1b[36m{speaker}\x1b[0m {text}"),
(Some(speaker), false) => format!("[{ts}] [{speaker}] {text}"),
(None, true) => format!("\x1b[2m{ts}\x1b[0m {text}"),
(None, false) => format!("[{ts}] {text}"),
}
}
#[cfg(feature = "whisper")]
fn format_notice(msg: &str, use_color: bool) -> String {
if use_color {
format!("\x1b[2m{msg}\x1b[0m")
} else {
msg.to_string()
}
}
#[cfg(feature = "whisper")]
fn format_warning(msg: &str, use_color: bool) -> String {
if use_color {
format!("\x1b[33m{msg}\x1b[0m")
} else {
msg.to_string()
}
}
#[cfg(feature = "whisper")]
fn source_tag(source: Option<&TranscriptSource>) -> &'static str {
match source {
Some(TranscriptSource::RecordingSidecar) => "recording sidecar",
Some(TranscriptSource::Standalone) => "live session",
None => "live session",
}
}
#[cfg(feature = "whisper")]
fn write_line_checked(out: &mut impl Write, line: &str) -> io::Result<bool> {
match writeln!(out, "{line}") {
Ok(()) => Ok(true),
Err(e) if e.kind() == io::ErrorKind::BrokenPipe => Ok(false),
Err(e) => Err(e),
}
}
#[cfg(feature = "whisper")]
fn flush_checked(out: &mut impl Write) -> io::Result<bool> {
match out.flush() {
Ok(()) => Ok(true),
Err(e) if e.kind() == io::ErrorKind::BrokenPipe => Ok(false),
Err(e) => Err(e),
}
}
#[cfg(feature = "whisper")]
fn emit_lines(
lines: &[TranscriptLine],
format: FollowFormat,
use_color: bool,
out: &mut impl Write,
) -> Result<(usize, bool)> {
let mut max_line = 0usize;
for line in lines {
let rendered = match format {
FollowFormat::Text => format_text_line(line, use_color),
FollowFormat::Json => serde_json::to_string(line)?,
};
if !write_line_checked(out, &rendered)? {
return Ok((max_line, false));
}
max_line = max_line.max(line.line);
}
if !lines.is_empty() && !flush_checked(out)? {
return Ok((max_line, false));
}
Ok((max_line, true))
}
#[cfg(feature = "whisper")]
fn emit_notice(
options: FollowOptions,
err: &mut impl Write,
msg: &str,
is_warning: bool,
) -> io::Result<()> {
if options.format != FollowFormat::Text {
return Ok(());
}
let formatted = if is_warning {
format_warning(msg, options.use_color)
} else {
format_notice(msg, options.use_color)
};
let _ = write_line_checked(err, &formatted)?;
let _ = flush_checked(err)?;
Ok(())
}
#[cfg(feature = "whisper")]
struct FollowSessionState {
options: FollowOptions,
initialized: bool,
was_active: bool,
identity: Option<SessionIdentity>,
cursor: usize,
last_seen_line_count: usize,
last_remote_audio: Option<RemoteAudioStatus>,
last_diagnostic: Option<String>,
disabled_reported: bool,
}
#[cfg(feature = "whisper")]
impl FollowSessionState {
fn new(options: FollowOptions) -> Self {
Self {
options,
initialized: false,
was_active: false,
identity: None,
cursor: 0,
last_seen_line_count: 0,
last_remote_audio: None,
last_diagnostic: None,
disabled_reported: false,
}
}
fn step(
&mut self,
source: &impl FollowSource,
out: &mut impl Write,
err: &mut impl Write,
) -> Result<bool> {
let status = source.status();
if let Some(LiveTranscriptDisabled::RecordingSidecarConfig) = status.disabled {
if !self.disabled_reported {
self.disabled_reported = true;
emit_notice(
self.options,
err,
"Live transcript is off for this recording (live_transcript.recording_sidecar = false); the transcript will be written after stop.",
true,
)?;
}
return Ok(false);
}
if !self.initialized {
self.initialized = true;
if status.active {
self.was_active = true;
self.identity = Some(SessionIdentity::from_status(&status));
self.last_seen_line_count = status.line_count;
emit_notice(
self.options,
err,
&format!(
"Following live transcript ({}) — Ctrl-C to stop",
source_tag(status.source.as_ref())
),
false,
)?;
self.maybe_report_warnings(&status, err)?;
let initial_lines = match self.options.initial {
InitialWindow::All => source.read_since_line(0)?,
InitialWindow::SinceLine(n) => source.read_since_line(n)?,
InitialWindow::SinceDurationMs(ms) => source.read_since_duration(ms)?,
};
let (max_emitted, keep_going) = emit_lines(
&initial_lines,
self.options.format,
self.options.use_color,
out,
)?;
if !keep_going {
return Ok(false);
}
self.cursor = match self.options.initial {
InitialWindow::All => max_emitted.max(status.line_count),
InitialWindow::SinceLine(n) => max_emitted.max(n).max(status.line_count),
InitialWindow::SinceDurationMs(_) => max_emitted.max(status.line_count),
};
} else {
self.was_active = false;
emit_notice(
self.options,
err,
"Waiting for live transcript... (Ctrl-C to stop)",
false,
)?;
}
return Ok(true);
}
if status.active {
let new_identity = SessionIdentity::from_status(&status);
if !self.was_active {
self.was_active = true;
self.identity = Some(new_identity);
self.cursor = 0;
self.last_seen_line_count = 0;
self.last_remote_audio = None;
self.last_diagnostic = None;
emit_notice(
self.options,
err,
&format!(
"Connected · following {} (Ctrl-C to stop)",
source_tag(status.source.as_ref())
),
false,
)?;
} else {
let identity_changed = self
.identity
.as_ref()
.is_some_and(|prev| prev.changed_from(&new_identity));
let truncated = status.line_count < self.last_seen_line_count;
if identity_changed || truncated {
self.identity = Some(new_identity);
self.cursor = 0;
self.last_seen_line_count = 0;
self.last_remote_audio = None;
self.last_diagnostic = None;
emit_notice(
self.options,
err,
"--- New live transcript session ---",
false,
)?;
}
}
self.maybe_report_warnings(&status, err)?;
if status.line_count > self.cursor {
let lines = source.read_since_line(self.cursor)?;
let (max_emitted, keep_going) =
emit_lines(&lines, self.options.format, self.options.use_color, out)?;
if !keep_going {
return Ok(false);
}
self.cursor = max_emitted.max(status.line_count);
}
self.last_seen_line_count = status.line_count;
} else if self.was_active {
let lines = source.read_since_line(self.cursor)?;
let (max_emitted, keep_going) =
emit_lines(&lines, self.options.format, self.options.use_color, out)?;
if !keep_going {
return Ok(false);
}
let final_count = max_emitted.max(status.line_count).max(self.cursor);
self.was_active = false;
self.identity = None;
self.cursor = 0;
self.last_seen_line_count = 0;
self.last_remote_audio = None;
self.last_diagnostic = None;
emit_notice(
self.options,
err,
&format!(
"Live transcript ended ({final_count} line{}). Waiting for next session... (Ctrl-C to stop)",
if final_count == 1 { "" } else { "s" }
),
false,
)?;
}
Ok(true)
}
fn maybe_report_warnings(
&mut self,
status: &SessionStatus,
err: &mut impl Write,
) -> Result<()> {
if status.remote_audio != self.last_remote_audio {
self.last_remote_audio = status.remote_audio;
if let Some(remote_audio) = status.remote_audio {
let message = match remote_audio {
RemoteAudioStatus::Missing => {
"[minutes] Remote call audio is missing — live lines are from your microphone only."
}
RemoteAudioStatus::Partial => {
"[minutes] Remote call audio dropped out — recent live lines may be from your microphone only."
}
};
emit_notice(self.options, err, message, true)?;
}
}
if status.disabled.is_none() && status.diagnostic != self.last_diagnostic {
self.last_diagnostic = status.diagnostic.clone();
if let Some(diag) = status.diagnostic.as_deref() {
emit_notice(self.options, err, &format!("[minutes] {diag}"), true)?;
}
}
Ok(())
}
}
#[cfg(feature = "whisper")]
pub fn follow_transcript(
source: &impl FollowSource,
options: FollowOptions,
stop: &AtomicBool,
out: &mut impl Write,
err: &mut impl Write,
) -> Result<()> {
let mut state = FollowSessionState::new(options);
while !stop.load(Ordering::Relaxed) {
if !state.step(source, out, err)? {
break;
}
if stop.load(Ordering::Relaxed) {
break;
}
let mut remaining = options.poll_interval;
let slice = Duration::from_millis(50);
while !remaining.is_zero() && !stop.load(Ordering::Relaxed) {
let nap = remaining.min(slice);
std::thread::sleep(nap);
remaining = remaining.saturating_sub(nap);
}
}
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn parse_since_window_handles_all_lines_and_durations() {
assert_eq!(parse_since_window(None).unwrap(), InitialWindow::All);
assert_eq!(
parse_since_window(Some("12")).unwrap(),
InitialWindow::SinceLine(12)
);
assert_eq!(
parse_since_window(Some("30s")).unwrap(),
InitialWindow::SinceDurationMs(30_000)
);
assert_eq!(
parse_since_window(Some("5m")).unwrap(),
InitialWindow::SinceDurationMs(300_000)
);
assert!(parse_since_window(Some("bogus")).is_err());
}
#[test]
fn color_respects_tty_no_color_and_dumb_term() {
assert!(should_use_color(true, false, Some("xterm-256color")));
assert!(!should_use_color(false, false, Some("xterm-256color")));
assert!(!should_use_color(true, true, Some("xterm-256color")));
assert!(!should_use_color(true, false, Some("dumb")));
}
#[test]
fn sanitize_strips_control_chars_and_normalizes_whitespace() {
assert_eq!(
sanitize_terminal_text("Hello\x1b[31m\nworld\t!"),
"Hello[31m world !"
);
assert_eq!(sanitize_terminal_text("Alex\x07"), "Alex");
assert_eq!(
sanitize_terminal_text("safe\u{202E}gnioops\u{2066}text\u{200F}"),
"safegnioopstext"
);
}
#[test]
fn effective_format_defaults_to_text_when_following_and_json_otherwise() {
assert_eq!(effective_transcript_format(None, false), "json");
assert_eq!(effective_transcript_format(None, true), "text");
assert_eq!(effective_transcript_format(Some("json"), true), "json");
assert_eq!(effective_transcript_format(Some("text"), false), "text");
}
}
#[cfg(all(test, feature = "whisper"))]
mod follow_tests {
use super::*;
use chrono::TimeZone;
use std::cell::RefCell;
use std::collections::VecDeque;
fn make_line(line: usize, text: &str, speaker: Option<&str>) -> TranscriptLine {
let ts = chrono::Local
.with_ymd_and_hms(2026, 12, 3, 14, 5, (line % 60) as u32)
.single()
.unwrap();
TranscriptLine {
line,
ts,
offset_ms: (line as u64) * 5_000,
duration_ms: 2_000,
text: text.to_string(),
speaker: speaker.map(str::to_string),
}
}
fn base_status(active: bool, line_count: usize) -> SessionStatus {
SessionStatus {
active,
pid: active.then_some(4242),
line_count,
duration_secs: (line_count as f64) * 5.0,
latest_final_age_secs: None,
session_id: active.then(|| "sess-1".to_string()),
jsonl_path: None,
source: active.then_some(TranscriptSource::Standalone),
diagnostic: None,
disabled: None,
remote_audio: None,
}
}
struct ScriptedSource {
steps: RefCell<VecDeque<(SessionStatus, Vec<TranscriptLine>)>>,
current_lines: RefCell<Vec<TranscriptLine>>,
}
impl ScriptedSource {
fn new(steps: Vec<(SessionStatus, Vec<TranscriptLine>)>) -> Self {
Self {
steps: RefCell::new(steps.into()),
current_lines: RefCell::new(Vec::new()),
}
}
}
impl FollowSource for ScriptedSource {
fn status(&self) -> SessionStatus {
let (status, lines) = self
.steps
.borrow_mut()
.pop_front()
.expect("scripted source exhausted");
*self.current_lines.borrow_mut() = lines;
status
}
fn read_since_line(&self, since_line: usize) -> Result<Vec<TranscriptLine>> {
Ok(self
.current_lines
.borrow()
.iter()
.filter(|l| l.line > since_line)
.cloned()
.collect())
}
fn read_since_duration(&self, _duration_ms: u64) -> Result<Vec<TranscriptLine>> {
Ok(self
.current_lines
.borrow()
.last()
.cloned()
.into_iter()
.collect())
}
}
fn text_options(initial: InitialWindow) -> FollowOptions {
FollowOptions {
format: FollowFormat::Text,
initial,
poll_interval: Duration::from_millis(1),
use_color: false,
}
}
#[test]
fn format_text_line_omits_unknown_speaker_and_strips_controls() {
let plain = make_line(1, "Hello\x1b[31m\nworld\t!", None);
assert_eq!(
format_text_line(&plain, false),
"[14:05:01] Hello[31m world !"
);
let spoken = make_line(2, "Agreed.", Some("Alex\x07"));
assert_eq!(
format_text_line(&spoken, false),
"[14:05:02] [Alex] Agreed."
);
let colored = format_text_line(&spoken, true);
assert!(colored.contains("\x1b[2m14:05:02\x1b[0m"));
assert!(colored.contains("\x1b[36mAlex\x1b[0m"));
assert!(colored.ends_with("Agreed."));
}
#[test]
fn waits_for_session_without_dumping_stale_lines_then_streams_and_drains_on_stop() {
let stale = vec![make_line(1, "Yesterday's meeting", None)];
let l1 = make_line(1, "Okay, quick sync on Valley deliveries.", None);
let l2 = make_line(2, "Y.T. has a 90-day exclusive trial.", None);
let l3 = make_line(3, "Let's confirm Friday.", None);
let source = ScriptedSource::new(vec![
(base_status(false, 1), stale),
(base_status(true, 1), vec![l1.clone()]),
(base_status(true, 2), vec![l1.clone(), l2.clone()]),
(base_status(false, 3), vec![l1, l2, l3]),
]);
let mut state = FollowSessionState::new(text_options(InitialWindow::All));
let mut out = Vec::new();
let mut err = Vec::new();
for _ in 0..4 {
assert!(state.step(&source, &mut out, &mut err).unwrap());
}
let stdout = String::from_utf8(out).unwrap();
let stderr = String::from_utf8(err).unwrap();
assert!(!stdout.contains("Yesterday's meeting"));
assert_eq!(
stdout.lines().collect::<Vec<_>>(),
vec![
"[14:05:01] Okay, quick sync on Valley deliveries.",
"[14:05:02] Y.T. has a 90-day exclusive trial.",
"[14:05:03] Let's confirm Friday.",
]
);
assert!(stderr.contains("Waiting for live transcript"));
assert!(stderr.contains("Connected"));
assert!(stderr.contains("Live transcript ended (3 lines)"));
}
#[test]
fn since_duration_sets_cursor_past_older_lines_and_only_emits_new_ones() {
let l1 = make_line(1, "Old line one", None);
let l2 = make_line(2, "Recent line two", None);
let l3 = make_line(3, "New line three", None);
let source = ScriptedSource::new(vec![
(base_status(true, 2), vec![l1.clone(), l2.clone()]),
(base_status(true, 2), vec![l1.clone(), l2.clone()]),
(base_status(true, 3), vec![l1, l2, l3]),
]);
let mut state =
FollowSessionState::new(text_options(InitialWindow::SinceDurationMs(30_000)));
let mut out = Vec::new();
let mut err = Vec::new();
for _ in 0..3 {
assert!(state.step(&source, &mut out, &mut err).unwrap());
}
let stdout = String::from_utf8(out).unwrap();
assert_eq!(
stdout.lines().collect::<Vec<_>>(),
vec!["[14:05:02] Recent line two", "[14:05:03] New line three",]
);
}
#[test]
fn handles_session_rollover_without_restarting_follow() {
let s1 = base_status(true, 2);
let mut s2 = base_status(true, 1);
s2.session_id = Some("sess-2".to_string());
s2.pid = Some(9999);
let source = ScriptedSource::new(vec![
(
s1,
vec![make_line(1, "First call", None), make_line(2, "Done", None)],
),
(s2, vec![make_line(1, "Second call starts", None)]),
]);
let mut state = FollowSessionState::new(text_options(InitialWindow::All));
let mut out = Vec::new();
let mut err = Vec::new();
assert!(state.step(&source, &mut out, &mut err).unwrap());
assert!(state.step(&source, &mut out, &mut err).unwrap());
let stdout = String::from_utf8(out).unwrap();
let stderr = String::from_utf8(err).unwrap();
assert_eq!(
stdout.lines().collect::<Vec<_>>(),
vec![
"[14:05:01] First call",
"[14:05:02] Done",
"[14:05:01] Second call starts",
]
);
assert!(stderr.contains("New live transcript session"));
}
#[test]
fn json_mode_streams_ndjson_and_keeps_stderr_quiet() {
let source = ScriptedSource::new(vec![(
base_status(true, 1),
vec![make_line(1, "Ship it", Some("Mat"))],
)]);
let options = FollowOptions {
format: FollowFormat::Json,
initial: InitialWindow::All,
poll_interval: Duration::from_millis(1),
use_color: false,
};
let mut state = FollowSessionState::new(options);
let mut out = Vec::new();
let mut err = Vec::new();
assert!(state.step(&source, &mut out, &mut err).unwrap());
let stdout = String::from_utf8(out).unwrap();
let parsed: TranscriptLine = serde_json::from_str(stdout.trim()).unwrap();
assert_eq!(parsed.line, 1);
assert_eq!(parsed.text, "Ship it");
assert_eq!(parsed.speaker.as_deref(), Some("Mat"));
assert!(err.is_empty());
}
#[test]
fn disabled_recording_sidecar_prints_notice_and_exits_cleanly() {
let mut status = base_status(false, 0);
status.disabled = Some(LiveTranscriptDisabled::RecordingSidecarConfig);
let source = ScriptedSource::new(vec![(status, vec![])]);
let mut state = FollowSessionState::new(text_options(InitialWindow::All));
let mut out = Vec::new();
let mut err = Vec::new();
assert!(!state.step(&source, &mut out, &mut err).unwrap());
assert!(out.is_empty());
assert!(String::from_utf8(err)
.unwrap()
.contains("recording_sidecar = false"));
}
#[test]
fn remote_audio_warning_prints_once_per_transition() {
let mut s1 = base_status(true, 0);
s1.remote_audio = Some(RemoteAudioStatus::Missing);
let s2 = s1.clone();
let mut s3 = base_status(true, 0);
s3.remote_audio = Some(RemoteAudioStatus::Partial);
let source = ScriptedSource::new(vec![(s1, vec![]), (s2, vec![]), (s3, vec![])]);
let mut state = FollowSessionState::new(text_options(InitialWindow::All));
let mut out = Vec::new();
let mut err = Vec::new();
assert!(state.step(&source, &mut out, &mut err).unwrap());
assert!(state.step(&source, &mut out, &mut err).unwrap());
assert!(state.step(&source, &mut out, &mut err).unwrap());
let stderr = String::from_utf8(err).unwrap();
assert_eq!(stderr.matches("Remote call audio is missing").count(), 1);
assert_eq!(stderr.matches("Remote call audio dropped out").count(), 1);
}
#[test]
fn broken_pipe_exits_cleanly_without_error() {
struct BrokenPipeWriter;
impl Write for BrokenPipeWriter {
fn write(&mut self, _buf: &[u8]) -> io::Result<usize> {
Err(io::Error::new(io::ErrorKind::BrokenPipe, "closed"))
}
fn flush(&mut self) -> io::Result<()> {
Ok(())
}
}
let source = ScriptedSource::new(vec![(
base_status(true, 1),
vec![make_line(1, "Hello", None)],
)]);
let mut state = FollowSessionState::new(text_options(InitialWindow::All));
let mut out = BrokenPipeWriter;
let mut err = Vec::new();
assert!(!state.step(&source, &mut out, &mut err).unwrap());
}
}