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
30 changes: 16 additions & 14 deletions src/crates/core/src/agentic/persistence/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ impl PersistenceManager {
}
}

fn build_session_metadata(
async fn build_session_metadata(
&self,
workspace_path: &Path,
session: &Session,
Expand All @@ -581,17 +581,18 @@ impl PersistenceManager {
.or_else(|| existing.map(|value| value.model_name.clone()))
.unwrap_or_else(|| "default".to_string());

let resolved_identity = session
.config
.workspace_path
.as_deref()
.and_then(|workspace_root| {
futures::executor::block_on(resolve_workspace_session_identity(
workspace_root,
session.config.remote_connection_id.as_deref(),
session.config.remote_ssh_host.as_deref(),
))
});
let resolved_identity = if let Some(workspace_root) =
session.config.workspace_path.as_deref()
{
resolve_workspace_session_identity(
workspace_root,
session.config.remote_connection_id.as_deref(),
session.config.remote_ssh_host.as_deref(),
)
.await
} else {
None
};

let workspace_root = resolved_identity
.as_ref()
Expand Down Expand Up @@ -1513,8 +1514,9 @@ impl PersistenceManager {
let existing_metadata = self
.load_session_metadata(workspace_path, &session.session_id)
.await?;
let metadata =
self.build_session_metadata(workspace_path, session, existing_metadata.as_ref());
let metadata = self
.build_session_metadata(workspace_path, session, existing_metadata.as_ref())
.await;
self.save_session_metadata(workspace_path, &metadata)
.await?;

Expand Down
2 changes: 1 addition & 1 deletion src/web-ui/src/app/layout/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ const AppLayout: React.FC<AppLayoutProps> = ({ className = '' }) => {

let sessionId: string | undefined;
const { flowChatStore } = await import('@/flow_chat/store/FlowChatStore');
if (!hasHistoricalSessions || !flowChatStore.getState().activeSessionId) {
if (!hasHistoricalSessions) {
const initialSessionMode =
currentWorkspace.workspaceKind === WorkspaceKind.Assistant
? 'Claw'
Expand Down
7 changes: 0 additions & 7 deletions src/web-ui/src/flow_chat/services/FlowChatManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export class FlowChatManager {
remoteSshHost?: string;
}) => {
const sp = session.workspacePath || workspacePath;
if (sp !== workspacePath) return false;
return sessionBelongsToWorkspaceNavRow(
{
workspacePath: sp,
Expand Down Expand Up @@ -128,12 +127,6 @@ export class FlowChatManager {
return hasHistoricalSessions;
}

// If no session matches preferred mode, keep activeSessionId unset for caller to create one.
if (preferredMode && latestSession.mode !== preferredMode) {
this.context.currentWorkspacePath = workspacePath;
return hasHistoricalSessions;
}

if (latestSession.isHistorical) {
await this.context.flowChatStore.loadSessionHistory(
latestSession.sessionId,
Expand Down
16 changes: 9 additions & 7 deletions src/web-ui/src/flow_chat/utils/sessionOrdering.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Session } from '../types/flow-chat';
import { normalizeRemoteWorkspacePath } from '@/shared/utils/pathUtils';
import { isSamePath, normalizeRemoteWorkspacePath } from '@/shared/utils/pathUtils';

/** Extract `host` from our saved form `ssh-{user}@{host}:{port}` (used when metadata omits `remoteSshHost`). */
function hostFromSshConnectionId(connectionId: string): string | null {
Expand Down Expand Up @@ -29,8 +29,10 @@ export function sessionBelongsToWorkspaceNavRow(
remoteConnectionId?: string | null,
remoteSshHost?: string | null
): boolean {
const wp = normalizeRemoteWorkspacePath(workspacePath);
const sp = normalizeRemoteWorkspacePath(session.workspacePath || workspacePath);
const sessionRoot = session.workspacePath || workspacePath;
const pathsMatch =
isSamePath(sessionRoot, workspacePath) ||
normalizeRemoteWorkspacePath(sessionRoot) === normalizeRemoteWorkspacePath(workspacePath);

const wsConn = remoteConnectionId?.trim() ?? '';
const sessConn = session.remoteConnectionId?.trim() ?? '';
Expand All @@ -41,18 +43,18 @@ export function sessionBelongsToWorkspaceNavRow(

if (wsHostEff.length > 0) {
// Host match alone is insufficient (same server, different remote folders).
if (sessHost === wsHostEff && sp === wp) {
if (sessHost === wsHostEff && pathsMatch) {
return true;
}
if (sessConnHost === wsHostEff && sp === wp) {
if (sessConnHost === wsHostEff && pathsMatch) {
return true;
}
if (sessConnHost && wsConnHost && sessConnHost === wsConnHost) {
return sp === wp;
return pathsMatch;
}
}

if (sp !== wp) return false;
if (!pathsMatch) return false;

if (wsConn.length > 0 || sessConn.length > 0) {
return sessConn === wsConn;
Expand Down
Loading