src/vs/workbench/contrib/terminal/electron-sandbox/terminalRemote.ts/registerRemoteContributions
export function registerRemoteContributions() {
	registerAction2(class extends Action2 {
		constructor() {
			super({
				id: TerminalCommandId.NewLocal,
				title: { value: localize('workbench.action.terminal.newLocal', "Create New Integrated Terminal (Local)"), original: 'Create New Integrated Terminal (Local)' },
				f1: true
			});
		}
		async run(accessor: ServicesAccessor) {
			const historyService = accessor.get(IHistoryService);
			const remoteAuthorityResolverService = accessor.get(IRemoteAuthorityResolverService);
			const nativeEnvironmentService = accessor.get(INativeEnvironmentService);
			const terminalService = accessor.get(ITerminalService);
			const terminalGroupService = accessor.get(ITerminalGroupService);
			let cwd: URI | undefined;
			try {
				const activeWorkspaceRootUri = historyService.getLastActiveWorkspaceRoot(Schemas.vscodeRemote);
				if (activeWorkspaceRootUri) {
					const canonicalUri = await remoteAuthorityResolverService.getCanonicalURI(activeWorkspaceRootUri);
					if (canonicalUri.scheme === Schemas.file) {
						cwd = canonicalUri;
					}
				}
			} catch { }
			if (!cwd) {
				cwd = nativeEnvironmentService.userHome;
			}
			const instance = await terminalService.createTerminal({ cwd });
			if (!instance) {
				return Promise.resolve(undefined);
			}

			terminalService.setActiveInstance(instance);
			return terminalGroupService.showPanel(true);
		}
	});
}