Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onDidExecuteTerminalCommand does not fire events for hidden terminal #199611

Closed
Tracked by #22879
karrtikr opened this issue Nov 29, 2023 · 9 comments · Fixed by #208036 or #210698
Closed
Tracked by #22879

onDidExecuteTerminalCommand does not fire events for hidden terminal #199611

karrtikr opened this issue Nov 29, 2023 · 9 comments · Fixed by #208036 or #210698
Assignees
Labels
api bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders terminal-shell-integration Shell integration infrastructure, command decorations, etc. verified Verification succeeded
Milestone

Comments

@karrtikr
Copy link
Contributor

karrtikr commented Nov 29, 2023

Does this issue occur when all extensions are disabled?: Yes/No

For proposed API: #145234

Version: 1.85.0-insider (user setup)
OS: Windows_NT x64 10.0.22518

Steps to Reproduce:

  1. Create a hidden terminal using hideFromUser to true
  2. Send text to terminal, for eg. "echo hello"
  3. Watch no events are fired

Same is not the case if hideFromUser is set to false.

cc/ @Tyriar

@karrtikr
Copy link
Contributor Author

@Tyriar @meganrogge Any idea where the issue could be here? We require this to start leveraging #145234.

@Tyriar
Copy link
Member

Tyriar commented Mar 18, 2024

This is by design according to this:

if (!options.shellIntegration.enabled || !shellLaunchConfig.executable || (shellLaunchConfig.isFeatureTerminal && !shellLaunchConfig.forceShellIntegration) || shellLaunchConfig.hideFromUser || shellLaunchConfig.ignoreShellIntegration || useWinpty) {
return undefined;
}

We tweaked the condition in #206543 to work properly on remotes, and tried to force shell integration for debug terminals here:

// Since debug termnials are REPLs, we want shell integration to be enabled.
// Ignore isFeatureTerminal when evaluating shell integration enablement.
forceShellIntegration: true,

I don't see an issue with changing hidden terminals from having shell integration, we just need to watch the incoming issues for problems.

@Tyriar
Copy link
Member

Tyriar commented Mar 18, 2024

If we have shell integration in hidden terminals is conflicts with #197187 (comment) but I think the thinking was changed in #194819 (comment)?

If you don't want env collections you must pass strictEnv, which means you need to provide the entire environment.

@Tyriar Tyriar closed this as completed in f5f392c Mar 18, 2024
@vscodenpa vscodenpa added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Mar 18, 2024
@rzhao271 rzhao271 modified the milestones: Backlog, March 2024 Mar 25, 2024
@TylerLeonhardt
Copy link
Member

TylerLeonhardt commented Mar 27, 2024

I still repro this with the following minimum repro:

import * as vscode from 'vscode';

export async function activate(context: vscode.ExtensionContext) {
	const terminal = vscode.window.createTerminal({
		hideFromUser: true,
		shellPath: '/bin/bash',
	});
	vscode.window.onDidExecuteTerminalCommand(e=> {
		// Does not fire
		vscode.window.showInformationMessage(e.commandLine ?? '');
	});
	terminal.sendText('echo "hello"');
}

Changing to hideFromUser: false fires the event.

Or maybe there are other steps that should be taken?

@TylerLeonhardt TylerLeonhardt added the verification-steps-needed Steps to verify are needed for verification label Mar 27, 2024
@meganrogge meganrogge reopened this Mar 27, 2024
@meganrogge meganrogge added verification-found Issue verification failed and removed verification-steps-needed Steps to verify are needed for verification labels Mar 27, 2024
@vscodenpa vscodenpa removed the insiders-released Patch has been released in VS Code Insiders label Mar 27, 2024
@meganrogge meganrogge modified the milestones: March 2024, April 2024 Mar 27, 2024
@meganrogge
Copy link
Contributor

Reopening as your steps seem correct @TylerLeonhardt

@meganrogge
Copy link
Contributor

possible that the hidden terminal isn't yet a part of terminalGroupInstances yet, so is not within this.instances here?

return this._terminalGroupService.instances.concat(this._terminalEditorService.instances);

return createInstanceCapabilityEventMultiplexer(this.instances, this.onDidCreateInstance, this.onDidDisposeInstance, capabilityId, getEvent);

Yes, seems like it

setActiveInstance(value: ITerminalInstance) {
// If this was a hideFromUser terminal created by the API this was triggered by show,
// in which case we need to create the terminal group
if (value.shellLaunchConfig.hideFromUser) {
this._showBackgroundTerminal(value);
}

@meganrogge
Copy link
Contributor

We should include _backgroundedTerminalInstances in instances I think

@meganrogge meganrogge removed the verification-found Issue verification failed label Apr 18, 2024
meganrogge added a commit that referenced this issue Apr 18, 2024
@vscodenpa vscodenpa added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Apr 18, 2024
@eleanorjboyd eleanorjboyd added the ~verification-steps-needed Steps to verify are needed (with bot comment) label Apr 24, 2024
@vscodenpa
Copy link

Friendly ping! Looks like this issue requires some further steps to be verified. Please provide us with the steps necessary to verify this issue.

@vscodenpa vscodenpa added verification-steps-needed Steps to verify are needed for verification and removed ~verification-steps-needed Steps to verify are needed (with bot comment) labels Apr 24, 2024
@meganrogge meganrogge removed the verification-steps-needed Steps to verify are needed for verification label Apr 24, 2024
@meganrogge
Copy link
Contributor

@eleanorjboyd these steps are good

#199611 (comment)

@rzhao271 rzhao271 added the verified Verification succeeded label Apr 25, 2024
@microsoft microsoft locked and limited conversation to collaborators Jun 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders terminal-shell-integration Shell integration infrastructure, command decorations, etc. verified Verification succeeded
Projects
None yet
7 participants