|
| 1 | +<template> |
| 2 | + <v-card v-if="sessionController" class="session-debug ma-2" elevation="2"> |
| 3 | + <v-card-title class="text-caption bg-grey-darken-3"> |
| 4 | + Session Controller Debug |
| 5 | + <v-spacer></v-spacer> |
| 6 | + <v-icon size="small">mdi-bug</v-icon> |
| 7 | + </v-card-title> |
| 8 | + |
| 9 | + <v-card-text class="pa-2"> |
| 10 | + <v-row dense> |
| 11 | + <!-- Review Queue --> |
| 12 | + <v-col cols="12" md="4"> |
| 13 | + <div class="debug-section"> |
| 14 | + <div class="debug-header"> |
| 15 | + <v-icon size="x-small" class="mr-1">mdi-calendar-check</v-icon> |
| 16 | + <strong>Review Queue</strong> |
| 17 | + </div> |
| 18 | + <div class="debug-stats"> |
| 19 | + <span class="text-caption">Length: {{ debugInfo.reviewQueue.length }}</span> |
| 20 | + <span class="text-caption ml-2">Dequeued: {{ debugInfo.reviewQueue.dequeueCount }}</span> |
| 21 | + </div> |
| 22 | + <div v-if="debugInfo.reviewQueue.items.length > 0" class="debug-items"> |
| 23 | + <div |
| 24 | + v-for="(item, idx) in debugInfo.reviewQueue.items.slice(0, 5)" |
| 25 | + :key="idx" |
| 26 | + class="debug-item" |
| 27 | + > |
| 28 | + <span class="text-caption">{{ idx }}: {{ item.courseID }}::{{ item.cardID }}</span> |
| 29 | + <span class="text-caption text-grey ml-1">({{ item.status }})</span> |
| 30 | + </div> |
| 31 | + <div v-if="debugInfo.reviewQueue.items.length > 5" class="text-caption text-grey"> |
| 32 | + ... +{{ debugInfo.reviewQueue.items.length - 5 }} more |
| 33 | + </div> |
| 34 | + </div> |
| 35 | + <div v-else class="text-caption text-grey"> |
| 36 | + (empty) |
| 37 | + </div> |
| 38 | + </div> |
| 39 | + </v-col> |
| 40 | + |
| 41 | + <!-- New Cards Queue --> |
| 42 | + <v-col cols="12" md="4"> |
| 43 | + <div class="debug-section"> |
| 44 | + <div class="debug-header"> |
| 45 | + <v-icon size="x-small" class="mr-1">mdi-file-document-plus</v-icon> |
| 46 | + <strong>New Cards Queue</strong> |
| 47 | + </div> |
| 48 | + <div class="debug-stats"> |
| 49 | + <span class="text-caption">Length: {{ debugInfo.newQueue.length }}</span> |
| 50 | + <span class="text-caption ml-2">Dequeued: {{ debugInfo.newQueue.dequeueCount }}</span> |
| 51 | + </div> |
| 52 | + <div v-if="debugInfo.newQueue.items.length > 0" class="debug-items"> |
| 53 | + <div |
| 54 | + v-for="(item, idx) in debugInfo.newQueue.items.slice(0, 5)" |
| 55 | + :key="idx" |
| 56 | + class="debug-item" |
| 57 | + > |
| 58 | + <span class="text-caption">{{ idx }}: {{ item.courseID }}::{{ item.cardID }}</span> |
| 59 | + <span class="text-caption text-grey ml-1">({{ item.status }})</span> |
| 60 | + </div> |
| 61 | + <div v-if="debugInfo.newQueue.items.length > 5" class="text-caption text-grey"> |
| 62 | + ... +{{ debugInfo.newQueue.items.length - 5 }} more |
| 63 | + </div> |
| 64 | + </div> |
| 65 | + <div v-else class="text-caption text-grey"> |
| 66 | + (empty) |
| 67 | + </div> |
| 68 | + </div> |
| 69 | + </v-col> |
| 70 | + |
| 71 | + <!-- Failed Cards Queue --> |
| 72 | + <v-col cols="12" md="4"> |
| 73 | + <div class="debug-section"> |
| 74 | + <div class="debug-header"> |
| 75 | + <v-icon size="x-small" class="mr-1">mdi-alert-circle</v-icon> |
| 76 | + <strong>Failed Cards Queue</strong> |
| 77 | + </div> |
| 78 | + <div class="debug-stats"> |
| 79 | + <span class="text-caption">Length: {{ debugInfo.failedQueue.length }}</span> |
| 80 | + <span class="text-caption ml-2">Dequeued: {{ debugInfo.failedQueue.dequeueCount }}</span> |
| 81 | + </div> |
| 82 | + <div v-if="debugInfo.failedQueue.items.length > 0" class="debug-items"> |
| 83 | + <div |
| 84 | + v-for="(item, idx) in debugInfo.failedQueue.items.slice(0, 5)" |
| 85 | + :key="idx" |
| 86 | + class="debug-item" |
| 87 | + > |
| 88 | + <span class="text-caption">{{ idx }}: {{ item.courseID }}::{{ item.cardID }}</span> |
| 89 | + <span class="text-caption text-grey ml-1">({{ item.status }})</span> |
| 90 | + </div> |
| 91 | + <div v-if="debugInfo.failedQueue.items.length > 5" class="text-caption text-grey"> |
| 92 | + ... +{{ debugInfo.failedQueue.items.length - 5 }} more |
| 93 | + </div> |
| 94 | + </div> |
| 95 | + <div v-else class="text-caption text-grey"> |
| 96 | + (empty) |
| 97 | + </div> |
| 98 | + </div> |
| 99 | + </v-col> |
| 100 | + </v-row> |
| 101 | + |
| 102 | + <!-- Hydrated Cards Cache --> |
| 103 | + <v-row dense> |
| 104 | + <v-col cols="12"> |
| 105 | + <v-divider class="my-2"></v-divider> |
| 106 | + <div class="debug-section"> |
| 107 | + <div class="debug-header"> |
| 108 | + <v-icon size="x-small" class="mr-1">mdi-database</v-icon> |
| 109 | + <strong>Hydrated Cards Cache</strong> |
| 110 | + </div> |
| 111 | + <div class="debug-stats"> |
| 112 | + <span class="text-caption">Cached: {{ debugInfo.hydratedCache.count }}</span> |
| 113 | + <span class="text-caption ml-2">Failed Cache: {{ debugInfo.hydratedCache.failedCacheSize }}</span> |
| 114 | + </div> |
| 115 | + <div v-if="debugInfo.hydratedCache.items.length > 0" class="debug-items"> |
| 116 | + <div |
| 117 | + v-for="(item, idx) in debugInfo.hydratedCache.items.slice(0, 8)" |
| 118 | + :key="idx" |
| 119 | + class="debug-item d-inline-block mr-3" |
| 120 | + > |
| 121 | + <span class="text-caption">{{ item.courseID }}::{{ item.cardID }}</span> |
| 122 | + </div> |
| 123 | + <div v-if="debugInfo.hydratedCache.items.length > 8" class="text-caption text-grey"> |
| 124 | + ... +{{ debugInfo.hydratedCache.items.length - 8 }} more |
| 125 | + </div> |
| 126 | + </div> |
| 127 | + <div v-else class="text-caption text-grey"> |
| 128 | + (empty) |
| 129 | + </div> |
| 130 | + </div> |
| 131 | + </v-col> |
| 132 | + </v-row> |
| 133 | + </v-card-text> |
| 134 | + </v-card> |
| 135 | +</template> |
| 136 | + |
| 137 | +<script lang="ts"> |
| 138 | +import { defineComponent, PropType, computed, ref, onMounted, onUnmounted } from 'vue'; |
| 139 | +import { SessionController } from '@vue-skuilder/db'; |
| 140 | +
|
| 141 | +interface QueueDebugInfo { |
| 142 | + length: number; |
| 143 | + dequeueCount: number; |
| 144 | + items: Array<{ courseID: string; cardID: string; status: string }>; |
| 145 | +} |
| 146 | +
|
| 147 | +interface HydratedCacheInfo { |
| 148 | + count: number; |
| 149 | + failedCacheSize: number; |
| 150 | + items: Array<{ courseID: string; cardID: string }>; |
| 151 | +} |
| 152 | +
|
| 153 | +export interface SessionDebugInfo { |
| 154 | + reviewQueue: QueueDebugInfo; |
| 155 | + newQueue: QueueDebugInfo; |
| 156 | + failedQueue: QueueDebugInfo; |
| 157 | + hydratedCache: HydratedCacheInfo; |
| 158 | +} |
| 159 | +
|
| 160 | +export default defineComponent({ |
| 161 | + name: 'SessionControllerDebug', |
| 162 | +
|
| 163 | + props: { |
| 164 | + sessionController: { |
| 165 | + type: Object as PropType<SessionController<any> | null>, |
| 166 | + required: true, |
| 167 | + }, |
| 168 | + }, |
| 169 | +
|
| 170 | + setup(props) { |
| 171 | + const refreshTrigger = ref(0); |
| 172 | + let pollInterval: NodeJS.Timeout | null = null; |
| 173 | +
|
| 174 | + onMounted(() => { |
| 175 | + // Poll every 500ms to update debug display |
| 176 | + pollInterval = setInterval(() => { |
| 177 | + refreshTrigger.value++; |
| 178 | + }, 500); |
| 179 | + }); |
| 180 | +
|
| 181 | + onUnmounted(() => { |
| 182 | + if (pollInterval) { |
| 183 | + clearInterval(pollInterval); |
| 184 | + } |
| 185 | + }); |
| 186 | +
|
| 187 | + const debugInfo = computed((): SessionDebugInfo => { |
| 188 | + // Create dependency on refreshTrigger to force updates |
| 189 | + refreshTrigger.value; |
| 190 | +
|
| 191 | + if (!props.sessionController) { |
| 192 | + return { |
| 193 | + reviewQueue: { length: 0, dequeueCount: 0, items: [] }, |
| 194 | + newQueue: { length: 0, dequeueCount: 0, items: [] }, |
| 195 | + failedQueue: { length: 0, dequeueCount: 0, items: [] }, |
| 196 | + hydratedCache: { count: 0, failedCacheSize: 0, items: [] }, |
| 197 | + }; |
| 198 | + } |
| 199 | +
|
| 200 | + return props.sessionController.getDebugInfo(); |
| 201 | + }); |
| 202 | +
|
| 203 | + return { |
| 204 | + debugInfo, |
| 205 | + }; |
| 206 | + }, |
| 207 | +}); |
| 208 | +</script> |
| 209 | + |
| 210 | +<style scoped> |
| 211 | +.session-debug { |
| 212 | + font-family: 'Courier New', monospace; |
| 213 | + font-size: 0.75rem; |
| 214 | + max-height: 400px; |
| 215 | + overflow-y: auto; |
| 216 | +} |
| 217 | +
|
| 218 | +.debug-section { |
| 219 | + padding: 8px; |
| 220 | + background-color: rgba(255, 255, 255, 0.05); |
| 221 | + border-radius: 4px; |
| 222 | + min-height: 120px; |
| 223 | +} |
| 224 | +
|
| 225 | +.debug-header { |
| 226 | + display: flex; |
| 227 | + align-items: center; |
| 228 | + margin-bottom: 4px; |
| 229 | + padding-bottom: 4px; |
| 230 | + border-bottom: 1px solid rgba(255, 255, 255, 0.1); |
| 231 | +} |
| 232 | +
|
| 233 | +.debug-stats { |
| 234 | + margin-bottom: 8px; |
| 235 | + display: flex; |
| 236 | + gap: 8px; |
| 237 | +} |
| 238 | +
|
| 239 | +.debug-items { |
| 240 | + margin-top: 4px; |
| 241 | + padding-left: 8px; |
| 242 | +} |
| 243 | +
|
| 244 | +.debug-item { |
| 245 | + padding: 2px 0; |
| 246 | + border-left: 2px solid rgba(255, 255, 255, 0.2); |
| 247 | + padding-left: 6px; |
| 248 | + margin-bottom: 2px; |
| 249 | +} |
| 250 | +</style> |
0 commit comments