fix(maestro): fifth-review findings, incl. the guarded-worktree dead end
The cleanup guard plus deterministic paths had created a trap: one untracked file an agent left behind — a log, a .env, a stray artifact — made the guard refuse removal, the directory stayed, and every later spawn of that branch hit PathExists. The branch was burned permanently and the product offered no way to clear it. A leftover tree registered for the same branch is now adopted, so the operator lands back in their own unsaved work. A tree a *live* session holds is still rejected, since two sessions must not share a checkout. Also: - Fast-forward still awaited /api/info, /api/projects and /api/names inline, the exact freeze the draft loaders were restructured to avoid. It posts to the same channel now. - Draft updates were routed by tab index, which shifts when a tab closes: an in-flight load could be dropped or land on the wrong pane. Drafts carry an id and are found by it. - extend_names left the name it had just displayed at the head of the queue, so the next reroll produced it again and the key looked dead. - The fast-forward fallback discarded info.home_dir, so its draft showed unabbreviated paths and seeded "Other directory…" with / — disagreeing with the normal draft entry point. - Web fast-forward mounted via openSession, which replaces the focused pane: pressing it while attached evicted that session from the layout. It reuses an empty pane or splits, as the TUI does. - branchEdited was inferred from the seeded branch value, but in "new" mode that value is the auto-synced session name — so any form rebuild froze the branch against later rerolls. - resolveBaseRepo ignored the worktree checkbox, rebuilding the fieldset expanded under an unticked box and probing gitroot for a worktree the operator had turned off. - short_hash used DefaultHasher, whose algorithm is not stable across Rust releases, in a directory name — a toolchain bump would orphan every worktree under the override root. Now FNV-1a.
This commit is contained in:
@@ -114,6 +114,11 @@ pub enum DraftInputResult {
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct DraftPane {
|
||||
/// Identity for routing async load results back to *this* draft.
|
||||
///
|
||||
/// Tab indices shift when a tab closes, so an in-flight load addressed by
|
||||
/// index could be dropped or land on the wrong pane (#67 review).
|
||||
pub id: u64,
|
||||
/// Includes the implicit custom tile (empty `command`) last.
|
||||
pub presets: Vec<SpawnPreset>,
|
||||
pub selected_preset: usize,
|
||||
@@ -164,6 +169,9 @@ pub struct DraftPane {
|
||||
pub home_dir: String,
|
||||
}
|
||||
|
||||
/// Source of [`DraftPane::id`].
|
||||
static NEXT_DRAFT_ID: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(1);
|
||||
|
||||
impl Default for DraftPane {
|
||||
fn default() -> Self {
|
||||
// Built-ins until `/api/info` answers — the form must be usable even
|
||||
@@ -171,6 +179,7 @@ impl Default for DraftPane {
|
||||
let mut presets = builtin_presets();
|
||||
presets.push(custom_preset());
|
||||
Self {
|
||||
id: NEXT_DRAFT_ID.fetch_add(1, std::sync::atomic::Ordering::Relaxed),
|
||||
presets,
|
||||
selected_preset: 0,
|
||||
custom_command: crate::text_input::TextInput::default(),
|
||||
@@ -256,10 +265,16 @@ impl DraftPane {
|
||||
|
||||
/// Append a refill batch; the first name replaces the field (this only
|
||||
/// happens after an explicit reroll on an empty batch).
|
||||
pub fn extend_names(&mut self, names: Vec<String>) {
|
||||
if let Some(first) = names.first() {
|
||||
self.set_name(first.clone());
|
||||
///
|
||||
/// The shown name is *consumed*, not left at the head — queueing it too
|
||||
/// made the next reroll produce the same name and the key look dead
|
||||
/// (#67 review).
|
||||
pub fn extend_names(&mut self, mut names: Vec<String>) {
|
||||
if names.is_empty() {
|
||||
return;
|
||||
}
|
||||
let first = names.remove(0);
|
||||
self.set_name(first);
|
||||
self.name_queue.extend(names);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user