Skip to content

Commit 5be201b

Browse files
committed
fix(extraction): handle unknown-table ops in stable height reservation
When all operations target unknown tables, groupOperationsByTable returns empty groups but hasOps is true. Fall back to rendered section line count instead of returning 0 from stablePreviewLines, preserving overlay sizing behavior for this edge case.
1 parent c91ac06 commit 5be201b

2 files changed

Lines changed: 36 additions & 7 deletions

File tree

internal/app/extraction_render.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,19 @@ func (m *Model) buildExtractionPipelineOverlay(
155155
// Reserve height for the tallest preview tab so the overlay
156156
// doesn't jump when switching tabs in explore mode.
157157
previewLines = stablePreviewLines(ex.previewGroups)
158-
// Pad rendered section to stable height so the overlay
159-
// doesn't shrink when a shorter tab is displayed.
160-
actualLines := strings.Count(previewSection, "\n")
161-
targetLines := previewLines - 2 // -2: sep+blank added as separate parts
162-
for actualLines < targetLines {
163-
previewSection += "\n"
164-
actualLines++
158+
if previewLines == 0 {
159+
// Fallback for unknown-table ops where no preview groups
160+
// are generated: use rendered section's actual line count.
161+
previewLines = strings.Count(previewSection, "\n") + 2
162+
} else {
163+
// Pad rendered section to stable height so the overlay
164+
// doesn't shrink when a shorter tab is displayed.
165+
actualLines := strings.Count(previewSection, "\n")
166+
targetLines := previewLines - 2 // -2: sep+blank added as separate parts
167+
for actualLines < targetLines {
168+
previewSection += "\n"
169+
actualLines++
170+
}
165171
}
166172
}
167173

internal/app/extraction_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3689,3 +3689,26 @@ func TestExploreMode_TabPersistsOnExit(t *testing.T) {
36893689
assert.Contains(t, plain, "Total",
36903690
"pipeline mode should show last-explored tab content")
36913691
}
3692+
3693+
func TestExploreMode_UnknownTableOverlayStable(t *testing.T) {
3694+
t.Parallel()
3695+
// Unknown tables produce no preview groups but hasOps is still true.
3696+
// Overlay should render without panicking and maintain stable height.
3697+
m := newPreviewModel(t, []extract.Operation{
3698+
{Action: "create", Table: "unknown_table", Data: map[string]any{"x": "y"}},
3699+
})
3700+
3701+
out := m.buildExtractionPipelineOverlay(100, 90, "test")
3702+
plain := ansi.Strip(out)
3703+
lines := strings.Count(out, "\n")
3704+
3705+
assert.Greater(t, lines, 0, "overlay should render with nonzero height")
3706+
assert.Contains(t, plain, "no operations",
3707+
"should show fallback text for unknown tables")
3708+
3709+
// Build again -- height should be identical (stable).
3710+
out2 := m.buildExtractionPipelineOverlay(100, 90, "test")
3711+
lines2 := strings.Count(out2, "\n")
3712+
assert.Equal(t, lines, lines2,
3713+
"overlay height should be stable across renders")
3714+
}

0 commit comments

Comments
 (0)