feat: advance login workflow and integration gates
This commit is contained in:
@@ -19,6 +19,8 @@ use ratatui::{
|
||||
const MAX_IMAGE_SIDE: u32 = 480;
|
||||
const MAX_SOURCE_SIDE: u32 = 8_192;
|
||||
const MAX_SOURCE_PIXELS: u64 = 16_777_216;
|
||||
const MAX_ANIMATION_WIDTH: usize = 160;
|
||||
const MAX_ANIMATION_HEIGHT: usize = 64;
|
||||
const FRAME_INTERVAL: Duration = Duration::from_millis(120);
|
||||
|
||||
/// Background state owned by the TUI thread.
|
||||
@@ -189,6 +191,10 @@ struct Automata {
|
||||
|
||||
impl Automata {
|
||||
fn resize(&mut self, width: usize, height: usize) {
|
||||
// Keep procedural state bounded even when a terminal reports an
|
||||
// unusually large window. Rendering remains clipped to this layer.
|
||||
let width = width.min(MAX_ANIMATION_WIDTH);
|
||||
let height = height.min(MAX_ANIMATION_HEIGHT);
|
||||
if self.width == width && self.height == height {
|
||||
return;
|
||||
}
|
||||
@@ -221,11 +227,11 @@ impl Automata {
|
||||
let mut count = 0;
|
||||
for dy in [self.height.wrapping_sub(1), 0, 1] {
|
||||
for dx in [self.width.wrapping_sub(1), 0, 1] {
|
||||
if dx == 0 && dy == 0 {
|
||||
continue;
|
||||
}
|
||||
let nx = (x + dx) % self.width;
|
||||
let ny = (y + dy) % self.height;
|
||||
if nx == x && ny == y {
|
||||
continue;
|
||||
}
|
||||
count += self.current[ny * self.width + nx];
|
||||
}
|
||||
}
|
||||
@@ -264,4 +270,16 @@ mod tests {
|
||||
automata.tick();
|
||||
assert_eq!(automata.current.len(), 32);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn automata_caps_untrusted_terminal_dimensions() {
|
||||
let mut automata = Automata::default();
|
||||
automata.resize(usize::MAX, usize::MAX);
|
||||
assert_eq!(automata.width, MAX_ANIMATION_WIDTH);
|
||||
assert_eq!(automata.height, MAX_ANIMATION_HEIGHT);
|
||||
assert_eq!(
|
||||
automata.current.len(),
|
||||
MAX_ANIMATION_WIDTH * MAX_ANIMATION_HEIGHT
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user