fix: preserve span input/metadata, auto-expand subspans, force-arm poll
Three fixes in response to user feedback: 1. Span input disappearing on End/Fail The Upsert's DoUpdates always listed input/output/metadata, so calls that only set output (EndSpan) or only set error_* (FailSpan) wrote NULL into input/metadata, clobbering whatever Begin had recorded. Build the column list dynamically: skip input/output/metadata when the incoming row's value is nil. nil now means "preserve existing" (matches user's intuition "Begin recorded it, End shouldn't erase it"). 2. Subspans not auto-expanded Stages with children (multimodal.image[*], postprocess.summary, postprocess.question, postprocess.graph.chunk[*]) required a click on the ▸ caret to surface — easy to miss. On the FIRST successful fetch per (knowledgeId × attempt), auto-expand any stage that has children. Subsequent polls honor whatever the user has collapsed, so manual collapse mid-parse stays collapsed. 3. Auto-poll still not firing Force-arm the polling interval in onMounted regardless of state. The per-tick callback decides whether to actually fetch based on current parse_status — so the loop can never get stranded waiting on a status transition that already happened. Added a console.debug when the interval arms, so we can verify from DevTools console that polling is actually running. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -52,25 +52,41 @@ func (r *knowledgeSpanRepository) Upsert(ctx context.Context, row *types.Knowled
|
||||
// transition between calls — name/kind/parent are immutable once
|
||||
// set so we don't list them in DoUpdates (saves a few bytes per
|
||||
// write, and any mismatch indicates a programming error).
|
||||
//
|
||||
// CRITICAL: input / output / metadata are CONTENT fields that
|
||||
// individual call sites only fill when they have something to set.
|
||||
// EndSpan e.g. only sets `output`; if we always listed `input` in
|
||||
// DoUpdates, the End call would clobber the input set by Begin with
|
||||
// NULL. Same for metadata. Build the DoUpdates list dynamically and
|
||||
// skip these three columns when the incoming row has nothing to
|
||||
// write — so "no value" preserves the existing column instead of
|
||||
// nuking it.
|
||||
cols := []string{
|
||||
"status",
|
||||
"error_code",
|
||||
"error_message",
|
||||
"error_detail",
|
||||
"started_at",
|
||||
"finished_at",
|
||||
"duration_ms",
|
||||
"updated_at",
|
||||
}
|
||||
if row.Input != nil {
|
||||
cols = append(cols, "input")
|
||||
}
|
||||
if row.Output != nil {
|
||||
cols = append(cols, "output")
|
||||
}
|
||||
if row.Metadata != nil {
|
||||
cols = append(cols, "metadata")
|
||||
}
|
||||
return r.db.WithContext(ctx).Clauses(clause.OnConflict{
|
||||
Columns: []clause.Column{
|
||||
{Name: "knowledge_id"},
|
||||
{Name: "attempt"},
|
||||
{Name: "span_id"},
|
||||
},
|
||||
DoUpdates: clause.AssignmentColumns([]string{
|
||||
"status",
|
||||
"input",
|
||||
"output",
|
||||
"metadata",
|
||||
"error_code",
|
||||
"error_message",
|
||||
"error_detail",
|
||||
"started_at",
|
||||
"finished_at",
|
||||
"duration_ms",
|
||||
"updated_at",
|
||||
}),
|
||||
DoUpdates: clause.AssignmentColumns(cols),
|
||||
}).Create(row).Error
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user