mirror of
https://github.com/lukaszraczylo/claude-mnemonic.git
synced 2026-06-13 02:06:24 +00:00
Display only current project statistics in statusline. (#3)
This commit is contained in:
+3
-1
@@ -8,9 +8,9 @@ import Sidebar from '@/components/Sidebar.vue'
|
||||
|
||||
// Composables
|
||||
const { isConnected, isReconnecting, reconnectCountdown, isProcessing, queueDepth } = useSSE()
|
||||
const { stats } = useStats()
|
||||
const { updateInfo, updateStatus, isUpdating, applyUpdate } = useUpdate()
|
||||
const { health } = useHealth()
|
||||
// Initialize useTimeline first to get currentProject ref
|
||||
const {
|
||||
filteredItems,
|
||||
loading,
|
||||
@@ -27,6 +27,8 @@ const {
|
||||
setTypeFilter,
|
||||
setConceptFilter
|
||||
} = useTimeline()
|
||||
// Pass currentProject ref to useStats for project-specific retrieval stats
|
||||
const { stats } = useStats(currentProject)
|
||||
|
||||
// Note: Timeline refresh is handled by useTimeline's SSE watcher
|
||||
</script>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ref, onMounted, onUnmounted, watch } from 'vue'
|
||||
import { ref, onMounted, onUnmounted, watch, type Ref } from 'vue'
|
||||
import type { Stats } from '@/types'
|
||||
import { fetchStats } from '@/utils/api'
|
||||
import { useSSE } from './useSSE'
|
||||
@@ -6,7 +6,7 @@ import { useSSE } from './useSSE'
|
||||
// Fallback poll interval when SSE is disconnected
|
||||
const FALLBACK_POLL_INTERVAL = 10000 // 10 seconds
|
||||
|
||||
export function useStats() {
|
||||
export function useStats(projectRef?: Ref<string | null>) {
|
||||
const stats = ref<Stats | null>(null)
|
||||
const loading = ref(false)
|
||||
const error = ref<string | null>(null)
|
||||
@@ -21,7 +21,8 @@ export function useStats() {
|
||||
error.value = null
|
||||
|
||||
try {
|
||||
stats.value = await fetchStats()
|
||||
const project = projectRef?.value ?? null
|
||||
stats.value = await fetchStats(project)
|
||||
} catch (err) {
|
||||
error.value = err instanceof Error ? err.message : 'Failed to fetch stats'
|
||||
console.error('[Stats] Error:', err)
|
||||
@@ -54,6 +55,14 @@ export function useStats() {
|
||||
}
|
||||
})
|
||||
|
||||
// Watch for project filter changes
|
||||
if (projectRef) {
|
||||
watch(projectRef, () => {
|
||||
console.log('[Stats] Project filter changed, refreshing stats')
|
||||
refresh()
|
||||
})
|
||||
}
|
||||
|
||||
// Switch between SSE-driven and fallback polling based on connection status
|
||||
watch(isConnected, (connected) => {
|
||||
if (connected) {
|
||||
|
||||
+5
-2
@@ -107,8 +107,11 @@ export async function fetchSummaries(limit: number = 50, project?: string, signa
|
||||
return fetchWithRetry<SessionSummary[]>(`${API_BASE}/summaries?${params}`, { signal })
|
||||
}
|
||||
|
||||
export async function fetchStats(): Promise<Stats> {
|
||||
return fetchWithRetry<Stats>(`${API_BASE}/stats`)
|
||||
export async function fetchStats(project?: string | null): Promise<Stats> {
|
||||
const params = new URLSearchParams()
|
||||
if (project) params.append('project', project)
|
||||
const query = params.toString()
|
||||
return fetchWithRetry<Stats>(`${API_BASE}/stats${query ? '?' + query : ''}`)
|
||||
}
|
||||
|
||||
export async function fetchProjects(): Promise<string[]> {
|
||||
|
||||
Reference in New Issue
Block a user