Improve connector detection for migrated sessions (#36977)

## Why

Session IDs are derived from file stems and can repeat across projects. Keying
connector attribution only by session ID can therefore assign one session's
connectors to another session during a batched migration.

## What changed

- Preserve connector candidates by canonical source path until each imported
  session is annotated, then aggregate them for detection summaries.
- Resolve project-backed MCP tool calls from both `CallMcpTool` server IDs and
  `mcpDetails.serverName`, while requiring a match in project metadata.

## Testing

Add coverage for duplicate session stems, per-source connector results, and
both supported project-backed MCP tool-call formats.

GitOrigin-RevId: 10563d47c29673c07daa83be5f4e1a256740b901
This commit is contained in:
charlesgong-openai
2026-08-04 21:45:28 +00:00
committed by copyberry
parent 1b90b1d16b
commit 1a5e152189
10 changed files with 546 additions and 172 deletions
@@ -719,24 +719,21 @@ fn detected_session_connectors(
) {
let mut connector_names_by_source_path = BTreeMap::new();
let mut connectors_by_name = BTreeMap::<String, DetectedConnectorCandidate>::new();
for session in sessions {
if !session.path.is_file() {
continue;
}
let session_connectors =
migration_service.detect_session_connectors(std::slice::from_ref(session));
if session_connectors.is_empty() {
continue;
}
if let Ok(source_path) = std::fs::canonicalize(&session.path) {
connector_names_by_source_path.insert(
source_path,
session_connectors
.iter()
.map(|candidate| candidate.name.clone())
.collect(),
);
}
let sessions = sessions
.iter()
.filter(|session| session.path.is_file())
.cloned()
.collect::<Vec<_>>();
for (source_path, session_connectors) in
migration_service.detect_session_connectors_by_source_path(&sessions)
{
connector_names_by_source_path.insert(
source_path,
session_connectors
.iter()
.map(|candidate| candidate.name.clone())
.collect(),
);
for candidate in session_connectors {
let key = candidate.name.to_lowercase();
let session_count = candidate.session_count;