Complete TUI coverage and security audit

This commit is contained in:
Hermes Agent
2026-08-10 11:39:45 +00:00
parent 71bbff934e
commit c2632656bc
10 changed files with 958 additions and 44 deletions

View File

@@ -106,6 +106,7 @@ pub struct GenerateForm {
no_symbols: bool,
overwrite: bool,
in_place: bool,
presentation: GeneratedPresentation,
focus: usize,
}
@@ -297,6 +298,7 @@ impl WorkflowForm {
no_symbols: request.no_symbols,
overwrite: request.force,
in_place: request.in_place,
presentation: request.presentation,
focus: 0,
})
}
@@ -438,6 +440,11 @@ impl WorkflowForm {
row(form.focus == 2, "Symbols", yes_no(!form.no_symbols)),
row(form.focus == 3, "Overwrite", yes_no(form.overwrite)),
row(form.focus == 4, "In place", yes_no(form.in_place)),
row(
form.focus == 5,
"Presentation",
generated_presentation_label(form.presentation),
),
],
Self::Grep(form) => vec![
row(form.focus == 0, "Pattern", &form.pattern),
@@ -605,7 +612,7 @@ impl WorkflowForm {
no_symbols: form.no_symbols,
force: form.overwrite,
in_place: form.in_place,
presentation: GeneratedPresentation::Terminal,
presentation: form.presentation,
},
overwrite: if form.overwrite || form.in_place {
OverwriteDecision::Allow
@@ -708,7 +715,8 @@ impl WorkflowForm {
fn focus_count(&self) -> usize {
match self {
Self::Init(form) => form.recipients.len() + 1,
Self::Insert(_) | Self::Generate(_) => 5,
Self::Insert(_) => 5,
Self::Generate(_) => 6,
Self::Grep(_) => 5,
Self::Remove(_) | Self::Move(_) | Self::Copy(_) => 4,
Self::Otp(_) => 4,
@@ -751,6 +759,13 @@ impl WorkflowForm {
form.overwrite = false;
}
}
Self::Generate(form) if form.focus == 5 => {
form.presentation = match form.presentation {
GeneratedPresentation::Terminal => GeneratedPresentation::Clipboard,
GeneratedPresentation::Clipboard => GeneratedPresentation::QrCode,
GeneratedPresentation::QrCode => GeneratedPresentation::Terminal,
}
}
Self::Grep(form) if form.focus == 1 => form.ignore_case ^= true,
Self::Grep(form) if form.focus == 2 => form.invert_match ^= true,
Self::Grep(form) if form.focus == 3 => form.line_number ^= true,
@@ -892,6 +907,14 @@ fn yes_no(value: bool) -> &'static str {
if value { "yes" } else { "no" }
}
fn generated_presentation_label(presentation: GeneratedPresentation) -> &'static str {
match presentation {
GeneratedPresentation::Terminal => "masked viewer",
GeneratedPresentation::Clipboard => "clipboard with timeout",
GeneratedPresentation::QrCode => "terminal QR",
}
}
#[cfg(test)]
mod tests {
use super::*;
@@ -938,6 +961,25 @@ mod tests {
assert!(generate.submission().is_ok());
type_text(&mut generate, "0");
assert!(generate.submission().unwrap_err().contains("positive"));
let qr = WorkflowForm::generate(Some(GenerateRequest {
entry: "entry".to_owned(),
length: None,
no_symbols: false,
force: false,
in_place: false,
presentation: GeneratedPresentation::QrCode,
}));
assert!(matches!(
qr.submission(),
Ok(WorkflowSubmission::Generate {
request: GenerateRequest {
presentation: GeneratedPresentation::QrCode,
..
},
..
})
));
}
#[test]