Persist Midra workspace setup and captured layer previews
Beffroi/beffroi-tools/pipeline/head This commit looks good Details

This commit is contained in:
Dandaedre 2026-11-15 12:05:51 +01:00
parent ba9a671d65
commit 3fdb9879ad
17 changed files with 707 additions and 61 deletions

View File

@ -53,6 +53,8 @@ struct LayerPreview {
host: String,
source: usize,
texture: Option<egui::TextureHandle>,
bytes: Vec<u8>,
paused: bool,
automatic: bool,
capture_on_selection: bool,
name: String,
@ -92,6 +94,81 @@ pub(super) struct CaptureUi {
discard_result: bool,
}
impl CaptureUi {
pub(super) fn save_workspace(&self, layout: &Layout, w: &mut midra_layout::project::Workspace) {
use base64::Engine;
w.capture_interval_seconds = self.refresh.seconds;
w.show_empty_inputs = self.show_empty_inputs;
w.previews = self
.layers
.iter()
.filter_map(|(&id, p)| {
let i = (0..layout.layers().len()).find(|&i| layout.layer_info(i).id == id)?;
if layout.formats().source_for[i] != p.source {
return None;
}
Some(midra_layout::project::Preview {
layer_id: id,
source_id: p.source + 1,
input: p.input,
// The connection text box may contain an unfinished address.
// It is not a capture binding until it is a valid endpoint.
host: if midra_layout::device::address(&p.host).is_ok() {
p.host.clone()
} else {
String::new()
},
enabled: p.enabled,
automatic: p.automatic,
guide_opacity: p.guides,
name: p.name.clone(),
image_base64: base64::engine::general_purpose::STANDARD.encode(&p.bytes),
})
})
.collect();
}
pub(super) fn from_workspace(
ctx: &egui::Context,
w: &midra_layout::project::Workspace,
) -> Result<Self, String> {
let mut capture = Self::default();
capture.refresh.seconds = w.capture_interval_seconds;
capture.show_empty_inputs = w.show_empty_inputs;
for p in &w.previews {
let bytes = p.bytes()?;
let texture = if bytes.is_empty() {
None
} else {
Some(
super::super::reference::Reference::load(
ctx,
&egui::DroppedFile {
name: p.name.clone(),
bytes: Some(bytes.clone().into()),
..Default::default()
},
)?
.texture,
)
};
capture.layers.insert(
p.layer_id,
LayerPreview {
input: p.input,
host: p.host.clone(),
source: p.source_id - 1,
texture,
bytes,
paused: true,
automatic: p.automatic,
capture_on_selection: false,
name: p.name.clone(),
enabled: p.enabled,
guides: p.guide_opacity,
},
);
}
Ok(capture)
}
pub(super) fn clear_preview(&mut self) {
self.preview = None;
self.capture_on_selection = false;
@ -177,6 +254,7 @@ impl Editor {
.filter(|p| {
p.enabled
&& p.automatic
&& !p.paused
&& p.source == self.layout.formats().source_for[i]
&& p.host == self.device.host
&& available.iter().any(|a| a.id == p.input && a.enabled)
@ -265,6 +343,8 @@ impl Editor {
host: self.device.host.clone(),
source,
texture: None,
bytes: Vec::new(),
paused: false,
automatic: false,
capture_on_selection: false,
name: String::new(),
@ -302,16 +382,19 @@ impl Editor {
host: self.device.host.clone(),
source,
texture: None,
bytes: Vec::new(),
paused: false,
name: String::new(),
enabled: false,
automatic: false,
capture_on_selection: false,
guides: 0.35,
});
if preview.source != source || preview.host != self.device.host {
if preview.source != source {
preview.source = source;
preview.host = self.device.host.clone();
preview.texture = None;
preview.bytes.clear();
preview.name.clear();
preview.automatic = false;
preview.capture_on_selection = false;
@ -322,7 +405,10 @@ impl Editor {
let before = preview.input;
input_picker(ui, ("layer-preview-input", id), &mut preview.input, &inputs, &mut self.capture.show_empty_inputs);
if before != preview.input {
preview.host = self.device.host.clone();
preview.paused = false;
preview.texture = None;
preview.bytes.clear();
preview.name.clear();
preview.capture_on_selection = true;
ui.ctx().request_repaint();
@ -330,7 +416,17 @@ impl Editor {
let available = online && inputs.iter().any(|input| input.id == preview.input && input.enabled);
capture = ui.add_enabled(available && idle && !cooling, egui::Button::new("Capture still"))
.on_hover_text("Fetch the selected input and replace this layer's preview directly.").clicked();
ui.add_enabled(available || preview.automatic, egui::Checkbox::new(&mut preview.automatic, "Auto-refresh this preview"));
if ui.add_enabled(available || preview.automatic, egui::Checkbox::new(&mut preview.automatic, "Auto-refresh this preview")).changed() {
preview.paused = false;
preview.host = self.device.host.clone();
}
if preview.paused && preview.automatic {
ui.small("Saved auto-refresh is paused.");
if ui.add_enabled(available, egui::Button::new("Resume auto-refresh")).clicked() {
preview.paused = false;
preview.host = self.device.host.clone();
}
}
ui.add_enabled(preview.automatic, egui::Slider::new(&mut self.capture.refresh.seconds, 5..=300).text("Request interval").suffix(" s"));
ui.small("One input per interval across automatic previews; shared inputs use one request. Leave auto-refresh off to keep a still.");
let has_image = preview.enabled && preview.texture.is_some();
@ -349,6 +445,9 @@ impl Editor {
ui.colored_label(ui.visuals().error_fg_color, &self.capture.error);
}
if capture {
let preview = self.capture.layers.get_mut(&id).unwrap();
preview.host = self.device.host.clone();
preview.paused = false;
self.capture
.layers
.get_mut(&id)
@ -397,7 +496,7 @@ impl Editor {
})
{
let requested = preview.capture_on_selection
|| preview.automatic
|| (preview.automatic && !preview.paused)
|| direct.as_ref().is_some_and(|(target, source, _, host)| {
*target == *id && *source == preview.source && *host == preview.host
});
@ -407,6 +506,7 @@ impl Editor {
&& let Ok(reference) = &result
{
preview.texture = Some(reference.texture.clone());
preview.bytes = reference.bytes.clone();
preview.name = reference.name.clone();
}
}
@ -442,7 +542,7 @@ impl Editor {
.capture
.layers
.values()
.any(|p| p.enabled && (p.automatic || p.capture_on_selection))
.any(|p| p.enabled && ((p.automatic && !p.paused) || p.capture_on_selection))
|| self.capture.capture_on_selection
{
ctx.request_repaint_after(std::time::Duration::from_secs(1));
@ -559,6 +659,8 @@ impl Editor {
host: self.device.host.clone(),
source: self.layout.formats().source_for[i],
texture: Some(reference.texture.clone()),
bytes: reference.bytes.clone(),
paused: false,
automatic: self.capture.keep_refreshing,
capture_on_selection: false,
name: reference.name.clone(),
@ -589,6 +691,94 @@ impl Editor {
mod tests {
use super::super::tests::{click_text, frame};
use super::*;
#[test]
fn project_restores_capture_stills_and_settings_without_network_work() {
use midra_layout::project::Project;
let ctx = egui::Context::default();
let reference = tiny_reference(&ctx, "Input 4 still");
let mut app = Editor::default();
app.device.host = "192.168.10.146:3000".into();
let id = app.layout.layer_info(0).id;
app.capture.layers.insert(
id,
LayerPreview {
input: 4,
host: app.device.host.clone(),
source: app.layout.formats().source_for[0],
texture: Some(reference.texture),
bytes: reference.bytes.clone(),
paused: false,
automatic: true,
capture_on_selection: false,
name: reference.name,
enabled: true,
guides: 0.27,
},
);
app.capture.refresh.seconds = 31;
app.capture.show_empty_inputs = true;
app.snapping.grid_divisions = [13, 7];
let saved = app.project();
let mut restored = Editor::default();
restored
.install_project(&ctx, Project::from_json(&saved.to_json().unwrap()).unwrap())
.unwrap();
assert_eq!(restored.project(), saved);
assert_eq!(restored.capture.layers[&id].bytes, reference.bytes);
assert!(restored.layer_preview(0).is_some());
assert!(restored.capture.layers[&id].paused);
assert!(restored.capture.pending.is_none());
assert!(restored.capture.last_request.is_none());
restored.device.host = app.device.host;
restored.device.snapshot = Some(midra_layout::device::Snapshot {
identity: "Eikos4K".into(),
screens: Vec::new(),
raw: serde_json::json!({"device":{"inputList":{"items":{
"INPUT_4":{"status":{"pp":{"isAvailable":true,"plug":"1"}},"snapshot":{"pp":{"enable":true}}}
}}}}),
});
assert!(restored.next_selection_capture().is_none());
assert!(restored.next_preview_refresh().is_none());
restored.capture.layers.get_mut(&id).unwrap().paused = false;
assert_eq!(restored.next_preview_refresh(), Some(4));
let mut invalid = saved.clone();
invalid.workspace.previews[0].image_base64 = "bm90IGFuIGltYWdl".into();
assert!(restored.install_project(&ctx, invalid).is_err());
assert_eq!(restored.project(), saved);
restored
.install_project(&ctx, Project::from_layout(&Layout::default()))
.unwrap();
assert!(restored.capture.layers.is_empty());
assert!(restored.layer_preview(0).is_none());
}
#[test]
fn saving_ignores_stale_capture_sources_and_unfinished_connection_text() {
let mut app = Editor::default();
let id = app.layout.layer_info(0).id;
app.capture.layers.insert(
id,
LayerPreview {
input: 0,
host: "192.168.".into(),
source: app.layout.formats().source_for[0],
texture: None,
bytes: Vec::new(),
paused: false,
automatic: false,
capture_on_selection: false,
name: String::new(),
enabled: false,
guides: 0.35,
},
);
let saved = app.project();
assert!(saved.workspace.previews[0].host.is_empty());
assert!(saved.to_json().is_ok());
app.capture.layers.get_mut(&id).unwrap().source = usize::MAX;
assert!(app.project().workspace.previews.is_empty());
}
#[test]
fn linked_input_preselection_is_inert_and_preserves_operator_choices() {
let mut app = Editor::default();
@ -831,6 +1021,8 @@ mod tests {
host: app.device.host.clone(),
source: app.layout.formats().source_for[i],
texture: None,
bytes: Vec::new(),
paused: false,
automatic: false,
capture_on_selection: true,
name: String::new(),
@ -843,6 +1035,7 @@ mod tests {
for preview in app.capture.layers.values_mut() {
preview.capture_on_selection = true;
preview.texture = None;
preview.bytes.clear();
}
app.capture.last_request = Some(std::time::Instant::now());
let (tx, rx) = std::sync::mpsc::channel();
@ -905,6 +1098,8 @@ mod tests {
host: app.device.host.clone(),
source: app.layout.formats().source_for[i],
texture: None,
bytes: Vec::new(),
paused: false,
name: String::new(),
enabled: true,
automatic: i == 0,
@ -1177,6 +1372,8 @@ mod tests {
input,
host: app.device.host.clone(),
source: app.layout.formats().source_for[i],
bytes: Vec::new(),
paused: false,
texture: Some(ctx.load_texture(
format!("Input {input}"),
egui::ColorImage::new([2, 2], Color32::RED),
@ -1236,6 +1433,8 @@ mod tests {
host: app.device.host.clone(),
source: app.layout.formats().source_for[i],
texture: Some(texture),
bytes: Vec::new(),
paused: false,
automatic: false,
capture_on_selection: false,
name: "Input still".into(),

View File

@ -33,7 +33,8 @@ pub enum ResizeHandle {
Right,
}
/// How a handle drag affects selected layers.
#[derive(Clone, Copy, Debug, Default, PartialEq)]
#[derive(Clone, Copy, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ResizeMode {
#[default]
Individual,

View File

@ -107,9 +107,55 @@ fn deserialize_layer_point<'de, D: serde::Deserializer<'de>>(
) -> Result<Option<PositionPoint>, D::Error> {
Option::<PositionPoint>::deserialize(deserializer)
}
/// Project-specific working setup; network jobs and connections are never restored.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Workspace {
pub snapping: crate::snapping::Snapping,
pub resize_mode: crate::ResizeMode,
pub grid_spacing: Option<u32>,
pub collapsed_folders: Vec<String>,
pub capture_interval_seconds: u64,
pub show_empty_inputs: bool,
pub previews: Vec<Preview>,
}
impl Default for Workspace {
fn default() -> Self {
Self {
snapping: Default::default(),
resize_mode: Default::default(),
grid_spacing: None,
collapsed_folders: Vec::new(),
capture_interval_seconds: 10,
show_empty_inputs: false,
previews: Vec::new(),
}
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Preview {
pub layer_id: usize,
pub source_id: usize,
pub input: u32,
pub host: String,
pub enabled: bool,
pub automatic: bool,
pub guide_opacity: f32,
pub name: String,
pub image_base64: String,
}
impl Preview {
pub fn bytes(&self) -> Result<Vec<u8>, String> {
STANDARD
.decode(&self.image_base64)
.map_err(|e| format!("Invalid preview image: {e}"))
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Project {
pub workspace: Workspace,
pub format: String,
pub version: u32,
pub next_layer_id: usize,
@ -122,8 +168,9 @@ pub struct Project {
impl Project {
pub fn from_layout(layout: &Layout) -> Self {
Self {
workspace: Workspace::default(),
format: FORMAT.into(),
version: 10,
version: 11,
next_layer_id: layout.next_id,
output_resolution: layout.formats.output.into(),
inputs: (0..layout.formats.sources.len())
@ -172,9 +219,9 @@ impl Project {
}
/// Build a fresh document only after validating the entire file. No history is restored.
pub fn layout(&self) -> Result<Layout, String> {
if self.format != FORMAT || self.version != 10 {
if self.format != FORMAT || self.version != 11 {
return Err(
"Unsupported project format/version; expected beffroi.midra-layout version 10."
"Unsupported project format/version; expected beffroi.midra-layout version 11."
.into(),
);
}
@ -286,8 +333,44 @@ impl Project {
for r in &self.references {
reference_bytes += r.bytes()?.len();
}
let w = &self.workspace;
if !(5..=300).contains(&w.capture_interval_seconds)
|| w.snapping
.grid_divisions
.iter()
.any(|n| !(1..=64).contains(n))
|| w.grid_spacing.is_some_and(|n| ![10, 100].contains(&n))
{
return Err("Invalid workspace grid or capture interval.".into());
}
let mut folders = std::collections::BTreeSet::new();
for folder in &w.collapsed_folders {
if folder.is_empty()
|| !folders.insert(folder)
|| !self.layers.iter().any(|l| &l.folder == folder)
{
return Err("Collapsed folders must be unique existing folders.".into());
}
}
let mut ids = std::collections::BTreeSet::new();
for preview in &w.previews {
if !ids.insert(preview.layer_id)
|| !self
.layers
.iter()
.any(|l| l.id == preview.layer_id && l.source_id == preview.source_id)
|| preview.input > 1024
|| (!preview.host.is_empty() && crate::device::address(&preview.host).is_err())
|| !preview.guide_opacity.is_finite()
|| !(0.0..=1.0).contains(&preview.guide_opacity)
|| preview.name.len() > 1024
{
return Err("Invalid layer preview assignment or settings.".into());
}
reference_bytes += preview.bytes()?.len();
}
if reference_bytes > 64 * 1024 * 1024 {
return Err("Reference images exceed the combined 64 MiB limit.".into());
return Err("Reference and preview images exceed the combined 64 MiB limit.".into());
}
Ok(layout)
}
@ -309,8 +392,8 @@ impl Project {
}
let header: Header =
serde_json::from_str(text).map_err(|e| format!("Invalid project JSON: {e}"))?;
if !(1..=10).contains(&header.version) {
return Err("Unsupported project version; expected versions 1–10.".into());
if !(1..=11).contains(&header.version) {
return Err("Unsupported project version; expected versions 1–11.".into());
}
let mut migrated: serde_json::Value = if header.version == 1 || header.version == 2 {
let mut value: serde_json::Value =
@ -452,6 +535,17 @@ impl Project {
);
object.insert("version".into(), 10.into());
}
if header.version <= 10 {
let object = migrated.as_object_mut().ok_or("Invalid project")?;
if object.contains_key("workspace") {
return Err("Unexpected workspace in old project".into());
}
object.insert(
"workspace".into(),
serde_json::to_value(Workspace::default()).unwrap(),
);
object.insert("version".into(), 11.into());
}
let p: Self =
serde_json::from_value(migrated).map_err(|e| format!("Invalid project JSON: {e}"))?;
p.layout()?;

View File

@ -4,6 +4,7 @@ use midra_layout::project::{Project, Reference as SavedReference, write_file};
use std::path::PathBuf;
pub(super) struct PreparedProject {
project: Project,
capture: capture_ui::CaptureUi,
layout: Layout,
references: Vec<super::super::reference::Reference>,
}
@ -49,7 +50,9 @@ impl PreparedProject {
Ok::<_, String>(reference)
})
.collect::<Result<Vec<_>, _>>()?;
let capture = capture_ui::CaptureUi::from_workspace(ctx, &project.workspace)?;
Ok(Self {
capture,
project,
layout,
references,
@ -81,6 +84,17 @@ impl Editor {
offset: r.offset,
})
.collect();
p.workspace.snapping = self.snapping;
p.workspace.resize_mode = self.resize_mode;
p.workspace.grid_spacing = self.grid_tool;
p.workspace.collapsed_folders = self
.layer_ui
.collapsed
.iter()
.filter(|folder| p.layers.iter().any(|l| &l.folder == *folder))
.cloned()
.collect();
self.capture.save_workspace(&self.layout, &mut p.workspace);
p
}
pub(super) fn install_project(
@ -103,6 +117,7 @@ impl Editor {
);
}
let PreparedProject {
capture,
project,
layout,
references,
@ -111,15 +126,18 @@ impl Editor {
self.device.reset_mappings();
self.device.input_edits.clear();
self.capture.clear_preview();
let mut layer_ui = layers_ui::LayerUi::default();
layer_ui.collapsed = project.workspace.collapsed_folders.into_iter().collect();
// Replace only after both the document and embedded images are ready.
*self = Self {
device: std::mem::take(&mut self.device),
capture: std::mem::take(&mut self.capture),
capture,
settings: std::mem::take(&mut self.settings),
recovery: std::mem::take(&mut self.recovery),
snapping: self.snapping,
resize_mode: self.resize_mode,
grid_tool: self.grid_tool,
snapping: project.workspace.snapping,
resize_mode: project.workspace.resize_mode,
grid_tool: project.workspace.grid_spacing,
layer_ui,
pivot_tool: self.pivot_tool,
navigation_tool: self.navigation_tool,
layout,
@ -731,7 +749,27 @@ mod tests {
}
#[test]
fn opening_project_preserves_session_resize_choice() {
fn folder_collapse_roundtrip_filters_deleted_folder_names() {
let ctx = egui::Context::default();
let mut project = Project::from_layout(&Layout::default());
project.layers[0].folder = "Memory A".into();
let mut app = Editor::default();
app.install_project(&ctx, project).unwrap();
app.layer_ui
.collapsed
.extend(["Memory A".into(), "Deleted".into()]);
let saved = Project::from_json(&app.project().to_json().unwrap()).unwrap();
assert_eq!(saved.workspace.collapsed_folders, ["Memory A"]);
app.layer_ui.collapsed.clear();
app.install_project(&ctx, saved).unwrap();
assert_eq!(
app.layer_ui.collapsed.into_iter().collect::<Vec<_>>(),
["Memory A"]
);
}
#[test]
fn opening_project_restores_resize_setup_but_preserves_active_tool() {
let ctx = egui::Context::default();
for mode in [ResizeMode::Same, ResizeMode::Mirror, ResizeMode::Opposite] {
let mut app = Editor {
@ -741,8 +779,10 @@ mod tests {
navigation_tool: NavigationTool::Pan,
..Default::default()
};
app.install_project(&ctx, Project::from_layout(&Layout::default()))
.unwrap();
let saved = app.project();
app.resize_mode = ResizeMode::Individual;
app.grid_tool = None;
app.install_project(&ctx, saved).unwrap();
assert_eq!(app.resize_mode, mode);
assert_eq!(app.grid_tool, Some(100));
assert!(app.pivot_tool);

View File

@ -230,7 +230,7 @@ fn persistent_midra_links_roundtrip_migrate_and_undo() {
include_str!("../../../docs/interfaces/midra-layout-v5.example.json"),
] {
let p = Project::from_json(text).unwrap();
assert_eq!(p.version, 10);
assert_eq!(p.version, 11);
assert!(p.layers.iter().all(|l| l.midra_link.is_none()));
}
let mut value = serde_json::to_value(&project).unwrap();
@ -307,7 +307,7 @@ fn position_point_schema_migrates_corners_and_rejects_mislabeled_files() {
.unwrap();
old["editor"]["position_corner"] = name.into();
let loaded = Project::from_json(&old.to_string()).unwrap();
assert_eq!(loaded.version, 10);
assert_eq!(loaded.version, 11);
assert_eq!(loaded.editor.position_point, expected);
old["editor"]["position_corner"] = "center".into();
assert!(Project::from_json(&old.to_string()).is_err());
@ -316,7 +316,7 @@ fn position_point_schema_migrates_corners_and_rejects_mislabeled_files() {
assert!(Project::from_json(&old.to_string()).is_err());
}
let value: serde_json::Value = serde_json::from_str(&current.to_json().unwrap()).unwrap();
for version in [0, 11] {
for version in [0, 12] {
let mut invalid = value.clone();
invalid["version"] = version.into();
assert!(
@ -357,7 +357,7 @@ fn backdrop_title_roundtrips_and_older_projects_gain_the_default() {
}
let old = include_str!("../../../docs/interfaces/midra-layout-v6.example.json");
let migrated = Project::from_json(old).unwrap();
assert_eq!(migrated.version, 10);
assert_eq!(migrated.version, 11);
assert_eq!(migrated.editor.backdrop_title, DEFAULT_BACKDROP_TITLE);
let mut invalid: serde_json::Value = serde_json::from_str(old).unwrap();
invalid["editor"]["backdrop_title"] = "Unexpected".into();
@ -428,7 +428,7 @@ fn saved_pivots_roundtrip_and_old_projects_default_to_center() {
assert_eq!(loaded.layer_info(0).pivot, custom);
assert_eq!(loaded.layer_info(1).pivot, [0.5; 2]);
let example = include_str!("../../../docs/interfaces/midra-layout-v9.example.json");
assert_eq!(Project::from_json(example).unwrap().version, 10);
assert_eq!(Project::from_json(example).unwrap().version, 11);
let old = include_str!("../../../docs/interfaces/midra-layout-v8.example.json");
let migrated = Project::from_json(old).unwrap();
assert!(migrated.layers.iter().all(|l| l.pivot == [0.5; 2]));
@ -460,7 +460,7 @@ fn reference_collection_migrates_single_images_and_rejects_mislabeled_or_oversiz
let reference = serde_json::json!({"name":"guide.png","image_base64":STANDARD.encode(b"image bytes"),"visible":false,"opacity":0.4,"preserve_ratio":true,"native_size":false,"offset":[0.0,0.0]});
old["reference"] = reference.clone();
let migrated = Project::from_json(&old.to_string()).unwrap();
assert_eq!(migrated.version, 10);
assert_eq!(migrated.version, 11);
assert_eq!(migrated.references.len(), 1);
assert!(!migrated.references[0].visible);
assert_eq!(migrated.references[0].opacity, 0.4);
@ -480,7 +480,7 @@ fn reference_collection_migrates_single_images_and_rejects_mislabeled_or_oversiz
gallery.references = vec![migrated.references[0].clone(); 33];
assert!(gallery.to_json().unwrap_err().contains("32 reference"));
let example = include_str!("../../../docs/interfaces/midra-layout-v10.example.json");
assert_eq!(Project::from_json(example).unwrap().version, 10);
assert_eq!(Project::from_json(example).unwrap().version, 11);
}
#[test]
@ -527,3 +527,78 @@ fn editor_inputs_grow_independently_and_roundtrip_with_undo() {
);
assert_eq!(layout.formats(), &before);
}
#[test]
fn workspace_roundtrip_migration_and_validation() {
use midra_layout::project::{Preview, Workspace};
let old = include_str!("../../../docs/interfaces/midra-layout-v10.example.json");
let migrated = Project::from_json(old).unwrap();
assert_eq!(migrated.workspace, Workspace::default());
let current = include_str!("../../../docs/interfaces/midra-layout-v11.example.json");
assert_eq!(Project::from_json(current).unwrap(), migrated);
let mut p = Project::from_layout(&Layout::default());
p.layers[0].folder = "Memory A".into();
p.workspace.collapsed_folders = vec!["Memory A".into()];
p.workspace.resize_mode = midra_layout::ResizeMode::Opposite;
p.workspace.grid_spacing = Some(100);
p.workspace.snapping.grid_divisions = [13, 7];
p.workspace.snapping.enabled = true;
p.workspace.capture_interval_seconds = 37;
p.workspace.show_empty_inputs = true;
p.workspace.previews.push(Preview {
layer_id: p.layers[0].id,
source_id: p.layers[0].source_id,
input: 8,
host: "192.168.10.146:3000".into(),
enabled: true,
automatic: true,
guide_opacity: 0.27,
name: "Input 8".into(),
image_base64: String::new(),
});
assert_eq!(Project::from_json(&p.to_json().unwrap()).unwrap(), p);
let good = serde_json::to_value(&p).unwrap();
for (path, value) in [
("/workspace/capture_interval_seconds", serde_json::json!(0)),
("/workspace/grid_spacing", serde_json::json!(0)),
(
"/workspace/snapping/grid_divisions/0",
serde_json::json!(65),
),
("/workspace/resize_mode", serde_json::json!("unknown")),
(
"/workspace/collapsed_folders/0",
serde_json::json!("missing"),
),
("/workspace/previews/0/layer_id", serde_json::json!(999)),
("/workspace/previews/0/source_id", serde_json::json!(999)),
("/workspace/previews/0/input", serde_json::json!(1025)),
(
"/workspace/previews/0/host",
serde_json::json!("https://example.org/"),
),
(
"/workspace/previews/0/guide_opacity",
serde_json::json!(1.1),
),
(
"/workspace/previews/0/image_base64",
serde_json::json!("!bad"),
),
] {
let mut bad = good.clone();
*bad.pointer_mut(path).unwrap() = value;
assert!(Project::from_json(&bad.to_string()).is_err(), "{path}");
}
let mut bad = p.clone();
bad.workspace
.previews
.push(bad.workspace.previews[0].clone());
assert!(bad.to_json().is_err());
let mut old: serde_json::Value = serde_json::from_str(old).unwrap();
old["workspace"] = good["workspace"].clone();
assert!(Project::from_json(&old.to_string()).is_err());
let mut missing = good.clone();
missing.as_object_mut().unwrap().remove("workspace");
assert!(Project::from_json(&missing.to_string()).is_err());
}

View File

@ -68,7 +68,7 @@ Changing device address/disconnecting invalidates the pending preview; input cha
clear the old preview. A cancelled/late result cannot become a new reference.
The initial image name contains the input number and configured device IP.
Added stills use the existing [project v10 reference object](midra-layout.md):
Added stills use the existing [project reference object](midra-layout.md):
name, embedded PNG image_base64, visible, opacity, preserve_ratio,
native_size, offset. No new fields, version or migration are needed.
**Import into layer** assigns a session-only still texture to the destination
@ -80,7 +80,7 @@ Reordering layers does not move an assignment to another layer.
In the layer Preview tab, the workflow is **Enable input preview → Input →
automatic first still → optional Capture still / Auto-refresh this preview**. Enable and auto-refresh are separate
per-layer session booleans. An enabled preview may have an input selected but no
per-layer booleans saved in project version 11. An enabled preview may have an input selected but no
texture yet. Capture still directly replaces only that layer's texture; repeating
it recaptures. Auto-refresh can fetch the first image without a manual capture.
The physical input picker uses available device inputs and is unrelated to the
@ -89,7 +89,7 @@ Manual jobs bind to the layer's stable ID, source identity, physical input and
host at request time; selection changes do not redirect results. Changed/removed
assignments and disabled previews reject late results. Disabling a preview hides
its image and pauses requests without losing its still or chosen opacity. **Crop guide
opacity** is a per-layer session value from 0–100%, initially 35% when assigned.
opacity** is a per-layer saved value from 0–100%, initially 35% when assigned.
The source test-pattern guides paint above the image; selection borders/handles
remain opaque. When the preview is hidden or absent, the slider is disabled at
100% and the original opaque pattern is used. Showing the preview again restores
@ -99,13 +99,13 @@ tab in Layer properties. That tab contains capture, auto-refresh, visibility and
guide-opacity controls; Crop contains geometry controls. Opening Preview does not
activate visual crop editing. The layer context menu also exposes preview controls.
Layer-preview assignments, texture bytes, visibility toggles and guide opacity
are not saved/exported. Add as reference remains the separate persistent path;
Layer-preview assignments, original image bytes, visibility toggles and guide opacity
are saved in project version 11, but omitted from geometry exports. Add as reference remains the fixed-reference path;
generic artwork exports include those references only through the existing
background option. Reloading a project makes no capture requests.
**Auto-refresh this preview** is opt-in per layer and session-only, with a shared request interval
**Auto-refresh this preview** is opt-in per layer and restored paused, with a shared request interval
of 5–300 seconds (default 10). Assignments also retain the device address and
physical input number in memory. Visible layers with enabled automatic previews, unchanged
physical input number in the project. Visible layers with enabled automatic previews, unchanged
local inputs and the current device address are eligible; unavailable or
snapshot-disabled inputs are skipped. Unique inputs refresh round-robin, one
request per interval. Every completed capture (manual, selection or timer) shares
@ -130,9 +130,9 @@ Manual, selection and automatic capture share one worker slot and the five-secon
Automatic capture pauses offline, during project loading and while the capture
dialog is open. Errors retain the last good image and wait for the next interval;
there are no immediate retries. Turning off refresh prevents applying an in-flight
automatic result. Project replacement clears assignments and discards stale results.
automatic result. Project replacement restores saved assignments and discards stale results.
Automatic refresh never changes fixed references or device settings. Timer settings
are not persisted; no save schema changes are involved.
are persisted in project version 11. Saved automatic previews stay paused until an explicit capture or resume; opening a project makes no device requests.
Live feeds and separate image-file saving are not implemented.
After successful connection/linked load or device-layer import, untouched layer
@ -140,5 +140,4 @@ preview controls preselect the linked device layer’s `INPUT_n` source when tha
physical input is available. Signal presence is not required. Existing selections
are preserved; no texture, enabled flag, auto-refresh flag or capture-on-selection
request is created. Opening/enabling these controls does not fetch the preselected
input; Capture still or explicit auto-refresh starts capture. This is session-only
state and does not change project or settings schemas.
input; Capture still or explicit auto-refresh starts capture. The preselected input is saved with the preview assignment in project version 11.

View File

@ -3,7 +3,7 @@
The Export menu writes **SVG v2**, **draw.io v1**, **geometry JSON v1**,
**geometry CSV v1**, **DXF/DWG**, **HTML/CSS v1**, **PPTX**, **Figma FIG** and
**Illustrator AI** (the latter via a local VectorCraft CLI). Project
JSON is version 10 and is the full-fidelity save format. These exchanges
JSON is version 11 and is the full-fidelity save format. These exchanges
preserve layer **visible-box geometry**, not sources, crop settings, zoom, pivots,
Midra links, locks, visibility, camera or selection. Pictures illustrate current
cropping; importing a picture does not reconstruct its crop or source settings.
@ -381,7 +381,7 @@ and Autodesk's [DXF group-code reference](https://help.autodesk.com/cloudhelp/20
Multiple references are flattened into the same single background image in
artwork-capable exports; no format version changes. Reimport reconstructs that
background as a geometry/artwork item, not the editable reference collection.
Use project JSON v10 to preserve independent images and visibility.
Use project JSON v11 to preserve independent images and visibility.
### QCAD interoperability check

View File

@ -0,0 +1,44 @@
# Midra Layout persistence audit
Audited against the editor, project loader, application settings, capture controls,
layer tree, format properties, import/export controls and device transfer state.
Implemented with [project version 11](midra-layout.md). This is an ownership audit:
not every control should become document data.
| Parameters | Owner and decision |
| --- | --- |
| Output resolution / aspect | Project: exact width/height. The output aspect preset is derived from them, not stored twice. |
| Layer position, dimensions, stacking order | Project: full-precision bounds and array order; display/export rounding never changes the saved values. |
| Input format, native dimensions, custom input crop, shared input slot | Project: `inputs` and layer `source_id`, already saved. |
| Layer format, dynamic crop, zoom and offset | Project: final bounds and advanced crop, already saved. Zoom/offset/aspect are derived from these authoritative values. |
| Names, stable IDs, next ID, folder membership, visibility, lock, pivot | Project, already saved. Folder visibility/locking acts on members, so there is no separate state to save. Empty folders are not document objects. |
| Device screen/layer mapping | Project, already saved per layer. Physical source routing is separate and is not silently changed by a geometry send. |
| Reference images, order, visibility, opacity, fit/native sizing, offset | Project, already embedded. Focused reference row is temporary. |
| Selected layers, viewport zoom/pan, positioning origins | Project, already saved. Selection is validated against visible/unlocked IDs. |
| Backdrop title, source guide pattern, outline mode, aspect-ratio lock, icon captions | Project, already saved. Pattern/ratio lock/captions also have application defaults. |
| Magnet, pixel/edge snapping, overlay visibility/divisions, overlay snapping | **Added to project**. Application settings remain the defaults for a new workspace; opening a project restores its setup. |
| 10/100-pixel tool grid, group resize mode | **Added to project**. They determine editing behavior and now follow the saved workspace rather than the previously opened document. |
| Collapsed folder rows | **Added to project**. Keeps larger memory collections manageable; stale folder names are filtered out. |
| Preview input, device-address binding, editor-source binding, enable flag | **Added to project** per stable layer ID. Preselected-but-not-yet-captured inputs are saved too. |
| Last captured still, guide opacity | **Added to project**. Original image bytes are embedded for offline reuse, subject to the shared 64 MiB image budget. |
| Auto-refresh choice, refresh interval, show no-signal inputs | **Added to project**. Auto-refresh restores paused; no fetch or connection is initiated by loading. Resume/capture is explicit. |
| Theme/recent themes, connection address/history, startup connection, allow Program | Application settings only. These belong to the workstation/operator; opening a document must not switch connections or global permissions. Capture host strings are bindings, not connection instructions. |
| All/selected/folder transfer scope, target bank, export sizing strategy | Session choices. Links and folders are persistent; the current transfer action and destination bank are not document content. Existing behavior is retained. |
| Advanced shared-device input edit checkbox and staged edits | Session-only by design. These are pending changes to external shared input settings; only explicit edits are sent. Local source/crop geometry is saved separately. |
| Import mapping, size/position/zoom toggles, ignored items/pages | Temporary import review. Applied results are saved; unfinished operations and their external payloads are not. |
| Geometry export codec, selection scope, background/placeholders options | Temporary export choices. No destination files are reopened or overwritten by project loading. |
| Alignment reference, prepared numeric ratio, active navigation/pivot/grid gesture, crop-edit mode, open tab/menu/dialog | Temporary editing context. No partial interaction is replayed; the resize mode and grid spacing themselves are saved as above. |
| Undo/redo, text drafts, drag snapshots, selection marquee, errors/progress, cached device capabilities, network jobs/timers | Transient runtime state. Loading starts a fresh document history and discards late capture results. |
| Named project path and last manual-save time | Recovery envelope only, not the portable project. Recovery uses the same project representation and image validation. |
The [application settings contract](midra-layout-settings.md) is unchanged (v8).
The [recovery envelope](midra-layout-recovery.md) is unchanged (v1); its nested
project migrates to v11. Geometry export representations are unchanged and omit
capture images/settings; optional fixed-reference backgrounds retain their
existing behavior.
Regression coverage includes current-schema round trips, versions 1–10 migration,
invalid assignments/settings and unknown/missing fields, embedded-still decoding,
atomic failure on malformed images, cleared stale previews, restore-without-fetch,
manual resumption eligibility and saved resize setup. The guide and example JSON
are updated with the schema.

View File

@ -7,7 +7,7 @@ not a named project export. Headless/default editors never access this path.
| Field | Meaning |
| --- | --- |
| `version` | Integer `1`; other versions rejected |
| `project` | Complete [project v10](midra-layout.md), including embedded reference bytes; its units, precision and validation apply without display rounding |
| `project` | Complete [project v11](midra-layout.md), including embedded reference bytes; its units, precision and validation apply without display rounding |
| `project_path` | Last opened/successfully saved named JSON path, or null; geometry exports do not change it |
| `manual_saved_at` | Unix UTC seconds of the last successful explicit project save, or null when unknown; recovery and measurement-point autosaves do not update it |
@ -34,7 +34,7 @@ last successful writer wins.
Recovery retains applied values only: no undo history, pending text/format/import
drafts, transient tools, or credentials. A normal exit cancels unfinished canvas
gestures before the final checkpoint. The schema does not replace named project
JSON: Save continues to emit a bare project v10 document. Opening/New replaces the
JSON: Save continues to emit a bare project v11 document. Opening/New replaces the
single recovery slot; New warns with the manual-save age and Save/Discard/Cancel.
A failed or cancelled manual save never completes Save-and-create-new.
@ -43,6 +43,6 @@ A failed or cancelled manual save never completes Save-and-create-new.
Future breaking envelope changes require a version bump and explicit migration
or rejection. Recovery is not an interchange format; use Save for portable files.
Recovery envelope version 1 is unchanged. Nested project versions 1–9 migrate
Recovery envelope version 1 is unchanged. Nested project versions 1–10 migrate
through the normal project loader before typed decoding, including the former
single `reference` field. All reference images and visibility settings are saved.

View File

@ -0,0 +1,129 @@
{
"format": "beffroi.midra-layout",
"version": 11,
"output_resolution": {
"width": 1920,
"height": 1080
},
"inputs": [
{
"id": 1,
"source_format": "sixteen_nine",
"native_resolution": {
"width": 1920,
"height": 1080
},
"input_crop": {
"left": 0.0,
"right": 0.0,
"top": 0.0,
"bottom": 0.0
}
},
{
"id": 2,
"source_format": "sixteen_nine",
"native_resolution": {
"width": 1920,
"height": 1080
},
"input_crop": {
"left": 0.0,
"right": 0.0,
"top": 0.0,
"bottom": 0.0
}
}
],
"layers": [
{
"id": 2,
"source_id": 1,
"bounds": {
"x": 120.0,
"y": 180.0,
"width": 640.0,
"height": 360.0
},
"advanced_crop": {
"left": 0.0,
"right": 0.0,
"top": 0.0,
"bottom": 0.0
},
"visible": true,
"locked": false,
"name": "Slides",
"folder": "",
"midra_link": null,
"pivot": [
0.5,
0.5
]
},
{
"id": 1,
"source_id": 2,
"bounds": {
"x": 1160.0,
"y": 180.0,
"width": 640.0,
"height": 360.0
},
"advanced_crop": {
"left": 0.0,
"right": 0.0,
"top": 0.0,
"bottom": 0.0
},
"visible": true,
"locked": false,
"name": "Presenter",
"folder": "",
"midra_link": null,
"pivot": [
0.5,
0.5
]
}
],
"editor": {
"backdrop_title": "Example Conference Name",
"selected_layer_ids": [
1
],
"position_point": "top_left",
"keep_aspect_ratio": true,
"viewport_zoom": 1.0,
"viewport_pan": [
0.0,
0.0
],
"show_source_pattern": false,
"show_toolbar_icon_names": false,
"outline_layers": false,
"position_layer_point": null
},
"next_layer_id": 3,
"references": [],
"workspace": {
"snapping": {
"enabled": false,
"pixels": true,
"screen_edges": true,
"layer_edges": true,
"grid": false,
"show_grid": true,
"grid_divisions": [
8,
6
]
},
"resize_mode": "individual",
"grid_spacing": null,
"collapsed_folders": [],
"capture_interval_seconds": 10,
"show_empty_inputs": false,
"previews": []
}
}

View File

@ -5,7 +5,7 @@ These are offline editor formats, not Analog Way REST payloads. Implementation:
[`project.rs`](../../crates/midra-layout/tests/project.rs). Update this contract,
examples and tests in the same change as any save/export schema change.
## Project JSON, version 10
## Project JSON, version 11
Suggested filename: `layout.midra.json`. Encoding: UTF-8, pretty-printed JSON,
with a trailing newline. A project preserves applied document values at their
@ -18,10 +18,10 @@ and `next_layer_id: 3`; other values are preserved.
The [version 1 example](midra-layout-v1.example.json) remains a migration fixture.
Version 4 adds `editor.outline_layers: false`, and reference `native_size: false`
and `offset: [0, 0]` when migrating versions 1–3. Old fitting behavior is preserved.
Version 5 adds required `midra_link` to every layer. Versions 1–4 migrate with null links; links cannot be supplied under an older version. Version 6 renames `editor.position_corner` to `editor.position_point` and adds `center`. Versions 1–5 retain their original corner; center and the new field are rejected in those older schemas. Version 7 adds `editor.backdrop_title`; versions 1–6 gain `"Example Conference Name"` and cannot supply this field under the old schema. Version 8 adds required `editor.position_layer_point`: null keeps matched points; a point enables independent measurement. Versions 1–7 migrate to null and cannot supply this field. Version 9 adds required `layers[].pivot`; versions 1–8 migrate to `[0.5, 0.5]` and cannot supply this field. Version 10 replaces `reference` with the required ordered `references` array. Versions 1–9 migrate null to `[]` and a single image to a one-element array, preserving all image settings. Saving always writes version 10; older applications reject it.
Version 5 adds required `midra_link` to every layer. Versions 1–4 migrate with null links; links cannot be supplied under an older version. Version 6 renames `editor.position_corner` to `editor.position_point` and adds `center`. Versions 1–5 retain their original corner; center and the new field are rejected in those older schemas. Version 7 adds `editor.backdrop_title`; versions 1–6 gain `"Example Conference Name"` and cannot supply this field under the old schema. Version 8 adds required `editor.position_layer_point`: null keeps matched points; a point enables independent measurement. Versions 1–7 migrate to null and cannot supply this field. Version 9 adds required `layers[].pivot`; versions 1–8 migrate to `[0.5, 0.5]` and cannot supply this field. Version 10 replaces `reference` with the required ordered `references` array. Versions 1–9 migrate null to `[]` and a single image to a one-element array, preserving all image settings. Version 11 adds required `workspace` settings and embedded layer previews. Versions 1–10 gain the documented workspace defaults, with no captures or collapsed folders; supplying `workspace` in an older schema is rejected. Saving always writes version 11; older applications reject it.
Incompatible files are never partially applied.
[Complete example](midra-layout-v10.example.json) is a valid default project,
[Complete example](midra-layout-v11.example.json) is a valid default project,
without a reference image. New projects label the lower layer `02 / Slides` and
the upper layer `01 / Presenter`; existing projects retain their saved IDs/names.
It is loaded by the regression tests.
@ -29,13 +29,14 @@ It is loaded by the regression tests.
| Root field | Representation / meaning |
| --- | --- |
| `format` | Exactly `"beffroi.midra-layout"` |
| `version` | Integer `10` |
| `version` | Integer `11` |
| `next_layer_id` | Positive integer strictly greater than every layer ID; not rewound by undo |
| `output_resolution` | `{ "width": integer, "height": integer }`, screen pixels |
| `inputs` | 1–1024 input objects, consecutive IDs starting at 1 |
| `layers` | 1–256 layer objects, unique positive stable IDs, in back-to-front stacking order (last is topmost) |
| `references` | Required array of 0–32 embedded reference-image objects, back-to-front compositing order |
| `editor` | Selection, positioning and viewport preferences |
| `workspace` | Required working setup and layer previews, described below |
Input objects:
@ -130,10 +131,8 @@ missing fields and non-finite values are rejected before replacing the document.
Projects larger than 96 MiB are rejected.
Save includes **applied values only**. Pending text/format/import drafts, prepared aspect-ratio targets, open
dialogs, undo/redo history, crop-edit mode, resize mode, grid/pivot/navigation tool selections, and provisional device
export calculations are not persisted. The current resize mode stays selected
when opening another project in the same session; a fresh launch starts with
Individual mode. Names and folder labels are stored. Removing layers does not renumber surviving
dialogs, undo/redo history, crop-edit mode, pivot/navigation tools, alignment targets, and provisional device
export calculations are not persisted. Resize mode and grid snapping setup are restored from the project. Names and folder labels are stored. Removing layers does not renumber surviving
IDs; adding a layer consumes `next_layer_id`. Unused input slots are retained
to preserve shared-source references. Loading starts a fresh history. Loading requires a
replacement confirmation; failed loading leaves current work intact. Writes use
@ -142,7 +141,7 @@ files require explicit replacement confirmation for Save/exports. Measurement-po
clicks and the independent-point toggle are an exception: they reread the current
project and atomically update only `editor.position_point` and
`editor.position_layer_point`, preserving its other stored values (including external edits).
Older schemas migrate to v10 on this write. No project path is stored in settings;
Older schemas migrate to v11 on this write. No project path is stored in settings;
new documents require a first Save. Geometry exports never change the active project path.
Missing/invalid/unwritable projects are left untouched and an error is shown;
active in-memory choices remain available for a manual Save. A failed no-overwrite write
@ -177,8 +176,8 @@ Moving a folder reorders its members as one contiguous block, preserving member
IDs, source references, crops and Midra links. A layer row drop changes membership and
stacking together in one history step. Folder eye/lock actions update each member's
`visible`/`locked` flags atomically; Undo restores mixed prior states. Folder selection
respects each member's visibility/lock. Collapse state is session-only and is omitted
from save/export formats; an empty group disappears when its last member leaves.
respects each member's visibility/lock. Collapse state is saved in `workspace.collapsed_folders`, but omitted
from geometry exports; an empty group disappears when its last member leaves.
Geometry exports continue to omit folders.
## Legacy SVG geometry exchange, version 1
@ -222,7 +221,7 @@ and `viewBox="0 0 W H"` equal to the output screen. The root carries
## Compatibility changes
Project version 10 and the versioned geometry exchanges are strict contracts. A breaking project field/meaning change must bump
Project version 11 and the versioned geometry exchanges are strict contracts. A breaking project field/meaning change must bump
`version` and either implement a tested migration or clearly reject older/newer
files. Changing rectangle/marker semantics requires a corresponding documented
exchange-interface revision and importer tests. Update this document and its example
@ -240,7 +239,7 @@ retarget existing links; choosing a destination there explicitly replaces that
layer's saved link. Direct send/load actions use each layer's saved screen,
independently of the screen currently displayed in the configuration window.
Automatic session recovery wraps this project representation in a separate [recovery file](midra-layout-recovery.md); named project JSON is version 10.
Automatic session recovery wraps this project representation in a separate [recovery file](midra-layout-recovery.md); named project JSON is version 11.
## Folder-scoped Midra transfers
@ -266,3 +265,42 @@ edit. Multiple layers may share the new identity. Existing smaller projects rema
unchanged until Apply; saving writes the materialized slots in `inputs` and the
one-based assignment in `layers[].source_id`. Version 10 and older-version
migration rules are unchanged. These IDs do not select or route physical inputs.
## Workspace settings (version 11)
| Field | Representation / validation / migration default |
| --- | --- |
| `snapping` | Required booleans `enabled` (false), `pixels` (true), `screen_edges` (true), `layer_edges` (true), `grid` (false), `show_grid` (true), and `grid_divisions` (two integers 1–64, default `[8,6]`). These override application defaults for the opened project. |
| `resize_mode` | `individual` (default), `same`, `mirror`, or `opposite` |
| `grid_spacing` | null (default), 10 or 100, in output pixels |
| `collapsed_folders` | Unique existing nonempty folder names; default `[]`. Deleted/renamed stale entries are omitted when saving. |
| `capture_interval_seconds` | Integer 5–300, default 10 |
| `show_empty_inputs` | Boolean, default false |
| `previews` | Array with at most one entry per existing layer; default `[]` |
Each preview has required fields `layer_id` (stable existing editor layer ID),
`source_id` (the layer's current editor input slot ID, starting at 1), `input`
(physical capture input number, 0 means unassigned; maximum 1024), `host`
(empty or numeric IP with optional port, used only to match capture assignments),
`enabled`, `automatic` (booleans), `guide_opacity` (finite 0–1), `name`
(at most 1024 UTF-8 bytes), and `image_base64` (standard padded base64 encoded
original image bytes, empty if no still has been captured). Stale assignments for
removed layers or changed editor input slots are omitted on save. Captures retain
original bytes, without recompression or display rounding.
Reference and preview images together must fit within **64 MiB decoded base64
bytes**, and the whole JSON within 96 MiB. Decoding uses the same bounded image
loader as references, on the project-loading worker. Malformed images abort the
entire open, preserving current work. A capture shared by several layers is
embedded in each preview entry; the same combined size limit applies.
Restoring a project never starts a connection or a capture. Saved stills appear
offline; saved automatic capture choices are **paused** until Capture still,
Resume auto-refresh, changing the input, or explicitly toggling auto-refresh.
Pending jobs, throttles and queued selection captures are not restored. Device
host matching still applies to automatic requests. These settings/stills are not
part of geometry export formats; fixed references retain their existing optional
background export behavior.
For the complete persistence audit and the reasons for keeping other controls
out of project files, see [Project persistence audit](midra-layout-persistence-audit.md).

View File

@ -19,6 +19,7 @@
- [Resolution and cropping model](../../midra-layout/resolutions.md)
- [File and device contracts](../../interfaces/README.md)
- [Project file contract](../../interfaces/midra-layout.md)
- [Persistence audit](../../interfaces/midra-layout-persistence-audit.md)
- [Geometry exchange contract](../../interfaces/midra-layout-exchange.md)
- [Settings contract](../../interfaces/midra-layout-settings.md)
- [Recovery contract](../../interfaces/midra-layout-recovery.md)

View File

@ -4,6 +4,14 @@
## Unreleased
- Audit project persistence: version 11 now saves snapping/grid setup, group resize
mode, collapsed folders, capture assignments/stills, guide opacity and refresh
settings. Saved auto-refresh reopens paused. Versions 1–10 migrate explicitly;
invalid previews leave current work intact. Added round-trip/migration and
preview restoration regression tests; documented project/application/session
ownership in the persistence audit.
- Preselect linked Midra input sources in untouched capture controls after connection or layer import/load, without enabling previews or requesting images. Preserve operator selections and leave unassigned/non-input sources unselected; regression coverage checks the scheduler stays idle.
- Replace the nested input-preview context submenu with Configure capture…, opening the layer properties Preview tab directly. Keep long input lists in the window instead of nested popups that can close while selecting near the canvas edge.

View File

@ -122,7 +122,9 @@ input's image. Disabling the preview hides it and pauses its refreshes.
**Crop guide opacity** defaults to 35% with an image; without an enabled image,
guides remain fully opaque and the slider is disabled. Selection handles stay
fully visible. Layer previews and timer settings are session-only. The timer
fully visible. Layer previews, captured stills and timer settings are saved in the project.
Saved auto-refresh reopens paused: use **Resume auto-refresh** or **Capture still**
to resume. Opening a project does not fetch images. The timer
pauses offline and while the separate capture/import dialog is open. Reduced
snapshot resolution and freshness are controlled by the device. If snapshots
are disabled for an input, enable them in WebRCS and refresh the connection.

View File

@ -91,8 +91,8 @@ to every selected layer’s own width.
independently. Side handles affect only their axis when the ratio is unlocked.
- Minimum sizes constrain the shared scale. Invalid geometry rejects the whole
update. Crops adjust with sizing, and one Undo restores all layers and crops.
- The last resize mode stays selected for the session, including after selection
changes, Escape, Undo/Redo and project loads. A single selected layer resizes
- The resize mode survives selection changes, Escape and Undo/Redo, and is saved
with the project. Opening a project restores its saved resize mode. A single selected layer resizes
individually; reselecting multiple layers reuses the chosen mode. Mirror and
Opposite still require exactly two layers. Choose **Resize: individual layer**
to change back explicitly. **Escape** cancels an active drag without resetting
@ -148,6 +148,6 @@ Stable IDs survive removal and are independent of Midra layer numbers. Group
movement, alignment and Same-handles resizing work across the selection;
Mirror/Opposite resizing still require exactly two layers.
Project JSON is version 10, with tested migration from older supported versions.
Project JSON is version 11, with tested migration from older supported versions.
Every format’s **Selected layers…** action exports just the current selection,
including a single layer. All/visible export remains available.

View File

@ -279,3 +279,19 @@ a layer or open its Crop properties to show its pattern and faded cropped overfl
leaving crop editing hides them again. **Show source patterns on other layers
while cropping** optionally displays patterns on the other layers during that
mode only (except outline-only layers).
## What the project saves
Project JSON includes source formats, both crop stages, geometry, layer ordering,
folders, visibility/locking, pivots, Midra links, reference images, selection,
viewport and positioning settings. It also saves snapping/grid settings, group
resize mode, collapsed folders, capture input assignments, the last captured
stills, guide opacity and refresh settings. Saved stills work offline; automatic
refresh reopens paused until you capture or resume it explicitly.
Connection history, startup connection, theme and Program permission remain in
application preferences. Unsaved drafts, undo history, open menus, active editing
gestures and pending device operations are temporary. Transfer scope, target bank,
sizing strategy and opt-in advanced device input edits remain session choices.
See the [complete persistence audit](../../interfaces/midra-layout-persistence-audit.md)
and [versioned project contract](../../interfaces/midra-layout.md).

View File

@ -44,7 +44,7 @@ device readback and physical-screen acceptance.
PPTX, FIG and AI through VectorCraft. Shared geometry, scope and review,
optional artwork where supported, page/frame selection and licensing build flag.
Two-layer Full HD and UHD templates exist for all ten formats.
- [x] Project JSON v10, tested legacy/recovery migration, saved layer links,
- [x] Project JSON v11, tested legacy/recovery migration, saved layer links,
central application preferences, full Settings, themes and recent-theme list.
- [x] Separate Midra connection and mapping/transfer controls, saved address,
optional startup connection, online status, explicit direct linked send/load
@ -78,8 +78,8 @@ device readback and physical-screen acceptance.
verifying those semantics. Source routing synchronization remains separate
from the opt-in shared-input settings editor.
- [ ] **Optional capture extensions, if wanted.** Standalone
capture saving and persistence of layer-preview assignments are not implemented.
Captures can be session-only layer textures or saved fixed reference images;
capture saving as separate image files is not implemented. Project version 11
saves layer-preview assignments, stills and refresh settings (restored paused);
low device load remains a requirement for any refresh extension.
## Confirmed format acceptance