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