Add application read models and thin TUI command adapter

This commit is contained in:
2026-10-30 23:02:35 +02:00
parent 9a143e975e
commit 7123197ec4
12 changed files with 2669 additions and 703 deletions
+24 -11
View File
@@ -771,7 +771,7 @@ fn handle_key(
KeyCode::Char('n') if state.view.is_some() => forms.open_create(),
KeyCode::Char('i') => forms.open_import(),
KeyCode::Char('r') => {
if state.selected_client_mutable() {
if state.selected_rename_available() {
let selected = state.selected_identity.and_then(|id| {
state
.view
@@ -788,7 +788,7 @@ fn handle_key(
}
}
KeyCode::Char('d') => {
if state.selected_client_mutable() {
if state.selected_delete_available() {
if let (Some(id), Some(view)) = (state.selected_identity, state.view.as_ref()) {
let label = view
.clients
@@ -806,16 +806,25 @@ fn handle_key(
KeyCode::Char('p') => forms.open_draft_review(),
KeyCode::Char('c') => forms.open_commit(),
KeyCode::Char('x') => forms.open_discard(),
KeyCode::Char('R') => submit_command(worker, UiCommand::PreviewRestart, state),
KeyCode::Char('o') | KeyCode::Char('O') => {
if state.selected_client_mutable()
&& let Some(identity) = state.selected_identity
&& state.view.as_ref().is_some_and(|view| {
view.client_states
.get(&identity)
.is_some_and(|row| row.saved.is_some())
})
KeyCode::Char('R') => {
if state
.view
.as_ref()
.is_some_and(|view| view.restart_eligibility().is_none_or(|item| item.available))
{
submit_command(worker, UiCommand::PreviewRestart, state);
} else {
state.status_message =
Some("Restart preview is unavailable for the saved configuration.".to_owned());
}
}
KeyCode::Char('o') | KeyCode::Char('O') => {
let eligible = if code == KeyCode::Char('o') {
state.selected_first_delivery_available()
} else {
state.selected_reissue_available()
};
if eligible && let Some(identity) = state.selected_identity {
forms.open_delivery(identity, code == KeyCode::Char('O'));
} else {
state.status_message =
@@ -1038,6 +1047,7 @@ mod tests {
statistics: RuntimeObservation::unknown(),
has_draft: false,
vault_initialized: true,
application: None,
}
}
@@ -1319,6 +1329,7 @@ mod tests {
statistics: RuntimeObservation::unknown(),
has_draft: false,
vault_initialized: true,
application: None,
}),
..UiState::default()
};
@@ -1350,6 +1361,7 @@ mod tests {
statistics: RuntimeObservation::unknown(),
has_draft: false,
vault_initialized: true,
application: None,
}),
..UiState::default()
};
@@ -1584,6 +1596,7 @@ mod tests {
statistics: RuntimeObservation::unknown(),
has_draft: false,
vault_initialized: true,
application: None,
};
let mut worker = FakeWorker {
shutdown_calls: 0,