From 92a52a3199b2d3abd434f181811fee449b5ff6ee Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Tue, 17 Mar 2026 00:14:59 +0100 Subject: [PATCH] fix: apply column union when total_cols >= max (not just >) Zone 4 found 4 columns incl. page_ref, union also yields 4. The strict > check prevented union from applying to Zone 0. Changed to >= so all content zones get the merged column set. Co-Authored-By: Claude Opus 4.6 --- klausur-service/backend/grid_editor_api.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/klausur-service/backend/grid_editor_api.py b/klausur-service/backend/grid_editor_api.py index ecb13c2..3139795 100644 --- a/klausur-service/backend/grid_editor_api.py +++ b/klausur-service/backend/grid_editor_api.py @@ -568,9 +568,11 @@ async def build_grid(session_id: str): for zg in content_zones ) - # Only apply union if it found more columns than - # any single zone (union adds information) - if total_cols > max_zone_cols: + # Apply union whenever it has at least as many + # columns as the best single zone. Even with the + # same count the union boundaries are better because + # they incorporate evidence from all zones. + if total_cols >= max_zone_cols: cx_min = min(w["left"] for w in all_words) cx_max = max( w["left"] + w["width"] for w in all_words