Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a2a79e1
fix(context_engine): stop auto-creating workspace in sync
laststylebender14 Mar 20, 2026
29aeb7b
fix(context_engine): stop auto-creating workspace in sync
laststylebender14 Mar 20, 2026
59db627
Merge branch 'main' into fix/avoid-creating-workspace-in-sync-command
laststylebender14 Mar 21, 2026
9d9e38c
fix(context_engine): avoid auto-creating workspace in sync command
laststylebender14 Mar 21, 2026
75a07fa
Merge branch 'main' into fix/avoid-creating-workspace-in-sync-command
tusharmath Mar 22, 2026
c22a72c
Merge branch 'main' into fix/avoid-creating-workspace-in-sync-command
laststylebender14 Mar 23, 2026
d0aa726
fix(context_engine): avoid auto-creating workspace in sync
tusharmath Mar 23, 2026
2e9b99b
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 23, 2026
aa0fd2c
fix(context_engine): avoid auto-creating workspace in sync
tusharmath Mar 23, 2026
59ed853
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 23, 2026
d0c02c1
refactor(context_engine): reuse canonicalize_path helper
tusharmath Mar 23, 2026
659c0f7
refactor(context_engine): extract failed file statuses helper
tusharmath Mar 23, 2026
1b4a3bd
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 23, 2026
7441ac0
refactor(context_engine): inline file deletion call
tusharmath Mar 23, 2026
53952c0
fix(context_engine): upload files without removed helper
tusharmath Mar 23, 2026
bfe3961
fix(context_engine): prevent workspace auto-creation during sync
tusharmath Mar 23, 2026
6a27775
fix(ui): ensure authentication before initializing workspace
laststylebender14 Mar 23, 2026
052e128
fix(workspace): add --init option to sync without auto-creating
tusharmath Mar 23, 2026
4183c41
fix(context_engine): avoid workspace creation by routing file discovery
tusharmath Mar 23, 2026
0224542
fix(context_engine): avoid creating workspace during sync
tusharmath Mar 23, 2026
b9f4525
Merge branch 'main' into fix/avoid-creating-workspace-in-sync-command
tusharmath Mar 23, 2026
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
1 change: 0 additions & 1 deletion crates/forge_api/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ pub trait API: Sync + Send {
async fn sync_workspace(
&self,
path: PathBuf,
batch_size: usize,
) -> Result<MpscStream<Result<forge_domain::SyncProgress>>>;

/// Query the indexed workspace
Expand Down
3 changes: 1 addition & 2 deletions crates/forge_api/src/forge_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,8 @@ impl<
async fn sync_workspace(
&self,
path: PathBuf,
batch_size: usize,
) -> Result<MpscStream<Result<forge_domain::SyncProgress>>> {
self.services.sync_workspace(path, batch_size).await
self.services.sync_workspace(path).await
}

async fn query_workspace(
Expand Down
6 changes: 1 addition & 5 deletions crates/forge_app/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ pub trait WorkspaceService: Send + Sync {
async fn sync_workspace(
&self,
path: PathBuf,
batch_size: usize,
) -> anyhow::Result<forge_stream::MpscStream<anyhow::Result<SyncProgress>>>;

/// Query the indexed workspace with semantic search
Expand Down Expand Up @@ -1110,11 +1109,8 @@ impl<I: Services> WorkspaceService for I {
async fn sync_workspace(
&self,
path: PathBuf,
batch_size: usize,
) -> anyhow::Result<forge_stream::MpscStream<anyhow::Result<SyncProgress>>> {
self.workspace_service()
.sync_workspace(path, batch_size)
.await
self.workspace_service().sync_workspace(path).await
}

async fn query_workspace(
Expand Down
4 changes: 4 additions & 0 deletions crates/forge_main/src/built_in_commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
"command": "sync-info",
"description": "Show workspace information with sync details"
},
{
"command": "sync-init",
"description": "Initialize a new workspace without syncing files"
},
{
"command": "clone",
"description": "Clone and manage conversation context"
Expand Down
7 changes: 4 additions & 3 deletions crates/forge_main/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,10 @@ pub enum WorkspaceCommand {
#[arg(default_value = ".")]
path: PathBuf,

/// Number of files to process concurrently
#[arg(long, default_value = "100")]
batch_size: usize,
/// Automatically initialize the workspace before syncing if it has not
/// been initialized yet.
#[arg(long)]
init: bool,
},
/// List all workspaces.
List {
Expand Down
36 changes: 21 additions & 15 deletions crates/forge_main/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,8 @@ impl<A: API + ConsoleWriter + 'static, F: Fn() -> A + Send + Sync> UI<A, F> {
}
TopLevelCommand::Workspace(index_group) => {
match index_group.command {
crate::cli::WorkspaceCommand::Sync { path, batch_size } => {
self.on_index(path, batch_size).await?;
crate::cli::WorkspaceCommand::Sync { path, init } => {
self.on_index(path, init).await?;
}
crate::cli::WorkspaceCommand::List { porcelain } => {
self.on_list_workspaces(porcelain).await?;
Expand Down Expand Up @@ -1980,8 +1980,7 @@ impl<A: API + ConsoleWriter + 'static, F: Fn() -> A + Send + Sync> UI<A, F> {
}
SlashCommand::Index => {
let working_dir = self.state.cwd.clone();
// Use default batch size of 100 for slash command
self.on_index(working_dir, 100).await?;
self.on_index(working_dir, false).await?;
}
SlashCommand::AgentSwitch(agent_id) => {
// Validate that the agent exists by checking against loaded agents
Expand Down Expand Up @@ -3634,11 +3633,7 @@ impl<A: API + ConsoleWriter + 'static, F: Fn() -> A + Send + Sync> UI<A, F> {
Ok(())
}

async fn on_index(
&mut self,
path: std::path::PathBuf,
batch_size: usize,
) -> anyhow::Result<()> {
async fn on_index(&mut self, path: std::path::PathBuf, init: bool) -> anyhow::Result<()> {
use forge_domain::SyncProgress;
use forge_spinner::ProgressBarManager;

Expand All @@ -3647,7 +3642,17 @@ impl<A: API + ConsoleWriter + 'static, F: Fn() -> A + Send + Sync> UI<A, F> {
self.init_forge_services().await?;
}

let mut stream = self.api.sync_workspace(path.clone(), batch_size).await?;
// When init is set, check if the workspace is already initialized
// via get_workspace_info before calling init, so we only initialize
// when a workspace does not yet exist for the given path.
if init {
let workspace_info = self.api.get_workspace_info(path.clone()).await?;
if workspace_info.is_none() {
self.on_workspace_init(path.clone()).await?;
}
}

let mut stream = self.api.sync_workspace(path.clone()).await?;
let mut progress_bar = ProgressBarManager::default();

while let Some(event) = stream.next().await {
Expand Down Expand Up @@ -3998,19 +4003,20 @@ impl<A: API + ConsoleWriter + 'static, F: Fn() -> A + Send + Sync> UI<A, F> {

/// Initialize workspace for a directory without syncing files
async fn on_workspace_init(&mut self, path: std::path::PathBuf) -> anyhow::Result<()> {
// Check if auth already exists and create if needed
if !self.api.is_authenticated().await? {
self.init_forge_services().await?;
}

self.spinner.start(Some("Initializing workspace"))?;

let workspace_id = self.api.init_workspace(path.clone()).await?;

self.spinner.stop(None)?;

// Resolve and display the path
let canonical_path = path.canonicalize().unwrap_or_else(|_| path.clone());

self.writeln_title(
TitleFormat::info("Workspace initialized successfully")
.sub_title(format!("Path: {}", canonical_path.display()))
.sub_title(format!("Workspace ID: {}", workspace_id)),
.sub_title(format!("{}", workspace_id)),
)?;

Ok(())
Expand Down
Loading
Loading