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:
Torbjörn MolinandClaude Opus 5.5 committed 2026-10-19 10:55:20 +02:00
1 parent 4b729c5d32
commit d5e7b484fc
13 files changed
+997 -237

No files matched your search

+71 -13
View File
@@ -25,8 +25,11 @@ pub struct AppState {
pub tabs: Vec<Tab>,
pub active: Option<TabId>,
pub next_tab_id: TabId,
pub collection: Option<CollectionState>,
pub selected_env: Option<String>,
/// Open collections, in the order they were opened.
pub collections: Vec<CollectionState>,
/// The collection last chosen in the sidebar or through a tab. Untitled
/// tabs, the environment picker and the cookie viewer use it.
pub active_collection: Option<PathBuf>,
pub settings: Settings,
/// Oldest first.
pub history: Vec<HistoryEntry>,
@@ -61,6 +64,8 @@ pub struct Windows {
pub enum Dialog {
/// Closing a tab with unsaved changes.
ConfirmCloseTab(TabId),
/// Closing several tabs, these of which have unsaved changes.
ConfirmCloseTabs(Vec<TabId>),
/// Quitting with unsaved changes.
ConfirmQuit,
/// The file of a tab with unsaved changes changed on disk.
@@ -95,6 +100,7 @@ pub enum PromptKind {
NewFile { dir: PathBuf },
RenameFile { path: PathBuf },
RenameRequest { file: PathBuf, index: usize },
RenameTab { tab: TabId },
NewEnvironment,
}
@@ -107,6 +113,8 @@ pub struct QuickOpen {
/// The environment editor works on a copy that is written on Save.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EnvEditor {
/// The collection whose env files are being edited.
pub root: PathBuf,
pub envs: Environments,
pub selected: String,
/// Private values whose text is shown instead of `••••`.
@@ -119,6 +127,7 @@ pub struct CollectionState {
pub tree: Node,
pub files: BTreeMap<PathBuf, HttpFile>,
pub envs: Environments,
pub selected_env: Option<String>,
pub env_error: Option<String>,
/// The private env file exists but is not git-ignored.
pub private_not_ignored: bool,
@@ -136,6 +145,14 @@ impl CollectionState {
pub fn relative<'a>(&self, p: &'a Path) -> &'a Path {
p.strip_prefix(&self.root).unwrap_or(p)
}
pub fn name(&self) -> &str {
self.tree.name()
}
pub fn contains(&self, p: &Path) -> bool {
p.starts_with(&self.root)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
@@ -356,27 +373,68 @@ impl AppState {
self.tabs.iter().any(Tab::is_dirty)
}
/// File variables of the tab's file plus the selected environment.
/// The collection a path belongs to.
pub fn collection_of(&self, p: &Path) -> Option<&CollectionState> {
self.collections.iter().find(|c| c.contains(p))
}
pub fn collection_of_mut(&mut self, p: &Path) -> Option<&mut CollectionState> {
self.collections.iter_mut().find(|c| c.contains(p))
}
pub fn collection(&self, root: &Path) -> Option<&CollectionState> {
self.collections.iter().find(|c| c.root == root)
}
pub fn collection_mut(&mut self, root: &Path) -> Option<&mut CollectionState> {
self.collections.iter_mut().find(|c| c.root == root)
}
/// The collection the environment picker and untitled tabs use: the
/// active tab's, else the one last chosen, else the first.
pub fn current_collection(&self) -> Option<&CollectionState> {
if let Some(c) = self
.active_tab()
.and_then(|t| t.origin.as_ref())
.and_then(|o| self.collection_of(&o.file))
{
return Some(c);
}
self.active_collection
.as_deref()
.and_then(|r| self.collection(r))
.or_else(|| self.collections.first())
}
/// The collection a tab belongs to (its file's, or the current one for
/// untitled tabs).
pub fn collection_for_tab(&self, tab: &Tab) -> Option<&CollectionState> {
match &tab.origin {
Some(o) => self.collection_of(&o.file),
None => self.current_collection(),
}
}
/// File variables of the tab's file plus its collection's environment.
pub fn resolver_for(&self, tab: &Tab) -> Resolver {
let file_vars = tab
.origin
.as_ref()
.and_then(|o| self.collection.as_ref()?.files.get(&o.file))
.and_then(|o| self.collection_of(&o.file)?.files.get(&o.file))
.map(|f| f.variables())
.unwrap_or_default();
match &self.collection {
Some(c) => c.envs.resolver(self.selected_env.as_deref(), &file_vars),
match self.collection_for_tab(tab) {
Some(c) => c.envs.resolver(c.selected_env.as_deref(), &file_vars),
None => Environments::default().resolver(None, &file_vars),
}
}
/// Whether `name` comes from the private env file (shown masked).
pub fn is_private_var(&self, name: &str) -> bool {
match (&self.collection, &self.selected_env) {
(Some(c), Some(env)) => c.envs.is_private(env, name),
(Some(c), None) => c.envs.is_private(reqlite_core::env::SHARED_ENV, name),
_ => false,
}
pub fn is_private_var(&self, tab: &Tab, name: &str) -> bool {
self.collection_for_tab(tab).is_some_and(|c| {
let env = c.selected_env.as_deref().unwrap_or(reqlite_core::env::SHARED_ENV);
c.envs.is_private(env, name)
})
}
/// Directory that relative file references in the tab resolve against.
@@ -386,7 +444,7 @@ impl AppState {
return p.to_path_buf();
}
}
if let Some(c) = &self.collection {
if let Some(c) = self.current_collection() {
return c.root.clone();
}
std::env::current_dir().unwrap_or_default()