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