YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
refactor(redact): remove the OCR/text-driven on-serve image blur path (#4370)
Louis Beaumont2c41cccff29e
diff --git a/crates/screenpipe-core/src/pii_removal.rs b/crates/screenpipe-core/src/pii_removal.rsindex 5fc54faf7..28c877ea0 100644--- a/crates/screenpipe-core/src/pii_removal.rs+++ b/crates/screenpipe-core/src/pii_removal.rs@@ -1,6 +1,5 @@use lazy_static::lazy_static;use regex::{Regex, RegexSet};-use serde::{Deserialize, Serialize};use std::collections::HashMap;lazy_static! {@@ -170,21 +169,6 @@ lazy_static! {).unwrap();}-/// Represents a region in an image that contains PII and should be redacted-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]-pub struct PiiRegion {- /// X coordinate (pixels from left)- pub x: u32,- /// Y coordinate (pixels from top)- pub y: u32,- /// Width of the region in pixels- pub width: u32,- /// Height of the region in pixels- pub height: u32,- /// Type of PII detected (e.g., "CREDIT_CARD", "SSN", "EMAIL")- pub pii_type: String,-}-pub fn remove_pii(text: &str) -> String {// Fast path: single RegexSet DFA pass checks all patterns at once.// Most captured text has zero PII, so we avoid 27 individual replace_all calls.@@ -246,94 +230,6 @@ pub fn get_pii_type(text: &str) -> Option<String> {None}-/// Detect PII regions from OCR text_json output with bounding boxes.-///-/// The text_json is expected to contain entries with:-/// - "text": the recognized text-/// - "left", "top", "width", "height": bounding box (can be normalized 0-1 or pixels)-///-/// If coordinates are normalized (0-1 range), they will be converted to pixels-/// using the provided image dimensions.-///-/// # Arguments-/// * `text_json` - Vector of HashMaps containing OCR results with bounding boxes-/// * `image_width` - Width of the image in pixels-/// * `image_height` - Height of the image in pixels-///-/// # Returns-/// Vector of PiiRegion structs representing areas to redact-pub fn detect_pii_regions(- text_json: &[HashMap<String, String>],- image_width: u32,- image_height: u32,-) -> Vec<PiiRegion> {- let mut regions = Vec::new();-- for entry in text_json {- let text = match entry.get("text") {- Some(t) => t,- None => continue,- };-- // Check if this text contains PII- let pii_type = match get_pii_type(text) {- Some(t) => t,- None => continue,- };-- // Parse bounding box coordinates- let left = match entry.get("left").and_then(|v| v.parse::<f64>().ok()) {- Some(v) => v,- None => continue,- };- let top = match entry.get("top").and_then(|v| v.parse::<f64>().ok()) {- Some(v) => v,- None => continue,- };- let width = match entry.get("width").and_then(|v| v.parse::<f64>().ok()) {- Some(v) => v,- None => continue,- };- let height = match entry.get("height").and_then(|v| v.parse::<f64>().ok()) {- Some(v) => v,- None => continue,- };-- // Determine if coordinates are normalized (0-1) or pixel values- // Apple OCR returns normalized, Tesseract returns pixels- let (x_px, y_px, w_px, h_px) = if left <= 1.0 && top <= 1.0 && width <= 1.0 && height <= 1.0- {- // Normalized coordinates (Apple OCR style)- // Note: Apple's coordinate system has origin at bottom-left, so we need to flip Y- let x = (left * image_width as f64) as u32;- let y = ((1.0 - top - height) * image_height as f64) as u32;- let w = (width * image_width as f64) as u32;- let h = (height * image_height as f64) as u32;- (x, y, w, h)- } else {- // Pixel coordinates (Tesseract style)- (left as u32, top as u32, width as u32, height as u32)- };-- // Add some padding around the region for better coverage- let padding = 5u32;- let x_padded = x_px.saturating_sub(padding);- let y_padded = y_px.saturating_sub(padding);- let w_padded = (w_px + padding * 2).min(image_width - x_padded);- let h_padded = (h_px + padding * 2).min(image_height - y_padded);-- regions.push(PiiRegion {- x: x_padded,- y: y_padded,- width: w_padded,- height: h_padded,- pii_type,- });- }-- regions-}-#[cfg(test)]mod tests {use super::*;@@ -394,112 +290,6 @@ mod tests {assert_eq!(get_pii_type("Hello World"), None);}- #[test]- fn test_detect_pii_regions_credit_card_normalized() {- // Simulating Apple OCR output with normalized coordinates- let text_json = vec![HashMap::from([- ("text".to_string(), "4532-1234-5678-9012".to_string()),- ("left".to_string(), "0.1".to_string()),- ("top".to_string(), "0.8".to_string()), // Apple has bottom-left origin- ("width".to_string(), "0.3".to_string()),- ("height".to_string(), "0.05".to_string()),- ])];-- let regions = detect_pii_regions(&text_json, 1920, 1080);-- assert_eq!(regions.len(), 1);- assert_eq!(regions[0].pii_type, "CREDIT_CARD");- // With padding of 5px, x should be (0.1 * 1920) - 5 = 192 - 5 = 187- assert!(regions[0].x > 0);- assert!(regions[0].width > 0);- assert!(regions[0].height > 0);- }-- #[test]- fn test_detect_pii_regions_pixel_coordinates() {- // Simulating Tesseract output with pixel coordinates- let text_json = vec![HashMap::from([- ("text".to_string(), "[email protected]".to_string()),- ("left".to_string(), "100".to_string()),- ("top".to_string(), "200".to_string()),- ("width".to_string(), "300".to_string()),- ("height".to_string(), "50".to_string()),- ])];-- let regions = detect_pii_regions(&text_json, 1920, 1080);-- assert_eq!(regions.len(), 1);- assert_eq!(regions[0].pii_type, "EMAIL");- // With padding, x should be 100 - 5 = 95- assert_eq!(regions[0].x, 95);- assert_eq!(regions[0].y, 195);- }-- #[test]- fn test_detect_pii_regions_multiple() {- let text_json = vec![- HashMap::from([- ("text".to_string(), "4532-1234-5678-9012".to_string()),- ("left".to_string(), "100".to_string()),- ("top".to_string(), "100".to_string()),- ("width".to_string(), "200".to_string()),- ("height".to_string(), "30".to_string()),- ]),- HashMap::from([- ("text".to_string(), "123-45-6789".to_string()),- ("left".to_string(), "100".to_string()),- ("top".to_string(), "200".to_string()),- ("width".to_string(), "150".to_string()),- ("height".to_string(), "30".to_string()),- ]),- HashMap::from([- ("text".to_string(), "Normal text here".to_string()),- ("left".to_string(), "100".to_string()),- ("top".to_string(), "300".to_string()),- ("width".to_string(), "200".to_string()),- ("height".to_string(), "30".to_string()),- ]),- ];-- let regions = detect_pii_regions(&text_json, 1920, 1080);-- assert_eq!(regions.len(), 2);- assert_eq!(regions[0].pii_type, "CREDIT_CARD");- assert_eq!(regions[1].pii_type, "SSN");- }-- #[test]- fn test_detect_pii_regions_no_pii() {- let text_json = vec![HashMap::from([- ("text".to_string(), "Hello World".to_string()),- ("left".to_string(), "100".to_string()),- ("top".to_string(), "100".to_string()),- ("width".to_string(), "200".to_string()),- ("height".to_string(), "30".to_string()),- ])];-- let regions = detect_pii_regions(&text_json, 1920, 1080);- assert!(regions.is_empty());- }-- #[test]- fn test_detect_pii_regions_missing_coordinates() {- let text_json = vec![HashMap::from([- ("text".to_string(), "4532-1234-5678-9012".to_string()),- // Missing bounding box coordinates- ])];-- let regions = detect_pii_regions(&text_json, 1920, 1080);- assert!(regions.is_empty());- }-- #[test]- fn test_detect_pii_regions_empty_input() {- let text_json: Vec<HashMap<String, String>> = vec![];- let regions = detect_pii_regions(&text_json, 1920, 1080);- assert!(regions.is_empty());- }-// ==================== NEW PATTERN TESTS ====================#[test]diff --git a/crates/screenpipe-engine/src/routes/frames.rs b/crates/screenpipe-engine/src/routes/frames.rsindex eb36ebcd1..27d49dc84 100644--- a/crates/screenpipe-engine/src/routes/frames.rs+++ b/crates/screenpipe-engine/src/routes/frames.rs@@ -11,14 +11,11 @@ use axum::{use oasgen::{oasgen, OaSchema};use chrono::{DateTime, Utc};-use screenpipe_core::pii_removal::detect_pii_regions;use screenpipe_db::TextPosition;-use image::GenericImageView;use serde::{Deserialize, Serialize};use serde_json::{json, Value};use std::{- collections::HashMap,sync::Arc,time::{Duration, Instant},};@@ -26,75 +23,66 @@ use tokio::fs::File;use tokio_util::io::ReaderStream;use tracing::{debug, error};-use crate::{- server::AppState,- video_utils::{extract_frame_from_video, redact_frame_pii},-};+use crate::{server::AppState, video_utils::extract_frame_from_video};use tokio::time::timeout;-/// Query parameters for frame retrieval-#[derive(Debug, Deserialize, OaSchema)]-pub struct GetFrameQuery {- /// If true, blur/redact any detected PII (credit cards, SSNs, emails) in the frame- #[serde(default)]- pub redact_pii: bool,-}-#[oasgen]pub async fn get_frame_data(State(state): State<Arc<AppState>>,Path(frame_id): Path<i64>,- Query(query): Query<GetFrameQuery>,) -> Result<Response<Body>, (StatusCode, JsonResponse<Value>)> {let start_time = Instant::now();match timeout(Duration::from_secs(5), async {- // Skip cache if redact_pii is requested (need fresh processing)- if !query.redact_pii {- // Try to get frame from cache if enabled- if let Some(cache) = &state.frame_image_cache {- let cache_result = cache.try_lock();- match cache_result {- Ok(mut cache) => {- if let Some((file_path, timestamp)) = cache.get(&frame_id) {- // Increased TTL from 5 minutes to 30 minutes.- // Frames are immutable once captured, so longer caching is safe- // and significantly improves timeline scrolling performance.- if timestamp.elapsed() < Duration::from_secs(1800) {- let path_owned = file_path.clone();- drop(cache);- match serve_file(&path_owned).await {- Ok(resp) => {- debug!(- "Cache hit for frame_id: {}. Retrieved in {:?}",- frame_id,- start_time.elapsed()- );- return Ok(resp);- }- Err(_) => {- // File was deleted (e.g. by compaction) — evict stale entry- // and fall through to DB lookup for updated path- debug!(- "Cache stale for frame_id: {} (file gone), evicting",- frame_id- );- if let Ok(mut cache) =- state.frame_image_cache.as_ref().unwrap().try_lock()- {- cache.pop(&frame_id);- }+ // Frame images are redacted AT REST by the image-PII worker+ // (rfdetr → black boxes, atomic overwrite) when "AI PII removal" is+ // on, so serving the file already serves the redacted pixels — no+ // per-request redaction step. (The old text/OCR-driven on-serve blur+ // was removed: it only worked on OCR-fallback frames and was a second+ // unreliable path. Screenshot redaction relies on the image model.)+ // Try to get frame from cache if enabled.+ if let Some(cache) = &state.frame_image_cache {+ let cache_result = cache.try_lock();+ match cache_result {+ Ok(mut cache) => {+ if let Some((file_path, timestamp)) = cache.get(&frame_id) {+ // Increased TTL from 5 minutes to 30 minutes.+ // Frames are immutable once captured, so longer caching is safe+ // and significantly improves timeline scrolling performance.+ if timestamp.elapsed() < Duration::from_secs(1800) {+ let path_owned = file_path.clone();+ drop(cache);+ match serve_file(&path_owned).await {+ Ok(resp) => {+ debug!(+ "Cache hit for frame_id: {}. Retrieved in {:?}",+ frame_id,+ start_time.elapsed()+ );+ return Ok(resp);+ }+ Err(_) => {+ // File was deleted (e.g. by compaction) — evict stale entry+ // and fall through to DB lookup for updated path+ debug!(+ "Cache stale for frame_id: {} (file gone), evicting",+ frame_id+ );+ if let Ok(mut cache) =+ state.frame_image_cache.as_ref().unwrap().try_lock()+ {+ cache.pop(&frame_id);}}- } else {- cache.pop(&frame_id);}+ } else {+ cache.pop(&frame_id);}}- Err(_) => {- debug!("Cache lock contention for frame_id: {}", frame_id);- }+ }+ Err(_) => {+ debug!("Cache lock contention for frame_id: {}", frame_id);}}}@@ -136,9 +124,6 @@ pub async fn get_frame_data(// Snapshot frame — serve JPEG directly (no ffmpeg needed)match serve_file(&file_path).await {Ok(resp) => {- if query.redact_pii {- return apply_pii_redaction(&state, frame_id, &file_path).await;- }// Cache snapshot pathif let Some(cache) = &state.frame_image_cache {if let Ok(mut cache) = cache.try_lock() {@@ -158,9 +143,7 @@ pub async fn get_frame_data("Snapshot file missing for frame {}, trying nearest frame",frame_id);- if let Some(fallback) =- try_nearest_frame(&state, frame_id, query.redact_pii).await- {+ if let Some(fallback) = try_nearest_frame(&state, frame_id).await {return Ok(fallback);}return Err((@@ -176,14 +159,8 @@ pub async fn get_frame_data(}// Legacy video-chunk frame — extract via ffmpeg- match try_extract_and_serve_frame(- &state,- frame_id,- &file_path,- offset_index,- query.redact_pii,- )- .await+ match try_extract_and_serve_frame(&state, frame_id, &file_path, offset_index)+ .await{Ok(response) => {debug!("Frame {} extracted in {:?}", frame_id, start_time.elapsed());@@ -195,9 +172,7 @@ pub async fn get_frame_data("Frame {} extraction failed ({}), trying nearest frame",frame_id, e);- if let Some(fallback) =- try_nearest_frame(&state, frame_id, query.redact_pii).await- {+ if let Some(fallback) = try_nearest_frame(&state, frame_id).await {return Ok(fallback);}@@ -283,7 +258,6 @@ async fn try_extract_and_serve_frame(frame_id: i64,file_path: &str,offset_index: i64,- redact_pii: bool,) -> Result<Response<Body>, anyhow::Error> {let _permit = state.frame_extraction_semaphore@@ -294,12 +268,6 @@ async fn try_extract_and_serve_frame(let jpeg_q = crate::video::video_quality_to_jpeg_q(&state.video_quality);let frame_path = extract_frame_from_video(file_path, offset_index, jpeg_q).await?;- if redact_pii {- return apply_pii_redaction(state, frame_id, &frame_path)- .await- .map_err(|(status, _)| anyhow::anyhow!("PII redaction failed: {}", status));- }-// Store in cache if enabledif let Some(cache) = &state.frame_image_cache {if let Ok(mut cache) = cache.try_lock() {@@ -314,11 +282,7 @@ async fn try_extract_and_serve_frame(/// Find the nearest extractable frame by searching backward then forward./// Checks file existence/size before expensive ffmpeg extraction to stay fast.-async fn try_nearest_frame(- state: &Arc<AppState>,- frame_id: i64,- redact_pii: bool,-) -> Option<Response<Body>> {+async fn try_nearest_frame(state: &Arc<AppState>, frame_id: i64) -> Option<Response<Body>> {// Keep small: each miss spawns ffmpeg (~100-500ms). 3 candidates per// direction is enough — the bad frame is almost always at a chunk boundary// so the very next frame in the other chunk works.@@ -341,17 +305,7 @@ async fn try_nearest_frame(if is_snapshot {// Snapshot frame — just check file existsif tokio::fs::metadata(&file_path).await.is_ok() {- if redact_pii {- if let Ok(response) =- apply_pii_redaction(state, candidate_id, &file_path).await- {- debug!(- "Frame {} unavailable, serving nearest snapshot {} ({})",- frame_id, candidate_id, dir_name- );- return Some(response);- }- } else if let Ok(response) = serve_file(&file_path).await {+ if let Ok(response) = serve_file(&file_path).await {debug!("Frame {} unavailable, serving nearest snapshot {} ({})",frame_id, candidate_id, dir_name@@ -368,15 +322,7 @@ async fn try_nearest_frame(_ => continue,}- match try_extract_and_serve_frame(- state,- candidate_id,- &file_path,- offset_index,- redact_pii,- )- .await- {+ match try_extract_and_serve_frame(state, candidate_id, &file_path, offset_index).await {Ok(response) => {debug!("Frame {} unavailable, serving nearest frame {} ({})",@@ -1018,92 +964,6 @@ pub async fn run_frame_ocr(}))}-/// Apply PII redaction to a frame image-pub(crate) async fn apply_pii_redaction(- state: &Arc<AppState>,- frame_id: i64,- frame_path: &str,-) -> Result<Response<Body>, (StatusCode, JsonResponse<Value>)> {- // Read the frame file- let frame_data = match tokio::fs::read(frame_path).await {- Ok(data) => data,- Err(e) => {- error!("Failed to read frame file for PII redaction: {}", e);- return serve_file(frame_path).await; // Fall back to unredacted- }- };-- // Get OCR text_json for this frame- let text_json_str = match state.db.get_frame_ocr_text_json(frame_id).await {- Ok(Some(json)) => json,- Ok(None) => {- debug!("No OCR data for frame {}, serving unredacted", frame_id);- return serve_file(frame_path).await;- }- Err(e) => {- error!("Failed to get OCR data for frame {}: {}", frame_id, e);- return serve_file(frame_path).await;- }- };-- // Parse the text_json- let text_json: Vec<HashMap<String, String>> = match serde_json::from_str(&text_json_str) {- Ok(json) => json,- Err(e) => {- debug!("Failed to parse OCR text_json: {}", e);- return serve_file(frame_path).await;- }- };-- // Get image dimensions- let img = match image::load_from_memory(&frame_data) {- Ok(img) => img,- Err(e) => {- error!("Failed to load image for PII detection: {}", e);- return serve_file(frame_path).await;- }- };- let (width, height) = img.dimensions();-- // Detect PII regions- let pii_regions = detect_pii_regions(&text_json, width, height);-- if pii_regions.is_empty() {- debug!("No PII detected in frame {}", frame_id);- return serve_file(frame_path).await;- }-- debug!(- "Detected {} PII regions in frame {}: {:?}",- pii_regions.len(),- frame_id,- pii_regions.iter().map(|r| &r.pii_type).collect::<Vec<_>>()- );-- // Apply redaction- match redact_frame_pii(&frame_data, &pii_regions) {- Ok(redacted_data) => {- let body = Body::from(redacted_data);- Response::builder()- .header("content-type", "image/jpeg")- .header("cache-control", "no-cache") // Don't cache redacted frames- .header("x-pii-redacted", "true")- .header("x-pii-regions-count", pii_regions.len().to_string())- .body(body)- .map_err(|e| {- (- StatusCode::INTERNAL_SERVER_ERROR,- JsonResponse(json!({"error": format!("Failed to create response: {}", e)})),- )- })- }- Err(e) => {- error!("Failed to redact PII from frame {}: {}", frame_id, e);- serve_file(frame_path).await // Fall back to unredacted- }- }-}-pub(crate) async fn serve_file(path: &str) -> Result<Response, (StatusCode, JsonResponse<Value>)> {match File::open(path).await {Ok(file) => {diff --git a/crates/screenpipe-engine/src/video_utils.rs b/crates/screenpipe-engine/src/video_utils.rsindex a4352bb6e..4896e1b8c 100644--- a/crates/screenpipe-engine/src/video_utils.rs+++ b/crates/screenpipe-engine/src/video_utils.rs@@ -2,16 +2,12 @@ use anyhow::Result;use base64::{engine::general_purpose, Engine as _};use chrono::NaiveDateTime;use chrono::{DateTime, Utc};-use image::codecs::jpeg::JpegEncoder;-use image::{DynamicImage, GenericImageView, Rgba};-use imageproc::filter::gaussian_blur_f32;+use image::DynamicImage;use oasgen::OaSchema;-use screenpipe_core::pii_removal::PiiRegion;use screenpipe_core::{ffmpeg_cmd_async, find_ffmpeg_path};use screenpipe_db::VideoMetadata as DBVideoMetadata;use serde::{Deserialize, Serialize};use std::collections::HashMap;-use std::io::Cursor;use std::path::Path;use std::path::PathBuf;use std::sync::LazyLock;@@ -967,222 +963,3 @@ pub async fn extract_high_quality_frame(Ok(output_path.to_str().unwrap().to_string())}--/// Redact PII regions from a frame image by applying blur-///-/// # Arguments-/// * `image_data` - Raw JPEG image bytes-/// * `regions` - Vector of PII regions to blur-///-/// # Returns-/// Result containing the modified JPEG image bytes-pub fn redact_frame_pii(image_data: &[u8], regions: &[PiiRegion]) -> Result<Vec<u8>> {- if regions.is_empty() {- // No PII to redact, return original- return Ok(image_data.to_vec());- }-- // Load the image- let img = image::load_from_memory(image_data)?;- let mut img_rgba = img.to_rgba8();- let (img_width, img_height) = img_rgba.dimensions();-- for region in regions {- // Validate region bounds- if region.x >= img_width || region.y >= img_height {- continue;- }-- // Clamp region to image bounds- let x = region.x;- let y = region.y;- let w = region.width.min(img_width - x);- let h = region.height.min(img_height - y);-- if w == 0 || h == 0 {- continue;- }-- // Extract the region to blur- let sub_img = img_rgba.view(x, y, w, h).to_image();-- // Apply Gaussian blur (sigma of 10.0 provides strong blur)- let blurred = gaussian_blur_f32(&sub_img, 10.0);-- // Copy blurred region back to the image- for (dx, dy, pixel) in blurred.enumerate_pixels() {- let target_x = x + dx;- let target_y = y + dy;- if target_x < img_width && target_y < img_height {- img_rgba.put_pixel(target_x, target_y, *pixel);- }- }- }-- // Encode back to JPEG- let mut output = Cursor::new(Vec::new());- let mut encoder = JpegEncoder::new_with_quality(&mut output, 85);- encoder.encode_image(&img_rgba)?;-- Ok(output.into_inner())-}--/// Alternative redaction method using solid color overlay instead of blur-/// This is faster but less visually appealing-pub fn redact_frame_pii_solid(image_data: &[u8], regions: &[PiiRegion]) -> Result<Vec<u8>> {- if regions.is_empty() {- return Ok(image_data.to_vec());- }-- let img = image::load_from_memory(image_data)?;- let mut img_rgba = img.to_rgba8();- let (img_width, img_height) = img_rgba.dimensions();-- // Use a dark gray color for redaction- let redact_color = Rgba([40, 40, 40, 255]);-- for region in regions {- if region.x >= img_width || region.y >= img_height {- continue;- }-- let x_end = (region.x + region.width).min(img_width);- let y_end = (region.y + region.height).min(img_height);-- for py in region.y..y_end {- for px in region.x..x_end {- img_rgba.put_pixel(px, py, redact_color);- }- }- }-- let mut output = Cursor::new(Vec::new());- let mut encoder = JpegEncoder::new_with_quality(&mut output, 85);- encoder.encode_image(&img_rgba)?;-- Ok(output.into_inner())-}--#[cfg(test)]-mod pii_redaction_tests {- use super::*;- use image::{ImageBuffer, Rgb};-- fn create_test_jpeg() -> Vec<u8> {- // Create a 100x100 image with a checkerboard pattern so that- // blurring a region actually changes pixel values (a uniform- // white image stays white after Gaussian blur).- let img: ImageBuffer<Rgb<u8>, Vec<u8>> = ImageBuffer::from_fn(100, 100, |x, y| {- if (x / 5 + y / 5) % 2 == 0 {- Rgb([0, 0, 0])- } else {- Rgb([255, 255, 255])- }- });- let dynamic_img = DynamicImage::ImageRgb8(img);-- let mut output = Cursor::new(Vec::new());- let mut encoder = JpegEncoder::new_with_quality(&mut output, 85);- encoder.encode_image(&dynamic_img).unwrap();- output.into_inner()- }-- #[test]- fn test_redact_frame_pii_empty_regions() {- let image_data = create_test_jpeg();- let regions: Vec<PiiRegion> = vec![];-- let result = redact_frame_pii(&image_data, ®ions).unwrap();- assert_eq!(result, image_data);- }-- #[test]- fn test_redact_frame_pii_single_region() {- let image_data = create_test_jpeg();- let regions = vec![PiiRegion {- x: 10,- y: 10,- width: 30,- height: 20,- pii_type: "CREDIT_CARD".to_string(),- }];-- let result = redact_frame_pii(&image_data, ®ions).unwrap();- // Result should be different from original (blurred)- assert_ne!(result, image_data);- // Should still be a valid image- assert!(image::load_from_memory(&result).is_ok());- }-- #[test]- fn test_redact_frame_pii_multiple_regions() {- let image_data = create_test_jpeg();- let regions = vec![- PiiRegion {- x: 10,- y: 10,- width: 20,- height: 15,- pii_type: "CREDIT_CARD".to_string(),- },- PiiRegion {- x: 50,- y: 50,- width: 25,- height: 20,- pii_type: "EMAIL".to_string(),- },- ];-- let result = redact_frame_pii(&image_data, ®ions).unwrap();- assert!(image::load_from_memory(&result).is_ok());- }-- #[test]- fn test_redact_frame_pii_region_at_edge() {- let image_data = create_test_jpeg();- // Region that extends beyond image bounds- let regions = vec![PiiRegion {- x: 90,- y: 90,- width: 50, // Would extend beyond 100px image- height: 50,- pii_type: "SSN".to_string(),- }];-- let result = redact_frame_pii(&image_data, ®ions).unwrap();- assert!(image::load_from_memory(&result).is_ok());- }-- #[test]- fn test_redact_frame_pii_region_outside_bounds() {- let image_data = create_test_jpeg();- // Region completely outside image- let regions = vec![PiiRegion {- x: 200,- y: 200,- width: 50,- height: 50,- pii_type: "EMAIL".to_string(),- }];-- let result = redact_frame_pii(&image_data, ®ions).unwrap();- // Should return valid image unchanged (region was skipped)- assert!(image::load_from_memory(&result).is_ok());- }-- #[test]- fn test_redact_frame_pii_solid() {- let image_data = create_test_jpeg();- let regions = vec![PiiRegion {- x: 10,- y: 10,- width: 30,- height: 20,- pii_type: "CREDIT_CARD".to_string(),- }];-- let result = redact_frame_pii_solid(&image_data, ®ions).unwrap();- assert!(image::load_from_memory(&result).is_ok());- }-}diff --git a/docs/TIMELINE_VIDEO_SPEC.md b/docs/TIMELINE_VIDEO_SPEC.mdindex 90bdb19df..494f9deba 100644--- a/docs/TIMELINE_VIDEO_SPEC.md+++ b/docs/TIMELINE_VIDEO_SPEC.md@@ -304,9 +304,11 @@ This is the fallback for when asset protocol scope doesn't cover the file path.Don't remove the existing endpoint. It serves as:- Fallback for platforms without HEVC browser support (Linux)- Fallback for corrupt video files where `<video>` fails-- Support for PII redaction (`?redact_pii=true`)- Export functionality that needs JPEG frames+Note: frame images are redacted at rest by the image-PII worker (rfdetr →+black boxes); there is no per-request `?redact_pii` query param.+### 5.2 Frontend Changes#### 5.2.1 New Component: `VideoFrameDisplay`diff --git a/docs/mintlify/docs-mintlify-mig-tmp/openapi.yaml b/docs/mintlify/docs-mintlify-mig-tmp/openapi.yamlindex db04ab784..26d32f081 100644--- a/docs/mintlify/docs-mintlify-mig-tmp/openapi.yaml+++ b/docs/mintlify/docs-mintlify-mig-tmp/openapi.yaml@@ -279,11 +279,6 @@ paths:in: pathrequired: truestyle: simple- - name: redact_pii- schema:- type: boolean- in: query- style: formresponses:'200':description: OK@@ -3026,14 +3021,6 @@ components:required:- frame_id- text_positions- GetFrameQuery:- description: Query parameters for frame retrieval- type: object- properties:- redact_pii:- type: boolean- required:- - redact_piiGetSimilarSpeakersRequest:type: objectproperties: