Change:
Part of We want to support other common shell integration sequences as fallbacks to the VS Code specific one ()
can you add verification steps for this?
Disable shell integration Open pwsh 7+ Run the following: It should change the terminal tab's description to .

Discussion:
import { ISerializedCommandDetectionCapability } from 'vs/platform/terminal/common/terminalProcess'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { Emitter } from 'vs/base/common/event'; <ins> import { URI } from 'vs/base/common/uri'; </ins> /** * Shell integration is a feature that enhances the terminal's understanding of what's happening

/** * Sequences pioneered by iTerm. */ <del> ITerm = 1337 </del> <ins> ITerm = 1337, SetCwd = 7, SetWindowsFriendlyCwd = 9 </ins> } /**

/** * Sets a mark/point-of-interest in the buffer. `OSC 1337 ; SetMark` */ <del> SetMark = 'SetMark' </del> <ins> SetMark = 'SetMark', /** * Reports current working directory (CWD). `OSC 1337 ; CurrentDir=<Cwd> ST` */ CurrentDir = 'CurrentDir' </ins> } /**

this._commonProtocolDisposables.push( xterm.parser.registerOscHandler(ShellIntegrationOscPs.FinalTerm, data => this._handleFinalTermSequence(data)) ); <ins> this._register(xterm.parser.registerOscHandler(ShellIntegrationOscPs.SetCwd, data => this._doHandleSetCwd(data))); this._register(xterm.parser.registerOscHandler(ShellIntegrationOscPs.SetWindowsFriendlyCwd, data => this._doHandleSetWindowsFriendlyCwd(data))); </ins> this._ensureCapabilitiesOrAddFailureTelemetry(); }

return true; } case VSCodeOscPt.Property: { <del> const [key, rawValue] = args[0].split('='); if (rawValue === undefined) { </del> <ins> const { key, value } = this._parseKeyValueAssignment(args[0]); if (value === undefined) { </ins> return true; } <del> const value = this._deserializeMessage(rawValue); </del> switch (key) { case 'Cwd': { <del> // TODO: Ideally we would also support the following to supplement our own: //       - OSC 1337 ; CurrentDir=<Cwd> ST (iTerm) //       - OSC 7 ; scheme://cwd ST        (Unknown origin) //       - OSC 9 ; 9 ; <cwd> ST           (cmder) this._createOrGetCwdDetection().updateCwd(value); const commandDetection = this.capabilities.get(TerminalCapability.CommandDetection); commandDetection?.setCwd(value); </del> <ins> this._updateCwd(value); </ins> return true; } case 'IsWindows': {

return false; } <ins> private _updateCwd(value: string) { this._createOrGetCwdDetection().updateCwd(value); const commandDetection = this.capabilities.get(TerminalCapability.CommandDetection); commandDetection?.setCwd(value); } </ins> private _doHandleITermSequence(data: string): boolean { if (!this._terminal) { return false;

case ITermOscPt.SetMark: { this._createOrGetCommandDetection(this._terminal).handleGenericCommand({ genericMarkProperties: { disableCommandStorage: true } }); } <ins> default: { // Checking for known `<key>=<value>` pairs. const { key, value } = this._parseKeyValueAssignment(command); if (value === undefined) { // No '=' was found, so it's not a property assignment. return true; } switch (key) { case ITermOscPt.CurrentDir: // Encountered: `OSC 1337 ; CurrentDir=<Cwd> ST` this._updateCwd(value); return true; } } </ins> } <ins> // Unrecognized sequence return false; } private _doHandleSetWindowsFriendlyCwd(data: string): boolean { if (!this._terminal) { return false; } const [command, ...args] = data.split(';'); switch (command) { case '9': // Encountered `OSC 9 ; 9 ; <cwd> ST` if (args.length) { this._updateCwd(args[0]); } return true; } // Unrecognized sequence return false; } /** * Handles the sequence: `OSC 7 ; scheme://cwd ST` */ private _doHandleSetCwd(data: string): boolean { if (!this._terminal) { return false; } const [command] = data.split(';'); // We need to manually make sure the given URI is not merely `file://` because The `URI.parse` handles it // exactly as it handles `file:///` (which is a valid URI for us here). if (command.startsWith('file://') && command.length > 7) { const uri = URI.parse(command); if (uri.path && uri.path.length > 0) { this._updateCwd(uri.path); return true; } } </ins> // Unrecognized sequence return false; }

} return result; } <ins> private _parseKeyValueAssignment(message: string): { key: string; value: string | undefined } { const [key, ...rawValues] = message.split('='); if (!rawValues.length) { return { key, value: undefined }; // No '=' was found. } const rawValue = rawValues.join('='); const value = this._deserializeMessage(rawValue); return { key, value }; } </ins> }

*--------------------------------------------------------------------------------------------*/ import { Terminal } from 'xterm'; <del> import { strictEqual } from 'assert'; </del> <ins> import { strictEqual, deepStrictEqual } from 'assert'; </ins> import { timeout } from 'vs/base/common/async'; import * as sinon from 'sinon'; import { ShellIntegrationAddon } from 'vs/platform/terminal/common/xterm/shellIntegrationAddon';

await writeP(xterm, 'x1b]633;P;Cwd=/foox07'); mock.verify(); }); <ins> suite('detect `OSC 7; scheme://cwd ST`', async () => { suite('should extract CWD from URL format', async () => { test('should accept well-formatted URLs', async () => { type TestCase = [title: string, input: string, expected: string]; const cases: TestCase[] = [ // Different hostname values: ['empty hostname, pointing root', 'file:///', '/'], ['empty hostname', 'file:///test-root/local', '/test-root/local'], ['non-empty hostname', 'file://some-hostname/test-root/local', '/test-root/local'], // URL-encoded chars: ['URL-encoded value (1)', 'file:///test-root/%6c%6f%63%61%6c', '/test-root/local'], ['URL-encoded value (2)', 'file:///test-root/local%22', '/test-root/local"'], ['URL-encoded value (3)', 'file:///test-root/local"', '/test-root/local"'], ]; for (const x of cases) { const [title, input, expected] = x; const mock = shellIntegrationAddon.getCwdDectionMock(); mock.expects('updateCwd').once().withExactArgs(expected).named(title); await writeP(xterm, `x1b]7;${input}x07`); mock.verify(); } }); test('should ignore ill-formatted URLs', async () => { type TestCase = [title: string, input: string]; const cases: TestCase[] = [ // Different hostname values: ['no hostname, pointing root', 'file://'], // Non-`file` scheme values: ['no scheme (1)', '/test-root'], ['no scheme (2)', '//test-root'], ['no scheme (3)', '///test-root'], ['no scheme (4)', ':///test-root'], ['http', 'http:///test-root'], ['ftp', 'ftp:///test-root'], ['ssh', 'ssh:///test-root'], ]; for (const x of cases) { const [title, input] = x; const mock = shellIntegrationAddon.getCwdDectionMock(); mock.expects('updateCwd').never().named(title); await writeP(xterm, `x1b]7;${input}x07`); mock.verify(); } }); }); }); </ins> }); suite('command tracking', async () => {