Skip to content
Merged
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
14 changes: 11 additions & 3 deletions src/crates/core/src/agentic/coordination/coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ use crate::agentic::image_analysis::ImageContextData;
use crate::agentic::session::SessionManager;
use crate::agentic::tools::pipeline::{SubagentParentInfo, ToolPipeline};
use crate::agentic::WorkspaceBinding;
use crate::service::bootstrap::is_workspace_bootstrap_pending;
use crate::service::bootstrap::{
initialize_workspace_persona_files, is_workspace_bootstrap_pending,
};
use crate::util::errors::{BitFunError, BitFunResult};
use log::{debug, error, info, warn};
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -633,7 +635,11 @@ Update the persona files and delete BOOTSTRAP.md as soon as bootstrap is complet
workspace_path: String,
) -> BitFunResult<AssistantBootstrapEnsureOutcome> {
let workspace_root = PathBuf::from(&workspace_path);
if !is_workspace_bootstrap_pending(&workspace_root) {
// Empty or partial assistant dirs may never have run create_assistant_workspace; fill only
// missing persona stubs (never overwrite). Ensures BOOTSTRAP.md exists when appropriate.
initialize_workspace_persona_files(&workspace_root).await?;
let bootstrap_pending = is_workspace_bootstrap_pending(&workspace_root);
if !bootstrap_pending {
return Ok(AssistantBootstrapEnsureOutcome::Skipped {
session_id,
reason: AssistantBootstrapSkipReason::BootstrapNotRequired,
Expand All @@ -649,7 +655,9 @@ Update the persona files and delete BOOTSTRAP.md as soon as bootstrap is complet
}
};

if self.session_manager.get_turn_count(&session_id) > 0 {
let turn_count = self.session_manager.get_turn_count(&session_id);

if turn_count > 0 {
return Ok(AssistantBootstrapEnsureOutcome::Skipped {
session_id,
reason: AssistantBootstrapSkipReason::SessionHasExistingTurns,
Expand Down
1 change: 1 addition & 0 deletions src/crates/core/src/service/workspace/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ impl WorkspaceService {
})?;
}

// New assistant dirs get persona files at creation; coordinator also fills missing files when opening.
initialize_workspace_persona_files(&path).await?;

self.create_workspace(path, options).await
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ const WorkspaceItem: React.FC<WorkspaceItemProps> = ({
await flowChatManager.resetWorkspaceSessions(workspace.rootPath, {
reinitialize: isActive,
preferredMode: 'Claw',
ensureAssistantBootstrap:
isActive && workspace.workspaceKind === WorkspaceKind.Assistant,
});
notificationService.success(t('nav.workspaces.workspaceReset'), { duration: 2500 });
} catch (error) {
Expand Down
25 changes: 24 additions & 1 deletion src/web-ui/src/flow_chat/services/FlowChatManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,12 @@ export class FlowChatManager {

async resetWorkspaceSessions(
workspacePath: string,
options?: { reinitialize?: boolean; preferredMode?: string }
options?: {
reinitialize?: boolean;
preferredMode?: string;
/** After reinit, ask core to run assistant bootstrap if BOOTSTRAP.md is present (e.g. workspace reset). */
ensureAssistantBootstrap?: boolean;
}
): Promise<void> {
const removedSessionIds = this.context.flowChatStore.removeSessionsByWorkspace(workspacePath);

Expand All @@ -180,6 +185,24 @@ export class FlowChatManager {
if (!hasHistoricalSessions || !hasActiveWorkspaceSession) {
await this.createChatSession({}, options.preferredMode);
}

if (options?.ensureAssistantBootstrap) {
const sid = this.context.flowChatStore.getState().activeSessionId;
if (sid) {
try {
const { agentAPI } = await import('@/infrastructure/api/service-api/AgentAPI');
await agentAPI.ensureAssistantBootstrap({
sessionId: sid,
workspacePath,
});
} catch (error) {
log.warn('ensureAssistantBootstrap after resetWorkspaceSessions failed', {
workspacePath,
error,
});
}
}
}
}

async sendMessage(
Expand Down
Loading