fix(e2e): update chunks synchronously in store to prevent rechunk timeout
ChunkPanel emitted 'rechunked' which triggered an async re-fetch via analysisStore.select() — but Vue does not await async emit handlers, so chunk-cards never appeared before the E2E 30s timeout. Now rechunk/edit/delete write returned chunks directly into the analysis store via updateChunks(), removing the async round-trip.
This commit is contained in:
parent
2477a2af4b
commit
c4057bb010
3 changed files with 18 additions and 14 deletions
|
|
@ -111,6 +111,15 @@ export const useAnalysisStore = defineStore('analysis', () => {
|
|||
}
|
||||
}
|
||||
|
||||
function updateChunks(chunks: Chunk[]): void {
|
||||
if (currentAnalysis.value) {
|
||||
currentAnalysis.value = {
|
||||
...currentAnalysis.value,
|
||||
chunksJson: JSON.stringify(chunks),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function select(id: string): Promise<void> {
|
||||
try {
|
||||
currentAnalysis.value = await api.fetchAnalysis(id)
|
||||
|
|
@ -142,6 +151,7 @@ export const useAnalysisStore = defineStore('analysis', () => {
|
|||
load,
|
||||
run,
|
||||
select,
|
||||
updateChunks,
|
||||
remove,
|
||||
stopPolling,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -225,6 +225,7 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive, computed } from 'vue'
|
||||
import { useChunkingStore } from '../store'
|
||||
import { useAnalysisStore } from '../../analysis/store'
|
||||
import { useI18n } from '../../../shared/i18n'
|
||||
import { usePagination } from '../../../shared/composables/usePagination'
|
||||
import { PaginationBar } from '../../../shared/ui'
|
||||
|
|
@ -240,10 +241,10 @@ const props = defineProps<{
|
|||
|
||||
const emit = defineEmits<{
|
||||
'highlight-bboxes': [bboxes: ChunkBbox[]]
|
||||
rechunked: []
|
||||
}>()
|
||||
|
||||
const chunkingStore = useChunkingStore()
|
||||
const analysisStore = useAnalysisStore()
|
||||
const { t } = useI18n()
|
||||
|
||||
const configOpen = ref(true)
|
||||
|
|
@ -284,9 +285,9 @@ function confirmDelete(chunkIndex: number) {
|
|||
|
||||
async function doDelete() {
|
||||
if (!props.analysisId || deleteConfirmIdx.value === -1) return
|
||||
await chunkingStore.deleteChunk(props.analysisId, deleteConfirmIdx.value)
|
||||
const chunks = await chunkingStore.deleteChunk(props.analysisId, deleteConfirmIdx.value)
|
||||
deleteConfirmIdx.value = -1
|
||||
emit('rechunked')
|
||||
analysisStore.updateChunks(chunks)
|
||||
}
|
||||
|
||||
const editingIdx = ref(-1)
|
||||
|
|
@ -310,8 +311,8 @@ async function saveEdit(chunkIndex: number) {
|
|||
cancelEdit()
|
||||
return
|
||||
}
|
||||
await chunkingStore.updateChunkText(props.analysisId, chunkIndex, editText.value)
|
||||
emit('rechunked')
|
||||
const chunks = await chunkingStore.updateChunkText(props.analysisId, chunkIndex, editText.value)
|
||||
analysisStore.updateChunks(chunks)
|
||||
cancelEdit()
|
||||
}
|
||||
|
||||
|
|
@ -330,8 +331,8 @@ function onChunkLeave() {
|
|||
|
||||
async function doRechunk() {
|
||||
if (!props.analysisId) return
|
||||
await chunkingStore.rechunk(props.analysisId, { ...options })
|
||||
emit('rechunked')
|
||||
const chunks = await chunkingStore.rechunk(props.analysisId, { ...options })
|
||||
analysisStore.updateChunks(chunks)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -464,7 +464,6 @@
|
|||
:has-document-json="analysisStore.currentAnalysis?.hasDocumentJson ?? false"
|
||||
:chunks="analysisStore.currentChunks"
|
||||
@highlight-bboxes="highlightedChunkBboxes = $event"
|
||||
@rechunked="onRechunked"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
@ -607,12 +606,6 @@ function addMore() {
|
|||
documentStore.selectedId = null
|
||||
}
|
||||
|
||||
async function onRechunked() {
|
||||
if (analysisStore.currentAnalysis?.id) {
|
||||
await analysisStore.select(analysisStore.currentAnalysis.id)
|
||||
}
|
||||
}
|
||||
|
||||
// Clear highlights when switching modes or pages
|
||||
watch(mode, () => {
|
||||
highlightedElementIndex.value = -1
|
||||
|
|
|
|||
Loading…
Reference in a new issue