From a0aa48f82a45ae5e64065bfa9e98aff3faa7cfd0 Mon Sep 17 00:00:00 2001
From: dirwin31 <83434411+dirwin31@users.noreply.github.com>
Date: Thu, 27 Aug 2026 17:36:07 -0700
Subject: [PATCH] Fix search and sort
---
.../components/recordings/dashcam_routes.js | 18 ++++++-------
.../recordings/dashcam_routes_helpers.js | 12 +++++++--
.../tests/test_dashcam_routes_helpers.py | 26 +++++++++++++++++++
3 files changed, 45 insertions(+), 11 deletions(-)
diff --git a/starpilot/system/the_galaxy/assets/components/recordings/dashcam_routes.js b/starpilot/system/the_galaxy/assets/components/recordings/dashcam_routes.js
index 246a8fe11..b89ae66c7 100644
--- a/starpilot/system/the_galaxy/assets/components/recordings/dashcam_routes.js
+++ b/starpilot/system/the_galaxy/assets/components/recordings/dashcam_routes.js
@@ -825,11 +825,11 @@ export function RouteRecordings() {
@@ -862,7 +862,7 @@ export function RouteRecordings() {
${group.label}
${group.routes.length} ${group.routes.length === 1 ? "drive" : "drives"}
- ${() => state.viewMode === "grid" ? html`
+ ${state.viewMode === "grid" ? html`
${group.routes.map(route => html`
{ state.selectedRoute = route }}">
@@ -901,7 +901,7 @@ export function RouteRecordings() {
- `)}
+ `.key(route.name))}
` : html`
${group.routes.map(route => html`
{ state.selectedRoute = route }}">
@@ -940,9 +940,9 @@ export function RouteRecordings() {
- `)}
+ `.key(route.name))}
`}
- `)}
+ `.key(group.key))}
${view.truncated ? html`Showing the first ${MAX_RENDERED_ROUTES} of ${view.matching.length} matching routes.
` : ""}`
}}
diff --git a/starpilot/system/the_galaxy/assets/components/recordings/dashcam_routes_helpers.js b/starpilot/system/the_galaxy/assets/components/recordings/dashcam_routes_helpers.js
index e52272a9a..364631a1e 100644
--- a/starpilot/system/the_galaxy/assets/components/recordings/dashcam_routes_helpers.js
+++ b/starpilot/system/the_galaxy/assets/components/recordings/dashcam_routes_helpers.js
@@ -40,6 +40,11 @@ export function normalizeRoute(route, locale) {
`${routeDate.getMonth() + 1}/${routeDate.getDate()}/${routeDate.getFullYear()}`,
`${routeDate.getFullYear()}-${routeDate.getMonth() + 1}-${routeDate.getDate()}`,
] : []
+ const timeAliases = routeDate ? [
+ new Intl.DateTimeFormat(locale, { hour: "numeric", minute: "2-digit" }).format(routeDate),
+ new Intl.DateTimeFormat("en-US", { hour: "numeric", minute: "2-digit", hour12: true }).format(routeDate),
+ `${String(routeDate.getHours()).padStart(2, "0")}:${String(routeDate.getMinutes()).padStart(2, "0")}`,
+ ] : []
return {
...route,
@@ -54,6 +59,7 @@ export function normalizeRoute(route, locale) {
normalizeRouteSearchText(route?.name),
normalizeRouteSearchText(isCustomName ? displayName : ""),
...dateAliases.map(normalizeRouteSearchText),
+ ...timeAliases.map(normalizeRouteSearchText),
].filter(Boolean),
}
}
@@ -120,7 +126,8 @@ export function sortRoutes(routes, sortOrder = "newest") {
}
export function routeMatchesSearch(route, searchQuery) {
- const queryTokens = normalizeRouteSearchText(searchQuery).split(" ").filter(Boolean)
+ const normalizedQuery = normalizeRouteSearchText(searchQuery)
+ const queryTokens = normalizedQuery.split(" ").filter(Boolean)
if (!queryTokens.length) return true
const searchValues = Array.isArray(route?._searchValues) ? route._searchValues : [
@@ -130,8 +137,9 @@ export function routeMatchesSearch(route, searchQuery) {
route?.displayDate,
].map(normalizeRouteSearchText).filter(Boolean)
return searchValues.some(value => {
+ if (value.includes(normalizedQuery)) return true
const searchTokens = value.split(" ").filter(Boolean)
- return queryTokens.every(queryToken => searchTokens.some(searchToken => searchToken.includes(queryToken)))
+ return queryTokens.every(queryToken => searchTokens.some(searchToken => searchToken.startsWith(queryToken)))
})
}
diff --git a/starpilot/system/the_galaxy/tests/test_dashcam_routes_helpers.py b/starpilot/system/the_galaxy/tests/test_dashcam_routes_helpers.py
index a52963950..fb9b5a4c4 100644
--- a/starpilot/system/the_galaxy/tests/test_dashcam_routes_helpers.py
+++ b/starpilot/system/the_galaxy/tests/test_dashcam_routes_helpers.py
@@ -79,6 +79,14 @@ def test_route_titles_and_custom_name_badges_are_reactive():
assert source.count('${() => route.isCustomName ? html`') >= 4
+def test_sort_order_select_and_route_items_are_keyed_and_reactive():
+ source = COMPONENT_PATH.read_text(encoding="utf-8")
+
+ assert '