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

on terminal reconnection, shellIntegration.cwd is undefined #234672

Closed
meganrogge opened this issue Nov 26, 2024 · 9 comments · Fixed by #237524 or #239238
Closed

on terminal reconnection, shellIntegration.cwd is undefined #234672

meganrogge opened this issue Nov 26, 2024 · 9 comments · Fixed by #237524 or #239238
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders terminal-persistence Relating to process reconnection or process revive verified Verification succeeded
Milestone

Comments

@meganrogge
Copy link
Contributor

meganrogge commented Nov 26, 2024

discovered with terminal suggest #234671

Related: #200777

@meganrogge meganrogge added bug Issue identified by VS Code Team member as probable bug terminal-shell-integration Shell integration infrastructure, command decorations, etc. labels Nov 26, 2024
@meganrogge meganrogge added this to the January 2025 milestone Nov 26, 2024
@meganrogge
Copy link
Contributor Author

Also noticed that terminal is getting reconnected to even though there's been no input

Screen.Recording.2024-11-26.at.10.59.45.AM.mov

@meganrogge
Copy link
Contributor Author

meganrogge commented Nov 26, 2024

this doesn't get hit for the reconnected terminal

capabilityListeners.set(capability, cwdDetection.onDidChangeCwd(e => {
this._cwd = e;
this._setTitle(this.title, TitleEventSource.Config);
}));

@meganrogge
Copy link
Contributor Author

this doesn't either

@meganrogge
Copy link
Contributor Author

@Tyriar since you did most of the detached terminal and terminal capability store work, do you know where we set the capabilities for reconnected terminals?

@meganrogge meganrogge removed their assignment Dec 9, 2024
@Tyriar Tyriar added terminal-persistence Relating to process reconnection or process revive and removed terminal-shell-integration Shell integration infrastructure, command decorations, etc. labels Dec 10, 2024
@Tyriar
Copy link
Member

Tyriar commented Dec 10, 2024

This is where we serialize:

@traceRpc
async serializeTerminalState(ids: number[]): Promise<string> {
const promises: Promise<ISerializedTerminalState>[] = [];
for (const [persistentProcessId, persistentProcess] of this._ptys.entries()) {
// Only serialize persistent processes that have had data written or performed a replay
if (persistentProcess.hasWrittenData && ids.indexOf(persistentProcessId) !== -1) {
promises.push(Promises.withAsyncBody<ISerializedTerminalState>(async r => {
r({
id: persistentProcessId,
shellLaunchConfig: persistentProcess.shellLaunchConfig,
processDetails: await this._buildProcessDetails(persistentProcessId, persistentProcess),
processLaunchConfig: persistentProcess.processLaunchOptions,
unicodeVersion: persistentProcess.unicodeVersion,
replayEvent: await persistentProcess.serializeNormalBuffer(),
timestamp: Date.now()
});
}));
}
}
const serialized: ICrossVersionSerializedTerminalState = {
version: 1,
state: await Promise.all(promises)
};
return JSON.stringify(serialized);
}

Revive:

@traceRpc
async reviveTerminalProcesses(workspaceId: string, state: ISerializedTerminalState[], dateTimeFormatLocale: string) {
const promises: Promise<void>[] = [];
for (const terminal of state) {
promises.push(this._reviveTerminalProcess(workspaceId, terminal));
}
await Promise.all(promises);
}

Reconnect:

/**
* This is a terminal that attaches to an already running terminal.
*/
attachPersistentProcess?: {
id: number;
findRevivedId?: boolean;
pid: number;
title: string;
titleSource: TitleEventSource;
cwd: string;
icon?: TerminalIcon;
color?: string;
hasChildProcesses?: boolean;
fixedDimensions?: IFixedTerminalDimensions;
environmentVariableCollections?: ISerializableEnvironmentVariableCollections;
reconnectionProperties?: IReconnectionProperties;
type?: TerminalType;
waitOnExit?: WaitOnExitValue;
hideFromUser?: boolean;
isFeatureTerminal?: boolean;
shellIntegrationNonce: string;
};

@meganrogge
Copy link
Contributor Author

meganrogge commented Jan 7, 2025

I see that this doesn't get hit for reconnected terminals

public $shellIntegrationChange(instanceId: number): void {

so, the terminal.shellIntegration object does not get set

terminal.shellIntegration = shellIntegration.value;

@meganrogge
Copy link
Contributor Author

Even with that, the cwd is still undefined until I press enter, so something else needs to be tweaked

@Tyriar Tyriar closed this as completed in 2e1cc38 Jan 8, 2025
@vs-code-engineering vs-code-engineering bot 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 Jan 8, 2025
@meganrogge meganrogge reopened this Jan 29, 2025
@meganrogge
Copy link
Contributor Author

still an issue #239027 (comment)

@vs-code-engineering vs-code-engineering bot removed the insiders-released Patch has been released in VS Code Insiders label Jan 29, 2025
@vs-code-engineering vs-code-engineering bot 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 Jan 30, 2025
@amunger amunger added the verified Verification succeeded label Jan 31, 2025
@amunger
Copy link
Contributor

amunger commented Jan 31, 2025

I don't see that log when recovering a terminal session if that's all there is to verify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders terminal-persistence Relating to process reconnection or process revive verified Verification succeeded
Projects
None yet
3 participants