function updateStream()

in ui-modules/app-inspector/app/components/stream/stream.directive.js [112:148]


        function updateStream() {
            activityApi.activityStream($scope.activityId, $scope.streamType).then((response)=> {

                // 1. Try to identify CLI XML output.
                const CLI_XML_HEADER_SIZE = 100; // estimated headers size in WinRM that can contain indication of CLI XML output
                if ($scope.cliXmlVerificationRequired && typeof response.data === 'string' && response.data.length >= CLI_XML_HEADER_SIZE) {
                    let header = response.data.slice(0, CLI_XML_HEADER_SIZE);
                    if (header.includes('#< CLIXML') || header.includes('xmlns="http://schemas.microsoft.com/powershell')) {
                        $scope.cliXmlIdentified = true;
                    }
                    $scope.cliXmlVerificationRequired = false; // perform verification once, if conditions match
                }

                // 2. Update the stream data holder in this directive.
                $scope.stream = typeof response.data === 'object' ? JSON.stringify(response.data, null, 2) : response.data;

                // Check if to drop filters, because of `ng-repeat` performance limits.
                if ($scope.cliXmlIdentified && !$scope.cliXml && !$scope.filteredStream.length && $scope.stream.length > 99999) {
                    $scope.noFilters = true;
                    brSnackbar.create('Stream content is too big, showing output without filters.');
                }

                // 3. Format the content where relevant.
                updateFormattedContent();

            }).catch((error)=> {
                if (error.data) {
                    $scope.error = error.data.message;
                }
            }).finally(() => {
                if ($scope.tail) {
                    $scope.$applyAsync(() => {
                        autoScrollableElement.forEach(item => item.scrollTop = item.scrollHeight);
                    });
                }
            })
        }