feat(maestro): "Spawn similar" catalog action + spawn-history/gitroot e2e (#28)
ci / rust (push) Successful in 4m15s

Web: rename the per-row clone affordance to "Spawn similar" — it reopens the
revamped spawn form pre-seeded from the session's host, dir, command (matched
back to a preset by the form), and label, but with a freshly generated name
since it's a new session. Built entirely on the existing prefill machinery; the
custom event is renamed `catalog-spawn-similar`.

e2e (maestro-e2e): against real tmux + git, spawn into a git repo dir and assert
(1) the daemon's recent-dirs endpoint surfaces that dir with its command — what
#27's recents picker reads on the next form open — proving the durable
spawn-history write, and (2) gitroot infers the enclosing repo as the worktree
base_repo.

Closes #28

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-20 22:05:48 +00:00
co-authored by Claude Opus 4.8
parent eef96548b8
commit c8bf240624
3 changed files with 80 additions and 12 deletions
+67
View File
@@ -455,6 +455,73 @@ async fn concurrent_spawns_each_get_unique_ids() {
}
}
#[tokio::test(flavor = "multi_thread")]
async fn spawn_records_history_and_infers_gitroot_for_form() {
// #24/#25/#26/#28: a real spawn writes a durable spawn-history record, which
// the daemon's recent-dirs endpoint surfaces on the spawn form's next open
// (#27's recents picker), and gitroot infers the worktree base_repo from the
// same dir. Exercised end to end against real tmux + git.
let (_reg, daemons, client) = bring_up(&["host"]).await;
let daemon_base = format!("http://{}", daemons[0].bind_addr);
// A git repo as the working dir, so gitroot has a repo to infer.
let repo = TempDir::new().unwrap();
init_repo(repo.path());
let cwd = repo.path().to_string_lossy().to_string();
// Spawn in that dir (the command stands in for a preset tile selection).
let s = client
.spawn_session(&create_req("host", repo.path(), "sleep 30"))
.await
.expect("spawn");
// The recents picker reads GET /recent-dirs on open: the just-spawned dir
// must surface, tagged with the command it was last used with. The history
// write is best-effort right after the spawn, so poll briefly.
wait_for_async(
"recent-dirs surfaces the spawned cwd",
Duration::from_secs(5),
|| {
let url = format!("{daemon_base}/api/daemons/host/recent-dirs");
let want = cwd.clone();
async move {
let resp = match reqwest::get(&url).await {
Ok(r) => r,
Err(_) => return false,
};
let recents: maestro_protocol::RecentDirs = match resp.json().await {
Ok(v) => v,
Err(_) => return false,
};
recents
.dirs
.iter()
.any(|d| d.cwd.to_string_lossy() == want && d.last_command == "sleep 30")
}
},
)
.await;
// gitroot infers the worktree base_repo from the same dir (#25/#26): the dir
// is itself the repo toplevel (it holds `.git`).
let gr: maestro_protocol::GitRoot = reqwest::Client::new()
.get(format!("{daemon_base}/api/daemons/host/gitroot"))
.query(&[("path", cwd.as_str())])
.send()
.await
.expect("gitroot request")
.json()
.await
.expect("gitroot json");
assert_eq!(
gr.root.as_deref().map(|p| p.to_string_lossy().to_string()),
Some(cwd.clone()),
"gitroot should infer the enclosing repo"
);
client.kill_session(s.id).await.expect("kill");
}
// ---------------------------------------------------------------------------
// Helpers
// ---------------------------------------------------------------------------