Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

Add `blank_line()` to output module

Maximilian Roos3adc0f72da14
diff --git a/src/commands/select.rs b/src/commands/select.rs
index ac29fb66a..77abc2c7c 100644
--- a/src/commands/select.rs
+++ b/src/commands/select.rs
@@ -9,7 +9,7 @@ use worktrunk::git::{GitError, GitResultExt, Repository};
use super::list::model::ListItem;
use super::repository_ext::RepositoryCliExt;
use super::worktree::handle_switch;
-use crate::output::handle_switch_output;
+use crate::output::{blank_line, handle_switch_output};
/// Preview modes for the interactive selector
///
@@ -358,6 +358,9 @@ pub fn handle_select() -> Result<(), GitError> {
let (result, resolved_branch) =
handle_switch(&identifier, false, None, false, false, &config)?;
+ // Skim leaves the prompt on the same line, so insert a blank line before our messages
+ blank_line()?;
+
// Show success message (show shell integration hint if not configured)
handle_switch_output(&result, &resolved_branch, false)?;
}
diff --git a/src/output/directive.rs b/src/output/directive.rs
index 675a304d7..2b165f762 100644
--- a/src/output/directive.rs
+++ b/src/output/directive.rs
@@ -75,6 +75,11 @@ impl DirectiveOutput {
io::stdout().flush()
}
+ pub fn blank_line(&mut self) -> io::Result<()> {
+ // Blank lines are only meaningful in interactive mode; no-op here to avoid empty directives
+ Ok(())
+ }
+
pub fn gutter(&mut self, content: String) -> io::Result<()> {
// Gutter content has its own visual structure - print with NUL terminator
write!(io::stdout(), "{content}\0")?;
diff --git a/src/output/global.rs b/src/output/global.rs
index b8ce77a7d..c71b97a89 100644
--- a/src/output/global.rs
+++ b/src/output/global.rs
@@ -124,6 +124,14 @@ pub fn warning(message: impl Into<String>) -> io::Result<()> {
})
}
+/// Insert a blank line between UI output and worktrunk messages
+pub fn blank_line() -> io::Result<()> {
+ OUTPUT_CONTEXT.with(|ctx| match &mut *ctx.borrow_mut() {
+ OutputHandler::Interactive(i) => i.blank_line(),
+ OutputHandler::Directive(d) => d.blank_line(),
+ })
+}
+
/// Emit gutter-formatted content
///
/// Gutter content has its own visual structure (column 0 gutter + content),
diff --git a/src/output/interactive.rs b/src/output/interactive.rs
index 3161da56f..8f4b30360 100644
--- a/src/output/interactive.rs
+++ b/src/output/interactive.rs
@@ -57,6 +57,12 @@ impl InteractiveOutput {
Ok(())
}
+ pub fn blank_line(&mut self) -> io::Result<()> {
+ // Ensure subsequent output starts on a fresh line after interactive UIs like skim
+ println!();
+ stdout().flush()
+ }
+
pub fn gutter(&mut self, content: String) -> io::Result<()> {
// Gutter content has its own visual structure - just print it
use worktrunk::styling::print;
diff --git a/src/output/mod.rs b/src/output/mod.rs
index c66f7c484..8b6f34983 100644
--- a/src/output/mod.rs
+++ b/src/output/mod.rs
@@ -63,8 +63,8 @@ pub mod interactive;
// Re-export the public API
pub use global::{
- OutputMode, change_directory, execute, flush, gutter, hint, info, initialize, progress,
- success, terminate_output, warning,
+ OutputMode, blank_line, change_directory, execute, flush, gutter, hint, info, initialize,
+ progress, success, terminate_output, warning,
};
// Re-export output handlers