Skip to main content

artifactize_core/
monitor.rs

1//! Repository/worktree -> Run -> artifacts/evals -> Detail: the model every interface shows.
2pub mod catalog;
3pub mod evidence;
4pub mod fold;
5pub mod live;
6pub mod loader;
7pub mod model;
8pub mod session;
9
10pub use catalog::{Badge, Catalog, CatalogRow, Repository, Scope};
11pub use evidence::{Evidence, EvidenceStamp, evidence, original};
12pub use fold::upstream;
13pub use loader::{Input, Loader, Origin, Page, Snapshot, newer_offset, older_offset};
14pub use model::code;
15pub use model::{
16    Activity, Busy, Card, Clock, Completion, Detail, EvalView, Graph, GraphEdge, GraphNode, Kind,
17    Light, Node, NodeId, NotRun, Progress, Queue, RunRow, Section, Segment, Source, Status, Strip,
18    Tally, Target, Tone, Upstream, Waits, Weight, card, counts, detail, duration, glyph, graph,
19    progress, run_node, run_rows, strip, tree, upstream_index,
20};
21
22use crate::workspace::canonical_target;
23use std::{borrow::Cow, path::PathBuf};
24
25/// Bound retained Run pages while allowing the selected scope to page older records.
26pub const PAGE: u32 = 100;
27
28/// The path that picks the first scope from cwd or `--repo`, canonical like the catalog's
29/// paths; `None` (`--all`) starts on every repository.
30pub fn initial(repo: Option<PathBuf>) -> Option<PathBuf> {
31    repo.map(|path| canonical_target(&path).unwrap_or(path))
32}
33
34/// Text for one row: line breaks and tabs become spaces and other control characters go, so
35/// every interface measures and shows what a terminal would.
36pub fn plain(text: &str) -> Cow<'_, str> {
37    if !text.contains(char::is_control) {
38        return Cow::Borrowed(text);
39    }
40    Cow::Owned(
41        text.chars()
42            .filter_map(|character| match character {
43                '\n' | '\t' => Some(' '),
44                character if character.is_control() => None,
45                character => Some(character),
46            })
47            .collect(),
48    )
49}
50
51#[cfg(test)]
52pub(crate) mod tests;