Skip to content
Draft
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
7 changes: 7 additions & 0 deletions DevProxy.Abstractions/Proxy/ProxyEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ public class ProxyResponseArgs(SessionEventArgs session, ResponseState responseS
public class InitArgs
{
public required IServiceProvider ServiceProvider { get; init; }
/// <summary>
/// Indicates whether the proxy command (root command) is being invoked.
/// When false, a CLI subcommand is being executed and plugins should
/// skip initialization that is only relevant for proxy operation
/// (e.g., opening browsers, starting listeners).
/// </summary>
public bool IsProxyCommand { get; init; } = true;
}

public class OptionsLoadedArgs(ParseResult parseResult)
Expand Down
7 changes: 7 additions & 0 deletions DevProxy.Plugins/Inspection/DevToolsPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,17 @@ public sealed class DevToolsPlugin(

public override async Task InitializeAsync(InitArgs e, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(e);

_cancellationToken = cancellationToken;

await base.InitializeAsync(e, cancellationToken);

if (!e.IsProxyCommand)
{
return;
}

InitInspector();
}

Expand Down
5 changes: 5 additions & 0 deletions DevProxy.Plugins/Inspection/OpenAITelemetryPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public override async Task InitializeAsync(InitArgs e, CancellationToken cancell

await base.InitializeAsync(e, cancellationToken);

if (!e.IsProxyCommand)
{
return;
}

if (Configuration.IncludeCosts)
{
Configuration.PricesFile = ProxyUtils.GetFullPath(Configuration.PricesFile, ProxyConfiguration.ConfigFile);
Expand Down
4 changes: 2 additions & 2 deletions DevProxy/Plugins/PluginServiceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private static void RegisterPlugin(
// stage is synchronous, but if the implementation changes
// in the future then we won't need to change the interface
#pragma warning disable VSTHRD002
plugin.InitializeAsync(new() { ServiceProvider = sp }, CancellationToken.None).Wait();
plugin.InitializeAsync(new() { ServiceProvider = sp, IsProxyCommand = DevProxyCommand.IsRootCommand }, CancellationToken.None).Wait();
Comment thread
waldekmastykarz marked this conversation as resolved.
#pragma warning restore VSTHRD002
return plugin;
});
Expand All @@ -200,7 +200,7 @@ private static void RegisterPlugin(
// stage is synchronous, but if the implementation changes
// in the future then we won't need to change the interface
#pragma warning disable VSTHRD002
plugin.InitializeAsync(new() { ServiceProvider = sp }, CancellationToken.None).Wait();
plugin.InitializeAsync(new() { ServiceProvider = sp, IsProxyCommand = DevProxyCommand.IsRootCommand }, CancellationToken.None).Wait();
Comment thread
waldekmastykarz marked this conversation as resolved.
#pragma warning restore VSTHRD002
return plugin;
});
Expand Down
Loading