Skip to content

Commit 1e46a82

Browse files
committed
feat(web-ui): consume debounced scan.settled event; drop per-scanner lifecycle
Related #786 Spec 077 US4 (MCP-2207): forward the new security.scan_settled SSE event from the system store as a mcpproxy:scan-settled window event, and have useSecurityScannerStatus refresh its cached scan totals off that single settled signal instead of tracking per-scanner lifecycle events. ## Changes - stores/system.ts: add a security.scan_settled SSE listener that dispatches mcpproxy:scan-settled. - composables/useSecurityScannerStatus.ts: register a module-scope mcpproxy:scan-settled listener that triggers a status refresh. ## Testing - frontend vue-tsc --noEmit clean; vite build succeeds. Related: Spec 077 (specs/077-scanner-simplification)
1 parent 9491dac commit 1e46a82

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

frontend/src/composables/useSecurityScannerStatus.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ const totalFindings = ref<number>(0)
1717
const totalScans = ref<number>(0)
1818
let inflight: Promise<void> | null = null
1919

20+
// Spec 077 US4 (MCP-2207): the backend now collapses the per-scanner
21+
// scan_started/progress/completed/failed storm into a single debounced
22+
// `security.scan_settled` event per server per scan (forwarded by the system
23+
// store as `mcpproxy:scan-settled`). We consume that one settled signal to
24+
// refresh the cached scan totals, instead of tracking per-scanner lifecycle
25+
// events. Registered once at module scope so all consumers share it.
26+
if (typeof window !== 'undefined') {
27+
window.addEventListener('mcpproxy:scan-settled', () => {
28+
void refreshSecurityScannerStatus()
29+
})
30+
}
31+
2032
export async function refreshSecurityScannerStatus(): Promise<void> {
2133
if (inflight) {
2234
return inflight

frontend/src/stores/system.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,19 @@ export const useSystemStore = defineStore('system', () => {
185185
}
186186
})
187187

188+
// Spec 077 US4 (MCP-2207): a single debounced settled event per server per
189+
// scan replaces the per-scanner scan_started/progress/completed/failed
190+
// storm. Forward it so scan-status consumers can refresh once per scan.
191+
es.addEventListener('security.scan_settled', (event) => {
192+
try {
193+
const data = JSON.parse(event.data)
194+
const payload = data.payload || data
195+
window.dispatchEvent(new CustomEvent('mcpproxy:scan-settled', { detail: payload }))
196+
} catch (error) {
197+
console.error('Failed to parse SSE security.scan_settled event:', error)
198+
}
199+
})
200+
188201
// Listen for activity events (tool calls, policy decisions, etc.)
189202
es.addEventListener('activity.tool_call.started', (event) => {
190203
try {

0 commit comments

Comments
 (0)