src/vs/workbench/contrib/terminal/browser/terminalActions.ts/getActiveInstance
function getActiveInstance(accessor: ServicesAccessor, resource: unknown): ITerminalInstance | undefined {
	const terminalService = accessor.get(ITerminalService);
	const castedResource = URI.isUri(resource) ? resource : undefined;
	const instance = terminalService.getInstanceFromResource(castedResource) || terminalService.activeInstance;
	return instance;
}