From 36e09ee48f1154ed8c5597439a8be5c88d632c08 Mon Sep 17 00:00:00 2001 From: KeyffMS <124252104+KeyffMS@users.noreply.github.com> Date: Wed, 16 Sep 2026 16:22:18 +0200 Subject: [PATCH 1/3] refactor: split application substates (R2e) --- crates/lantern-app/src/application/state.rs | 66 +++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 crates/lantern-app/src/application/state.rs diff --git a/crates/lantern-app/src/application/state.rs b/crates/lantern-app/src/application/state.rs new file mode 100644 index 00000000..c4482cc7 --- /dev/null +++ b/crates/lantern-app/src/application/state.rs @@ -0,0 +1,66 @@ +use std::sync::Arc; + +use lantern_domain::ParameterId; +use lantern_profile::ValidatedDeviceProfile; + +use crate::{ + CsvLoggingRuntimeStatus, MonitoringRuntimeSnapshot, ParameterDescriptorView, PreparedWritePlan, + ScopeSelection, StagedWriteIntent, default_dashboard_parameters, parameter_catalog, +}; + +#[derive(Clone, Debug, Default)] +pub(super) struct ApplicationMonitoringState { + pub(super) dashboard_parameters: Vec, + pub(super) scope: ScopeSelection, + pub(super) snapshot: Option, + pub(super) csv_parameters: Vec, + pub(super) csv_status: CsvLoggingRuntimeStatus, + pub(super) next_logging_id: u128, + pub(super) error: Option, +} + +impl ApplicationMonitoringState { + pub(super) fn for_profile(profile: &ValidatedDeviceProfile) -> Self { + Self { + dashboard_parameters: default_dashboard_parameters(profile), + scope: ScopeSelection::default(), + snapshot: None, + csv_parameters: Vec::new(), + csv_status: CsvLoggingRuntimeStatus::default(), + next_logging_id: 1, + error: None, + } + } +} + +#[derive(Clone, Debug)] +pub(super) struct ApplicationParameterState { + pub(super) catalog: Arc<[ParameterDescriptorView]>, + pub(super) visible: Vec, + pub(super) staged_intent: Option, + pub(super) prepared_write: Option, + pub(super) write_status: Option, + pub(super) error: Option, +} + +impl Default for ApplicationParameterState { + fn default() -> Self { + Self { + catalog: Vec::::new().into(), + visible: Vec::new(), + staged_intent: None, + prepared_write: None, + write_status: None, + error: None, + } + } +} + +impl ApplicationParameterState { + pub(super) fn for_profile(profile: &ValidatedDeviceProfile) -> Self { + Self { + catalog: parameter_catalog(profile), + ..Self::default() + } + } +} From 4572f575a0f399bf310784799b57c82b535dbffe Mon Sep 17 00:00:00 2001 From: KeyffMS <124252104+KeyffMS@users.noreply.github.com> Date: Wed, 16 Sep 2026 16:23:39 +0200 Subject: [PATCH 2/3] refactor: wire application substates module (R2e) --- crates/lantern-app/src/application.rs | 75 ++++----------------------- 1 file changed, 9 insertions(+), 66 deletions(-) diff --git a/crates/lantern-app/src/application.rs b/crates/lantern-app/src/application.rs index a6d2eb34..fa97756e 100644 --- a/crates/lantern-app/src/application.rs +++ b/crates/lantern-app/src/application.rs @@ -1,6 +1,6 @@ use std::{path::PathBuf, sync::Arc}; -use lantern_domain::{DriveState, ParameterId, ProfileId, SessionId, SlaveId}; +use lantern_domain::{DriveState, ProfileId, SessionId, SlaveId}; use lantern_profile::ValidatedDeviceProfile; use thiserror::Error; @@ -8,85 +8,28 @@ use crate::{ AuditHealth, Authorization, BackupCaptureRequest, BackupRestoreAction, BackupRestoreEffect, BackupRestoreState, BusError, ConnectionAction, ConnectionAttemptKind, ConnectionEffect, ConnectionFailure, ConnectionStep, ConnectionWizardState, Connectivity, CsvLoggingFaultSummary, - CsvLoggingRuntimeStatus, CsvLoggingStateView, FaultAction, FaultEffect, FaultTracker, - MAX_PARAMETER_BROWSER_VISIBLE, MonitoringAction, MonitoringEffect, MonitoringRuntimeSnapshot, - MonitoringView, OperationState, ParameterAction, ParameterBrowserView, ParameterDescriptorView, - ParameterIntentContext, ParameterWritePresentation, PreparedWritePlan, ProfileRegistry, - RestoreConfirmation, ScopeSelection, SerialConnectError, SessionEffect, SessionFault, - SessionInput, SessionState, SessionStateMachine, StagedWriteIntent, WriteConfirmation, - WriteConfirmationModel, WriteEffect, WriteSessionSnapshot, default_dashboard_parameters, - parameter_catalog, prepare_parameter_intent, project_monitoring_view, + CsvLoggingStateView, FaultAction, FaultEffect, FaultTracker, MAX_PARAMETER_BROWSER_VISIBLE, + MonitoringAction, MonitoringEffect, MonitoringView, OperationState, ParameterAction, + ParameterBrowserView, ParameterIntentContext, ParameterWritePresentation, ProfileRegistry, + RestoreConfirmation, SerialConnectError, SessionEffect, SessionFault, SessionInput, SessionState, + SessionStateMachine, WriteConfirmation, WriteConfirmationModel, WriteEffect, + WriteSessionSnapshot, prepare_parameter_intent, project_monitoring_view, project_parameter_browser_view, }; mod connection; mod faults; mod monitoring; +mod state; mod view; +use state::{ApplicationMonitoringState, ApplicationParameterState}; use view::port_label; pub use view::{ ApplicationView, AuditHealthView, AuthorizationView, OperationView, SessionPhaseView, SessionView, }; -#[derive(Clone, Debug, Default)] -struct ApplicationMonitoringState { - dashboard_parameters: Vec, - scope: ScopeSelection, - snapshot: Option, - csv_parameters: Vec, - csv_status: CsvLoggingRuntimeStatus, - next_logging_id: u128, - error: Option, -} - -impl ApplicationMonitoringState { - fn for_profile(profile: &ValidatedDeviceProfile) -> Self { - Self { - dashboard_parameters: default_dashboard_parameters(profile), - scope: ScopeSelection::default(), - snapshot: None, - csv_parameters: Vec::new(), - csv_status: CsvLoggingRuntimeStatus::default(), - next_logging_id: 1, - error: None, - } - } -} - -#[derive(Clone, Debug)] -struct ApplicationParameterState { - catalog: Arc<[ParameterDescriptorView]>, - visible: Vec, - staged_intent: Option, - prepared_write: Option, - write_status: Option, - error: Option, -} - -impl Default for ApplicationParameterState { - fn default() -> Self { - Self { - catalog: Vec::::new().into(), - visible: Vec::new(), - staged_intent: None, - prepared_write: None, - write_status: None, - error: None, - } - } -} - -impl ApplicationParameterState { - fn for_profile(profile: &ValidatedDeviceProfile) -> Self { - Self { - catalog: parameter_catalog(profile), - ..Self::default() - } - } -} - #[derive(Clone, Debug)] pub struct ApplicationState { active_profile: Option, From 54db50e6922bbe07788ce67b9289ccfb996ac33d Mon Sep 17 00:00:00 2001 From: KeyffMS <124252104+KeyffMS@users.noreply.github.com> Date: Wed, 16 Sep 2026 16:37:27 +0200 Subject: [PATCH 3/3] style: rustfmt application state split --- crates/lantern-app/src/application.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/lantern-app/src/application.rs b/crates/lantern-app/src/application.rs index fa97756e..e5e98bb9 100644 --- a/crates/lantern-app/src/application.rs +++ b/crates/lantern-app/src/application.rs @@ -11,8 +11,8 @@ use crate::{ CsvLoggingStateView, FaultAction, FaultEffect, FaultTracker, MAX_PARAMETER_BROWSER_VISIBLE, MonitoringAction, MonitoringEffect, MonitoringView, OperationState, ParameterAction, ParameterBrowserView, ParameterIntentContext, ParameterWritePresentation, ProfileRegistry, - RestoreConfirmation, SerialConnectError, SessionEffect, SessionFault, SessionInput, SessionState, - SessionStateMachine, WriteConfirmation, WriteConfirmationModel, WriteEffect, + RestoreConfirmation, SerialConnectError, SessionEffect, SessionFault, SessionInput, + SessionState, SessionStateMachine, WriteConfirmation, WriteConfirmationModel, WriteEffect, WriteSessionSnapshot, prepare_parameter_intent, project_monitoring_view, project_parameter_browser_view, };