diff --git a/frontend/src/App.vue b/frontend/src/App.vue index cf6b639d6..c068a20e0 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -17,7 +17,14 @@ its track and the footer ended up overlapping the last row at 390px (UX audit F14). -->
- + +
@@ -79,24 +86,44 @@ function handleAuthModalClose() { systemStore.setAuthRequired(false) } +// Re-prime everything that only loads at mount. The key covers +// the routed view, but these surfaces live outside it and would otherwise keep +// their failed state until a full page reload (#1065). +async function reloadAfterAuth() { + systemStore.connectEventSource() + serversStore.fetchServers() + systemStore.fetchInfo() // TopHeader version / update state + systemStore.fetchRouting() // TopHeader routing chip + // Server-edition role-based nav. The router guard does not run for a + // key-driven remount, so re-check here. + await authStore.checkAuth() +} + function handleAuthModalAuthenticated() { authModal.show = false authModal.lastError = '' - systemStore.setAuthRequired(false) + // markAuthRecovered, not setAuthRequired(false): this path validated the key, + // so it is safe to invalidate every view that failed while auth was broken. + systemStore.markAuthRecovered() - // Refresh data now that we're authenticated - systemStore.connectEventSource() - serversStore.fetchServers() + void reloadAfterAuth() } -function handleAuthModalRefresh() { +function handleAuthModalRefresh(verified: boolean) { + if (!verified) { + // The reloaded key did not authenticate. Leave the modal and the + // auth-required flag in place rather than remounting every view onto a + // key that is still 401. + return + } + authModal.show = false authModal.lastError = '' - systemStore.setAuthRequired(false) + // The modal verified the reloaded key, so this is a real recovery and the + // views holding stale auth errors must be invalidated too (#1065). + systemStore.markAuthRecovered() - // Reconnect with potentially new API key - systemStore.connectEventSource() - serversStore.fetchServers() + void reloadAfterAuth() } // Handle API authentication errors diff --git a/frontend/src/components/ActivityWidget.vue b/frontend/src/components/ActivityWidget.vue index 3b08314f2..c0b0926ab 100644 --- a/frontend/src/components/ActivityWidget.vue +++ b/frontend/src/components/ActivityWidget.vue @@ -105,6 +105,7 @@ import api from '@/services/api' import type { ActivityRecord, ActivitySummaryResponse } from '@/types/api' import { formatPreflightSummary, + getTypeIcon, isChildCall, isPreflightActivity, statusPresentation, @@ -161,18 +162,6 @@ const formatRelativeTime = (timestamp: string): string => { return `${Math.floor(diff / 86400000)}d ago` } -const getTypeIcon = (type: string): string => { - const typeIcons: Record = { - 'tool_call': 'πŸ”§', - 'policy_decision': 'πŸ›‘οΈ', - 'quarantine_change': '⚠️', - 'server_change': 'πŸ”„', - // Spec 098: required-tools preflight - 'preflight': 'πŸ›«' - } - return typeIcons[type] || 'πŸ“‹' -} - // Lifecycle onMounted(() => { loadData() diff --git a/frontend/src/components/AuthErrorModal.vue b/frontend/src/components/AuthErrorModal.vue index 8106efed6..7bf0704b2 100644 --- a/frontend/src/components/AuthErrorModal.vue +++ b/frontend/src/components/AuthErrorModal.vue @@ -109,7 +109,9 @@ interface Props { interface Emits { (e: 'close'): void (e: 'authenticated'): void - (e: 'refresh'): void + // `verified` says whether the reloaded key actually authenticated. App.vue + // only invalidates views when it did (#1065). + (e: 'refresh', verified: boolean): void } const props = withDefaults(defineProps(), { @@ -175,10 +177,27 @@ async function handleSetAPIKey() { } } -function handleRefresh() { - // Reinitialize API key from URL/localStorage - api.reinitializeAPIKey() - emit('refresh') +async function handleRefresh() { + // Reinitialize API key from URL/localStorage, then VERIFY it before telling + // the app auth is repaired. Without the verification this path could only + // assert recovery, so it could not safely invalidate the views holding stale + // auth errors -- and #1065's stale red panel survived on this path. + isValidating.value = true + inputError.value = '' + try { + api.reinitializeAPIKey() + const isValid = await api.validateAPIKey() + emit('refresh', isValid) + if (!isValid) { + inputError.value = 'No valid API key found β€” enter one above' + } + } catch (error) { + console.error('API key refresh error:', error) + inputError.value = error instanceof Error ? error.message : 'Refresh failed' + emit('refresh', false) + } finally { + isValidating.value = false + } } function handleClose() { diff --git a/frontend/src/components/ServerCard.vue b/frontend/src/components/ServerCard.vue index 9f7336914..7c49ea071 100644 --- a/frontend/src/components/ServerCard.vue +++ b/frontend/src/components/ServerCard.vue @@ -85,7 +85,14 @@ -
+ +
-
- +
+ - Quarantined β€” needs security review +
+
Quarantined β€” needs security review
+
{{ quarantineScanNote }}
+
{ } }) +// #1065: the subordinate half of the quarantine banner. Same reasoning as the +// #938 held-tools downgrade above, one level up -- a reassuring statement must +// never sit as a peer of a warning one. While quarantined the standalone badge +// is suppressed and its verdict is restated here as a clause of the quarantine +// headline: the verdict informs the review, it does not settle it. Returns '' +// when there is nothing worth saying, keeping the banner a one-liner. +const quarantineScanNote = computed(() => { + const scan = props.server.security_scan + const status = scan?.status + if (!scan || !status || status === 'not_scanned') return '' + switch (status) { + case 'scanning': + return 'Security scan in progress…' + case 'failed': + // A failed scan is an INCOMPLETE scan, never a threat verdict -- mirrors + // the scan-failed precaution branch in utils/quarantineBanner.ts. + return 'Last scan could not complete β€” still needs review' + case 'clean': + return 'Last scan: clean β€” still needs review' + case 'warnings': { + const n = scan.finding_counts?.warning ?? 0 + return `Last scan: ${n} warning${n !== 1 ? 's' : ''} β€” needs review` + } + case 'dangerous': + return 'Last scan: dangerous findings β€” needs review' + default: + return '' + } +}) + // Determine if error message should be shown (FR-018, FR-019) // Suppress verbose last_error when health.action already conveys the issue const shouldShowError = computed(() => { diff --git a/frontend/src/components/SidebarNav.vue b/frontend/src/components/SidebarNav.vue index 9becef7f4..11ee99d73 100644 --- a/frontend/src/components/SidebarNav.vue +++ b/frontend/src/components/SidebarNav.vue @@ -475,7 +475,7 @@