Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cd66dbf7d8 | ||
|
|
6bb812f6bd | ||
|
|
5de04af36a |
@@ -1349,9 +1349,7 @@ mod tests {
|
|||||||
for c in "crimson-otter".chars() {
|
for c in "crimson-otter".chars() {
|
||||||
app.handle_draft_input(&InputKey::char(c));
|
app.handle_draft_input(&InputKey::char(c));
|
||||||
}
|
}
|
||||||
app.handle_draft_input(&InputKey::Tab); // → worktree toggle
|
app.handle_draft_input(&InputKey::Tab); // → advanced disclosure (collapsed, #93)
|
||||||
app.handle_draft_input(&InputKey::Tab); // → branch mode
|
|
||||||
app.handle_draft_input(&InputKey::Tab); // → new-branch name
|
|
||||||
app.handle_draft_input(&InputKey::Tab); // → submit
|
app.handle_draft_input(&InputKey::Tab); // → submit
|
||||||
|
|
||||||
match app.handle_draft_input(&InputKey::Enter).as_slice() {
|
match app.handle_draft_input(&InputKey::Enter).as_slice() {
|
||||||
@@ -1553,8 +1551,8 @@ mod tests {
|
|||||||
panic!("expected a draft pane");
|
panic!("expected a draft pane");
|
||||||
};
|
};
|
||||||
assert_eq!(draft.command(), "aider");
|
assert_eq!(draft.command(), "aider");
|
||||||
assert_eq!(draft.groups.len(), 1);
|
assert_eq!(draft.rows.len(), 1);
|
||||||
assert_eq!(draft.groups[0].main.name, "maestro");
|
assert_eq!(draft.rows[0].project.name, "maestro");
|
||||||
assert_eq!(draft.home_dir, "/home/u");
|
assert_eq!(draft.home_dir, "/home/u");
|
||||||
assert_eq!(draft.name.value(), "crimson-otter");
|
assert_eq!(draft.name.value(), "crimson-otter");
|
||||||
}
|
}
|
||||||
|
|||||||
+250
-473
@@ -7,31 +7,13 @@
|
|||||||
//!
|
//!
|
||||||
//! Field groups (#64), mirroring the web form (`web/src/spawnForm.ts`):
|
//! Field groups (#64), mirroring the web form (`web/src/spawnForm.ts`):
|
||||||
//! command presets from `/api/info` (with an implicit `custom` free-text
|
//! command presets from `/api/info` (with an implicit `custom` free-text
|
||||||
//! entry), a two-step project/worktree picker (#96, mirroring the web
|
//! entry), a project picker fed by [`crate::projects`] over `/api/projects`
|
||||||
//! redesign in #95) fed by [`crate::projects`] over `/api/projects` plus an
|
//! plus an `Other directory…` escape hatch, a generated session name from
|
||||||
//! `Other directory…` escape hatch, a generated session name from
|
|
||||||
//! `/api/names` with a reroll key, and validation that reports which field is
|
//! `/api/names` with a reroll key, and validation that reports which field is
|
||||||
//! missing instead of posting an empty request. A worktree section (#65)
|
//! missing instead of posting an empty request. A worktree section (#65)
|
||||||
//! mirrors `web/src/spawnForm.ts`: on by default over a git repository,
|
//! mirrors `web/src/spawnForm.ts`: on by default over a git repository,
|
||||||
//! branch tracking the generated name until touched, with a new-or-existing
|
//! branch tracking the generated name until touched, with a new-or-existing
|
||||||
//! branch switch fed by `/api/branches`.
|
//! branch switch fed by `/api/branches`.
|
||||||
//!
|
|
||||||
//! The picker itself is two steps (#96), verbatim from the rules in
|
|
||||||
//! `web/src/spawnForm.ts`'s "working-directory picker (#95)" comment:
|
|
||||||
//! 1. Step one is one box per repository (name, then full path). A worktree
|
|
||||||
//! is a box only when its main checkout is missing from the scan.
|
|
||||||
//! 2. The filter keeps a repository when the query matches it or any of its
|
|
||||||
//! worktrees, so a worktree name still finds its box.
|
|
||||||
//! 3. Picking a box reveals step two: "+ new", then that repository's
|
|
||||||
//! worktrees newest-first. "Other directory…" clears both steps.
|
|
||||||
//! 4. "+ new" is the default selection — except on a box that is itself a
|
|
||||||
//! linked worktree, which defaults to that worktree.
|
|
||||||
//! 5. "+ new" means create: cwd is the repository, create-worktree on.
|
|
||||||
//! An existing worktree means run in it: cwd is that worktree,
|
|
||||||
//! create-worktree OFF. The daemon never adopts (docs/WORKTREES.md), so
|
|
||||||
//! these are separate acts.
|
|
||||||
//! 6. Neither step probes `/api/gitroot`; the scan already reports
|
|
||||||
//! repository membership. Only the free-text hatch pays for a probe.
|
|
||||||
|
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
@@ -70,16 +52,14 @@ pub enum DraftField {
|
|||||||
Preset,
|
Preset,
|
||||||
/// Free-text command, reachable only while a custom preset is selected.
|
/// Free-text command, reachable only while a custom preset is selected.
|
||||||
CustomCommand,
|
CustomCommand,
|
||||||
/// Step one: repository picker. Typing filters, Up / Down highlight,
|
/// Project picker: typing filters, Up / Down highlight, Enter picks.
|
||||||
/// Enter picks and reveals step two (#96).
|
|
||||||
DirPicker,
|
DirPicker,
|
||||||
/// Free-text path, revealed by picking `Other directory…`.
|
/// Free-text path, revealed by picking `Other directory…`.
|
||||||
CwdRaw,
|
CwdRaw,
|
||||||
/// Step two, shown once a repository is picked: "+ new" then that
|
|
||||||
/// repository's worktrees newest-first (#96 rule 3). Up / Down move and
|
|
||||||
/// apply immediately, mirroring the web form's per-click choice.
|
|
||||||
WorktreeChoice,
|
|
||||||
Name,
|
Name,
|
||||||
|
/// Disclosure collapsing the worktree/branch controls below (#93).
|
||||||
|
/// Closed by default; Enter / Space toggles.
|
||||||
|
Advanced,
|
||||||
/// Worktree on/off for this session (#65). Enter / Space toggles.
|
/// Worktree on/off for this session (#65). Enter / Space toggles.
|
||||||
WorktreeToggle,
|
WorktreeToggle,
|
||||||
/// New-vs-existing branch source; Left / Right switches.
|
/// New-vs-existing branch source; Left / Right switches.
|
||||||
@@ -101,50 +81,14 @@ pub enum WorktreeBranchMode {
|
|||||||
Existing,
|
Existing,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// "new" (create a worktree) or an existing worktree to run in — the TUI
|
/// One flattened project-picker entry: a discovered repo/worktree plus what
|
||||||
/// mirror of the web form's `WorktreeChoice` (#96 rule 5).
|
/// rendering needs to know about it. `indent` marks worktrees nested under
|
||||||
|
/// their main checkout.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum WorktreeChoice {
|
pub struct DraftRow {
|
||||||
New,
|
|
||||||
Existing(PathBuf),
|
|
||||||
}
|
|
||||||
|
|
||||||
/// One repository box for step one of the picker (#96 rule 1): the main
|
|
||||||
/// checkout (or, when it's missing from the scan, its freshest worktree
|
|
||||||
/// standing in for it) plus every other worktree of the same repository.
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
||||||
pub struct DraftGroup {
|
|
||||||
pub main: Project,
|
|
||||||
pub main_stale: bool,
|
|
||||||
pub worktrees: Vec<DraftWorktreeRow>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
||||||
pub struct DraftWorktreeRow {
|
|
||||||
pub project: Project,
|
pub project: Project,
|
||||||
pub stale: bool,
|
pub stale: bool,
|
||||||
}
|
pub indent: bool,
|
||||||
|
|
||||||
/// The repository key a [`DraftGroup`] was formed under — same key
|
|
||||||
/// `projects::group_projects` groups by, kept separately because the main
|
|
||||||
/// box's own path only equals it when the main checkout itself was found.
|
|
||||||
fn group_key(main: &Project) -> PathBuf {
|
|
||||||
main.base_repo.clone().unwrap_or_else(|| main.path.clone())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Every worktree of a group, including the group's own box when the scan
|
|
||||||
/// found no main checkout to nest it under — the TUI mirror of the web
|
|
||||||
/// form's `worktreesOf`. Already newest-first: when the main box stands in
|
|
||||||
/// for a missing main checkout it is the freshest member by construction
|
|
||||||
/// ([`projects::group_projects`]), and `worktrees` itself is sorted
|
|
||||||
/// newest-first.
|
|
||||||
fn worktree_rows_of(group: &DraftGroup) -> Vec<Project> {
|
|
||||||
let mut rows = Vec::new();
|
|
||||||
if group.main.is_worktree {
|
|
||||||
rows.push(group.main.clone());
|
|
||||||
}
|
|
||||||
rows.extend(group.worktrees.iter().map(|w| w.project.clone()));
|
|
||||||
rows
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Why a submit was refused. The message names the missing field so the form
|
/// Why a submit was refused. The message names the missing field so the form
|
||||||
@@ -189,23 +133,15 @@ pub struct DraftPane {
|
|||||||
pub presets: Vec<SpawnPreset>,
|
pub presets: Vec<SpawnPreset>,
|
||||||
pub selected_preset: usize,
|
pub selected_preset: usize,
|
||||||
pub custom_command: crate::text_input::TextInput,
|
pub custom_command: crate::text_input::TextInput,
|
||||||
/// Discovered projects, sorted fresh-first and grouped by repository
|
/// Discovered projects, sorted fresh-first with worktrees nested.
|
||||||
/// (#96 step one).
|
pub rows: Vec<DraftRow>,
|
||||||
pub groups: Vec<DraftGroup>,
|
|
||||||
pub filter: crate::text_input::TextInput,
|
pub filter: crate::text_input::TextInput,
|
||||||
/// Highlighted entry within the visible step-one list; the implicit
|
/// Highlighted entry within the visible list; the implicit
|
||||||
/// `Other directory…` entry sits at index `visible_groups().len()`.
|
/// `Other directory…` entry sits at index `visible_rows().len()`.
|
||||||
pub highlighted: usize,
|
pub highlighted: usize,
|
||||||
pub cwd_raw_visible: bool,
|
pub cwd_raw_visible: bool,
|
||||||
pub cwd_raw: crate::text_input::TextInput,
|
pub cwd_raw: crate::text_input::TextInput,
|
||||||
pub picked_cwd: Option<PathBuf>,
|
pub picked_cwd: Option<PathBuf>,
|
||||||
/// The repository picked in step one ([`group_key`] of its main box),
|
|
||||||
/// `None` until a box is picked. Looked up fresh in `groups` rather than
|
|
||||||
/// cached, so a project-list refresh can't leave it stale.
|
|
||||||
pub selected_group_key: Option<PathBuf>,
|
|
||||||
/// Step two's current pick (#96 rule 4/5). Meaningless while
|
|
||||||
/// `selected_group_key` is `None`.
|
|
||||||
pub worktree_choice: WorktreeChoice,
|
|
||||||
pub name: crate::text_input::TextInput,
|
pub name: crate::text_input::TextInput,
|
||||||
pub name_queue: VecDeque<String>,
|
pub name_queue: VecDeque<String>,
|
||||||
/// Set once the operator types or rerolls a name; guards refills against
|
/// Set once the operator types or rerolls a name; guards refills against
|
||||||
@@ -215,6 +151,10 @@ pub struct DraftPane {
|
|||||||
/// Worktree on for this spawn (#65). Defaults on; a failed gitroot probe
|
/// Worktree on for this spawn (#65). Defaults on; a failed gitroot probe
|
||||||
/// unticks it, like the web form.
|
/// unticks it, like the web form.
|
||||||
pub worktree_enabled: bool,
|
pub worktree_enabled: bool,
|
||||||
|
/// Whether the worktree/branch controls are collapsed behind the
|
||||||
|
/// "Advanced options" disclosure (#93). Closed by default — most spawns
|
||||||
|
/// take the default target.
|
||||||
|
pub advanced_collapsed: bool,
|
||||||
/// Enclosing repository of the chosen target — from the project scan for
|
/// Enclosing repository of the chosen target — from the project scan for
|
||||||
/// picked rows, `/api/gitroot` for raw paths. `None` until known.
|
/// picked rows, `/api/gitroot` for raw paths. `None` until known.
|
||||||
pub base_repo: Option<PathBuf>,
|
pub base_repo: Option<PathBuf>,
|
||||||
@@ -260,19 +200,18 @@ impl Default for DraftPane {
|
|||||||
presets,
|
presets,
|
||||||
selected_preset: 0,
|
selected_preset: 0,
|
||||||
custom_command: crate::text_input::TextInput::default(),
|
custom_command: crate::text_input::TextInput::default(),
|
||||||
groups: Vec::new(),
|
rows: Vec::new(),
|
||||||
filter: crate::text_input::TextInput::default(),
|
filter: crate::text_input::TextInput::default(),
|
||||||
highlighted: 0,
|
highlighted: 0,
|
||||||
cwd_raw_visible: false,
|
cwd_raw_visible: false,
|
||||||
cwd_raw: crate::text_input::TextInput::default(),
|
cwd_raw: crate::text_input::TextInput::default(),
|
||||||
picked_cwd: None,
|
picked_cwd: None,
|
||||||
selected_group_key: None,
|
|
||||||
worktree_choice: WorktreeChoice::New,
|
|
||||||
name: crate::text_input::TextInput::default(),
|
name: crate::text_input::TextInput::default(),
|
||||||
name_queue: VecDeque::new(),
|
name_queue: VecDeque::new(),
|
||||||
name_touched: false,
|
name_touched: false,
|
||||||
needs_name_refill: false,
|
needs_name_refill: false,
|
||||||
worktree_enabled: true,
|
worktree_enabled: true,
|
||||||
|
advanced_collapsed: true,
|
||||||
base_repo: None,
|
base_repo: None,
|
||||||
probed_cwd: None,
|
probed_cwd: None,
|
||||||
probe_seq: 0,
|
probe_seq: 0,
|
||||||
@@ -309,24 +248,24 @@ impl DraftPane {
|
|||||||
.unwrap_or(0);
|
.unwrap_or(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Replace the project snapshot: sort fresh-first (#54), group by
|
/// Replace the project snapshot: sort fresh-first (#54), nest worktrees
|
||||||
/// repository (#96), and precompute staleness for rendering.
|
/// under their main checkout, and precompute staleness for rendering.
|
||||||
pub fn set_projects(&mut self, discovered: Vec<Project>, now: DateTime<Utc>) {
|
pub fn set_projects(&mut self, discovered: Vec<Project>, now: DateTime<Utc>) {
|
||||||
let sorted = projects::sort_projects(discovered, now);
|
let sorted = projects::sort_projects(discovered, now);
|
||||||
let groups = projects::group_projects(&sorted);
|
let groups = projects::group_projects(&sorted);
|
||||||
self.groups = groups
|
self.rows = groups
|
||||||
.iter()
|
.iter()
|
||||||
.map(|g| DraftGroup {
|
.flat_map(|g| {
|
||||||
main: g.main.clone(),
|
std::iter::once(DraftRow {
|
||||||
main_stale: projects::is_stale(g.main, now),
|
stale: projects::is_stale(g.main, now),
|
||||||
worktrees: g
|
indent: false,
|
||||||
.worktrees
|
project: g.main.clone(),
|
||||||
.iter()
|
|
||||||
.map(|wt| DraftWorktreeRow {
|
|
||||||
project: (*wt).clone(),
|
|
||||||
stale: projects::is_stale(wt, now),
|
|
||||||
})
|
})
|
||||||
.collect(),
|
.chain(g.worktrees.iter().map(|wt| DraftRow {
|
||||||
|
stale: projects::is_stale(wt, now),
|
||||||
|
indent: true,
|
||||||
|
project: (*wt).clone(),
|
||||||
|
}))
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
self.highlighted = self.highlighted.min(self.entry_count().saturating_sub(1));
|
self.highlighted = self.highlighted.min(self.entry_count().saturating_sub(1));
|
||||||
@@ -511,6 +450,21 @@ impl DraftPane {
|
|||||||
self.set_branch_mode(next);
|
self.set_branch_mode(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Enter / Space on the "Advanced options" header (#93).
|
||||||
|
pub fn toggle_advanced(&mut self) {
|
||||||
|
self.advanced_collapsed = !self.advanced_collapsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// What the collapsed header says about this spawn's default, so it stays
|
||||||
|
/// visible without expanding (#93).
|
||||||
|
fn advanced_summary(&self) -> &'static str {
|
||||||
|
if self.worktree_enabled {
|
||||||
|
"creates a worktree"
|
||||||
|
} else {
|
||||||
|
"no worktree"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Enter / Space on the toggle. Re-enabling reuses a still-valid repo
|
/// Enter / Space on the toggle. Re-enabling reuses a still-valid repo
|
||||||
/// answer instead of re-probing.
|
/// answer instead of re-probing.
|
||||||
pub fn toggle_worktree(&mut self) {
|
pub fn toggle_worktree(&mut self) {
|
||||||
@@ -669,10 +623,10 @@ impl DraftPane {
|
|||||||
order.push(DraftField::DirPicker);
|
order.push(DraftField::DirPicker);
|
||||||
if self.cwd_raw_visible {
|
if self.cwd_raw_visible {
|
||||||
order.push(DraftField::CwdRaw);
|
order.push(DraftField::CwdRaw);
|
||||||
} else if self.selected_group_key.is_some() {
|
|
||||||
order.push(DraftField::WorktreeChoice);
|
|
||||||
}
|
}
|
||||||
order.push(DraftField::Name);
|
order.push(DraftField::Name);
|
||||||
|
order.push(DraftField::Advanced);
|
||||||
|
if !self.advanced_collapsed {
|
||||||
order.push(DraftField::WorktreeToggle);
|
order.push(DraftField::WorktreeToggle);
|
||||||
if self.worktree_body_visible() {
|
if self.worktree_body_visible() {
|
||||||
order.push(DraftField::BranchMode);
|
order.push(DraftField::BranchMode);
|
||||||
@@ -681,6 +635,7 @@ impl DraftPane {
|
|||||||
WorktreeBranchMode::Existing => DraftField::BranchExisting,
|
WorktreeBranchMode::Existing => DraftField::BranchExisting,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
order.extend([DraftField::Submit]);
|
order.extend([DraftField::Submit]);
|
||||||
order
|
order
|
||||||
}
|
}
|
||||||
@@ -712,25 +667,18 @@ impl DraftPane {
|
|||||||
((self.selected_preset as i32) + delta).rem_euclid(len as i32) as usize;
|
((self.selected_preset as i32) + delta).rem_euclid(len as i32) as usize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Step-one boxes surviving the type-to-filter, in display order. A
|
/// Rows surviving the type-to-filter, in display order.
|
||||||
/// group survives when the query matches its box or any of its
|
pub fn visible_rows(&self) -> Vec<&DraftRow> {
|
||||||
/// worktrees (#96 rule 2), so a worktree name still finds its box.
|
|
||||||
pub fn visible_groups(&self) -> Vec<&DraftGroup> {
|
|
||||||
let query = self.filter.value();
|
let query = self.filter.value();
|
||||||
self.groups
|
self.rows
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|g| {
|
.filter(|r| projects::matches_filter(&r.project, query))
|
||||||
projects::matches_filter(&g.main, query)
|
|
||||||
|| g.worktrees
|
|
||||||
.iter()
|
|
||||||
.any(|w| projects::matches_filter(&w.project, query))
|
|
||||||
})
|
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Visible entries including the trailing implicit `Other directory…`.
|
/// Visible entries including the trailing implicit `Other directory…`.
|
||||||
pub fn entry_count(&self) -> usize {
|
pub fn entry_count(&self) -> usize {
|
||||||
self.visible_groups().len() + 1
|
self.visible_rows().len() + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Highlight clamped to the current entry count.
|
/// Highlight clamped to the current entry count.
|
||||||
@@ -746,47 +694,35 @@ impl DraftPane {
|
|||||||
self.highlighted = ((self.selection() as i32) + delta).rem_euclid(count) as usize;
|
self.highlighted = ((self.selection() as i32) + delta).rem_euclid(count) as usize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The step-one group currently picked, looked up fresh against the
|
/// Act on the highlighted picker entry: a project becomes the working
|
||||||
/// latest snapshot so a project-list refresh can't leave a stale clone
|
/// directory (and pre-selects the command it was last used with), while
|
||||||
/// behind.
|
/// the trailing entry reveals the free-text path input.
|
||||||
pub fn selected_group(&self) -> Option<DraftGroup> {
|
|
||||||
let key = self.selected_group_key.as_ref()?;
|
|
||||||
self.groups
|
|
||||||
.iter()
|
|
||||||
.find(|g| &group_key(&g.main) == key)
|
|
||||||
.cloned()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Step two's rows: "+ new" first, then the repository's worktrees
|
|
||||||
/// newest-first (#96 rule 3). Empty while no group is picked.
|
|
||||||
pub fn worktree_choice_rows(&self) -> Vec<(WorktreeChoice, String, String)> {
|
|
||||||
let Some(group) = self.selected_group() else {
|
|
||||||
return Vec::new();
|
|
||||||
};
|
|
||||||
let mut rows = vec![(
|
|
||||||
WorktreeChoice::New,
|
|
||||||
"+ new".to_string(),
|
|
||||||
format!("new worktree of {}", group.main.name),
|
|
||||||
)];
|
|
||||||
rows.extend(worktree_rows_of(&group).into_iter().map(|p| {
|
|
||||||
(
|
|
||||||
WorktreeChoice::Existing(p.path.clone()),
|
|
||||||
p.name.clone(),
|
|
||||||
p.path.to_string_lossy().into_owned(),
|
|
||||||
)
|
|
||||||
}));
|
|
||||||
rows
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Act on the highlighted step-one box: reveals step two, defaulting per
|
|
||||||
/// rule 4. The trailing entry reveals the free-text path input and
|
|
||||||
/// clears both steps (rule 3).
|
|
||||||
pub fn select_entry(&mut self) {
|
pub fn select_entry(&mut self) {
|
||||||
let visible = self.visible_groups();
|
let visible = self.visible_rows();
|
||||||
let sel = self.selection();
|
let sel = self.selection();
|
||||||
if sel < visible.len() {
|
if sel < visible.len() {
|
||||||
let group = visible[sel].clone();
|
let project = visible[sel].project.clone();
|
||||||
self.select_group(&group);
|
self.picked_cwd = Some(project.path.clone());
|
||||||
|
self.cwd_raw_visible = false;
|
||||||
|
// A directory that *is* a linked worktree defaults to spawning in
|
||||||
|
// place (#91): creating a second worktree of its branch fails.
|
||||||
|
// Turning it back on by hand still tries (git's own message),
|
||||||
|
// which is deliberate (#91 non-goal).
|
||||||
|
self.worktree_enabled = !project.is_worktree;
|
||||||
|
// The scan already knows this directory's repo (#61): no probe
|
||||||
|
// round trip needed, exactly like the web form.
|
||||||
|
let repo = project
|
||||||
|
.base_repo
|
||||||
|
.clone()
|
||||||
|
.unwrap_or_else(|| project.path.clone());
|
||||||
|
if let Some(cmd) = project.last_command.as_deref() {
|
||||||
|
if !cmd.is_empty() {
|
||||||
|
if let Some(idx) = self.presets.iter().position(|p| p.command == cmd) {
|
||||||
|
self.selected_preset = idx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.note_picked_repo(repo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let seed = self.cwd().unwrap_or_else(|| {
|
let seed = self.cwd().unwrap_or_else(|| {
|
||||||
@@ -796,7 +732,6 @@ impl DraftPane {
|
|||||||
PathBuf::from(&self.home_dir)
|
PathBuf::from(&self.home_dir)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
self.clear_project_selection();
|
|
||||||
self.picked_cwd = None;
|
self.picked_cwd = None;
|
||||||
self.cwd_raw_visible = true;
|
self.cwd_raw_visible = true;
|
||||||
self.cwd_raw = crate::text_input::TextInput::with_value(seed.to_string_lossy());
|
self.cwd_raw = crate::text_input::TextInput::with_value(seed.to_string_lossy());
|
||||||
@@ -804,95 +739,6 @@ impl DraftPane {
|
|||||||
self.note_unknown_repo();
|
self.note_unknown_repo();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Pick a step-one box: remember it and default step two (#96 rule 4) —
|
|
||||||
/// "+ new", except a box that is itself a linked worktree (the scan
|
|
||||||
/// found no main checkout for it), which defaults to that worktree.
|
|
||||||
fn select_group(&mut self, group: &DraftGroup) {
|
|
||||||
self.selected_group_key = Some(group_key(&group.main));
|
|
||||||
let default = if group.main.is_worktree {
|
|
||||||
WorktreeChoice::Existing(group.main.path.clone())
|
|
||||||
} else {
|
|
||||||
WorktreeChoice::New
|
|
||||||
};
|
|
||||||
self.apply_worktree_choice(default);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Clear both picker steps (#96 rule 3), e.g. for `Other directory…`.
|
|
||||||
fn clear_project_selection(&mut self) {
|
|
||||||
self.selected_group_key = None;
|
|
||||||
self.worktree_choice = WorktreeChoice::New;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Apply a step-two pick (#96 rule 5): "+ new" targets the repository
|
|
||||||
/// itself with worktree creation on; an existing worktree targets it
|
|
||||||
/// directly with worktree creation off — the daemon never adopts
|
|
||||||
/// (docs/WORKTREES.md). Neither path probes `/api/gitroot` (rule 6): the
|
|
||||||
/// scan already reported this target's repository.
|
|
||||||
pub fn apply_worktree_choice(&mut self, choice: WorktreeChoice) {
|
|
||||||
let Some(group) = self.selected_group() else {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
let target = match &choice {
|
|
||||||
WorktreeChoice::New => group.main.clone(),
|
|
||||||
WorktreeChoice::Existing(path) => {
|
|
||||||
match worktree_rows_of(&group)
|
|
||||||
.into_iter()
|
|
||||||
.find(|p| &p.path == path)
|
|
||||||
{
|
|
||||||
Some(p) => p,
|
|
||||||
None => return,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
self.worktree_choice = choice.clone();
|
|
||||||
self.picked_cwd = Some(target.path.clone());
|
|
||||||
self.cwd_raw_visible = false;
|
|
||||||
if let Some(cmd) = target.last_command.as_deref() {
|
|
||||||
if !cmd.is_empty() {
|
|
||||||
if let Some(idx) = self.presets.iter().position(|p| p.command == cmd) {
|
|
||||||
self.selected_preset = idx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
match choice {
|
|
||||||
WorktreeChoice::New => {
|
|
||||||
self.worktree_enabled = true;
|
|
||||||
let repo = target
|
|
||||||
.base_repo
|
|
||||||
.clone()
|
|
||||||
.unwrap_or_else(|| target.path.clone());
|
|
||||||
self.note_picked_repo(repo);
|
|
||||||
}
|
|
||||||
WorktreeChoice::Existing(_) => {
|
|
||||||
self.worktree_enabled = false;
|
|
||||||
self.base_repo = None;
|
|
||||||
self.repo_missing = false;
|
|
||||||
self.probe_seq += 1;
|
|
||||||
self.needs_probe = false;
|
|
||||||
self.probe_due_at = None;
|
|
||||||
self.probed_cwd = self.cwd();
|
|
||||||
self.branches_for = None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Move step two's highlight and apply the newly-highlighted choice at
|
|
||||||
/// once, matching the web form's per-click pick — there is no separate
|
|
||||||
/// confirm step.
|
|
||||||
pub fn move_worktree_choice(&mut self, delta: i32) {
|
|
||||||
let rows = self.worktree_choice_rows();
|
|
||||||
let count = rows.len() as i32;
|
|
||||||
if count == 0 {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let cur = rows
|
|
||||||
.iter()
|
|
||||||
.position(|(c, _, _)| *c == self.worktree_choice)
|
|
||||||
.unwrap_or(0) as i32;
|
|
||||||
let next = ((cur + delta).rem_euclid(count)) as usize;
|
|
||||||
self.apply_worktree_choice(rows[next].0.clone());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Handle one keystroke while this draft owns input (Insert mode, pane
|
/// Handle one keystroke while this draft owns input (Insert mode, pane
|
||||||
/// focused). Returns [`DraftInputResult::Submit`] when the user accepts;
|
/// focused). Returns [`DraftInputResult::Submit`] when the user accepts;
|
||||||
/// the caller validates, fires the POST and replaces the draft with the
|
/// the caller validates, fires the POST and replaces the draft with the
|
||||||
@@ -913,6 +759,10 @@ impl DraftPane {
|
|||||||
self.select_entry();
|
self.select_entry();
|
||||||
DraftInputResult::Consumed
|
DraftInputResult::Consumed
|
||||||
}
|
}
|
||||||
|
DraftField::Advanced => {
|
||||||
|
self.toggle_advanced();
|
||||||
|
DraftInputResult::Consumed
|
||||||
|
}
|
||||||
DraftField::WorktreeToggle => {
|
DraftField::WorktreeToggle => {
|
||||||
self.toggle_worktree();
|
self.toggle_worktree();
|
||||||
DraftInputResult::Consumed
|
DraftInputResult::Consumed
|
||||||
@@ -924,6 +774,14 @@ impl DraftPane {
|
|||||||
DraftInputResult::Consumed
|
DraftInputResult::Consumed
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
InputKey::Char {
|
||||||
|
c: ' ',
|
||||||
|
ctrl: false,
|
||||||
|
..
|
||||||
|
} if self.focused_field == DraftField::Advanced => {
|
||||||
|
self.toggle_advanced();
|
||||||
|
DraftInputResult::Consumed
|
||||||
|
}
|
||||||
InputKey::Char {
|
InputKey::Char {
|
||||||
c: ' ',
|
c: ' ',
|
||||||
ctrl: false,
|
ctrl: false,
|
||||||
@@ -940,14 +798,6 @@ impl DraftPane {
|
|||||||
self.move_selection(1);
|
self.move_selection(1);
|
||||||
DraftInputResult::Consumed
|
DraftInputResult::Consumed
|
||||||
}
|
}
|
||||||
InputKey::Up if self.focused_field == DraftField::WorktreeChoice => {
|
|
||||||
self.move_worktree_choice(-1);
|
|
||||||
DraftInputResult::Consumed
|
|
||||||
}
|
|
||||||
InputKey::Down if self.focused_field == DraftField::WorktreeChoice => {
|
|
||||||
self.move_worktree_choice(1);
|
|
||||||
DraftInputResult::Consumed
|
|
||||||
}
|
|
||||||
InputKey::Left if self.focused_field == DraftField::Preset => {
|
InputKey::Left if self.focused_field == DraftField::Preset => {
|
||||||
self.cycle_preset(-1);
|
self.cycle_preset(-1);
|
||||||
DraftInputResult::Consumed
|
DraftInputResult::Consumed
|
||||||
@@ -1020,23 +870,18 @@ impl DraftPane {
|
|||||||
|
|
||||||
let show_custom = self.is_custom();
|
let show_custom = self.is_custom();
|
||||||
let show_raw = self.cwd_raw_visible;
|
let show_raw = self.cwd_raw_visible;
|
||||||
let show_wt_choice = self.selected_group_key.is_some() && !show_raw;
|
// The worktree toggle and its body stay behind the "Advanced options"
|
||||||
let wt_choice_rows_data = if show_wt_choice {
|
// disclosure (#93): collapsed hides both, regardless of what they'd
|
||||||
self.worktree_choice_rows()
|
// otherwise show.
|
||||||
} else {
|
let show_wt_toggle = !self.advanced_collapsed;
|
||||||
Vec::new()
|
let show_wt_body = show_wt_toggle && self.worktree_body_visible();
|
||||||
};
|
|
||||||
// Up to four choices (new + worktrees) stay visible around the
|
|
||||||
// selection.
|
|
||||||
let wt_choice_capacity = wt_choice_rows_data.len().clamp(1, 4) as u16;
|
|
||||||
let show_wt_body = self.worktree_body_visible();
|
|
||||||
// Up to three branch rows stay visible around the selection; held
|
// Up to three branch rows stay visible around the selection; held
|
||||||
// branches need their reason on screen, so they aren't collapsed.
|
// branches need their reason on screen, so they aren't collapsed.
|
||||||
let branch_rows = self.branches.len().clamp(1, 3) as u16;
|
let branch_rows = self.branches.len().clamp(1, 3) as u16;
|
||||||
let fixed: u16 = 3 /* tiles + dir + name */ + 1 /* worktree */ + 1 /* spawn */
|
let fixed: u16 = 3 /* tiles + dir + name */ + 1 /* advanced header */ + 1 /* spawn */
|
||||||
+ u16::from(show_custom)
|
+ u16::from(show_custom)
|
||||||
+ u16::from(show_raw)
|
+ u16::from(show_raw)
|
||||||
+ u16::from(show_wt_choice) * wt_choice_capacity
|
+ u16::from(show_wt_toggle)
|
||||||
+ u16::from(show_wt_body) * (1 + if self.branch_mode == WorktreeBranchMode::New { 1 } else { branch_rows })
|
+ u16::from(show_wt_body) * (1 + if self.branch_mode == WorktreeBranchMode::New { 1 } else { branch_rows })
|
||||||
+ u16::from(self.error.is_some());
|
+ u16::from(self.error.is_some());
|
||||||
let list_capacity = (inner.height.saturating_sub(fixed)).max(1) as usize;
|
let list_capacity = (inner.height.saturating_sub(fixed)).max(1) as usize;
|
||||||
@@ -1049,11 +894,12 @@ impl DraftPane {
|
|||||||
constraints.push(Constraint::Length(list_capacity as u16));
|
constraints.push(Constraint::Length(list_capacity as u16));
|
||||||
if show_raw {
|
if show_raw {
|
||||||
constraints.push(Constraint::Length(1));
|
constraints.push(Constraint::Length(1));
|
||||||
} else if show_wt_choice {
|
|
||||||
constraints.push(Constraint::Length(wt_choice_capacity));
|
|
||||||
}
|
}
|
||||||
constraints.push(Constraint::Length(1)); // name
|
constraints.push(Constraint::Length(1)); // name
|
||||||
|
constraints.push(Constraint::Length(1)); // advanced header
|
||||||
|
if show_wt_toggle {
|
||||||
constraints.push(Constraint::Length(1)); // worktree toggle
|
constraints.push(Constraint::Length(1)); // worktree toggle
|
||||||
|
}
|
||||||
if show_wt_body {
|
if show_wt_body {
|
||||||
constraints.push(Constraint::Length(1)); // branch mode
|
constraints.push(Constraint::Length(1)); // branch mode
|
||||||
match self.branch_mode {
|
match self.branch_mode {
|
||||||
@@ -1127,10 +973,7 @@ impl DraftPane {
|
|||||||
cursor = Some((col, filter_row.y));
|
cursor = Some((col, filter_row.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step one (#96 rule 1): one box per repository, name then the FULL
|
let visible = self.visible_rows();
|
||||||
// path — not the abbreviated form other lists use — so two projects
|
|
||||||
// sharing a basename stay distinguishable.
|
|
||||||
let visible = self.visible_groups();
|
|
||||||
let sel = self.selection();
|
let sel = self.selection();
|
||||||
let count = visible.len() + 1;
|
let count = visible.len() + 1;
|
||||||
let capacity = list_capacity.min(count);
|
let capacity = list_capacity.min(count);
|
||||||
@@ -1143,7 +986,7 @@ impl DraftPane {
|
|||||||
.iter()
|
.iter()
|
||||||
.take(start + capacity)
|
.take(start + capacity)
|
||||||
.skip(start)
|
.skip(start)
|
||||||
.map(|group| group.main.name.chars().count())
|
.map(|row| row.project.name.chars().count() + usize::from(row.indent) * 2)
|
||||||
.max()
|
.max()
|
||||||
.unwrap_or(0)
|
.unwrap_or(0)
|
||||||
.min(18);
|
.min(18);
|
||||||
@@ -1156,19 +999,31 @@ impl DraftPane {
|
|||||||
}
|
}
|
||||||
let active = pane_focused && self.focused_field == DraftField::DirPicker && i == sel;
|
let active = pane_focused && self.focused_field == DraftField::DirPicker && i == sel;
|
||||||
let line = if i < visible.len() {
|
let line = if i < visible.len() {
|
||||||
let group = visible[i];
|
let row = visible[i];
|
||||||
let mut base = Style::default();
|
let mut base = Style::default();
|
||||||
if group.main_stale {
|
if row.stale {
|
||||||
base = base.add_modifier(Modifier::DIM);
|
base = base.add_modifier(Modifier::DIM);
|
||||||
}
|
}
|
||||||
if active {
|
if active {
|
||||||
base = base.add_modifier(Modifier::REVERSED);
|
base = base.add_modifier(Modifier::REVERSED);
|
||||||
}
|
}
|
||||||
|
let name = if row.indent {
|
||||||
|
format!(" {}", row.project.name)
|
||||||
|
} else {
|
||||||
|
row.project.name.clone()
|
||||||
|
};
|
||||||
Line::from(vec![
|
Line::from(vec![
|
||||||
Span::styled(if active { ">" } else { " " }, base),
|
Span::styled(if active { ">" } else { " " }, base),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
Span::styled(format!("{:<name_width$}", group.main.name), base),
|
Span::styled(format!("{name:<name_width$}"), base),
|
||||||
Span::styled(format!(" {}", group.main.path.display()), base),
|
Span::styled(
|
||||||
|
format!(" {}", abbreviate_path(&row.project.path, &self.home_dir)),
|
||||||
|
base,
|
||||||
|
),
|
||||||
|
Span::styled(
|
||||||
|
format!(" {}", row.project.last_command.clone().unwrap_or_default()),
|
||||||
|
base,
|
||||||
|
),
|
||||||
])
|
])
|
||||||
} else {
|
} else {
|
||||||
let mut style = Style::default();
|
let mut style = Style::default();
|
||||||
@@ -1196,53 +1051,6 @@ impl DraftPane {
|
|||||||
if self.focused_field == DraftField::CwdRaw {
|
if self.focused_field == DraftField::CwdRaw {
|
||||||
cursor = Some((col, row.y));
|
cursor = Some((col, row.y));
|
||||||
}
|
}
|
||||||
} else if show_wt_choice {
|
|
||||||
// Step two (#96 rule 3): "+ new" first, then the repository's
|
|
||||||
// worktrees newest-first.
|
|
||||||
let choice_rows = wt_choice_rows_data;
|
|
||||||
let csel = choice_rows
|
|
||||||
.iter()
|
|
||||||
.position(|(c, _, _)| *c == self.worktree_choice)
|
|
||||||
.unwrap_or(0);
|
|
||||||
let ccap = (wt_choice_capacity as usize).min(choice_rows.len().max(1));
|
|
||||||
let cstart = if csel >= ccap { csel + 1 - ccap } else { 0 };
|
|
||||||
let label_width = choice_rows
|
|
||||||
.iter()
|
|
||||||
.skip(cstart)
|
|
||||||
.take(ccap)
|
|
||||||
.map(|(_, label, _)| label.chars().count())
|
|
||||||
.max()
|
|
||||||
.unwrap_or(0)
|
|
||||||
.min(18);
|
|
||||||
let choice_row = next_row();
|
|
||||||
for i in cstart..cstart + ccap {
|
|
||||||
let y = choice_row.y + (i - cstart) as u16;
|
|
||||||
if y >= choice_row.y + choice_row.height || i >= choice_rows.len() {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
let (_, label, sub) = &choice_rows[i];
|
|
||||||
let active =
|
|
||||||
pane_focused && self.focused_field == DraftField::WorktreeChoice && i == csel;
|
|
||||||
let mut base = Style::default();
|
|
||||||
if active {
|
|
||||||
base = base.add_modifier(Modifier::REVERSED);
|
|
||||||
}
|
|
||||||
let line = Line::from(vec![
|
|
||||||
Span::styled(if active { ">" } else { " " }, base),
|
|
||||||
Span::raw(" "),
|
|
||||||
Span::styled(format!("{label:<label_width$}"), base),
|
|
||||||
Span::styled(format!(" {sub}"), base),
|
|
||||||
]);
|
|
||||||
f.render_widget(
|
|
||||||
Paragraph::new(line),
|
|
||||||
Rect {
|
|
||||||
x: choice_row.x + GUTTER as u16,
|
|
||||||
y,
|
|
||||||
width: choice_row.width.saturating_sub(GUTTER as u16),
|
|
||||||
height: 1,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- name + reroll ---------------------------------------------------------
|
// -- name + reroll ---------------------------------------------------------
|
||||||
@@ -1268,7 +1076,28 @@ impl DraftPane {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// -- advanced disclosure (#93) ------------------------------------------
|
||||||
|
let advanced_row = next_row();
|
||||||
|
f.render_widget(
|
||||||
|
Paragraph::new(Line::from(vec![
|
||||||
|
Span::raw(format!("{:<GUTTER$}", "adv:")),
|
||||||
|
Span::styled(
|
||||||
|
format!(
|
||||||
|
"[{}] Advanced options",
|
||||||
|
if self.advanced_collapsed { "+" } else { "-" }
|
||||||
|
),
|
||||||
|
field_style(DraftField::Advanced),
|
||||||
|
),
|
||||||
|
Span::styled(
|
||||||
|
format!(" — {}", self.advanced_summary()),
|
||||||
|
Style::default().add_modifier(Modifier::DIM),
|
||||||
|
),
|
||||||
|
])),
|
||||||
|
advanced_row,
|
||||||
|
);
|
||||||
|
|
||||||
// -- worktree (#65) -----------------------------------------------------
|
// -- worktree (#65) -----------------------------------------------------
|
||||||
|
if show_wt_toggle {
|
||||||
let wt_row = next_row();
|
let wt_row = next_row();
|
||||||
let hint = if self.cwd().is_none() {
|
let hint = if self.cwd().is_none() {
|
||||||
Some("choose a directory first")
|
Some("choose a directory first")
|
||||||
@@ -1295,6 +1124,7 @@ impl DraftPane {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
f.render_widget(Paragraph::new(Line::from(tiles)), wt_row);
|
f.render_widget(Paragraph::new(Line::from(tiles)), wt_row);
|
||||||
|
}
|
||||||
|
|
||||||
if show_wt_body {
|
if show_wt_body {
|
||||||
// branch source: new (created) vs existing (checked out as-is)
|
// branch source: new (created) vs existing (checked out as-is)
|
||||||
@@ -1643,8 +1473,12 @@ mod tests {
|
|||||||
let stale_pos = rendered.find("stale-repo").unwrap();
|
let stale_pos = rendered.find("stale-repo").unwrap();
|
||||||
assert!(fresh_pos < stale_pos, "fresh before stale:\n{rendered}");
|
assert!(fresh_pos < stale_pos, "fresh before stale:\n{rendered}");
|
||||||
assert!(
|
assert!(
|
||||||
rendered.contains("/home/u/new/repo"),
|
rendered.contains("~/n/repo"),
|
||||||
"the full path, not an abbreviation (#96 rule 1):\n{rendered}"
|
"collapsed path stem:\n{rendered}"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
rendered.contains("claude"),
|
||||||
|
"last command shown:\n{rendered}"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Staleness dims the row's cells.
|
// Staleness dims the row's cells.
|
||||||
@@ -1673,7 +1507,7 @@ mod tests {
|
|||||||
assert_eq!(draft.focused_field, DraftField::DirPicker);
|
assert_eq!(draft.focused_field, DraftField::DirPicker);
|
||||||
typed(&mut draft, "maes");
|
typed(&mut draft, "maes");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
draft.visible_groups().len(),
|
draft.visible_rows().len(),
|
||||||
1,
|
1,
|
||||||
"type-to-filter narrows the list"
|
"type-to-filter narrows the list"
|
||||||
);
|
);
|
||||||
@@ -1957,139 +1791,38 @@ mod tests {
|
|||||||
assert!(wt.create_branch);
|
assert!(wt.create_branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A worktree of `group.main` (matching a solo worktree, is_worktree true).
|
|
||||||
fn linked_worktree(name: &str, path: &str, base: &str, days_ago: i64) -> Project {
|
|
||||||
let mut wt = repo_project(name, path, base, days_ago, None);
|
|
||||||
wt.is_worktree = true;
|
|
||||||
wt
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn a_query_matching_only_a_worktree_still_finds_its_repository_box() {
|
fn picking_a_worktree_project_defaults_the_toggle_off() {
|
||||||
// #96 rule 2: the filter keeps a repository when the query matches
|
|
||||||
// it or any of its worktrees.
|
|
||||||
let mut draft = DraftPane::default();
|
let mut draft = DraftPane::default();
|
||||||
|
let mut wt = repo_project("wt-91", "/repos/wt91", "/repos/main", 1, None);
|
||||||
|
wt.is_worktree = true;
|
||||||
draft.set_projects(
|
draft.set_projects(
|
||||||
vec![
|
vec![
|
||||||
repo_project("main", "/repos/main", "/repos/main", 2, None),
|
repo_project("main", "/repos/main", "/repos/main", 2, None),
|
||||||
linked_worktree("wt-91", "/repos/wt91", "/repos/main", 1),
|
wt,
|
||||||
],
|
],
|
||||||
Utc::now(),
|
Utc::now(),
|
||||||
);
|
);
|
||||||
draft.focused_field = DraftField::DirPicker;
|
draft.focused_field = DraftField::DirPicker;
|
||||||
typed(&mut draft, "wt-91");
|
typed(&mut draft, "wt-91");
|
||||||
assert_eq!(
|
draft.on_input(&InputKey::Enter);
|
||||||
draft.visible_groups().len(),
|
|
||||||
1,
|
|
||||||
"the worktree's name matches its repository's box"
|
|
||||||
);
|
|
||||||
assert_eq!(draft.visible_groups()[0].main.name, "main");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn picking_a_repository_box_reveals_step_two_defaulting_to_new() {
|
|
||||||
// #96 rule 3 (reveal) + rule 4 (default): a repository box that is
|
|
||||||
// itself a real main checkout defaults step two to "+ new".
|
|
||||||
let mut draft = DraftPane::default();
|
|
||||||
draft.set_projects(
|
|
||||||
vec![
|
|
||||||
repo_project("main", "/repos/main", "/repos/main", 2, None),
|
|
||||||
linked_worktree("wt-91", "/repos/wt91", "/repos/main", 1),
|
|
||||||
],
|
|
||||||
Utc::now(),
|
|
||||||
);
|
|
||||||
draft.focused_field = DraftField::DirPicker;
|
|
||||||
draft.on_input(&InputKey::Enter); // picks the only box: "main"
|
|
||||||
|
|
||||||
assert_eq!(draft.worktree_choice, WorktreeChoice::New);
|
|
||||||
assert_eq!(draft.picked_cwd.as_deref(), Some(Path::new("/repos/main")));
|
|
||||||
assert!(draft.worktree_enabled, "\"+ new\" means create-worktree on");
|
|
||||||
assert!(
|
assert!(
|
||||||
draft.field_order().contains(&DraftField::WorktreeChoice),
|
!draft.worktree_enabled,
|
||||||
"step two is now reachable"
|
"the directory is already a worktree; spawning in place"
|
||||||
);
|
);
|
||||||
assert!(
|
|
||||||
draft.take_gitroot_probe(probe_due()).is_none(),
|
|
||||||
"rule 6: the scan already knows this repository"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Step two: move onto the worktree and pick it (rule 5 — existing
|
|
||||||
// worktree means run in it, create-worktree off).
|
|
||||||
draft.focused_field = DraftField::WorktreeChoice;
|
|
||||||
draft.on_input(&InputKey::Down);
|
|
||||||
assert_eq!(
|
|
||||||
draft.worktree_choice,
|
|
||||||
WorktreeChoice::Existing(PathBuf::from("/repos/wt91"))
|
|
||||||
);
|
|
||||||
assert_eq!(draft.picked_cwd.as_deref(), Some(Path::new("/repos/wt91")));
|
|
||||||
assert!(!draft.worktree_enabled);
|
|
||||||
assert!(
|
assert!(
|
||||||
draft.build_request().unwrap().worktree.is_none(),
|
draft.build_request().unwrap().worktree.is_none(),
|
||||||
"no worktree record — the session just runs there"
|
"no worktree record — the session just runs there (#91)"
|
||||||
);
|
);
|
||||||
assert!(
|
|
||||||
draft.take_gitroot_probe(probe_due()).is_none(),
|
|
||||||
"rule 6: still no probe for a scan-known worktree"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
// Deliberately re-enabling still works, and the scan-known base repo
|
||||||
fn a_box_that_is_itself_a_linked_worktree_defaults_to_running_there() {
|
// survives so the toggle-on path needs no new probe.
|
||||||
// #96 rule 4: when the scan found no main checkout, the box IS a
|
draft.focused_field = DraftField::WorktreeToggle;
|
||||||
// worktree, and step two defaults to that worktree instead of
|
|
||||||
// "+ new".
|
|
||||||
let mut draft = DraftPane::default();
|
|
||||||
draft.set_projects(
|
|
||||||
vec![linked_worktree(
|
|
||||||
"solo-wt",
|
|
||||||
"/repos/solo-wt",
|
|
||||||
"/repos/solo",
|
|
||||||
1,
|
|
||||||
)],
|
|
||||||
Utc::now(),
|
|
||||||
);
|
|
||||||
draft.focused_field = DraftField::DirPicker;
|
|
||||||
draft.on_input(&InputKey::Enter);
|
draft.on_input(&InputKey::Enter);
|
||||||
|
assert!(draft.worktree_enabled);
|
||||||
assert_eq!(
|
assert_eq!(draft.base_repo.as_deref(), Some(Path::new("/repos/main")));
|
||||||
draft.worktree_choice,
|
assert!(draft.take_gitroot_probe(probe_due()).is_none());
|
||||||
WorktreeChoice::Existing(PathBuf::from("/repos/solo-wt"))
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
draft.picked_cwd.as_deref(),
|
|
||||||
Some(Path::new("/repos/solo-wt"))
|
|
||||||
);
|
|
||||||
assert!(!draft.worktree_enabled, "defaults to running in place");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn other_directory_clears_both_picker_steps() {
|
|
||||||
// #96 rule 3.
|
|
||||||
let mut draft = DraftPane::default();
|
|
||||||
draft.set_projects(
|
|
||||||
vec![
|
|
||||||
repo_project("main", "/repos/main", "/repos/main", 2, None),
|
|
||||||
linked_worktree("wt-91", "/repos/wt91", "/repos/main", 1),
|
|
||||||
],
|
|
||||||
Utc::now(),
|
|
||||||
);
|
|
||||||
draft.focused_field = DraftField::DirPicker;
|
|
||||||
draft.on_input(&InputKey::Enter); // picks "main", reveals step two
|
|
||||||
assert!(draft.selected_group_key.is_some());
|
|
||||||
|
|
||||||
draft.focused_field = DraftField::DirPicker;
|
|
||||||
draft.move_selection(1); // onto Other directory…
|
|
||||||
draft.on_input(&InputKey::Enter);
|
|
||||||
|
|
||||||
assert!(draft.cwd_raw_visible);
|
|
||||||
assert!(
|
|
||||||
draft.selected_group_key.is_none(),
|
|
||||||
"step one's pick is cleared"
|
|
||||||
);
|
|
||||||
assert!(
|
|
||||||
draft.worktree_choice_rows().is_empty(),
|
|
||||||
"step two is cleared too"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -2229,7 +1962,10 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn held_branches_render_unavailable_with_their_holder_as_the_reason() {
|
fn held_branches_render_unavailable_with_their_holder_as_the_reason() {
|
||||||
let mut draft = DraftPane::default();
|
let mut draft = DraftPane {
|
||||||
|
advanced_collapsed: false,
|
||||||
|
..DraftPane::default()
|
||||||
|
};
|
||||||
draft.set_projects(
|
draft.set_projects(
|
||||||
vec![repo_project(
|
vec![repo_project(
|
||||||
"maestro",
|
"maestro",
|
||||||
@@ -2400,49 +2136,11 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn render_shows_step_two_wording_full_paths_and_newest_first_order() {
|
|
||||||
let mut draft = DraftPane {
|
|
||||||
home_dir: "/home/u".into(),
|
|
||||||
..DraftPane::default()
|
|
||||||
};
|
|
||||||
draft.set_projects(
|
|
||||||
vec![
|
|
||||||
repo_project("main", "/home/u/repos/main", "/home/u/repos/main", 5, None),
|
|
||||||
linked_worktree("older-wt", "/home/u/repos/older", "/home/u/repos/main", 3),
|
|
||||||
linked_worktree("newer-wt", "/home/u/repos/newer", "/home/u/repos/main", 1),
|
|
||||||
],
|
|
||||||
Utc::now(),
|
|
||||||
);
|
|
||||||
draft.focused_field = DraftField::DirPicker;
|
|
||||||
draft.on_input(&InputKey::Enter); // picks the "main" box
|
|
||||||
let rendered = render_to_string(100, 24, |f| draft.render(f, f.area(), true));
|
|
||||||
|
|
||||||
assert!(
|
|
||||||
rendered.contains("/home/u/repos/main"),
|
|
||||||
"step one shows the full repository path:\n{rendered}"
|
|
||||||
);
|
|
||||||
assert!(
|
|
||||||
rendered.contains("+ new"),
|
|
||||||
"step two's create choice:\n{rendered}"
|
|
||||||
);
|
|
||||||
assert!(
|
|
||||||
rendered.contains("/home/u/repos/newer"),
|
|
||||||
"step two shows worktrees' full paths:\n{rendered}"
|
|
||||||
);
|
|
||||||
let new_pos = rendered.find("+ new").unwrap();
|
|
||||||
let newer_pos = rendered.find("newer-wt").unwrap();
|
|
||||||
let older_pos = rendered.find("older-wt").unwrap();
|
|
||||||
assert!(
|
|
||||||
new_pos < newer_pos && newer_pos < older_pos,
|
|
||||||
"\"+ new\" first, then worktrees newest-first:\n{rendered}"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn render_shows_the_worktree_section() {
|
fn render_shows_the_worktree_section() {
|
||||||
let mut draft = DraftPane {
|
let mut draft = DraftPane {
|
||||||
home_dir: "/home/u".into(),
|
home_dir: "/home/u".into(),
|
||||||
|
advanced_collapsed: false,
|
||||||
..DraftPane::default()
|
..DraftPane::default()
|
||||||
};
|
};
|
||||||
draft.set_projects(
|
draft.set_projects(
|
||||||
@@ -2481,6 +2179,85 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn advanced_section_is_collapsed_by_default_and_states_the_worktree_default() {
|
||||||
|
let mut draft = DraftPane {
|
||||||
|
home_dir: "/home/u".into(),
|
||||||
|
..DraftPane::default()
|
||||||
|
};
|
||||||
|
draft.set_projects(
|
||||||
|
vec![project("maestro", "/home/u/tea/maestro", 1, Some("claude"))],
|
||||||
|
Utc::now(),
|
||||||
|
);
|
||||||
|
assert!(draft.advanced_collapsed, "closed by default");
|
||||||
|
assert_eq!(
|
||||||
|
draft
|
||||||
|
.field_order()
|
||||||
|
.iter()
|
||||||
|
.filter(|f| matches!(f, DraftField::WorktreeToggle | DraftField::BranchMode))
|
||||||
|
.count(),
|
||||||
|
0,
|
||||||
|
"collapsed fields drop out of tab order"
|
||||||
|
);
|
||||||
|
|
||||||
|
let rendered = render_to_string(100, 24, |f| draft.render(f, f.area(), true));
|
||||||
|
assert!(
|
||||||
|
rendered.contains("Advanced options") && rendered.contains("creates a worktree"),
|
||||||
|
"header states the on-by-default worktree:\n{rendered}"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
!rendered.contains("[x] worktree"),
|
||||||
|
"checkbox stays hidden while collapsed:\n{rendered}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn advanced_header_states_no_worktree_for_a_worktree_row_91() {
|
||||||
|
let mut draft = DraftPane::default();
|
||||||
|
let mut wt = repo_project("wt-91", "/repos/wt91", "/repos/main", 1, None);
|
||||||
|
wt.is_worktree = true;
|
||||||
|
draft.set_projects(vec![wt], Utc::now());
|
||||||
|
draft.focused_field = DraftField::DirPicker;
|
||||||
|
draft.on_input(&InputKey::Enter);
|
||||||
|
|
||||||
|
assert!(!draft.worktree_enabled);
|
||||||
|
assert!(
|
||||||
|
draft.advanced_collapsed,
|
||||||
|
"picking a row must not force it open"
|
||||||
|
);
|
||||||
|
let rendered = render_to_string(100, 24, |f| draft.render(f, f.area(), true));
|
||||||
|
assert!(
|
||||||
|
rendered.contains("no worktree"),
|
||||||
|
"header reflects #91's off default:\n{rendered}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn enter_on_the_advanced_header_expands_it_without_moving_fields_above() {
|
||||||
|
let mut draft = DraftPane {
|
||||||
|
home_dir: "/home/u".into(),
|
||||||
|
focused_field: DraftField::Advanced,
|
||||||
|
..DraftPane::default()
|
||||||
|
};
|
||||||
|
draft.set_projects(
|
||||||
|
vec![project("maestro", "/home/u/tea/maestro", 1, Some("claude"))],
|
||||||
|
Utc::now(),
|
||||||
|
);
|
||||||
|
let before = render_to_string(100, 24, |f| draft.render(f, f.area(), true));
|
||||||
|
let before_head: Vec<&str> = before.lines().take(6).collect();
|
||||||
|
|
||||||
|
draft.on_input(&InputKey::Enter);
|
||||||
|
assert!(!draft.advanced_collapsed);
|
||||||
|
|
||||||
|
let after = render_to_string(100, 24, |f| draft.render(f, f.area(), true));
|
||||||
|
let after_head: Vec<&str> = after.lines().take(6).collect();
|
||||||
|
assert_eq!(
|
||||||
|
before_head, after_head,
|
||||||
|
"expanding must not move the fields above the disclosure"
|
||||||
|
);
|
||||||
|
assert!(after.contains("[x] worktree"), "body now visible:\n{after}");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn abbreviate_path_matches_the_web_helpers() {
|
fn abbreviate_path_matches_the_web_helpers() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|||||||
+27
-2
@@ -152,12 +152,16 @@ export function createSpawnForm(opts: SpawnFormOptions): SpawnFormHandle {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<fieldset class="worktree">
|
<fieldset class="worktree">
|
||||||
<legend>
|
<button type="button" class="tree-folder-header wt-toggle" aria-expanded="false">
|
||||||
|
<span class="chevron">▾</span>
|
||||||
|
<span class="folder-name">Advanced options</span>
|
||||||
|
<span class="wt-summary"></span>
|
||||||
|
</button>
|
||||||
|
<div class="wt-collapsible" hidden>
|
||||||
<label class="row-inline">
|
<label class="row-inline">
|
||||||
<input type="checkbox" name="worktree_enabled" />
|
<input type="checkbox" name="worktree_enabled" />
|
||||||
Create git worktree
|
Create git worktree
|
||||||
</label>
|
</label>
|
||||||
</legend>
|
|
||||||
<p class="wt-hint" hidden></p>
|
<p class="wt-hint" hidden></p>
|
||||||
<div class="wt-body" hidden>
|
<div class="wt-body" hidden>
|
||||||
<p class="wt-repo"></p>
|
<p class="wt-repo"></p>
|
||||||
@@ -180,6 +184,7 @@ export function createSpawnForm(opts: SpawnFormOptions): SpawnFormHandle {
|
|||||||
<select class="branch-select"></select>
|
<select class="branch-select"></select>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<p class="form-error" role="alert" aria-live="polite"></p>
|
<p class="form-error" role="alert" aria-live="polite"></p>
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
@@ -200,6 +205,9 @@ export function createSpawnForm(opts: SpawnFormOptions): SpawnFormHandle {
|
|||||||
const cwdRawWrap = form.querySelector(".cwd-raw-wrap") as HTMLElement;
|
const cwdRawWrap = form.querySelector(".cwd-raw-wrap") as HTMLElement;
|
||||||
const cwdRaw = form.querySelector(".cwd-raw") as HTMLInputElement;
|
const cwdRaw = form.querySelector(".cwd-raw") as HTMLInputElement;
|
||||||
const wtEnabled = form.querySelector("input[name=worktree_enabled]") as HTMLInputElement;
|
const wtEnabled = form.querySelector("input[name=worktree_enabled]") as HTMLInputElement;
|
||||||
|
const wtToggle = form.querySelector(".wt-toggle") as HTMLButtonElement;
|
||||||
|
const wtCollapsible = form.querySelector(".wt-collapsible") as HTMLElement;
|
||||||
|
const wtSummary = form.querySelector(".wt-summary") as HTMLElement;
|
||||||
const wtHint = form.querySelector(".wt-hint") as HTMLElement;
|
const wtHint = form.querySelector(".wt-hint") as HTMLElement;
|
||||||
const wtBody = form.querySelector(".wt-body") as HTMLElement;
|
const wtBody = form.querySelector(".wt-body") as HTMLElement;
|
||||||
const wtRepo = form.querySelector(".wt-repo") as HTMLElement;
|
const wtRepo = form.querySelector(".wt-repo") as HTMLElement;
|
||||||
@@ -526,9 +534,11 @@ export function createSpawnForm(opts: SpawnFormOptions): SpawnFormHandle {
|
|||||||
markActiveChoice();
|
markActiveChoice();
|
||||||
if (choice === "new") {
|
if (choice === "new") {
|
||||||
wtEnabled.checked = true;
|
wtEnabled.checked = true;
|
||||||
|
updateWtSummary();
|
||||||
applyProjectRepo(group.main.base_repo ?? group.main.path);
|
applyProjectRepo(group.main.base_repo ?? group.main.path);
|
||||||
} else {
|
} else {
|
||||||
wtEnabled.checked = false;
|
wtEnabled.checked = false;
|
||||||
|
updateWtSummary();
|
||||||
inferredBaseRepo = null;
|
inferredBaseRepo = null;
|
||||||
wtBody.hidden = true;
|
wtBody.hidden = true;
|
||||||
wtHint.hidden = true;
|
wtHint.hidden = true;
|
||||||
@@ -661,6 +671,18 @@ export function createSpawnForm(opts: SpawnFormOptions): SpawnFormHandle {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---- worktree: disclosure (#93), reuses the sidebar's folder-header ---
|
||||||
|
let advancedCollapsed = true;
|
||||||
|
function setAdvancedCollapsed(collapsed: boolean): void {
|
||||||
|
advancedCollapsed = collapsed;
|
||||||
|
wtToggle.setAttribute("aria-expanded", String(!collapsed));
|
||||||
|
wtCollapsible.hidden = collapsed;
|
||||||
|
}
|
||||||
|
function updateWtSummary(): void {
|
||||||
|
wtSummary.textContent = wtEnabled.checked ? "creates a worktree" : "no worktree";
|
||||||
|
}
|
||||||
|
wtToggle.addEventListener("click", () => setAdvancedCollapsed(!advancedCollapsed));
|
||||||
|
|
||||||
// ---- worktree (branch-only; base_repo inferred via scan or /gitroot) --
|
// ---- worktree (branch-only; base_repo inferred via scan or /gitroot) --
|
||||||
// The project scan already reports repo membership, so a picked project
|
// The project scan already reports repo membership, so a picked project
|
||||||
// resolves its base repo locally (#61); only the free-text escape hatch
|
// resolves its base repo locally (#61); only the free-text escape hatch
|
||||||
@@ -741,6 +763,7 @@ export function createSpawnForm(opts: SpawnFormOptions): SpawnFormHandle {
|
|||||||
// Publish the untick too, or the next render seeds the box checked with
|
// Publish the untick too, or the next render seeds the box checked with
|
||||||
// no inferred repo and submitting fails.
|
// no inferred repo and submitting fails.
|
||||||
wtEnabled.checked = false;
|
wtEnabled.checked = false;
|
||||||
|
updateWtSummary();
|
||||||
emit();
|
emit();
|
||||||
wtBody.hidden = true;
|
wtBody.hidden = true;
|
||||||
wtHint.hidden = false;
|
wtHint.hidden = false;
|
||||||
@@ -814,6 +837,7 @@ export function createSpawnForm(opts: SpawnFormOptions): SpawnFormHandle {
|
|||||||
branchSelect.addEventListener("change", () => emit());
|
branchSelect.addEventListener("change", () => emit());
|
||||||
|
|
||||||
wtEnabled.addEventListener("change", () => {
|
wtEnabled.addEventListener("change", () => {
|
||||||
|
updateWtSummary();
|
||||||
emit();
|
emit();
|
||||||
if (wtEnabled.checked) {
|
if (wtEnabled.checked) {
|
||||||
resolveBaseRepo();
|
resolveBaseRepo();
|
||||||
@@ -827,6 +851,7 @@ export function createSpawnForm(opts: SpawnFormOptions): SpawnFormHandle {
|
|||||||
// The toggle defaults ON (#61): the operator almost always wants a
|
// The toggle defaults ON (#61): the operator almost always wants a
|
||||||
// worktree, and every non-repo target unticks it via the gitroot probe.
|
// worktree, and every non-repo target unticks it via the gitroot probe.
|
||||||
wtEnabled.checked = prefill.worktreeEnabled ?? true;
|
wtEnabled.checked = prefill.worktreeEnabled ?? true;
|
||||||
|
updateWtSummary();
|
||||||
if (prefill.worktreeBranch) branchInput.value = prefill.worktreeBranch;
|
if (prefill.worktreeBranch) branchInput.value = prefill.worktreeBranch;
|
||||||
setBranchMode(branchMode);
|
setBranchMode(branchMode);
|
||||||
|
|
||||||
|
|||||||
@@ -180,6 +180,59 @@ describe("spawnForm worktree defaults and branch picker (#61)", () => {
|
|||||||
expect(modes.at(-1)).toBe("existing");
|
expect(modes.at(-1)).toBe("existing");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("collapses the advanced (worktree) section by default (#93)", async () => {
|
||||||
|
const form = await mount();
|
||||||
|
const toggle = form.querySelector<HTMLButtonElement>(".wt-toggle")!;
|
||||||
|
expect(toggle.getAttribute("aria-expanded")).toBe("false");
|
||||||
|
expect(form.querySelector<HTMLElement>(".wt-collapsible")!.hidden).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("states in the collapsed header that a worktree will be created by default (#93)", async () => {
|
||||||
|
const form = await mount();
|
||||||
|
expect(form.querySelector<HTMLElement>(".wt-summary")!.textContent).toMatch(/creates? a worktree/i);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("states in the collapsed header that no worktree will be created for a worktree row (#91, #93)", async () => {
|
||||||
|
urls = stubFetch({
|
||||||
|
projects: [
|
||||||
|
{
|
||||||
|
path: "/home/user/wt-91",
|
||||||
|
name: "wt-91",
|
||||||
|
is_worktree: true,
|
||||||
|
base_repo: "/home/user/maestro",
|
||||||
|
last_activity: "2026-08-20T10:00:00Z",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
handle = createSpawnForm({ onSuccess() {} });
|
||||||
|
document.body.appendChild(handle.el);
|
||||||
|
for (let i = 0; i < 40; i++) await Promise.resolve();
|
||||||
|
|
||||||
|
handle.el
|
||||||
|
.querySelectorAll<HTMLButtonElement>(".project-box")
|
||||||
|
.forEach((box) => box.dataset.cwd === "/home/user/wt-91" && box.click());
|
||||||
|
await drain();
|
||||||
|
|
||||||
|
expect(handle.el.querySelector<HTMLElement>(".wt-summary")!.textContent).toMatch(/no worktree/i);
|
||||||
|
// Still collapsed — picking a project must not force it open.
|
||||||
|
expect(handle.el.querySelector<HTMLButtonElement>(".wt-toggle")!.getAttribute("aria-expanded")).toBe(
|
||||||
|
"false",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("expanding the advanced section does not reorder the fields above it (#93)", async () => {
|
||||||
|
const form = await mount();
|
||||||
|
const before = [...form.querySelectorAll(".field")];
|
||||||
|
|
||||||
|
form.querySelector<HTMLButtonElement>(".wt-toggle")!.click();
|
||||||
|
|
||||||
|
expect(form.querySelector<HTMLButtonElement>(".wt-toggle")!.getAttribute("aria-expanded")).toBe(
|
||||||
|
"true",
|
||||||
|
);
|
||||||
|
expect(form.querySelector<HTMLElement>(".wt-collapsible")!.hidden).toBe(false);
|
||||||
|
expect([...form.querySelectorAll(".field")]).toStrictEqual(before);
|
||||||
|
});
|
||||||
|
|
||||||
it("does not repopulate a destroyed form when the branch list lands late", async () => {
|
it("does not repopulate a destroyed form when the branch list lands late", async () => {
|
||||||
const gate: { release?: () => void } = {};
|
const gate: { release?: () => void } = {};
|
||||||
urls = stubFetch({ gateBranches: (r) => (gate.release = r) });
|
urls = stubFetch({ gateBranches: (r) => (gate.release = r) });
|
||||||
|
|||||||
+21
-6
@@ -1284,18 +1284,33 @@ textarea {
|
|||||||
.worktree {
|
.worktree {
|
||||||
border: 1px solid var(--border);
|
border: 1px solid var(--border);
|
||||||
border-radius: var(--r-2);
|
border-radius: var(--r-2);
|
||||||
padding: var(--sp-3);
|
padding: 0 var(--sp-3);
|
||||||
margin: 0;
|
margin: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: var(--sp-3);
|
|
||||||
background: color-mix(in oklab, var(--surface-2) 50%, transparent);
|
background: color-mix(in oklab, var(--surface-2) 50%, transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
.worktree legend {
|
.worktree .wt-toggle {
|
||||||
padding: 0 6px;
|
margin: 0 calc(var(--sp-3) * -1);
|
||||||
color: var(--ink);
|
padding-left: var(--sp-3);
|
||||||
font-size: var(--fs-13);
|
width: calc(100% + var(--sp-3) * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wt-summary {
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: var(--fs-12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wt-collapsible {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--sp-3);
|
||||||
|
padding-bottom: var(--sp-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wt-collapsible[hidden] {
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-error {
|
.form-error {
|
||||||
|
|||||||
Reference in New Issue
Block a user