Improve bounded send verification recovery and device address handling
This commit is contained in:
parent
6cc89e405e
commit
fa0c7722bc
|
|
@ -602,7 +602,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "canvas-pilot"
|
||||
version = "0.10.0-rc.9"
|
||||
version = "0.10.0-rc.10"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"craft-dwg",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ default-members = ["crates/canvas-pilot"]
|
|||
resolver = "3"
|
||||
|
||||
[workspace.package]
|
||||
version = "0.10.0-rc.9"
|
||||
version = "0.10.0-rc.10"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
repository = "https://proxy.dandaedre.com/gitea/idle-org/canvas-pilot"
|
||||
|
|
|
|||
|
|
@ -154,13 +154,15 @@ fn read_json(
|
|||
}
|
||||
serde_json::from_slice(&bytes).map_err(|e| format!("Invalid device JSON: {e}"))
|
||||
}
|
||||
/// Parse an IP address with an optional TCP port (default 80).
|
||||
/// Parse an IP address with an optional TCP port (default 80), or a root HTTP URL.
|
||||
/// IPv6 with a port uses bracket notation: `[::1]:3000`.
|
||||
pub fn address(host: &str) -> Result<SocketAddr, String> {
|
||||
let host = host.trim();
|
||||
let host = host.strip_prefix("http://").unwrap_or(host);
|
||||
let host = host.strip_suffix('/').unwrap_or(host);
|
||||
let address = host.parse::<IpAddr>().map(|ip| SocketAddr::new(ip, 80))
|
||||
.or_else(|_| host.parse::<SocketAddr>())
|
||||
.map_err(|_| "Enter a device IP address, optionally with a port, e.g. 192.168.10.146:3000 or [::1]:3000; omit http:// and paths.")?;
|
||||
.map_err(|_| "Enter a device IP address, optionally with a port, e.g. 192.168.10.146:3000 or [::1]:3000; HTTP root URLs are also accepted; omit credentials, queries and paths.")?;
|
||||
if address.port() == 0 {
|
||||
return Err("Device port must be between 1 and 65535.".into());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -436,7 +436,7 @@ fn execute_changes(
|
|||
apply_preset: bool,
|
||||
) -> Result<Snapshot, String> {
|
||||
for (i, change) in changes.iter().enumerate() {
|
||||
transport.write(change).map_err(|e| format!("Send stopped after {i}/{} confirmed socket writes. Device may be partially changed; refresh before retrying. {e}", changes.len()))?;
|
||||
transport.write(change).map_err(|e| format!("Send stopped after {i}/{} completed socket writes (not device acknowledgements). Device may be partially changed; refresh before retrying. {e}", changes.len()))?;
|
||||
}
|
||||
// Input crop is staged independently of preset geometry, as in WebRCS.
|
||||
let input_crops: BTreeSet<_> = changes
|
||||
|
|
@ -483,10 +483,26 @@ fn execute_changes(
|
|||
})?;
|
||||
}
|
||||
}
|
||||
let started = std::time::Instant::now();
|
||||
let mut read_error = None;
|
||||
let mut mismatches = Vec::new();
|
||||
for _ in 0..3 {
|
||||
for attempt in 0..3 {
|
||||
// Do not multiply a slow/failed fetch by three. An in-flight read retains
|
||||
// its existing socket timeout; this bounds starting additional reads.
|
||||
if attempt > 0 && started.elapsed() >= Duration::from_secs(5) {
|
||||
break;
|
||||
}
|
||||
transport.pause();
|
||||
let snapshot = transport.read().map_err(|e| format!("Commands sent, but readback failed; outcome uncertain. Refresh before retrying. {e}"))?;
|
||||
let snapshot = match transport.read() {
|
||||
Ok(snapshot) => {
|
||||
read_error = None;
|
||||
snapshot
|
||||
}
|
||||
Err(error) => {
|
||||
read_error = Some(error);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
if changes.iter().all(|c| {
|
||||
snapshot
|
||||
.raw
|
||||
|
|
@ -511,6 +527,11 @@ fn execute_changes(
|
|||
.take(4)
|
||||
.collect();
|
||||
}
|
||||
if let Some(error) = read_error {
|
||||
return Err(format!(
|
||||
"Commands sent, but readback failed; outcome uncertain. Refresh before retrying. {error}"
|
||||
));
|
||||
}
|
||||
Err(format!(
|
||||
"Commands sent but readback did not match. Device may have clamped values or another controller changed them. Refresh and review; no automatic resend or rollback was performed. {}",
|
||||
mismatches.join("; ")
|
||||
|
|
@ -1100,6 +1121,65 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn readback_recovers_without_repeating_writes_and_reports_last_outcome() {
|
||||
struct Flaky {
|
||||
inner: Mock,
|
||||
failures: std::collections::VecDeque<bool>,
|
||||
reads: usize,
|
||||
}
|
||||
impl Transport for Flaky {
|
||||
fn read(&mut self) -> Result<Snapshot, String> {
|
||||
self.reads += 1;
|
||||
if self.failures.pop_front().unwrap() {
|
||||
Err("Temporary read failure".into())
|
||||
} else {
|
||||
self.inner.read()
|
||||
}
|
||||
}
|
||||
fn write(&mut self, change: &Change) -> Result<(), String> {
|
||||
self.inner.write(change)
|
||||
}
|
||||
}
|
||||
for (failures, ignore, expected, reads) in [
|
||||
(vec![true, false], false, "", 2),
|
||||
(vec![true, true, false], false, "", 3),
|
||||
(vec![true, true, true], false, "outcome uncertain", 3),
|
||||
(vec![false, true, false], true, "did not match", 3),
|
||||
(vec![false, false, true], true, "outcome uncertain", 3),
|
||||
] {
|
||||
let state = snapshot();
|
||||
let plan = Plan::prepare(
|
||||
&state,
|
||||
&layout(),
|
||||
0,
|
||||
&[(2, "1".into())],
|
||||
Target::Preview,
|
||||
Sizing::OutputBox,
|
||||
)
|
||||
.unwrap();
|
||||
let mut transport = Flaky {
|
||||
inner: Mock {
|
||||
state,
|
||||
writes: 0,
|
||||
fail_at: None,
|
||||
ignore,
|
||||
writes_log: vec![],
|
||||
},
|
||||
failures: failures.into(),
|
||||
reads: 0,
|
||||
};
|
||||
let result = execute(&plan, &mut transport);
|
||||
if expected.is_empty() {
|
||||
assert!(result.is_ok());
|
||||
} else {
|
||||
assert!(result.unwrap_err().contains(expected));
|
||||
}
|
||||
assert_eq!(transport.reads, reads);
|
||||
assert_eq!(transport.inner.writes, plan.changes.len() + 2);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn explicit_input_crop_changes_pulse_only_that_input_before_preset_apply() {
|
||||
let mut state = snapshot();
|
||||
|
|
|
|||
|
|
@ -1049,7 +1049,7 @@ impl Editor {
|
|||
pub(super) fn device_send_button(&mut self, ui: &mut egui::Ui) {
|
||||
let plans = self.device.linked_plans(&self.layout);
|
||||
let conflicts = link_conflicts(&self.layout, &self.device.scoped_send_links(&self.layout));
|
||||
let enabled = self.device.online() && self.device.pending.is_none() && conflicts.is_none();
|
||||
let enabled = self.device.online() && !self.device.busy() && conflicts.is_none();
|
||||
let tooltip = if let Some(error) = conflicts {
|
||||
error
|
||||
} else if self.device.sending {
|
||||
|
|
|
|||
|
|
@ -217,6 +217,9 @@ fn device_addresses_support_ports_and_ipv6() {
|
|||
("192.168.10.146", "192.168.10.146:80"),
|
||||
(" 192.168.10.146:3000 ", "192.168.10.146:3000"),
|
||||
("::1", "[::1]:80"),
|
||||
("http://127.0.0.1:3000", "127.0.0.1:3000"),
|
||||
(" http://192.168.10.142/ ", "192.168.10.142:80"),
|
||||
("http://[::1]:3000/", "[::1]:3000"),
|
||||
("[::1]:3000", "[::1]:3000"),
|
||||
] {
|
||||
assert_eq!(address(input).unwrap().to_string(), expected);
|
||||
|
|
@ -224,7 +227,11 @@ fn device_addresses_support_ports_and_ipv6() {
|
|||
for input in [
|
||||
"",
|
||||
"localhost",
|
||||
"http://127.0.0.1:3000",
|
||||
"https://127.0.0.1/",
|
||||
"http://user:pass@127.0.0.1/",
|
||||
"http://127.0.0.1/?query=1",
|
||||
"http://127.0.0.1/#fragment",
|
||||
"http://127.0.0.1/path",
|
||||
"127.0.0.1:0",
|
||||
"127.0.0.1:65536",
|
||||
"127.0.0.1:abc",
|
||||
|
|
|
|||
|
|
@ -4,6 +4,16 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
### v0.10.0-rc.10
|
||||
|
||||
- Recover from temporary send-readback failures using up to three read attempts,
|
||||
without repeating writes or apply pulses. Stop starting retries after five
|
||||
seconds; an in-flight read retains its existing timeout. Report uncertain
|
||||
outcomes when verification remains unavailable.
|
||||
- Accept pasted root HTTP device URLs as well as IP addresses, and disable linked
|
||||
Send while a shared-input send is active. Socket-write counts no longer imply
|
||||
device acknowledgement. Regression tests cover recovery and address validation.
|
||||
|
||||
### v0.10.0-rc.9
|
||||
|
||||
- Enabling Follow input now adapts the layer to the selected input’s processed
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@
|
|||
|
||||
Enter an IP address in **Device IP / port**, optionally followed by a TCP port:
|
||||
`192.168.10.146:3000`. Without a port, the app uses port 80. IPv6 addresses
|
||||
with a port use brackets, for example `[::1]:3000`. Omit URL schemes and paths.
|
||||
with a port use brackets, for example `[::1]:3000`. A pasted root HTTP URL,
|
||||
for example `http://192.168.10.142/`, also works. Omit credentials, queries,
|
||||
fragments and page paths; HTTPS and hostnames are not supported.
|
||||
The address is saved in preferences and used for identity, input snapshots,
|
||||
automatic reconnect and WebSocket sends. Aquilon also requires AWJ TCP port
|
||||
10606 on the same IP for its targeted geometry reads; Midra reads use the HTTP port.
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ unknown theme names are rejected. There are no numeric coordinates or units.
|
|||
| `language` | `"system"` (default), `"en"`, `"fr"`, `"ja"`, `"zh-CN"`, `"es"`, `"grc"`, `"eo"`, `"pt-PT"`, `"ne"`, `"th"`, `"hi"`, `"tok"`, or `{"pack":"uk"}` for an installed language. Pack identifiers use 1–63 lowercase ASCII letters, digits and hyphens, without a leading/trailing hyphen. Unknown built-in string values are rejected. |
|
||||
| `autoconnect_at_startup` | Boolean; default false. Try one background connection at application startup if the saved address is nonblank. |
|
||||
| `allow_sending_to_program` | Boolean; default false. Enables the Program destination in the exporter. Turning it off restores Preview; applies to quick Apply too. |
|
||||
| `midra_host` | Device IP address text with optional TCP port (e.g. `192.168.10.146:3000`, `[::1]:3000`; default port 80); default `""`. Saved as typed, including incomplete drafts; validated when connecting. |
|
||||
| `midra_host` | Device IP address text with optional TCP port (e.g. `192.168.10.146:3000`, `[::1]:3000`; default port 80; root HTTP URLs also accepted); default `""`. Saved as typed, including incomplete drafts; validated when connecting. |
|
||||
| `theme` | Built-in theme ID below or `{"pack":"pack-id/theme-id"}`; default `"midra"` |
|
||||
| `recent_themes` | 1–3 unique built-in IDs or pack references, newest first; first must equal `theme`; default `["midra"]` |
|
||||
| `show_toolbar_icon_names` | Boolean; default false |
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
# Midra reviewed layer exchange
|
||||
|
||||
The Rust adapter uses the configured IP and optional port for this endpoint
|
||||
(default 80), including emulator addresses such as `192.168.10.146:3000`.
|
||||
(default 80), accepting IP addresses or root HTTP URLs (no credentials, query,
|
||||
fragment or non-root path), including emulator addresses such as `192.168.10.146:3000`.
|
||||
|
||||
This is a transient device protocol, not a project/save schema. Reference collections in project v10 do not change device layer mapping. Compatibility exercised: Eikos 4K firmware 3.3.10, installed WebRCS
|
||||
`app.e42fce4879f318b28cde.js`. Other firmware needs verification.
|
||||
|
|
@ -86,7 +87,11 @@ Only an explicit Send click creates a worker. Read/refresh, editing, project loa
|
|||
import, undo and redo never write. Requests run off the UI thread with bounded
|
||||
socket operations. After preflight, changed fields are written sequentially once. Crop and mask decreases precede increases
|
||||
to avoid temporarily exhausting an axis while moving either window.
|
||||
Readback checks every changed field. Valid plans remain sendable even when stored geometry matches: sending still applies staged values. Failure reports
|
||||
Readback checks every changed field. Verification retries both mismatched values
|
||||
and read errors, up to three read attempts, without repeating writes or apply
|
||||
pulses. No additional attempt starts after five seconds of verification; an
|
||||
in-flight read retains its existing timeout. An unavailable final read reports an
|
||||
uncertain outcome, while a readable mismatch reports the mismatching fields. Valid plans remain sendable even when stored geometry matches: sending still applies staged values. Failure reports
|
||||
partial/uncertain outcomes without blind retries or automatic rollback.
|
||||
|
||||
Program selection is explicit. The application defaults to Preview and hides Program unless the persisted `allow_sending_to_program` preference is enabled. Turning it off resets the exporter to Preview, including quick Apply. Layer screen/destination links are saved in project version 5. Plans and raw snapshots are not saved in projects or preferences. The device address is saved in [application settings](canvas-pilot-settings.md), never in projects. Refresh and screen changes preserve saved links. Physical display
|
||||
|
|
|
|||
Loading…
Reference in New Issue