fix: default Keep checkbox to algorithm-selected survivor only

Only the row chosen by the survivor rule (first, last, most-recent, etc.)
is checked by default. Other rows start unchecked.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-29 00:15:13 +00:00
parent d368cad89d
commit e672488d50

View File

@@ -372,7 +372,7 @@ def match_group_card(
# --- Undecided: interactive editor with inline checkboxes & dropdowns --- # --- Undecided: interactive editor with inline checkboxes & dropdowns ---
editor_rows = [] editor_rows = []
for idx in group.row_indices: for idx in group.row_indices:
row_data = {"Keep": True, "Row": idx + 1} row_data = {"Keep": idx == group.survivor_index, "Row": idx + 1}
for col in display_cols: for col in display_cols:
row_data[col] = str(df.iloc[idx].get(col, "")) row_data[col] = str(df.iloc[idx].get(col, ""))
editor_rows.append(row_data) editor_rows.append(row_data)
@@ -441,7 +441,7 @@ def match_group_card(
# Confirm # Confirm
def _on_confirm( def _on_confirm(
g=gid, indices=list(group.row_indices), g=gid, indices=list(group.row_indices),
diff=differing_cols, diff=differing_cols, surv=group.survivor_index,
): ):
editor_state = st.session_state.get(f"editor_{g}", {}) editor_state = st.session_state.get(f"editor_{g}", {})
ed_rows = editor_state.get("edited_rows", {}) ed_rows = editor_state.get("edited_rows", {})
@@ -450,7 +450,8 @@ def match_group_card(
keep = [] keep = []
for i, idx in enumerate(indices): for i, idx in enumerate(indices):
changes = ed_rows.get(i, {}) changes = ed_rows.get(i, {})
if changes.get("Keep", True): default_keep = idx == surv
if changes.get("Keep", default_keep):
keep.append(idx) keep.append(idx)
if not keep: if not keep:
keep = list(indices) keep = list(indices)