Skip to content
Closed
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
</button>
</div>
</h3>
<div v-if="smells.length > 0" class="section-content">
<EmptyState
v-if="error"
icon="exclamation-triangle"
:message="$t('analytics.codebase.sectionLoadFailed', { error })"
/>
<div v-else-if="smells.length > 0" class="section-content">
<!-- Summary Cards by Severity -->
<div class="summary-cards">
<div class="summary-card total">
Expand Down Expand Up @@ -147,6 +152,8 @@ interface CodeHealthScore {
interface Props {
smells: CodeSmell[]
codeHealthScore: CodeHealthScore | null
/** The smells are derived from the problems load; its failure is not "no smells". */
error?: string
}

const props = defineProps<Props>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@

<!-- Issue #1579: Problems Report extracted to ProblemsReportSection -->
<ProblemsReportSection
:problems="problemsReport"
:problems="problemsReport" :error="problemsError"
@export="(fmt: string) => exportSection('problems', fmt as 'md' | 'json')"
/>

<!-- Code Intelligence: Anti-Pattern / Code Smells Report (#1469, #184) -->
<CodeSmellsSection
:smells="codeSmellsForPanel"
:smells="codeSmellsForPanel" :error="problemsError"
:code-health-score="codeHealthScore"
@export="(fmt: string) => exportSection('code-smells', fmt as 'md' | 'json')"
/>
Expand Down Expand Up @@ -189,14 +189,13 @@

<!-- Function Declarations (#1469, #184) -->
<DeclarationsSection
:declarations="declarationsForPanel"
:loading="loadingProgress.declarations"
:declarations="declarationsForPanel" :error="declarationsError" :loading="loadingProgress.declarations"
@export="(fmt: string) => exportSection('declarations', fmt as 'md' | 'json')"
/>

<!-- Hardcoded Values (#5277: wire orphan data flow) -->
<HardcodesSection
:hardcodes="hardcodeAnalysis"
:hardcodes="hardcodeAnalysis" :error="hardcodesError"
:loading="loadingProgress.hardcodes"
@export="(fmt: string) => exportSection('hardcodes', fmt as 'md' | 'json')"
/>
Expand Down Expand Up @@ -579,6 +578,7 @@ const {
duplicateScanState,
declarationAnalysis,
hardcodeAnalysis,
problemsError, declarationsError, hardcodesError,
loadingProgress,
chartData,
chartDataLoading,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
<Icon name="spinner" :spin="true" />
<span>{{ $t('analytics.codebase.actions.loading') }}</span>
</div>
<EmptyState
v-else-if="error"
icon="exclamation-triangle"
:message="$t('analytics.codebase.sectionLoadFailed', { error })"
/>
<div v-else-if="declarations && declarations.length > 0" class="section-content">
<!-- Type Summary Cards -->
<div class="summary-cards">
Expand Down Expand Up @@ -122,6 +127,8 @@ interface Props {
declarations: Declaration[]
/** #5368: render a spinner during the scan instead of empty-state. */
loading?: boolean
/** A failed load is not "no declarations found" -- show it as a failure. */
error?: string
}

const props = defineProps<Props>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
<Icon name="spinner" :spin="true" />
<span>{{ $t('analytics.codebase.actions.loading') }}</span>
</div>
<EmptyState
v-else-if="error"
icon="exclamation-triangle"
:message="$t('analytics.codebase.sectionLoadFailed', { error })"
/>
<div v-else-if="hardcodes && hardcodes.length > 0" class="section-content">
<!-- Summary Cards -->
<div class="summary-cards">
Expand Down Expand Up @@ -135,6 +140,8 @@ interface Props {
* message so users don't misread a running scan as "no results".
*/
loading?: boolean
/** A failed load is not "no hardcoded values detected" -- show it as a failure. */
error?: string
}

const props = defineProps<Props>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
</button>
</div>
</h3>
<div v-if="problems && problems.length > 0" class="section-content">
<EmptyState
v-if="error"
icon="exclamation-triangle"
:message="$t('analytics.codebase.sectionLoadFailed', { error })"
/>
<div v-else-if="problems && problems.length > 0" class="section-content">
<!-- Severity Summary Cards -->
<div class="summary-cards">
<div class="summary-card total">
Expand Down Expand Up @@ -141,6 +146,8 @@ interface Problem {

interface Props {
problems: Problem[]
/** A failed load is not "no problems detected" -- show it as a failure. */
error?: string
}

const props = defineProps<Props>()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright 2025-2026 mrveiss
// SPDX-License-Identifier: Apache-2.0
// AutoBot - AI-Powered Automation Platform
// Author: mrveiss
/**
* #17651: a section whose load FAILED must say so. Before, Problems, Code
* Smells, Declarations and Hardcodes had no error branch, so a 4xx/5xx
* rendered as "No problems detected" (a success-styled empty state).
*/

import { describe, it, expect } from 'vitest'
import { mount } from '@vue/test-utils'
import { createI18n } from 'vue-i18n'
import en from '@/i18n/locales/en.json'
import ProblemsReportSection from '../ProblemsReportSection.vue'
import CodeSmellsSection from '../CodeSmellsSection.vue'
import DeclarationsSection from '../DeclarationsSection.vue'
import HardcodesSection from '../HardcodesSection.vue'

const i18n = createI18n({ legacy: false, locale: 'en', messages: { en } })
const EmptyState = {
props: ['message'],
template: '<div class="empty-state">{{ message }}</div>',
}
const mountIt = (comp: object, props: Record<string, unknown>) =>
mount(comp as never, { props, global: { plugins: [i18n], stubs: { EmptyState } } })

const FAILED = 'could not be loaded'
const cases: Array<[string, object, Record<string, unknown>, string]> = [
['Problems', ProblemsReportSection, { problems: [] }, 'No problems detected'],
['Code smells', CodeSmellsSection, { smells: [], codeHealthScore: null }, 'No code smells detected'],
['Declarations', DeclarationsSection, { declarations: [] }, 'No declarations found'],
['Hardcodes', HardcodesSection, { hardcodes: [] }, 'No hardcoded values detected'],
]

describe('analytics sections report a failed load (#17651)', () => {
it.each(cases)('%s: error shows the failure, not the empty message', (_n, comp, props, emptyMsg) => {
const w = mountIt(comp, { ...props, error: 'Endpoint returned 500' })
expect(w.text()).toContain(FAILED)
expect(w.text()).toContain('returned 500')
expect(w.text()).not.toContain(emptyMsg)
})

it.each(cases)('%s: no error and no rows is still the honest empty state', (_n, comp, props, emptyMsg) => {
const w = mountIt(comp, props)
expect(w.text()).toContain(emptyMsg)
expect(w.text()).not.toContain(FAILED)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,7 @@ export function useAnalyticsDataFetchers(deps: UseAnalyticsDataFetchersDeps) {
const callGraphSummary = ref<Record<string, unknown> | null>(null)
const callGraphOrphaned = ref<OrphanedFunction[]>([])

const loadingProgress = reactive({
declarations: false,
duplicates: false,
hardcodes: false,
problems: false,
})
const loadingProgress = reactive({ declarations: false, duplicates: false, hardcodes: false, problems: false })

const showAllProblems = ref(false)
const showAllDeclarations = ref(false)
Expand Down Expand Up @@ -652,6 +647,8 @@ export function useAnalyticsDataFetchers(deps: UseAnalyticsDataFetchersDeps) {
duplicateScanState,
declarationAnalysis,
hardcodeAnalysis,
// A failed load must not render as an empty ("none found") section.
problemsError: problemsEndpoint.error, declarationsError: declarationsSilent.error, hardcodesError: hardcodesSilent.error,
chartData: chartEndpoint.data,
chartDataLoading: chartEndpoint.loading,
chartDataError: chartEndpoint.error,
Expand Down
1 change: 1 addition & 0 deletions autobot-frontend/src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,7 @@
"dashboard": "Dashboard",
"codebase": {
"title": "Real-time Codebase Analytics",
"sectionLoadFailed": "This section could not be loaded, so this is not a result: {error}",
"scanRunner": {
"title": "Scan Progress"
},
Expand Down
Loading