Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 48 additions & 3 deletions src/app/actions.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -355,8 +355,10 @@ impl AppState {
self.navigator.scroll = 0;
self.navigator.expanded_workspaces.clear();

for ws in &self.workspaces {
self.navigator.expanded_workspaces.insert(ws.id.clone());
if !self.navigator_collapse_workspaces {
for ws in &self.workspaces {
self.navigator.expanded_workspaces.insert(ws.id.clone());
}
}

self.mode = Mode::Navigator;
Expand DownExpand Up@@ -3419,7 +3421,7 @@ mod tests {
}

#[test]
fn opening_navigator_selects_current_pane_and_expands_attention_workspaces() {
fn opening_navigator_selects_current_pane_and_expands_workspaces_by_default() {
let mut state = app_with_workspaces(&["one", "two"]);
let blocked = state.workspaces[1].tabs[0].root_pane;
let blocked_terminal_id = state.workspaces[1].terminal_id(blocked).cloned().unwrap();
Expand All@@ -3443,6 +3445,49 @@ mod tests {
.contains(&state.workspaces[1].id));
}

#[test]
fn navigator_collapse_workspaces_option_opens_collapsed_rows() {
let mut state = app_with_workspaces(&["one", "two"]);
state.navigator_collapse_workspaces = true;
state.open_navigator();

assert!(state.navigator.expanded_workspaces.is_empty());
let rows = state.navigator_rows();
assert!(rows.iter().all(|row| row.is_workspace));
assert!(!rows.iter().any(|row| matches!(
row.target,
crate::app::state::NavigatorTarget::Pane { .. }
| crate::app::state::NavigatorTarget::Tab { .. }
)));
let selected = rows[state.navigator.selected].clone();
assert!(selected.is_workspace);
assert!(selected.is_current);
}

#[test]
fn navigator_query_expands_collapsed_workspaces_to_matching_panes() {
let mut state = app_with_workspaces(&["one"]);
let root = state.workspaces[0].tabs[0].root_pane;
let terminal_id = state.workspaces[0].terminal_id(root).cloned().unwrap();
state
.terminals
.get_mut(&terminal_id)
.unwrap()
.set_manual_label("weekly review".into());

state.navigator_collapse_workspaces = true;
state.open_navigator();
assert!(state.navigator.expanded_workspaces.is_empty());
assert!(state.navigator_rows().iter().all(|row| row.is_workspace));

state.navigator.query = "weekly".into();
let rows = state.navigator_rows();
assert!(rows.iter().any(|row| matches!(
row.target,
crate::app::state::NavigatorTarget::Pane { .. }
) && row.label.contains("weekly")));
}

#[test]
fn accepting_navigator_pane_switches_workspace_tab_and_focus() {
let mut state = app_with_workspaces(&["one", "two"]);
Expand Down
2 changes: 2 additions & 0 deletions src/app/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -601,6 +601,7 @@ impl App {
next_agent_state_change_seq: 0,
mouse_capture: config.ui.mouse_capture,
copy_on_select: config.ui.copy_on_select,
navigator_collapse_workspaces: config.ui.navigator_collapse_workspaces,
right_click_passthrough_modifiers: config.ui.right_click_passthrough_modifiers(),
right_click_passthrough: None,
redraw_on_focus_gained: config.ui.redraw_on_focus_gained,
Expand DownExpand Up@@ -1360,6 +1361,7 @@ impl App {
.clamp(self.state.sidebar_min_width, self.state.sidebar_max_width);
self.state.mouse_capture = config.ui.mouse_capture;
self.state.copy_on_select = config.ui.copy_on_select;
self.state.navigator_collapse_workspaces = config.ui.navigator_collapse_workspaces;
if !self.state.copy_on_select {
if self.state.mode == Mode::Copy {
self.state.stop_selection_autoscroll_state();
Expand Down
2 changes: 2 additions & 0 deletions src/app/state.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -1408,6 +1408,7 @@ pub struct AppState {
/// captures mouse while the focused pane app requests mouse reporting.
pub mouse_capture: bool,
pub copy_on_select: bool,
pub navigator_collapse_workspaces: bool,
pub right_click_passthrough_modifiers: Option<KeyModifiers>,
pub right_click_passthrough: Option<RightClickPassthroughGesture>,
pub redraw_on_focus_gained: bool,
Expand DownExpand Up@@ -1767,6 +1768,7 @@ impl AppState {
next_agent_state_change_seq: 0,
mouse_capture: true,
copy_on_select: true,
navigator_collapse_workspaces: false,
right_click_passthrough_modifiers: None,
right_click_passthrough: None,
redraw_on_focus_gained: true,
Expand Down
4 changes: 4 additions & 0 deletions src/config/model.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -788,6 +788,9 @@ pub struct UiConfig {
pub mouse_capture: bool,
/// Copy text selected with the mouse. Default: true.
pub copy_on_select: bool,
/// Open the navigator (goto) collapsed to the workspace level instead of
/// expanding every workspace to its panes on open. Default: false.
pub navigator_collapse_workspaces: bool,
/// Host cursor policy. Default: auto.
pub host_cursor: HostCursorModeConfig,
/// Modifier that lets right-click gestures pass through to pane apps. Empty disables it.
Expand DownExpand Up@@ -992,6 +995,7 @@ impl Default for UiConfig {
mobile_width_threshold: DEFAULT_MOBILE_WIDTH_THRESHOLD,
mouse_capture: true,
copy_on_select: true,
navigator_collapse_workspaces: false,
host_cursor: HostCursorModeConfig::Auto,
right_click_passthrough_modifier: RightClickPassthroughModifierConfig::default(),
redraw_on_focus_gained: true,
Expand Down
4 changes: 4 additions & 0 deletions src/main.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -263,6 +263,10 @@ const DEFAULT_CONFIG: &str = r##"# herdr configuration
# Set false to disable mouse text selection and copying.
# copy_on_select = true

# Open the navigator (goto) collapsed to the workspace level instead of
# expanding every workspace to its panes on open.
# navigator_collapse_workspaces = false

# Host cursor policy: "auto", "native", or "drawn".
# "auto" draws Herdr's own cursor on native Windows builds and WSL to avoid ConPTY cursor flicker, and uses the native terminal cursor elsewhere.
# "native" always uses the outer terminal cursor. "drawn" always draws Herdr's cursor as terminal cell content.
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
feat(navigator): add navigator_collapse_workspaces option by Castrozan · Pull Request #4 · Castrozan/herdr · GitHub
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 48 additions & 3 deletions src/app/actions.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -355,8 +355,10 @@ impl AppState {
self.navigator.scroll = 0;
self.navigator.expanded_workspaces.clear();

for ws in &self.workspaces {
self.navigator.expanded_workspaces.insert(ws.id.clone());
if !self.navigator_collapse_workspaces {
for ws in &self.workspaces {
self.navigator.expanded_workspaces.insert(ws.id.clone());
}
}

self.mode = Mode::Navigator;
Expand DownExpand Up@@ -3419,7 +3421,7 @@ mod tests {
}

#[test]
fn opening_navigator_selects_current_pane_and_expands_attention_workspaces() {
fn opening_navigator_selects_current_pane_and_expands_workspaces_by_default() {
let mut state = app_with_workspaces(&["one", "two"]);
let blocked = state.workspaces[1].tabs[0].root_pane;
let blocked_terminal_id = state.workspaces[1].terminal_id(blocked).cloned().unwrap();
Expand All@@ -3443,6 +3445,49 @@ mod tests {
.contains(&state.workspaces[1].id));
}

#[test]
fn navigator_collapse_workspaces_option_opens_collapsed_rows() {
let mut state = app_with_workspaces(&["one", "two"]);
state.navigator_collapse_workspaces = true;
state.open_navigator();

assert!(state.navigator.expanded_workspaces.is_empty());
let rows = state.navigator_rows();
assert!(rows.iter().all(|row| row.is_workspace));
assert!(!rows.iter().any(|row| matches!(
row.target,
crate::app::state::NavigatorTarget::Pane { .. }
| crate::app::state::NavigatorTarget::Tab { .. }
)));
let selected = rows[state.navigator.selected].clone();
assert!(selected.is_workspace);
assert!(selected.is_current);
}

#[test]
fn navigator_query_expands_collapsed_workspaces_to_matching_panes() {
let mut state = app_with_workspaces(&["one"]);
let root = state.workspaces[0].tabs[0].root_pane;
let terminal_id = state.workspaces[0].terminal_id(root).cloned().unwrap();
state
.terminals
.get_mut(&terminal_id)
.unwrap()
.set_manual_label("weekly review".into());

state.navigator_collapse_workspaces = true;
state.open_navigator();
assert!(state.navigator.expanded_workspaces.is_empty());
assert!(state.navigator_rows().iter().all(|row| row.is_workspace));

state.navigator.query = "weekly".into();
let rows = state.navigator_rows();
assert!(rows.iter().any(|row| matches!(
row.target,
crate::app::state::NavigatorTarget::Pane { .. }
) && row.label.contains("weekly")));
}

#[test]
fn accepting_navigator_pane_switches_workspace_tab_and_focus() {
let mut state = app_with_workspaces(&["one", "two"]);
Expand Down
2 changes: 2 additions & 0 deletions src/app/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -601,6 +601,7 @@ impl App {
next_agent_state_change_seq: 0,
mouse_capture: config.ui.mouse_capture,
copy_on_select: config.ui.copy_on_select,
navigator_collapse_workspaces: config.ui.navigator_collapse_workspaces,
right_click_passthrough_modifiers: config.ui.right_click_passthrough_modifiers(),
right_click_passthrough: None,
redraw_on_focus_gained: config.ui.redraw_on_focus_gained,
Expand DownExpand Up@@ -1360,6 +1361,7 @@ impl App {
.clamp(self.state.sidebar_min_width, self.state.sidebar_max_width);
self.state.mouse_capture = config.ui.mouse_capture;
self.state.copy_on_select = config.ui.copy_on_select;
self.state.navigator_collapse_workspaces = config.ui.navigator_collapse_workspaces;
if !self.state.copy_on_select {
if self.state.mode == Mode::Copy {
self.state.stop_selection_autoscroll_state();
Expand Down
2 changes: 2 additions & 0 deletions src/app/state.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -1408,6 +1408,7 @@ pub struct AppState {
/// captures mouse while the focused pane app requests mouse reporting.
pub mouse_capture: bool,
pub copy_on_select: bool,
pub navigator_collapse_workspaces: bool,
pub right_click_passthrough_modifiers: Option<KeyModifiers>,
pub right_click_passthrough: Option<RightClickPassthroughGesture>,
pub redraw_on_focus_gained: bool,
Expand DownExpand Up@@ -1767,6 +1768,7 @@ impl AppState {
next_agent_state_change_seq: 0,
mouse_capture: true,
copy_on_select: true,
navigator_collapse_workspaces: false,
right_click_passthrough_modifiers: None,
right_click_passthrough: None,
redraw_on_focus_gained: true,
Expand Down
4 changes: 4 additions & 0 deletions src/config/model.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -788,6 +788,9 @@ pub struct UiConfig {
pub mouse_capture: bool,
/// Copy text selected with the mouse. Default: true.
pub copy_on_select: bool,
/// Open the navigator (goto) collapsed to the workspace level instead of
/// expanding every workspace to its panes on open. Default: false.
pub navigator_collapse_workspaces: bool,
/// Host cursor policy. Default: auto.
pub host_cursor: HostCursorModeConfig,
/// Modifier that lets right-click gestures pass through to pane apps. Empty disables it.
Expand DownExpand Up@@ -992,6 +995,7 @@ impl Default for UiConfig {
mobile_width_threshold: DEFAULT_MOBILE_WIDTH_THRESHOLD,
mouse_capture: true,
copy_on_select: true,
navigator_collapse_workspaces: false,
host_cursor: HostCursorModeConfig::Auto,
right_click_passthrough_modifier: RightClickPassthroughModifierConfig::default(),
redraw_on_focus_gained: true,
Expand Down
4 changes: 4 additions & 0 deletions src/main.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -263,6 +263,10 @@ const DEFAULT_CONFIG: &str = r##"# herdr configuration
# Set false to disable mouse text selection and copying.
# copy_on_select = true

# Open the navigator (goto) collapsed to the workspace level instead of
# expanding every workspace to its panes on open.
# navigator_collapse_workspaces = false

# Host cursor policy: "auto", "native", or "drawn".
# "auto" draws Herdr's own cursor on native Windows builds and WSL to avoid ConPTY cursor flicker, and uses the native terminal cursor elsewhere.
# "native" always uses the outer terminal cursor. "drawn" always draws Herdr's cursor as terminal cell content.
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' feat(navigator): add navigator_collapse_workspaces option by Castrozan · Pull Request #4 · Castrozan/herdr · GitHub
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 48 additions & 3 deletions src/app/actions.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -355,8 +355,10 @@ impl AppState {
self.navigator.scroll = 0;
self.navigator.expanded_workspaces.clear();

for ws in &self.workspaces {
self.navigator.expanded_workspaces.insert(ws.id.clone());
if !self.navigator_collapse_workspaces {
for ws in &self.workspaces {
self.navigator.expanded_workspaces.insert(ws.id.clone());
}
}

self.mode = Mode::Navigator;
Expand DownExpand Up@@ -3419,7 +3421,7 @@ mod tests {
}

#[test]
fn opening_navigator_selects_current_pane_and_expands_attention_workspaces() {
fn opening_navigator_selects_current_pane_and_expands_workspaces_by_default() {
let mut state = app_with_workspaces(&["one", "two"]);
let blocked = state.workspaces[1].tabs[0].root_pane;
let blocked_terminal_id = state.workspaces[1].terminal_id(blocked).cloned().unwrap();
Expand All@@ -3443,6 +3445,49 @@ mod tests {
.contains(&state.workspaces[1].id));
}

#[test]
fn navigator_collapse_workspaces_option_opens_collapsed_rows() {
let mut state = app_with_workspaces(&["one", "two"]);
state.navigator_collapse_workspaces = true;
state.open_navigator();

assert!(state.navigator.expanded_workspaces.is_empty());
let rows = state.navigator_rows();
assert!(rows.iter().all(|row| row.is_workspace));
assert!(!rows.iter().any(|row| matches!(
row.target,
crate::app::state::NavigatorTarget::Pane { .. }
| crate::app::state::NavigatorTarget::Tab { .. }
)));
let selected = rows[state.navigator.selected].clone();
assert!(selected.is_workspace);
assert!(selected.is_current);
}

#[test]
fn navigator_query_expands_collapsed_workspaces_to_matching_panes() {
let mut state = app_with_workspaces(&["one"]);
let root = state.workspaces[0].tabs[0].root_pane;
let terminal_id = state.workspaces[0].terminal_id(root).cloned().unwrap();
state
.terminals
.get_mut(&terminal_id)
.unwrap()
.set_manual_label("weekly review".into());

state.navigator_collapse_workspaces = true;
state.open_navigator();
assert!(state.navigator.expanded_workspaces.is_empty());
assert!(state.navigator_rows().iter().all(|row| row.is_workspace));

state.navigator.query = "weekly".into();
let rows = state.navigator_rows();
assert!(rows.iter().any(|row| matches!(
row.target,
crate::app::state::NavigatorTarget::Pane { .. }
) && row.label.contains("weekly")));
}

#[test]
fn accepting_navigator_pane_switches_workspace_tab_and_focus() {
let mut state = app_with_workspaces(&["one", "two"]);
Expand Down
2 changes: 2 additions & 0 deletions src/app/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -601,6 +601,7 @@ impl App {
next_agent_state_change_seq: 0,
mouse_capture: config.ui.mouse_capture,
copy_on_select: config.ui.copy_on_select,
navigator_collapse_workspaces: config.ui.navigator_collapse_workspaces,
right_click_passthrough_modifiers: config.ui.right_click_passthrough_modifiers(),
right_click_passthrough: None,
redraw_on_focus_gained: config.ui.redraw_on_focus_gained,
Expand DownExpand Up@@ -1360,6 +1361,7 @@ impl App {
.clamp(self.state.sidebar_min_width, self.state.sidebar_max_width);
self.state.mouse_capture = config.ui.mouse_capture;
self.state.copy_on_select = config.ui.copy_on_select;
self.state.navigator_collapse_workspaces = config.ui.navigator_collapse_workspaces;
if !self.state.copy_on_select {
if self.state.mode == Mode::Copy {
self.state.stop_selection_autoscroll_state();
Expand Down
2 changes: 2 additions & 0 deletions src/app/state.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -1408,6 +1408,7 @@ pub struct AppState {
/// captures mouse while the focused pane app requests mouse reporting.
pub mouse_capture: bool,
pub copy_on_select: bool,
pub navigator_collapse_workspaces: bool,
pub right_click_passthrough_modifiers: Option<KeyModifiers>,
pub right_click_passthrough: Option<RightClickPassthroughGesture>,
pub redraw_on_focus_gained: bool,
Expand DownExpand Up@@ -1767,6 +1768,7 @@ impl AppState {
next_agent_state_change_seq: 0,
mouse_capture: true,
copy_on_select: true,
navigator_collapse_workspaces: false,
right_click_passthrough_modifiers: None,
right_click_passthrough: None,
redraw_on_focus_gained: true,
Expand Down
4 changes: 4 additions & 0 deletions src/config/model.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -788,6 +788,9 @@ pub struct UiConfig {
pub mouse_capture: bool,
/// Copy text selected with the mouse. Default: true.
pub copy_on_select: bool,
/// Open the navigator (goto) collapsed to the workspace level instead of
/// expanding every workspace to its panes on open. Default: false.
pub navigator_collapse_workspaces: bool,
/// Host cursor policy. Default: auto.
pub host_cursor: HostCursorModeConfig,
/// Modifier that lets right-click gestures pass through to pane apps. Empty disables it.
Expand DownExpand Up@@ -992,6 +995,7 @@ impl Default for UiConfig {
mobile_width_threshold: DEFAULT_MOBILE_WIDTH_THRESHOLD,
mouse_capture: true,
copy_on_select: true,
navigator_collapse_workspaces: false,
host_cursor: HostCursorModeConfig::Auto,
right_click_passthrough_modifier: RightClickPassthroughModifierConfig::default(),
redraw_on_focus_gained: true,
Expand Down
4 changes: 4 additions & 0 deletions src/main.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -263,6 +263,10 @@ const DEFAULT_CONFIG: &str = r##"# herdr configuration
# Set false to disable mouse text selection and copying.
# copy_on_select = true

# Open the navigator (goto) collapsed to the workspace level instead of
# expanding every workspace to its panes on open.
# navigator_collapse_workspaces = false

# Host cursor policy: "auto", "native", or "drawn".
# "auto" draws Herdr's own cursor on native Windows builds and WSL to avoid ConPTY cursor flicker, and uses the native terminal cursor elsewhere.
# "native" always uses the outer terminal cursor. "drawn" always draws Herdr's cursor as terminal cell content.
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' feat(navigator): add navigator_collapse_workspaces option by Castrozan · Pull Request #4 · Castrozan/herdr · GitHub
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 48 additions & 3 deletions src/app/actions.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -355,8 +355,10 @@ impl AppState {
self.navigator.scroll = 0;
self.navigator.expanded_workspaces.clear();

for ws in &self.workspaces {
self.navigator.expanded_workspaces.insert(ws.id.clone());
if !self.navigator_collapse_workspaces {
for ws in &self.workspaces {
self.navigator.expanded_workspaces.insert(ws.id.clone());
}
}

self.mode = Mode::Navigator;
Expand DownExpand Up@@ -3419,7 +3421,7 @@ mod tests {
}

#[test]
fn opening_navigator_selects_current_pane_and_expands_attention_workspaces() {
fn opening_navigator_selects_current_pane_and_expands_workspaces_by_default() {
let mut state = app_with_workspaces(&["one", "two"]);
let blocked = state.workspaces[1].tabs[0].root_pane;
let blocked_terminal_id = state.workspaces[1].terminal_id(blocked).cloned().unwrap();
Expand All@@ -3443,6 +3445,49 @@ mod tests {
.contains(&state.workspaces[1].id));
}

#[test]
fn navigator_collapse_workspaces_option_opens_collapsed_rows() {
let mut state = app_with_workspaces(&["one", "two"]);
state.navigator_collapse_workspaces = true;
state.open_navigator();

assert!(state.navigator.expanded_workspaces.is_empty());
let rows = state.navigator_rows();
assert!(rows.iter().all(|row| row.is_workspace));
assert!(!rows.iter().any(|row| matches!(
row.target,
crate::app::state::NavigatorTarget::Pane { .. }
| crate::app::state::NavigatorTarget::Tab { .. }
)));
let selected = rows[state.navigator.selected].clone();
assert!(selected.is_workspace);
assert!(selected.is_current);
}

#[test]
fn navigator_query_expands_collapsed_workspaces_to_matching_panes() {
let mut state = app_with_workspaces(&["one"]);
let root = state.workspaces[0].tabs[0].root_pane;
let terminal_id = state.workspaces[0].terminal_id(root).cloned().unwrap();
state
.terminals
.get_mut(&terminal_id)
.unwrap()
.set_manual_label("weekly review".into());

state.navigator_collapse_workspaces = true;
state.open_navigator();
assert!(state.navigator.expanded_workspaces.is_empty());
assert!(state.navigator_rows().iter().all(|row| row.is_workspace));

state.navigator.query = "weekly".into();
let rows = state.navigator_rows();
assert!(rows.iter().any(|row| matches!(
row.target,
crate::app::state::NavigatorTarget::Pane { .. }
) && row.label.contains("weekly")));
}

#[test]
fn accepting_navigator_pane_switches_workspace_tab_and_focus() {
let mut state = app_with_workspaces(&["one", "two"]);
Expand Down
2 changes: 2 additions & 0 deletions src/app/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -601,6 +601,7 @@ impl App {
next_agent_state_change_seq: 0,
mouse_capture: config.ui.mouse_capture,
copy_on_select: config.ui.copy_on_select,
navigator_collapse_workspaces: config.ui.navigator_collapse_workspaces,
right_click_passthrough_modifiers: config.ui.right_click_passthrough_modifiers(),
right_click_passthrough: None,
redraw_on_focus_gained: config.ui.redraw_on_focus_gained,
Expand DownExpand Up@@ -1360,6 +1361,7 @@ impl App {
.clamp(self.state.sidebar_min_width, self.state.sidebar_max_width);
self.state.mouse_capture = config.ui.mouse_capture;
self.state.copy_on_select = config.ui.copy_on_select;
self.state.navigator_collapse_workspaces = config.ui.navigator_collapse_workspaces;
if !self.state.copy_on_select {
if self.state.mode == Mode::Copy {
self.state.stop_selection_autoscroll_state();
Expand Down
2 changes: 2 additions & 0 deletions src/app/state.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -1408,6 +1408,7 @@ pub struct AppState {
/// captures mouse while the focused pane app requests mouse reporting.
pub mouse_capture: bool,
pub copy_on_select: bool,
pub navigator_collapse_workspaces: bool,
pub right_click_passthrough_modifiers: Option<KeyModifiers>,
pub right_click_passthrough: Option<RightClickPassthroughGesture>,
pub redraw_on_focus_gained: bool,
Expand DownExpand Up@@ -1767,6 +1768,7 @@ impl AppState {
next_agent_state_change_seq: 0,
mouse_capture: true,
copy_on_select: true,
navigator_collapse_workspaces: false,
right_click_passthrough_modifiers: None,
right_click_passthrough: None,
redraw_on_focus_gained: true,
Expand Down
4 changes: 4 additions & 0 deletions src/config/model.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -788,6 +788,9 @@ pub struct UiConfig {
pub mouse_capture: bool,
/// Copy text selected with the mouse. Default: true.
pub copy_on_select: bool,
/// Open the navigator (goto) collapsed to the workspace level instead of
/// expanding every workspace to its panes on open. Default: false.
pub navigator_collapse_workspaces: bool,
/// Host cursor policy. Default: auto.
pub host_cursor: HostCursorModeConfig,
/// Modifier that lets right-click gestures pass through to pane apps. Empty disables it.
Expand DownExpand Up@@ -992,6 +995,7 @@ impl Default for UiConfig {
mobile_width_threshold: DEFAULT_MOBILE_WIDTH_THRESHOLD,
mouse_capture: true,
copy_on_select: true,
navigator_collapse_workspaces: false,
host_cursor: HostCursorModeConfig::Auto,
right_click_passthrough_modifier: RightClickPassthroughModifierConfig::default(),
redraw_on_focus_gained: true,
Expand Down
4 changes: 4 additions & 0 deletions src/main.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -263,6 +263,10 @@ const DEFAULT_CONFIG: &str = r##"# herdr configuration
# Set false to disable mouse text selection and copying.
# copy_on_select = true

# Open the navigator (goto) collapsed to the workspace level instead of
# expanding every workspace to its panes on open.
# navigator_collapse_workspaces = false

# Host cursor policy: "auto", "native", or "drawn".
# "auto" draws Herdr's own cursor on native Windows builds and WSL to avoid ConPTY cursor flicker, and uses the native terminal cursor elsewhere.
# "native" always uses the outer terminal cursor. "drawn" always draws Herdr's cursor as terminal cell content.
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' feat(navigator): add navigator_collapse_workspaces option by Castrozan · Pull Request #4 · Castrozan/herdr · GitHub
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 48 additions & 3 deletions src/app/actions.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -355,8 +355,10 @@ impl AppState {
self.navigator.scroll = 0;
self.navigator.expanded_workspaces.clear();

for ws in &self.workspaces {
self.navigator.expanded_workspaces.insert(ws.id.clone());
if !self.navigator_collapse_workspaces {
for ws in &self.workspaces {
self.navigator.expanded_workspaces.insert(ws.id.clone());
}
}

self.mode = Mode::Navigator;
Expand DownExpand Up@@ -3419,7 +3421,7 @@ mod tests {
}

#[test]
fn opening_navigator_selects_current_pane_and_expands_attention_workspaces() {
fn opening_navigator_selects_current_pane_and_expands_workspaces_by_default() {
let mut state = app_with_workspaces(&["one", "two"]);
let blocked = state.workspaces[1].tabs[0].root_pane;
let blocked_terminal_id = state.workspaces[1].terminal_id(blocked).cloned().unwrap();
Expand All@@ -3443,6 +3445,49 @@ mod tests {
.contains(&state.workspaces[1].id));
}

#[test]
fn navigator_collapse_workspaces_option_opens_collapsed_rows() {
let mut state = app_with_workspaces(&["one", "two"]);
state.navigator_collapse_workspaces = true;
state.open_navigator();

assert!(state.navigator.expanded_workspaces.is_empty());
let rows = state.navigator_rows();
assert!(rows.iter().all(|row| row.is_workspace));
assert!(!rows.iter().any(|row| matches!(
row.target,
crate::app::state::NavigatorTarget::Pane { .. }
| crate::app::state::NavigatorTarget::Tab { .. }
)));
let selected = rows[state.navigator.selected].clone();
assert!(selected.is_workspace);
assert!(selected.is_current);
}

#[test]
fn navigator_query_expands_collapsed_workspaces_to_matching_panes() {
let mut state = app_with_workspaces(&["one"]);
let root = state.workspaces[0].tabs[0].root_pane;
let terminal_id = state.workspaces[0].terminal_id(root).cloned().unwrap();
state
.terminals
.get_mut(&terminal_id)
.unwrap()
.set_manual_label("weekly review".into());

state.navigator_collapse_workspaces = true;
state.open_navigator();
assert!(state.navigator.expanded_workspaces.is_empty());
assert!(state.navigator_rows().iter().all(|row| row.is_workspace));

state.navigator.query = "weekly".into();
let rows = state.navigator_rows();
assert!(rows.iter().any(|row| matches!(
row.target,
crate::app::state::NavigatorTarget::Pane { .. }
) && row.label.contains("weekly")));
}

#[test]
fn accepting_navigator_pane_switches_workspace_tab_and_focus() {
let mut state = app_with_workspaces(&["one", "two"]);
Expand Down
2 changes: 2 additions & 0 deletions src/app/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -601,6 +601,7 @@ impl App {
next_agent_state_change_seq: 0,
mouse_capture: config.ui.mouse_capture,
copy_on_select: config.ui.copy_on_select,
navigator_collapse_workspaces: config.ui.navigator_collapse_workspaces,
right_click_passthrough_modifiers: config.ui.right_click_passthrough_modifiers(),
right_click_passthrough: None,
redraw_on_focus_gained: config.ui.redraw_on_focus_gained,
Expand DownExpand Up@@ -1360,6 +1361,7 @@ impl App {
.clamp(self.state.sidebar_min_width, self.state.sidebar_max_width);
self.state.mouse_capture = config.ui.mouse_capture;
self.state.copy_on_select = config.ui.copy_on_select;
self.state.navigator_collapse_workspaces = config.ui.navigator_collapse_workspaces;
if !self.state.copy_on_select {
if self.state.mode == Mode::Copy {
self.state.stop_selection_autoscroll_state();
Expand Down
2 changes: 2 additions & 0 deletions src/app/state.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -1408,6 +1408,7 @@ pub struct AppState {
/// captures mouse while the focused pane app requests mouse reporting.
pub mouse_capture: bool,
pub copy_on_select: bool,
pub navigator_collapse_workspaces: bool,
pub right_click_passthrough_modifiers: Option<KeyModifiers>,
pub right_click_passthrough: Option<RightClickPassthroughGesture>,
pub redraw_on_focus_gained: bool,
Expand DownExpand Up@@ -1767,6 +1768,7 @@ impl AppState {
next_agent_state_change_seq: 0,
mouse_capture: true,
copy_on_select: true,
navigator_collapse_workspaces: false,
right_click_passthrough_modifiers: None,
right_click_passthrough: None,
redraw_on_focus_gained: true,
Expand Down
4 changes: 4 additions & 0 deletions src/config/model.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -788,6 +788,9 @@ pub struct UiConfig {
pub mouse_capture: bool,
/// Copy text selected with the mouse. Default: true.
pub copy_on_select: bool,
/// Open the navigator (goto) collapsed to the workspace level instead of
/// expanding every workspace to its panes on open. Default: false.
pub navigator_collapse_workspaces: bool,
/// Host cursor policy. Default: auto.
pub host_cursor: HostCursorModeConfig,
/// Modifier that lets right-click gestures pass through to pane apps. Empty disables it.
Expand DownExpand Up@@ -992,6 +995,7 @@ impl Default for UiConfig {
mobile_width_threshold: DEFAULT_MOBILE_WIDTH_THRESHOLD,
mouse_capture: true,
copy_on_select: true,
navigator_collapse_workspaces: false,
host_cursor: HostCursorModeConfig::Auto,
right_click_passthrough_modifier: RightClickPassthroughModifierConfig::default(),
redraw_on_focus_gained: true,
Expand Down
4 changes: 4 additions & 0 deletions src/main.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -263,6 +263,10 @@ const DEFAULT_CONFIG: &str = r##"# herdr configuration
# Set false to disable mouse text selection and copying.
# copy_on_select = true

# Open the navigator (goto) collapsed to the workspace level instead of
# expanding every workspace to its panes on open.
# navigator_collapse_workspaces = false

# Host cursor policy: "auto", "native", or "drawn".
# "auto" draws Herdr's own cursor on native Windows builds and WSL to avoid ConPTY cursor flicker, and uses the native terminal cursor elsewhere.
# "native" always uses the outer terminal cursor. "drawn" always draws Herdr's cursor as terminal cell content.
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' feat(navigator): add navigator_collapse_workspaces option by Castrozan · Pull Request #4 · Castrozan/herdr · GitHub
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 48 additions & 3 deletions src/app/actions.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -355,8 +355,10 @@ impl AppState {
self.navigator.scroll = 0;
self.navigator.expanded_workspaces.clear();

for ws in &self.workspaces {
self.navigator.expanded_workspaces.insert(ws.id.clone());
if !self.navigator_collapse_workspaces {
for ws in &self.workspaces {
self.navigator.expanded_workspaces.insert(ws.id.clone());
}
}

self.mode = Mode::Navigator;
Expand DownExpand Up@@ -3419,7 +3421,7 @@ mod tests {
}

#[test]
fn opening_navigator_selects_current_pane_and_expands_attention_workspaces() {
fn opening_navigator_selects_current_pane_and_expands_workspaces_by_default() {
let mut state = app_with_workspaces(&["one", "two"]);
let blocked = state.workspaces[1].tabs[0].root_pane;
let blocked_terminal_id = state.workspaces[1].terminal_id(blocked).cloned().unwrap();
Expand All@@ -3443,6 +3445,49 @@ mod tests {
.contains(&state.workspaces[1].id));
}

#[test]
fn navigator_collapse_workspaces_option_opens_collapsed_rows() {
let mut state = app_with_workspaces(&["one", "two"]);
state.navigator_collapse_workspaces = true;
state.open_navigator();

assert!(state.navigator.expanded_workspaces.is_empty());
let rows = state.navigator_rows();
assert!(rows.iter().all(|row| row.is_workspace));
assert!(!rows.iter().any(|row| matches!(
row.target,
crate::app::state::NavigatorTarget::Pane { .. }
| crate::app::state::NavigatorTarget::Tab { .. }
)));
let selected = rows[state.navigator.selected].clone();
assert!(selected.is_workspace);
assert!(selected.is_current);
}

#[test]
fn navigator_query_expands_collapsed_workspaces_to_matching_panes() {
let mut state = app_with_workspaces(&["one"]);
let root = state.workspaces[0].tabs[0].root_pane;
let terminal_id = state.workspaces[0].terminal_id(root).cloned().unwrap();
state
.terminals
.get_mut(&terminal_id)
.unwrap()
.set_manual_label("weekly review".into());

state.navigator_collapse_workspaces = true;
state.open_navigator();
assert!(state.navigator.expanded_workspaces.is_empty());
assert!(state.navigator_rows().iter().all(|row| row.is_workspace));

state.navigator.query = "weekly".into();
let rows = state.navigator_rows();
assert!(rows.iter().any(|row| matches!(
row.target,
crate::app::state::NavigatorTarget::Pane { .. }
) && row.label.contains("weekly")));
}

#[test]
fn accepting_navigator_pane_switches_workspace_tab_and_focus() {
let mut state = app_with_workspaces(&["one", "two"]);
Expand Down
2 changes: 2 additions & 0 deletions src/app/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -601,6 +601,7 @@ impl App {
next_agent_state_change_seq: 0,
mouse_capture: config.ui.mouse_capture,
copy_on_select: config.ui.copy_on_select,
navigator_collapse_workspaces: config.ui.navigator_collapse_workspaces,
right_click_passthrough_modifiers: config.ui.right_click_passthrough_modifiers(),
right_click_passthrough: None,
redraw_on_focus_gained: config.ui.redraw_on_focus_gained,
Expand DownExpand Up@@ -1360,6 +1361,7 @@ impl App {
.clamp(self.state.sidebar_min_width, self.state.sidebar_max_width);
self.state.mouse_capture = config.ui.mouse_capture;
self.state.copy_on_select = config.ui.copy_on_select;
self.state.navigator_collapse_workspaces = config.ui.navigator_collapse_workspaces;
if !self.state.copy_on_select {
if self.state.mode == Mode::Copy {
self.state.stop_selection_autoscroll_state();
Expand Down
2 changes: 2 additions & 0 deletions src/app/state.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -1408,6 +1408,7 @@ pub struct AppState {
/// captures mouse while the focused pane app requests mouse reporting.
pub mouse_capture: bool,
pub copy_on_select: bool,
pub navigator_collapse_workspaces: bool,
pub right_click_passthrough_modifiers: Option<KeyModifiers>,
pub right_click_passthrough: Option<RightClickPassthroughGesture>,
pub redraw_on_focus_gained: bool,
Expand DownExpand Up@@ -1767,6 +1768,7 @@ impl AppState {
next_agent_state_change_seq: 0,
mouse_capture: true,
copy_on_select: true,
navigator_collapse_workspaces: false,
right_click_passthrough_modifiers: None,
right_click_passthrough: None,
redraw_on_focus_gained: true,
Expand Down
4 changes: 4 additions & 0 deletions src/config/model.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -788,6 +788,9 @@ pub struct UiConfig {
pub mouse_capture: bool,
/// Copy text selected with the mouse. Default: true.
pub copy_on_select: bool,
/// Open the navigator (goto) collapsed to the workspace level instead of
/// expanding every workspace to its panes on open. Default: false.
pub navigator_collapse_workspaces: bool,
/// Host cursor policy. Default: auto.
pub host_cursor: HostCursorModeConfig,
/// Modifier that lets right-click gestures pass through to pane apps. Empty disables it.
Expand DownExpand Up@@ -992,6 +995,7 @@ impl Default for UiConfig {
mobile_width_threshold: DEFAULT_MOBILE_WIDTH_THRESHOLD,
mouse_capture: true,
copy_on_select: true,
navigator_collapse_workspaces: false,
host_cursor: HostCursorModeConfig::Auto,
right_click_passthrough_modifier: RightClickPassthroughModifierConfig::default(),
redraw_on_focus_gained: true,
Expand Down
4 changes: 4 additions & 0 deletions src/main.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -263,6 +263,10 @@ const DEFAULT_CONFIG: &str = r##"# herdr configuration
# Set false to disable mouse text selection and copying.
# copy_on_select = true

# Open the navigator (goto) collapsed to the workspace level instead of
# expanding every workspace to its panes on open.
# navigator_collapse_workspaces = false

# Host cursor policy: "auto", "native", or "drawn".
# "auto" draws Herdr's own cursor on native Windows builds and WSL to avoid ConPTY cursor flicker, and uses the native terminal cursor elsewhere.
# "native" always uses the outer terminal cursor. "drawn" always draws Herdr's cursor as terminal cell content.
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); feat(navigator): add navigator_collapse_workspaces option by Castrozan · Pull Request #4 · Castrozan/herdr · GitHub
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 48 additions & 3 deletions src/app/actions.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -355,8 +355,10 @@ impl AppState {
self.navigator.scroll = 0;
self.navigator.expanded_workspaces.clear();

for ws in &self.workspaces {
self.navigator.expanded_workspaces.insert(ws.id.clone());
if !self.navigator_collapse_workspaces {
for ws in &self.workspaces {
self.navigator.expanded_workspaces.insert(ws.id.clone());
}
}

self.mode = Mode::Navigator;
Expand DownExpand Up@@ -3419,7 +3421,7 @@ mod tests {
}

#[test]
fn opening_navigator_selects_current_pane_and_expands_attention_workspaces() {
fn opening_navigator_selects_current_pane_and_expands_workspaces_by_default() {
let mut state = app_with_workspaces(&["one", "two"]);
let blocked = state.workspaces[1].tabs[0].root_pane;
let blocked_terminal_id = state.workspaces[1].terminal_id(blocked).cloned().unwrap();
Expand All@@ -3443,6 +3445,49 @@ mod tests {
.contains(&state.workspaces[1].id));
}

#[test]
fn navigator_collapse_workspaces_option_opens_collapsed_rows() {
let mut state = app_with_workspaces(&["one", "two"]);
state.navigator_collapse_workspaces = true;
state.open_navigator();

assert!(state.navigator.expanded_workspaces.is_empty());
let rows = state.navigator_rows();
assert!(rows.iter().all(|row| row.is_workspace));
assert!(!rows.iter().any(|row| matches!(
row.target,
crate::app::state::NavigatorTarget::Pane { .. }
| crate::app::state::NavigatorTarget::Tab { .. }
)));
let selected = rows[state.navigator.selected].clone();
assert!(selected.is_workspace);
assert!(selected.is_current);
}

#[test]
fn navigator_query_expands_collapsed_workspaces_to_matching_panes() {
let mut state = app_with_workspaces(&["one"]);
let root = state.workspaces[0].tabs[0].root_pane;
let terminal_id = state.workspaces[0].terminal_id(root).cloned().unwrap();
state
.terminals
.get_mut(&terminal_id)
.unwrap()
.set_manual_label("weekly review".into());

state.navigator_collapse_workspaces = true;
state.open_navigator();
assert!(state.navigator.expanded_workspaces.is_empty());
assert!(state.navigator_rows().iter().all(|row| row.is_workspace));

state.navigator.query = "weekly".into();
let rows = state.navigator_rows();
assert!(rows.iter().any(|row| matches!(
row.target,
crate::app::state::NavigatorTarget::Pane { .. }
) && row.label.contains("weekly")));
}

#[test]
fn accepting_navigator_pane_switches_workspace_tab_and_focus() {
let mut state = app_with_workspaces(&["one", "two"]);
Expand Down
2 changes: 2 additions & 0 deletions src/app/mod.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -601,6 +601,7 @@ impl App {
next_agent_state_change_seq: 0,
mouse_capture: config.ui.mouse_capture,
copy_on_select: config.ui.copy_on_select,
navigator_collapse_workspaces: config.ui.navigator_collapse_workspaces,
right_click_passthrough_modifiers: config.ui.right_click_passthrough_modifiers(),
right_click_passthrough: None,
redraw_on_focus_gained: config.ui.redraw_on_focus_gained,
Expand DownExpand Up@@ -1360,6 +1361,7 @@ impl App {
.clamp(self.state.sidebar_min_width, self.state.sidebar_max_width);
self.state.mouse_capture = config.ui.mouse_capture;
self.state.copy_on_select = config.ui.copy_on_select;
self.state.navigator_collapse_workspaces = config.ui.navigator_collapse_workspaces;
if !self.state.copy_on_select {
if self.state.mode == Mode::Copy {
self.state.stop_selection_autoscroll_state();
Expand Down
2 changes: 2 additions & 0 deletions src/app/state.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -1408,6 +1408,7 @@ pub struct AppState {
/// captures mouse while the focused pane app requests mouse reporting.
pub mouse_capture: bool,
pub copy_on_select: bool,
pub navigator_collapse_workspaces: bool,
pub right_click_passthrough_modifiers: Option<KeyModifiers>,
pub right_click_passthrough: Option<RightClickPassthroughGesture>,
pub redraw_on_focus_gained: bool,
Expand DownExpand Up@@ -1767,6 +1768,7 @@ impl AppState {
next_agent_state_change_seq: 0,
mouse_capture: true,
copy_on_select: true,
navigator_collapse_workspaces: false,
right_click_passthrough_modifiers: None,
right_click_passthrough: None,
redraw_on_focus_gained: true,
Expand Down
4 changes: 4 additions & 0 deletions src/config/model.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -788,6 +788,9 @@ pub struct UiConfig {
pub mouse_capture: bool,
/// Copy text selected with the mouse. Default: true.
pub copy_on_select: bool,
/// Open the navigator (goto) collapsed to the workspace level instead of
/// expanding every workspace to its panes on open. Default: false.
pub navigator_collapse_workspaces: bool,
/// Host cursor policy. Default: auto.
pub host_cursor: HostCursorModeConfig,
/// Modifier that lets right-click gestures pass through to pane apps. Empty disables it.
Expand DownExpand Up@@ -992,6 +995,7 @@ impl Default for UiConfig {
mobile_width_threshold: DEFAULT_MOBILE_WIDTH_THRESHOLD,
mouse_capture: true,
copy_on_select: true,
navigator_collapse_workspaces: false,
host_cursor: HostCursorModeConfig::Auto,
right_click_passthrough_modifier: RightClickPassthroughModifierConfig::default(),
redraw_on_focus_gained: true,
Expand Down
4 changes: 4 additions & 0 deletions src/main.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -263,6 +263,10 @@ const DEFAULT_CONFIG: &str = r##"# herdr configuration
# Set false to disable mouse text selection and copying.
# copy_on_select = true

# Open the navigator (goto) collapsed to the workspace level instead of
# expanding every workspace to its panes on open.
# navigator_collapse_workspaces = false

# Host cursor policy: "auto", "native", or "drawn".
# "auto" draws Herdr's own cursor on native Windows builds and WSL to avoid ConPTY cursor flicker, and uses the native terminal cursor elsewhere.
# "native" always uses the outer terminal cursor. "drawn" always draws Herdr's cursor as terminal cell content.
Expand Down