Run AI classification in background with SignalR notifications
Move the classify-uncategorized endpoint from synchronous to async. The controller now queues a ClassificationJob to an unbounded channel and returns 202 Accepted. A new BackgroundService processes jobs and pushes results (or errors) to the user via SignalR. The frontend listens for the AiClassificationComplete event and surfaces it in the notification system. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { ref, computed } from 'vue'
|
||||
import { HubConnectionBuilder, HubConnection, LogLevel } from '@microsoft/signalr'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import type { AppNotification, FileImportNotification, BankSyncNotification } from '@/types'
|
||||
import type { AppNotification, FileImportNotification, BankSyncNotification, AiClassificationNotification } from '@/types'
|
||||
|
||||
const notifications = ref<AppNotification[]>([])
|
||||
const isConnected = ref(false)
|
||||
@@ -42,6 +42,16 @@ function connect() {
|
||||
})
|
||||
})
|
||||
|
||||
connection.on('AiClassificationComplete', (data: AiClassificationNotification) => {
|
||||
notifications.value.unshift({
|
||||
id: crypto.randomUUID(),
|
||||
type: 'AiClassificationComplete',
|
||||
data,
|
||||
timestamp: new Date().toISOString(),
|
||||
read: false
|
||||
})
|
||||
})
|
||||
|
||||
connection.onclose(() => {
|
||||
isConnected.value = false
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user