From 456f47a8bdf8e00f1cd06c0a3b23b07b0c92cda0 Mon Sep 17 00:00:00 2001 From: Tushar Date: Fri, 3 Apr 2026 17:38:46 +0530 Subject: [PATCH 1/2] feat(ui): add workspace init confirmation before syncing --- crates/forge_main/src/ui.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/crates/forge_main/src/ui.rs b/crates/forge_main/src/ui.rs index f5954dbb91..7a0bf8276b 100644 --- a/crates/forge_main/src/ui.rs +++ b/crates/forge_main/src/ui.rs @@ -3736,6 +3736,12 @@ impl A + Send + Sync> UI { let workspace_info = self.api.get_workspace_info(path.clone()).await?; if workspace_info.is_none() { self.on_workspace_init(path.clone()).await?; + // If the workspace still does not exist after init (e.g. user + // declined the consent prompt), abort the sync. + let workspace_info = self.api.get_workspace_info(path.clone()).await?; + if workspace_info.is_none() { + return Ok(()); + } } } @@ -4090,6 +4096,21 @@ impl A + Send + Sync> UI { /// Initialize workspace for a directory without syncing files async fn on_workspace_init(&mut self, path: std::path::PathBuf) -> anyhow::Result<()> { + // Ask for user consent before syncing and sharing directory contents + // with the ForgeCode Service. + let display_path = path.display().to_string(); + let confirmed = ForgeWidget::confirm(format!( + "This will sync and share the contents of '{}' with ForgeCode Services. Do you wish to continue?", + display_path + )) + .with_default(true) + .prompt()?; + + if !confirmed.unwrap_or(false) { + self.writeln_title(TitleFormat::info("Workspace initialization cancelled"))?; + return Ok(()); + } + // Check if auth already exists and create if needed if !self.api.is_authenticated().await? { self.init_forge_services().await?; From 4314c07ec336e5bb53982165f1881a4abec2fdeb Mon Sep 17 00:00:00 2001 From: Tushar Date: Fri, 3 Apr 2026 17:43:09 +0530 Subject: [PATCH 2/2] feat(sync): use interactive exec for workspace init and sync --- shell-plugin/lib/actions/config.zsh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/shell-plugin/lib/actions/config.zsh b/shell-plugin/lib/actions/config.zsh index 4cff73a498..c7869e3c2a 100644 --- a/shell-plugin/lib/actions/config.zsh +++ b/shell-plugin/lib/actions/config.zsh @@ -242,16 +242,18 @@ function _forge_action_suggest_model() { # Action handler: Sync workspace for codebase search function _forge_action_sync() { echo - # Execute sync with stdin redirected to prevent hanging - # Sync doesn't need interactive input, so close stdin immediately + # Use _forge_exec_interactive so that the consent prompt (and any other + # interactive prompts) can access /dev/tty even though ZLE owns the + # terminal's stdin/stdout pipes. # --init initializes the workspace first if it has not been set up yet - _forge_exec workspace sync --init