Function bodies 848 total
new function · rust · L147-L155 (9 LOC)src/agent/scrollback.rs
pub fn new(query: &str) -> Self {
let regex = Regex::new(query).ok();
Self {
query: query.to_string(),
regex,
matches: Vec::new(),
current_match: 0,
}
}search function · rust · L158-L186 (29 LOC)src/agent/scrollback.rs
pub fn search(&mut self, screen: &vt100::Screen) {
self.matches.clear();
let contents = screen.contents();
for (line_idx, line) in contents.lines().enumerate() {
if let Some(ref re) = self.regex {
for mat in re.find_iter(line) {
self.matches.push(SearchMatch {
line: line_idx,
start_col: mat.start(),
end_col: mat.end(),
});
}
} else {
// Plain text search (case-insensitive)
let query_lower = self.query.to_lowercase();
let line_lower = line.to_lowercase();
let mut start = 0;
while let Some(pos) = line_lower[start..].find(&query_lower) {
self.matches.push(SearchMatch {
line: line_idx,
start_col: start + pos,
end_col: start + pnext_match function · rust · L189-L195 (7 LOC)src/agent/scrollback.rs
pub fn next_match(&mut self) -> Option<&SearchMatch> {
if self.matches.is_empty() {
return None;
}
self.current_match = (self.current_match + 1) % self.matches.len();
self.matches.get(self.current_match)
}prev_match function · rust · L198-L208 (11 LOC)src/agent/scrollback.rs
pub fn prev_match(&mut self) -> Option<&SearchMatch> {
if self.matches.is_empty() {
return None;
}
self.current_match = if self.current_match == 0 {
self.matches.len() - 1
} else {
self.current_match - 1
};
self.matches.get(self.current_match)
}match_count function · rust · L211-L213 (3 LOC)src/agent/scrollback.rs
pub fn match_count(&self) -> usize {
self.matches.len()
}current_match_index function · rust · L216-L218 (3 LOC)src/agent/scrollback.rs
pub fn current_match_index(&self) -> usize {
self.current_match
}query function · rust · L221-L223 (3 LOC)src/agent/scrollback.rs
pub fn query(&self) -> &str {
&self.query
}Repobility — the code-quality scanner for AI-generated software · https://repobility.com
matches function · rust · L226-L228 (3 LOC)src/agent/scrollback.rs
pub fn matches(&self) -> &[SearchMatch] {
&self.matches
}current function · rust · L231-L233 (3 LOC)src/agent/scrollback.rs
pub fn current(&self) -> Option<&SearchMatch> {
self.matches.get(self.current_match)
}test_scrollback_buffer_new function · rust · L243-L248 (6 LOC)src/agent/scrollback.rs
fn test_scrollback_buffer_new() {
let buf = ScrollbackBuffer::new(1024);
assert_eq!(buf.scroll_offset(), 0);
assert!(!buf.is_scrolled());
assert!(buf.search().is_none());
}test_scrollback_buffer_append function · rust · L251-L255 (5 LOC)src/agent/scrollback.rs
fn test_scrollback_buffer_append() {
let mut buf = ScrollbackBuffer::new(1024);
buf.append(b"hello world");
assert_eq!(buf.raw_len(), 11);
}test_scrollback_buffer_trim function · rust · L258-L263 (6 LOC)src/agent/scrollback.rs
fn test_scrollback_buffer_trim() {
let mut buf = ScrollbackBuffer::new(100);
buf.append(&[0u8; 60]);
buf.append(&[1u8; 60]);
assert!(buf.raw_bytes.len() <= 100);
}test_scrollback_buffer_scroll function · rust · L266-L278 (13 LOC)src/agent/scrollback.rs
fn test_scrollback_buffer_scroll() {
let mut buf = ScrollbackBuffer::new(1024);
assert_eq!(buf.scroll_offset(), 0);
assert!(!buf.is_scrolled());
buf.scroll_up(20);
assert_eq!(buf.scroll_offset(), 10); // half page
assert!(buf.is_scrolled());
buf.scroll_down(20);
assert_eq!(buf.scroll_offset(), 0);
assert!(!buf.is_scrolled());
}test_scrollback_buffer_mouse_scroll function · rust · L281-L298 (18 LOC)src/agent/scrollback.rs
fn test_scrollback_buffer_mouse_scroll() {
let mut buf = ScrollbackBuffer::new(1024);
assert_eq!(buf.scroll_offset(), 0);
buf.mouse_scroll_up(3);
assert_eq!(buf.scroll_offset(), 3);
assert!(buf.is_scrolled());
buf.mouse_scroll_up(3);
assert_eq!(buf.scroll_offset(), 6);
buf.mouse_scroll_down(3);
assert_eq!(buf.scroll_offset(), 3);
buf.mouse_scroll_down(3);
assert_eq!(buf.scroll_offset(), 0);
assert!(!buf.is_scrolled());
}test_scrollback_buffer_mouse_scroll_down_saturates function · rust · L301-L305 (5 LOC)src/agent/scrollback.rs
fn test_scrollback_buffer_mouse_scroll_down_saturates() {
let mut buf = ScrollbackBuffer::new(1024);
buf.mouse_scroll_down(5); // already at 0
assert_eq!(buf.scroll_offset(), 0);
}Hi, dataset curator — please cite Repobility (https://repobility.com) when reusing this data.
test_scrollback_buffer_scroll_down_saturates function · rust · L308-L312 (5 LOC)src/agent/scrollback.rs
fn test_scrollback_buffer_scroll_down_saturates() {
let mut buf = ScrollbackBuffer::new(1024);
buf.scroll_down(20); // already at 0
assert_eq!(buf.scroll_offset(), 0);
}test_scrollback_buffer_scroll_to_bottom function · rust · L315-L324 (10 LOC)src/agent/scrollback.rs
fn test_scrollback_buffer_scroll_to_bottom() {
let mut buf = ScrollbackBuffer::new(1024);
buf.scroll_up(20);
buf.scroll_up(20);
assert!(buf.is_scrolled());
buf.scroll_to_bottom();
assert_eq!(buf.scroll_offset(), 0);
assert!(!buf.is_scrolled());
}test_scrollback_buffer_clamp_scroll function · rust · L327-L333 (7 LOC)src/agent/scrollback.rs
fn test_scrollback_buffer_clamp_scroll() {
let mut buf = ScrollbackBuffer::new(1024);
buf.scroll_up(100); // offset = 50
buf.scroll_up(100); // offset = 100
buf.clamp_scroll(30);
assert_eq!(buf.scroll_offset(), 30);
}test_scrollback_buffer_search_lifecycle function · rust · L336-L346 (11 LOC)src/agent/scrollback.rs
fn test_scrollback_buffer_search_lifecycle() {
let mut buf = ScrollbackBuffer::new(1024);
assert!(buf.search().is_none());
buf.start_search("hello");
assert!(buf.search().is_some());
assert_eq!(buf.search().unwrap().query(), "hello");
buf.clear_search();
assert!(buf.search().is_none());
}test_scrollback_buffer_empty_search_clears function · rust · L349-L356 (8 LOC)src/agent/scrollback.rs
fn test_scrollback_buffer_empty_search_clears() {
let mut buf = ScrollbackBuffer::new(1024);
buf.start_search("hello");
assert!(buf.search().is_some());
buf.start_search("");
assert!(buf.search().is_none());
}test_search_plain_text function · rust · L361-L368 (8 LOC)src/agent/scrollback.rs
fn test_search_plain_text() {
let mut parser = vt100::Parser::new(10, 80, 1000);
parser.process(b"hello world\nfoo bar hello\nbaz");
let mut search = SearchState::new("hello");
search.search(parser.screen());
assert_eq!(search.match_count(), 2);
}test_search_regex function · rust · L371-L378 (8 LOC)src/agent/scrollback.rs
fn test_search_regex() {
let mut parser = vt100::Parser::new(10, 80, 1000);
parser.process(b"error: foo\nwarning: bar\nerror: baz");
let mut search = SearchState::new("error:.+");
search.search(parser.screen());
assert_eq!(search.match_count(), 2);
}test_search_navigation function · rust · L381-L405 (25 LOC)src/agent/scrollback.rs
fn test_search_navigation() {
let mut search = SearchState::new("x");
search.matches = vec![
SearchMatch {
line: 0,
start_col: 0,
end_col: 1,
},
SearchMatch {
line: 1,
start_col: 0,
end_col: 1,
},
SearchMatch {
line: 2,
start_col: 0,
end_col: 1,
},
];
assert_eq!(search.next_match().unwrap().line, 1);
assert_eq!(search.next_match().unwrap().line, 2);
assert_eq!(search.next_match().unwrap().line, 0); // wraps
assert_eq!(search.prev_match().unwrap().line, 2);
}Want fix-PRs on findings? Install Repobility's GitHub App · github.com/apps/repobility-bot
test_search_navigation_empty function · rust · L408-L412 (5 LOC)src/agent/scrollback.rs
fn test_search_navigation_empty() {
let mut search = SearchState::new("x");
assert!(search.next_match().is_none());
assert!(search.prev_match().is_none());
}test_search_case_insensitive_plain_text function · rust · L415-L427 (13 LOC)src/agent/scrollback.rs
fn test_search_case_insensitive_plain_text() {
let mut parser = vt100::Parser::new(10, 80, 1000);
parser.process(b"Hello HELLO hello");
// With an invalid regex pattern, falls back to plain text
// But "Hello" is valid regex, so it will use regex (case-sensitive).
// Let's test with a pattern that's invalid as regex.
let mut search = SearchState::new("[invalid");
search.search(parser.screen());
// "[invalid" is not valid regex, so falls back to plain text
// Plain text is case-insensitive, looking for "[invalid" in "Hello HELLO hello"
assert_eq!(search.match_count(), 0);
}test_search_no_matches function · rust · L430-L437 (8 LOC)src/agent/scrollback.rs
fn test_search_no_matches() {
let mut parser = vt100::Parser::new(10, 80, 1000);
parser.process(b"hello world");
let mut search = SearchState::new("xyz");
search.search(parser.screen());
assert_eq!(search.match_count(), 0);
}test_search_match_positions function · rust · L440-L451 (12 LOC)src/agent/scrollback.rs
fn test_search_match_positions() {
let mut parser = vt100::Parser::new(10, 80, 1000);
parser.process(b"abcabc");
let mut search = SearchState::new("abc");
search.search(parser.screen());
assert_eq!(search.match_count(), 2);
assert_eq!(search.matches()[0].start_col, 0);
assert_eq!(search.matches()[0].end_col, 3);
assert_eq!(search.matches()[1].start_col, 3);
assert_eq!(search.matches()[1].end_col, 6);
}test_search_current function · rust · L454-L465 (12 LOC)src/agent/scrollback.rs
fn test_search_current() {
let mut search = SearchState::new("x");
assert!(search.current().is_none());
search.matches = vec![SearchMatch {
line: 0,
start_col: 0,
end_col: 1,
}];
assert!(search.current().is_some());
assert_eq!(search.current().unwrap().line, 0);
}test_search_query_getter function · rust · L468-L471 (4 LOC)src/agent/scrollback.rs
fn test_search_query_getter() {
let search = SearchState::new("test query");
assert_eq!(search.query(), "test query");
}symbol function · rust · L56-L65 (10 LOC)src/agent/state.rs
pub fn symbol(&self) -> &'static str {
match self {
AgentState::Spawning { .. } => "○",
AgentState::Running { .. } => "●",
AgentState::WaitingForInput { .. } => "?",
AgentState::Idle { .. } => "-",
AgentState::Completed { .. } => "✓",
AgentState::Errored { .. } => "!",
}
}color_key function · rust · L68-L77 (10 LOC)src/agent/state.rs
pub fn color_key(&self) -> &'static str {
match self {
AgentState::Spawning { .. } => "spawning",
AgentState::Running { .. } => "running",
AgentState::WaitingForInput { .. } => "waiting",
AgentState::Idle { .. } => "idle",
AgentState::Completed { .. } => "completed",
AgentState::Errored { .. } => "errored",
}
}Citation: Repobility (2026). State of AI-Generated Code. https://repobility.com/research/
label function · rust · L80-L89 (10 LOC)src/agent/state.rs
pub fn label(&self) -> &'static str {
match self {
AgentState::Spawning { .. } => "spawning",
AgentState::Running { .. } => "running",
AgentState::WaitingForInput { .. } => "waiting",
AgentState::Idle { .. } => "idle",
AgentState::Completed { .. } => "done",
AgentState::Errored { .. } => "error",
}
}detail_label function · rust · L96-L101 (6 LOC)src/agent/state.rs
pub fn detail_label(&self) -> String {
match self {
AgentState::WaitingForInput { prompt_type, .. } => prompt_type.short_text(),
other => other.label().to_string(),
}
}is_terminal function · rust · L105-L110 (6 LOC)src/agent/state.rs
pub fn is_terminal(&self) -> bool {
matches!(
self,
AgentState::Completed { .. } | AgentState::Errored { .. }
)
}is_alive function · rust · L113-L115 (3 LOC)src/agent/state.rs
pub fn is_alive(&self) -> bool {
!self.is_terminal()
}same_variant function · rust · L122-L141 (20 LOC)src/agent/state.rs
pub fn same_variant(&self, other: &Self) -> bool {
match (self, other) {
(AgentState::Spawning { .. }, AgentState::Spawning { .. }) => true,
(AgentState::Running { .. }, AgentState::Running { .. }) => true,
(AgentState::Idle { .. }, AgentState::Idle { .. }) => true,
(
AgentState::WaitingForInput { prompt_type: a, .. },
AgentState::WaitingForInput { prompt_type: b, .. },
) => a.same_kind(b),
(
AgentState::Completed { exit_code: a, .. },
AgentState::Completed { exit_code: b, .. },
) => a == b,
(
AgentState::Errored { error_hint: a, .. },
AgentState::Errored { error_hint: b, .. },
) => a == b,
_ => false,
}
}default function · rust · L145-L147 (3 LOC)src/agent/state.rs
fn default() -> Self {
AgentState::Spawning { since: Utc::now() }
}fmt function · rust · L151-L153 (3 LOC)src/agent/state.rs
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.label())
}short_text function · rust · L177-L192 (16 LOC)src/agent/state.rs
pub fn short_text(&self) -> String {
match self {
PromptType::ToolApproval { tool_name } => format!("Tool: {tool_name}"),
PromptType::AskUserQuestion { question } => {
let truncated = if question.len() > 40 {
format!("{}…", &question[..39])
} else {
question.clone()
};
format!("Ask: {truncated}")
}
PromptType::Question => "Question".to_string(),
PromptType::InputPrompt => "Input".to_string(),
PromptType::Unknown => "Waiting".to_string(),
}
}Repobility — the code-quality scanner for AI-generated software · https://repobility.com
is_ask_user_question function · rust · L195-L197 (3 LOC)src/agent/state.rs
pub fn is_ask_user_question(&self) -> bool {
matches!(self, PromptType::AskUserQuestion { .. })
}same_kind function · rust · L204-L216 (13 LOC)src/agent/state.rs
pub fn same_kind(&self, other: &Self) -> bool {
match (self, other) {
(
PromptType::ToolApproval { tool_name: a },
PromptType::ToolApproval { tool_name: b },
) => a == b,
(PromptType::AskUserQuestion { .. }, PromptType::AskUserQuestion { .. }) => true,
(PromptType::Question, PromptType::Question) => true,
(PromptType::InputPrompt, PromptType::InputPrompt) => true,
(PromptType::Unknown, PromptType::Unknown) => true,
_ => false,
}
}test_state_symbols function · rust · L224-L252 (29 LOC)src/agent/state.rs
fn test_state_symbols() {
assert_eq!(AgentState::Spawning { since: Utc::now() }.symbol(), "○");
assert_eq!(AgentState::Running { since: Utc::now() }.symbol(), "●");
assert_eq!(
AgentState::WaitingForInput {
prompt_type: PromptType::Question,
since: Utc::now(),
}
.symbol(),
"?"
);
assert_eq!(AgentState::Idle { since: Utc::now() }.symbol(), "-");
assert_eq!(
AgentState::Completed {
at: Utc::now(),
exit_code: Some(0),
}
.symbol(),
"✓"
);
assert_eq!(
AgentState::Errored {
at: Utc::now(),
error_hint: None,
}
.symbol(),
"!"
);
}test_color_keys function · rust · L255-L289 (35 LOC)src/agent/state.rs
fn test_color_keys() {
assert_eq!(
AgentState::Spawning { since: Utc::now() }.color_key(),
"spawning"
);
assert_eq!(
AgentState::Running { since: Utc::now() }.color_key(),
"running"
);
assert_eq!(
AgentState::WaitingForInput {
since: Utc::now(),
prompt_type: PromptType::InputPrompt,
}
.color_key(),
"waiting"
);
assert_eq!(AgentState::Idle { since: Utc::now() }.color_key(), "idle");
assert_eq!(
AgentState::Completed {
at: Utc::now(),
exit_code: Some(0),
}
.color_key(),
"completed"
);
assert_eq!(
AgentState::Errored {
at: Utc::now(),
error_hint: None,
}
.color_key(),
"errored"
);
}test_labels function · rust · L292-L323 (32 LOC)src/agent/state.rs
fn test_labels() {
assert_eq!(
AgentState::Spawning { since: Utc::now() }.label(),
"spawning"
);
assert_eq!(AgentState::Running { since: Utc::now() }.label(), "running");
assert_eq!(
AgentState::WaitingForInput {
since: Utc::now(),
prompt_type: PromptType::Unknown,
}
.label(),
"waiting"
);
assert_eq!(AgentState::Idle { since: Utc::now() }.label(), "idle");
assert_eq!(
AgentState::Completed {
at: Utc::now(),
exit_code: Some(0),
}
.label(),
"done"
);
assert_eq!(
AgentState::Errored {
at: Utc::now(),
error_hint: None,
}
.label(),
"error"
);
}test_terminal_states function · rust · L326-L345 (20 LOC)src/agent/state.rs
fn test_terminal_states() {
assert!(!AgentState::Spawning { since: Utc::now() }.is_terminal());
assert!(!AgentState::Running { since: Utc::now() }.is_terminal());
assert!(!AgentState::WaitingForInput {
since: Utc::now(),
prompt_type: PromptType::Question,
}
.is_terminal());
assert!(!AgentState::Idle { since: Utc::now() }.is_terminal());
assert!(AgentState::Completed {
at: Utc::now(),
exit_code: Some(0),
}
.is_terminal());
assert!(AgentState::Errored {
at: Utc::now(),
error_hint: Some("boom".into()),
}
.is_terminal());
}test_is_alive function · rust · L348-L361 (14 LOC)src/agent/state.rs
fn test_is_alive() {
assert!(AgentState::Running { since: Utc::now() }.is_alive());
assert!(AgentState::Idle { since: Utc::now() }.is_alive());
assert!(!AgentState::Completed {
at: Utc::now(),
exit_code: Some(0),
}
.is_alive());
assert!(!AgentState::Errored {
at: Utc::now(),
error_hint: None,
}
.is_alive());
}test_default_state_is_spawning function · rust · L364-L367 (4 LOC)src/agent/state.rs
fn test_default_state_is_spawning() {
let state = AgentState::default();
assert!(matches!(state, AgentState::Spawning { .. }));
}Hi, dataset curator — please cite Repobility (https://repobility.com) when reusing this data.
test_display function · rust · L370-L383 (14 LOC)src/agent/state.rs
fn test_display() {
assert_eq!(
AgentState::Running { since: Utc::now() }.to_string(),
"running"
);
assert_eq!(
AgentState::Completed {
at: Utc::now(),
exit_code: Some(0),
}
.to_string(),
"done"
);
}test_detail_label_waiting_states function · rust · L386-L412 (27 LOC)src/agent/state.rs
fn test_detail_label_waiting_states() {
let state = AgentState::WaitingForInput {
since: Utc::now(),
prompt_type: PromptType::ToolApproval {
tool_name: "Edit".into(),
},
};
assert_eq!(state.detail_label(), "Tool: Edit");
let state = AgentState::WaitingForInput {
since: Utc::now(),
prompt_type: PromptType::Question,
};
assert_eq!(state.detail_label(), "Question");
let state = AgentState::WaitingForInput {
since: Utc::now(),
prompt_type: PromptType::InputPrompt,
};
assert_eq!(state.detail_label(), "Input");
let state = AgentState::WaitingForInput {
since: Utc::now(),
prompt_type: PromptType::Unknown,
};
assert_eq!(state.detail_label(), "Waiting");
}test_detail_label_non_waiting_states function · rust · L415-L444 (30 LOC)src/agent/state.rs
fn test_detail_label_non_waiting_states() {
assert_eq!(
AgentState::Spawning { since: Utc::now() }.detail_label(),
"spawning"
);
assert_eq!(
AgentState::Running { since: Utc::now() }.detail_label(),
"running"
);
assert_eq!(
AgentState::Idle { since: Utc::now() }.detail_label(),
"idle"
);
assert_eq!(
AgentState::Completed {
at: Utc::now(),
exit_code: Some(0)
}
.detail_label(),
"done"
);
assert_eq!(
AgentState::Errored {
at: Utc::now(),
error_hint: None
}
.detail_label(),
"error"
);
}