Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ Versions follow [semantic versioning](https://semver.org/), with `0.x` meaning t

## Unreleased

- A large hull at a high subdivision level no longer freezes the window while it is refined: the window draws a
coarser level at once (level 3 for `container-230m`) and the full level replaces it when a background job has
built it, with "refining to level N…" in the status bar meanwhile. Smaller hulls (the demo hull up to level 4)
refine at once as before.
- One speed for resistance, waves and seakeeping. The Performance tab's speed slider now sits above all three
sections: it is marked on the resistance curve (click the curve to move it), the Wave pattern view computes at it,
and seakeeping runs at it. Changing the speed in the Wave pattern view moves the same speed; its kn / Fn switch
only changes how the speed reads. The Wave pattern view now opens at the Performance tab's speed (6 kn, or the
design speed) instead of Fn 0.30, and the design report's wave section uses it too.
- The Performance tab greys out the resistance curve and table rows where the method is outside the range it was
fitted to, instead of drawing them like the rest: the whole Holtrop & Mennen curve for a hull outside its Cp, L/B
or B/T range (the demo hull is, at L/B 3.02 and B/T 5.71), and the DSYHS speeds outside Fn 0.15 to 0.75. The
numbers stay; the plot's legend says which part is outside.
- The MCP `batch` tool now says what its rollback covers: on an error the session's model goes back to where it was
before the batch, but files written by earlier steps (a design report, an unfolded plate, a wave image) stay on disk.
It used to call the batch all-or-nothing (#8). Connected to the GUI, `load_hull`, `generate_hull` or `example`
inside a batch start a fresh history there, so the model is not rolled back past them. A rollback the GUI refuses,
or whose reply is lost, now shows as `restore_error` (unconfirmed) instead of passing in silence.

## 0.7.0 (2026-11-26)

SeaCraft in Turkish. The desktop app, the command line and every document SeaCraft writes can now be read in
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ neighbouring extrema), and the summary names the speed regime in a sentence. The
michell` adds the interference: the pair's wave resistance over twice one demihull's.

In the window, Analysis → *Wave pattern* opens the pattern in the drawer under the viewports. One speed, typed or
scrubbed, drives the regime sentence, the wavelength against the waterline, hull speed, the highest crest, the wave
scrubbed, and the same one the Performance tab marks on the resistance curve and runs seakeeping at, drives the
regime sentence, the wavelength against the waterline, hull speed, the highest crest, the wave
drag here, the wash height and, for a catamaran, the interference, each in plain words with units. A banner says
first when thin-ship theory does not fit the hull. The map shows dark calm water, the hull footprint, the Kelvin
wedge and the wash lines (drag one to move them); the plots give C_w against Fn with hull speed, humps and hollows
Expand Down
13 changes: 9 additions & 4 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ path; each cell is the range of the medians of separate runs, frame time then CP

At level 5 the old path asks wgpu for a 403 MiB vertex buffer, over its 256 MiB limit, and panics, so
`--no-gpu-hull` is no way out there. A new level 5 mesh of `container-230m` (1.29 million triangles, 103 MiB)
takes about 140 ms to build on the window thread and 12 ms to upload.
takes about 140 ms to build and 12 ms to upload. Since 2026-11-26 a mesh over about 24 000 refined faces is built in
a background job while the window draws the highest level under that at once (level 3 for `container-230m`), so an
edit no longer waits for it; orbiting is unchanged (alternating runs against 0.7.0 on a loaded machine). A pause of
about half a second after an edit to `container-230m` remains, at level 3 as well as 5, from something other than
the mesh; it is not yet profiled.

- [x] Profile the cost per frame.
- [x] Cut the waterline once per mesh and plane instead of once per view per frame.
Expand All @@ -94,9 +98,10 @@ takes about 140 ms to build on the window thread and 12 ms to upload.

- [ ] Floodable length curves.
- [ ] VRML import, and edge extrusion in the GUI.
- [ ] One speed shared across the Performance tab and the Wave pattern view (resistance, waves, seakeeping).
- [ ] Grey out or cut the Holtrop curve where the method does not apply (on the demo hull R_T falls past
7.25 kn).
- [x] One speed shared across the Performance tab and the Wave pattern view (resistance, waves, seakeeping).
- [x] Grey out the resistance curve where the method does not apply: all of the Holtrop curve for a hull outside
its Cp, L/B or B/T range, and DSYHS speeds outside Fn 0.15 to 0.75. Neither Holtrop paper prints a top Froude
number, so no Holtrop speed is greyed on that account.
- [ ] A 3D wave surface in Perspective view.
- [ ] A wave pattern method for planing hulls; the Wave pattern view's title, "Thin-ship theory (Michell)",
then becomes a drop-down that picks the method.
Expand Down
181 changes: 145 additions & 36 deletions crates/seacraft-cli/src/mcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -750,41 +750,35 @@ impl McpServer {

for (i, call) in calls.iter().enumerate() {
let Some(call_obj) = call.as_object() else {
if let Some(mark) = mark_id {
let _ = remote.request("history.restore", json!({"mark": mark}));
}
return text_result(
&json!({
return batch_remote_failed(
remote,
mark_id,
json!({
"failed": {"index": i, "name": "", "error": "each call must be an object"},
"completed": i,
}),
true,
);
};

let Some(name) = call_obj.get("name").and_then(Value::as_str) else {
if let Some(mark) = mark_id {
let _ = remote.request("history.restore", json!({"mark": mark}));
}
return text_result(
&json!({
return batch_remote_failed(
remote,
mark_id,
json!({
"failed": {"index": i, "name": "", "error": "missing call `name`"},
"completed": i,
}),
true,
);
};

if name == "batch" {
if let Some(mark) = mark_id {
let _ = remote.request("history.restore", json!({"mark": mark}));
}
return text_result(
&json!({
return batch_remote_failed(
remote,
mark_id,
json!({
"failed": {"index": i, "name": "batch", "error": "nested batch is rejected"},
"completed": i,
}),
true,
);
}

Expand All @@ -794,15 +788,13 @@ impl McpServer {
};

if let Err(e) = check_arguments(name, &args) {
if let Some(mark) = mark_id {
let _ = remote.request("history.restore", json!({"mark": mark}));
}
return text_result(
&json!({
return batch_remote_failed(
remote,
mark_id,
json!({
"failed": {"index": i, "name": name, "error": e},
"completed": i,
}),
true,
);
}

Expand All @@ -813,15 +805,13 @@ impl McpServer {
results.push(val);
}
Err(e) => {
if let Some(mark) = mark_id {
let _ = remote.request("history.restore", json!({"mark": mark}));
}
return text_result(
&json!({
return batch_remote_failed(
remote,
mark_id,
json!({
"failed": {"index": i, "name": name, "error": e},
"completed": i,
}),
true,
);
}
}
Expand Down Expand Up @@ -3901,12 +3891,20 @@ pub fn tool_definitions() -> Vec<Value> {
),
tool(
"batch",
"Run several tool calls atomically",
"Run tool calls in order, stopping at the first error. Each step is {name, arguments}. On an error earlier steps \
are rolled back, so the batch is all-or-nothing (both headless and when connected to the GUI). Returns each \
call's result on success, or {failed: {index, name, error}, completed: N} on failure. At most 100 calls; \
nested batch is rejected, and so is export_panels with both `nest` and `path` (files on disk cannot be \
rolled back; call it on its own).",
"Run several tool calls, restoring the model on error",
"Run tool calls in order, stopping at the first error, which restores the model (connected to the GUI, \
not past a load_hull, generate_hull or example in the batch) but not files already written. Each step \
is {name, arguments}. On an error the session's model is restored to what it was before the batch, \
headless or connected to the GUI, but files written by earlier steps stay on disk, and so may a file \
the failing step wrote before it failed (a hull saved before its sidecar): a design report, an \
unfolded plate or a wave image is not removed. Connected to the GUI, a tool that replaces the whole \
model (load_hull, generate_hull, example) starts a fresh history there, so the model from before it \
is not restored. A failure with `restore_error` means the rollback could not be confirmed (the GUI \
refused it, or its reply was lost). Connected, hull_info shows no geometry to check that by, so before \
a batch that matters save the model with save_hull, and after such a failure load it again instead of \
mending the model in place. Returns each call's result on success, or {failed: {index, name, error}, completed: N} on failure. \
At most 100 calls; nested batch is rejected, and so is export_panels with both `nest` and `path` (call it \
on its own).",
obj(
json!({
"calls": {
Expand All @@ -3930,6 +3928,18 @@ pub fn tool_definitions() -> Vec<Value> {
]
}

/// A connected batch failed: the GUI goes back to `mark`. A restore without a good reply is
/// reported as unconfirmed, not dropped: the GUI refused it (a model replaced in the batch started
/// a fresh history there), or it may have restored and lost the reply.
fn batch_remote_failed(remote: &mut Remote, mark: Option<u64>, mut failure: Value) -> Value {
if let Some(mark) = mark {
if let Err(e) = remote.request("history.restore", json!({"mark": mark})) {
failure["restore_error"] = Value::String(e);
}
}
text_result(&failure, true)
}

/// The tools as a markdown list: name, title, first sentence, effect.
fn tool_catalogue() -> String {
let mut out = String::from("# SeaCraft tools\n\n");
Expand Down Expand Up @@ -6472,6 +6482,53 @@ mod tests {
handle.join().expect("server thread finished");
}

/// CodeRabbit (PR #22): when the GUI cannot restore the mark (a `load_hull` inside the batch
/// started a fresh history there), the failure says so instead of dropping the error.
#[test]
fn connected_batch_reports_a_failed_restore() {
use std::io::Write;
let listener = std::net::TcpListener::bind("127.0.0.1:0").expect("bind");
let addr = listener.local_addr().expect("addr");

let handle = std::thread::spawn(move || {
let (mut stream, _) = listener.accept().expect("accept");
let mut reader = std::io::BufReader::new(stream.try_clone().expect("clone"));
let mut next = |expect: &str, reply: &[u8]| {
let mut line = String::new();
reader.read_line(&mut line).expect("read");
let v: Value = serde_json::from_str(line.trim()).expect("json");
assert_eq!(v["method"], expect);
stream.write_all(reply).expect("write");
};
next("history.mark", b"{\"ok\":true,\"result\":{\"mark\":42}}\n");
next(
"model.split_face",
b"{\"ok\":false,\"error\":\"split error\"}\n",
);
next(
"history.restore",
b"{\"ok\":false,\"error\":\"unknown mark 42\"}\n",
);
});

let mut s = McpServer::connect_no_auth(&addr.to_string()).expect("connect");
let err_text = fails(
&mut s,
1,
"batch",
json!({"calls": [{"name": "split_face", "arguments": {"face": 0}}]}),
);
let fail_json: Value = serde_json::from_str(&err_text).expect("fail json");
assert_eq!(fail_json["failed"]["name"], "split_face");
assert!(
fail_json["restore_error"]
.as_str()
.is_some_and(|e| e.contains("unknown mark 42")),
"{fail_json}"
);
handle.join().expect("server thread finished");
}

#[test]
fn mcp_connect_with_token_file_succeeds_end_to_end() {
use std::io::Write;
Expand Down Expand Up @@ -6798,6 +6855,58 @@ mod tests {
assert_eq!(seen[1], json!({"path": "/tmp/lines.svg", "format": "svg"}));
}

#[test]
fn batch_description_says_files_are_not_rolled_back() {
let mut s = McpServer::new();
let list = request(&mut s, 1, "tools/list", json!({}));
let tool = list["result"]["tools"]
.as_array()
.unwrap()
.iter()
.find(|t| t["name"] == "batch")
.expect("batch")
.clone();
let description = tool["description"].as_str().unwrap();
assert!(
description.contains("files written by earlier steps stay on disk"),
"{description}"
);
assert!(!description.contains("all-or-nothing"), "{description}");
let title = tool["title"].as_str().unwrap_or_default();
assert!(!title.to_lowercase().contains("atomic"), "{title}");
// CodeRabbit (PR #22): the failing step itself can leave a file (a hull saved before
// its sidecar failed), and a hull loaded inside a GUI-connected batch is not undone.
assert!(description.contains("the failing step"), "{description}");
assert!(description.contains("load_hull"), "{description}");
assert!(description.contains("restore_error"), "{description}");
// CodeRabbit (PR #22, second review): a lost reply also gives `restore_error`, so it says
// the rollback is unconfirmed, not that it failed, and to look before mending.
assert!(
description.contains("could not be confirmed"),
"{description}"
);
// CodeRabbit (PR #22, third review): connected, hull_info shows no geometry, so the
// description names a baseline to take before the batch instead.
assert!(
description.contains("hull_info shows no geometry"),
"{description}"
);
assert!(description.contains("save_hull"), "{description}");
// CodeRabbit (fourth review): hydro_compute skips layers kept out of hydrostatics, so
// it is no baseline; the saved hull is, loaded again after a failure.
assert!(!description.contains("hydro_compute"), "{description}");
assert!(description.contains("load it again"), "{description}");
// The catalogue shows only the first sentence: it carries the caveat too.
let catalogue = tool_catalogue();
let line = catalogue
.lines()
.find(|l| l.starts_with("- `batch`"))
.expect("batch in the catalogue");
assert!(line.contains("files"), "{line}");
// ...and the exception for a model replaced inside a connected batch.
assert!(line.contains("load_hull"), "{line}");
}

#[test]
fn export_templates_schema_lists_its_arguments() {
let mut s = McpServer::new();
Expand Down
Loading
Loading