From aa5bcd61e3fe8e7d3ccb03809abd654baa8ffff8 Mon Sep 17 00:00:00 2001 From: Sleeps Date: Wed, 7 Oct 2026 12:39:49 +0100 Subject: [PATCH] Preserve frame order when mixing saved and new routes --- scene_search/cli.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scene_search/cli.py b/scene_search/cli.py index 4fdf597..e715d0a 100644 --- a/scene_search/cli.py +++ b/scene_search/cli.py @@ -393,7 +393,10 @@ def _route_rows( if override is not None: decisions[str(row["id"])] = override - routed: list[tuple] = list(reusable) + routed_by_id = { + str(row["id"]): (row, route, score, reason) + for row, route, score, reason in reusable + } with connect(settings.db_path) as con: for row in valid_rows: frame_id = str(row["id"]) @@ -408,13 +411,19 @@ def _route_rows( """, (route, reason, score, route_model, policy, frame_id), ) - routed.append((row, route, score, reason)) + routed_by_id[frame_id] = (row, route, score, reason) if verbose: print( f"{row['title']} @ {format_ts(int(row['timestamp_ms']))}: " f"score={score:.4f} -> {route} ({reason})" ) + routed = [ + routed_by_id[str(row["id"])] + for row in rows + if str(row["id"]) in routed_by_id + ] + if progress is not None: progress( {