Multiple collections, tab close-all and rename, tab scroll bar fix
- Keep several collections open at once. Each has its own environments, selected environment, cookie jar and file watcher, and they are reopened on start. The environment picker acts on the current collection (the active tab's, or the one last chosen). Overlapping folders are refused. - Close all / close others for tabs (Ctrl+Shift+W, tab menu, File menu), asking once about tabs with unsaved changes. - Rename a request from its tab (double-click, tab menu, or the … menu). - Give the tab strip's scroll bar its own row so it no longer covers the tab names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4b729c5d32
commit
d5e7b484fc
13 files changed
+997
-237
No files matched your search
@@ -105,7 +105,7 @@ fn screenshots() {
|
||||
|
||||
h.state_mut().dispatch(Action::OpenCollection(root.clone()));
|
||||
wait(&mut h, |a| {
|
||||
a.state.collection.as_ref().is_some_and(|c| !c.envs.names().is_empty())
|
||||
a.state.collections.first().is_some_and(|c| !c.envs.names().is_empty())
|
||||
});
|
||||
h.state_mut().dispatch(Action::SelectEnv(Some("dev".into())));
|
||||
h.state_mut().dispatch(Action::OpenRequest {
|
||||
@@ -145,4 +145,34 @@ fn screenshots() {
|
||||
h.state_mut().dispatch(Action::SetResponseTab(id, ResponseTab::Body));
|
||||
h.state_mut().dispatch(Action::SetRequestTab(id, RequestTab::Params));
|
||||
shoot(&mut h, "07-light-theme");
|
||||
|
||||
// A second collection and enough tabs to need the tab scroll bar.
|
||||
let mut s = h.state().state.settings.clone();
|
||||
s.theme = reqlite_app::settings::ThemeChoice::Dark;
|
||||
h.state_mut().dispatch(Action::SettingsChanged(s));
|
||||
let second = tempfile::tempdir().unwrap();
|
||||
let root2 = second.path().canonicalize().unwrap();
|
||||
std::fs::write(
|
||||
root2.join("billing.http"),
|
||||
"### Invoices\nGET {{base_url}}/invoices\n\n### Refund\nPOST {{base_url}}/refunds\n",
|
||||
)
|
||||
.unwrap();
|
||||
h.state_mut().dispatch(Action::OpenCollection(root2.clone()));
|
||||
wait(&mut h, |a| a.state.collections.len() == 2);
|
||||
for i in 0..2 {
|
||||
h.state_mut().dispatch(Action::OpenRequest {
|
||||
file: root2.join("billing.http"),
|
||||
index: i,
|
||||
});
|
||||
}
|
||||
for i in 0..3 {
|
||||
h.state_mut().dispatch(Action::OpenRequest {
|
||||
file: root.join("users.http"),
|
||||
index: i,
|
||||
});
|
||||
}
|
||||
for _ in 0..8 {
|
||||
h.state_mut().dispatch(Action::NewTab);
|
||||
}
|
||||
shoot(&mut h, "08-two-collections-many-tabs");
|
||||
}
|
||||
@@ -123,6 +123,15 @@ fn keyboard_shortcuts_open_and_close_tabs() {
|
||||
h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::W);
|
||||
h.step();
|
||||
assert_eq!(h.state().state.tabs.len(), 1);
|
||||
// Ctrl+Shift+W closes them all (and is not taken as Ctrl+W).
|
||||
for _ in 0..3 {
|
||||
h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::T);
|
||||
h.step();
|
||||
}
|
||||
assert_eq!(h.state().state.tabs.len(), 4);
|
||||
h.key_press_modifiers(egui::Modifiers::COMMAND | egui::Modifiers::SHIFT, egui::Key::W);
|
||||
h.step();
|
||||
assert!(h.state().state.tabs.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -145,8 +154,8 @@ fn opens_a_collection_and_shows_its_requests() {
|
||||
step_until(&mut h, "the collection", |h| {
|
||||
h.state()
|
||||
.state
|
||||
.collection
|
||||
.as_ref()
|
||||
.collections
|
||||
.first()
|
||||
.is_some_and(|c| !c.envs.names().is_empty())
|
||||
});
|
||||
h.step();
|
||||
|
||||
@@ -23,7 +23,7 @@ fn reports_changes_to_http_and_env_files() {
|
||||
let root = dir.path().canonicalize().unwrap();
|
||||
std::fs::write(root.join("a.http"), "GET /a\n").unwrap();
|
||||
let (runner, mut rx) = Runner::new(rt.handle().clone(), None, Arc::new(NoClient), None, 4);
|
||||
runner.run(Effect::Watch(Some(root.clone())));
|
||||
runner.run(Effect::Watch(root.clone()));
|
||||
std::thread::sleep(Duration::from_millis(200));
|
||||
|
||||
std::fs::write(root.join("a.http"), "GET /changed\n").unwrap();
|
||||
@@ -41,7 +41,7 @@ fn reports_changes_to_http_and_env_files() {
|
||||
Ok(Some(Action::FileChangedOnDisk { path, text })) => {
|
||||
seen.insert(path, text);
|
||||
}
|
||||
Ok(Some(Action::Rescan)) => rescan = true,
|
||||
Ok(Some(Action::Rescan(r))) if r == root => rescan = true,
|
||||
Ok(Some(_)) => {}
|
||||
_ => break,
|
||||
}
|
||||
@@ -69,10 +69,41 @@ fn reports_changes_to_http_and_env_files() {
|
||||
assert_eq!(deleted, None);
|
||||
|
||||
// Stopping the watch stops the events.
|
||||
runner.run(Effect::Watch(None));
|
||||
runner.run(Effect::Unwatch(root.clone()));
|
||||
std::thread::sleep(Duration::from_millis(100));
|
||||
while rx.try_recv().is_ok() {}
|
||||
std::fs::write(root.join("b.http"), "GET /b\n").unwrap();
|
||||
std::thread::sleep(Duration::from_millis(400));
|
||||
assert!(rx.try_recv().is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn watches_several_collections_at_once() {
|
||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||
let (a, b) = (tempfile::tempdir().unwrap(), tempfile::tempdir().unwrap());
|
||||
let (a, b) = (a.path().canonicalize().unwrap(), b.path().canonicalize().unwrap());
|
||||
let (runner, mut rx) = Runner::new(rt.handle().clone(), None, Arc::new(NoClient), None, 4);
|
||||
runner.run(Effect::Watch(a.clone()));
|
||||
runner.run(Effect::Watch(b.clone()));
|
||||
std::thread::sleep(Duration::from_millis(200));
|
||||
std::fs::write(a.join("a.http"), "GET /a\n").unwrap();
|
||||
std::fs::write(b.join("b.http"), "GET /b\n").unwrap();
|
||||
|
||||
let mut seen = std::collections::HashSet::new();
|
||||
rt.block_on(async {
|
||||
let deadline = tokio::time::Instant::now() + Duration::from_secs(5);
|
||||
while seen.len() < 2 {
|
||||
match tokio::time::timeout_at(deadline, rx.recv()).await {
|
||||
Ok(Some(Action::FileChangedOnDisk { path, .. })) => {
|
||||
seen.insert(path);
|
||||
}
|
||||
Ok(Some(_)) => {}
|
||||
_ => break,
|
||||
}
|
||||
}
|
||||
});
|
||||
assert!(
|
||||
seen.contains(&a.join("a.http")) && seen.contains(&b.join("b.http")),
|
||||
"{seen:?}"
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user