Skip to content

Commit c19e683

Browse files
committed
Update McpActionExecutor.cs
1 parent ffca008 commit c19e683

1 file changed

Lines changed: 14 additions & 20 deletions

File tree

src/ProfileExplorerUI/Mcp/McpActionExecutor.cs

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,17 @@ public async Task<OpenTraceResult> OpenTraceAsync(string profileFilePath, string
7070
};
7171
}
7272

73-
OpenTraceResult result;
73+
// In --mcp mode the MainWindow was created hidden; show it now that we're
74+
// about to load a trace. WPF requires Owner to have been Show()n before
75+
// ProfileLoadWindow.Owner can be set during the load.
76+
dispatcher.Invoke(() =>
77+
{
78+
if (!mainWindow.IsVisible)
79+
{
80+
mainWindow.Show();
81+
}
82+
});
83+
7484
if (int.TryParse(processIdentifier, out int processId))
7585
{
7686
if (processId <= 0)
@@ -82,27 +92,11 @@ public async Task<OpenTraceResult> OpenTraceAsync(string profileFilePath, string
8292
ErrorMessage = "Process ID must be a positive integer."
8393
};
8494
}
85-
result = await OpenTraceByProcessIdAsync(profileFilePath, processId);
86-
}
87-
else
88-
{
89-
// If not a number, treat as process name
90-
result = await OpenTraceByProcessNameAsync(profileFilePath, processIdentifier);
95+
return await OpenTraceByProcessIdAsync(profileFilePath, processId);
9196
}
9297

93-
// In --mcp mode MainWindow is hidden; show it only on a successful load,
94-
// not earlier — a late load failure should not leave a window behind.
95-
if (result.Success)
96-
{
97-
await dispatcher.InvokeAsync(() =>
98-
{
99-
if (!mainWindow.IsVisible)
100-
{
101-
mainWindow.Show();
102-
}
103-
});
104-
}
105-
return result;
98+
// If not a number, treat as process name
99+
return await OpenTraceByProcessNameAsync(profileFilePath, processIdentifier);
106100
}
107101

108102
/// <summary>

0 commit comments

Comments
 (0)