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> {
|
async function select(id: string): Promise<void> {
|
||||||
try {
|
try {
|
||||||
currentAnalysis.value = await api.fetchAnalysis(id)
|
currentAnalysis.value = await api.fetchAnalysis(id)
|
||||||
|
|
@ -142,6 +151,7 @@ export const useAnalysisStore = defineStore('analysis', () => {
|
||||||
load,
|
load,
|
||||||
run,
|
run,
|
||||||
select,
|
select,
|
||||||
|
updateChunks,
|
||||||
remove,
|
remove,
|
||||||
stopPolling,
|
stopPolling,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -225,6 +225,7 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, computed } from 'vue'
|
import { ref, reactive, computed } from 'vue'
|
||||||
import { useChunkingStore } from '../store'
|
import { useChunkingStore } from '../store'
|
||||||
|
import { useAnalysisStore } from '../../analysis/store'
|
||||||
import { useI18n } from '../../../shared/i18n'
|
import { useI18n } from '../../../shared/i18n'
|
||||||
import { usePagination } from '../../../shared/composables/usePagination'
|
import { usePagination } from '../../../shared/composables/usePagination'
|
||||||
import { PaginationBar } from '../../../shared/ui'
|
import { PaginationBar } from '../../../shared/ui'
|
||||||
|
|
@ -240,10 +241,10 @@ const props = defineProps<{
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
'highlight-bboxes': [bboxes: ChunkBbox[]]
|
'highlight-bboxes': [bboxes: ChunkBbox[]]
|
||||||
rechunked: []
|
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const chunkingStore = useChunkingStore()
|
const chunkingStore = useChunkingStore()
|
||||||
|
const analysisStore = useAnalysisStore()
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
const configOpen = ref(true)
|
const configOpen = ref(true)
|
||||||
|
|
@ -284,9 +285,9 @@ function confirmDelete(chunkIndex: number) {
|
||||||
|
|
||||||
async function doDelete() {
|
async function doDelete() {
|
||||||
if (!props.analysisId || deleteConfirmIdx.value === -1) return
|
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
|
deleteConfirmIdx.value = -1
|
||||||
emit('rechunked')
|
analysisStore.updateChunks(chunks)
|
||||||
}
|
}
|
||||||
|
|
||||||
const editingIdx = ref(-1)
|
const editingIdx = ref(-1)
|
||||||
|
|
@ -310,8 +311,8 @@ async function saveEdit(chunkIndex: number) {
|
||||||
cancelEdit()
|
cancelEdit()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await chunkingStore.updateChunkText(props.analysisId, chunkIndex, editText.value)
|
const chunks = await chunkingStore.updateChunkText(props.analysisId, chunkIndex, editText.value)
|
||||||
emit('rechunked')
|
analysisStore.updateChunks(chunks)
|
||||||
cancelEdit()
|
cancelEdit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -330,8 +331,8 @@ function onChunkLeave() {
|
||||||
|
|
||||||
async function doRechunk() {
|
async function doRechunk() {
|
||||||
if (!props.analysisId) return
|
if (!props.analysisId) return
|
||||||
await chunkingStore.rechunk(props.analysisId, { ...options })
|
const chunks = await chunkingStore.rechunk(props.analysisId, { ...options })
|
||||||
emit('rechunked')
|
analysisStore.updateChunks(chunks)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -464,7 +464,6 @@
|
||||||
:has-document-json="analysisStore.currentAnalysis?.hasDocumentJson ?? false"
|
:has-document-json="analysisStore.currentAnalysis?.hasDocumentJson ?? false"
|
||||||
:chunks="analysisStore.currentChunks"
|
:chunks="analysisStore.currentChunks"
|
||||||
@highlight-bboxes="highlightedChunkBboxes = $event"
|
@highlight-bboxes="highlightedChunkBboxes = $event"
|
||||||
@rechunked="onRechunked"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -607,12 +606,6 @@ function addMore() {
|
||||||
documentStore.selectedId = null
|
documentStore.selectedId = null
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onRechunked() {
|
|
||||||
if (analysisStore.currentAnalysis?.id) {
|
|
||||||
await analysisStore.select(analysisStore.currentAnalysis.id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear highlights when switching modes or pages
|
// Clear highlights when switching modes or pages
|
||||||
watch(mode, () => {
|
watch(mode, () => {
|
||||||
highlightedElementIndex.value = -1
|
highlightedElementIndex.value = -1
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue