Skip to content

Conversation

@baronfel
Copy link
Member

@baronfel baronfel commented Mar 3, 2025

This change unifies the --interactive infrastructure for all dotnet commands. With that common infra, it also enables interactivity for non-CI scenarios by default. We reuse CI detection from telemetry and from output redirection to determine whether to enable interactivity.

Fixes #35165

@ghost ghost added Area-Infrastructure untriaged Request triage from a team member labels Mar 3, 2025
@baronfel baronfel force-pushed the default-interactive-to-on-for-local-sessions branch from 712f4d8 to cc28c6e Compare March 3, 2025 20:10
@baronfel baronfel force-pushed the default-interactive-to-on-for-local-sessions branch from cc28c6e to 61a448b Compare March 5, 2025 23:38
@baronfel baronfel added Document for new feature cli-ux Issues and PRs that deal with the UX of the CLI (exit codes, log output, verbs/options, and so on) and removed Area-Infrastructure labels Mar 5, 2025
@baronfel baronfel force-pushed the default-interactive-to-on-for-local-sessions branch 2 times, most recently from 939013b to 6615f0f Compare March 7, 2025 17:13
@baronfel baronfel marked this pull request as ready for review March 7, 2025 19:30
Copilot AI review requested due to automatic review settings March 7, 2025 19:30
@baronfel baronfel requested review from a team, arunchndr and tmat as code owners March 7, 2025 19:30
@baronfel baronfel requested a review from a team March 7, 2025 19:30
baronfel added 9 commits March 7, 2025 13:30
This change unifies the `--interactive` infrastructure for all `dotnet` commands.
With that common infra, it also enables interactivity for non-CI scenarios by default.
We reuse CI detection from telemetry and from output redirection to determine whether to enable interactivity.
@baronfel baronfel force-pushed the default-interactive-to-on-for-local-sessions branch from 6615f0f to feb6c94 Compare March 7, 2025 19:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR unifies the handling of the --interactive option across dotnet CLI commands to enable interactivity by default for local sessions while still allowing it to be explicitly disabled. Key changes include refactoring interactive option definitions to use a common implementation, updating forwarding functions to conditionally include interactive arguments, and adjusting tests to expect the interactive flag in the command arguments.

Reviewed Changes

File Description
src/Cli/dotnet/CommonOptions.cs Introduces helper IsCIEnvironmentOrRedirected() and redefines InteractiveOption to use the new common infra.
test/dotnet-run.Tests/GivenDotnetRunBuildsCsProj.cs Updates tests to reflect that interactivity is enabled by default and adds tests for when it is explicitly disabled.
src/BuiltInTools/dotnet-watch/CommandLineOptions.cs Adjusts forwarding logic to skip the interactive token when --non-interactive is specified.
src/Cli/dotnet/* Updates various command parsers to use the common InteractiveOption implementation.
src/Cli/dotnet/OptionForwardingExtensions.cs Refactors forwarding extension methods to work with nullable values and use a concise array literal syntax.
test/dotnet-watch.Tests/CommandLineOptionsTests.cs Updates test expectations so that interactive defaults are correctly injected into command and build arguments.

Copilot reviewed 34 out of 34 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/Cli/dotnet/OptionForwardingExtensions.cs:14

  • [nitpick] The use of array literal syntax like [option.Name] may reduce clarity for readers; consider using an explicit array initializer (e.g. new string[] { option.Name }) for improved readability.
public static ForwardedOption<T> Forward<T>(this ForwardedOption<T> option) => option.SetForwardingFunction((T? o) => [option.Name]);

.WithWorkingDirectory(testInstance.Path)
.Execute();

// this message should show because interactivity (and therefore nuget auth) is the default
Copy link

Copilot AI Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment in the ItDoesNotShowImportantLevelMessageByDefaultWhenInteractivityDisabled test is misleading because the test name and assertion expect that important level messages are not shown when interactivity is disabled. Please update the comment so it accurately reflects the expected behavior.

Copilot uses AI. Check for mistakes.
@baronfel baronfel enabled auto-merge (squash) March 8, 2025 15:24
@baronfel baronfel merged commit 301a914 into dotnet:main Mar 8, 2025
39 checks passed
@baronfel baronfel deleted the default-interactive-to-on-for-local-sessions branch March 8, 2025 18:35
baronfel added a commit to dotnet/msbuild that referenced this pull request Jul 10, 2025
Part of dotnet/sdk#47602

### Context

With `NuGetInteractive=true` being passed in more scenarios as of
dotnet/sdk#47226, the default verbosity for
`dotnet run` is now `minimal` for user-present scenarios - that's gross.

### Changes Made

Broadly what I'm trying to do here is not require passing `-v m` to
loggers to get the authentication-related messages. Right now `dotnet
run` does this and it's quite noisy compared to previous behavior. This
changed because recently I made the SDK start passing `--interactive`
when the user is at the keyboard (similar logic to Terminal Logger's own
enablement), and `dotnet run` has logic to force verbosity to minimal
when that happens so that the auth messages print where a user can see
them.
 
I kind of think of auth messages as messages that we should write
regardless of verbosity (like errors are), so this is a step down that
path for TL.

This change ensures that auth messages are always written in the TL
experience, as immediate messages.

If this is accepted, then the SDK could remove the [special case it
currently has](dotnet/sdk#47389).

### Testing

Updated snapshot baselines, manual testing.

### Notes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli-ux Issues and PRs that deal with the UX of the CLI (exit codes, log output, verbs/options, and so on) Document for new feature untriaged Request triage from a team member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default --interactive to true across the commands

3 participants