Nearby-in-time location suggestions - #59
Merged
Merged
Conversation
Suggest locations from the closest photos in time (before/after) within a 6h window, ranked by proximity.
Add SUGGESTIONS_NEIGHBOR_WINDOW_HOURS environment variable (default 6) to tune the "Nearby in time" search window
There was a problem hiding this comment.
Pull request overview
Adds a new “Nearby in time” suggestion category that surfaces geolocated photos closest (before/after) to a selected asset’s timestamp, with a configurable search window, and renders these points in the UI labeled by time offset.
Changes:
- Backend: adds
neighborClustersto suggestions response, with per-pointsecondsFromRef, plusSUGGESTIONS_NEIGHBOR_WINDOW_HOURSconfiguration and DB query support. - Frontend: introduces the
neighborcategory (labels/colors/max items), renders neighbor points, and formats signed offsets (e.g., “2 min before”). - Docs/ops: updates README, env example, and compose files to document and pass through the new configuration.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/suggestions.ts | Adds neighbor category metadata and formatNeighborOffset formatter. |
| src/shared/types/suggestion.ts | Extends suggestion types to include neighborClusters and optional secondsFromRef. |
| src/shared/services/backendApi.ts | Normalizes neighborClusters in fetchSuggestions. |
| src/shared/services/backendApi.guards.ts | Updates type guards to validate neighborClusters and optional secondsFromRef. |
| src/features/suggestions/useSuggestionState.ts | Adds neighbor color, stable key includes offset, and per-category max item cap. |
| src/features/suggestions/useSuggestions.ts | Adds “Nearby in time” category construction from API response. |
| src/features/suggestions/SuggestionsPill.tsx | Displays time-offset label for neighbor items instead of count. |
| src/features/suggestions/Readme.md | Documents the new neighbor suggestion category behavior. |
| README.md | Documents the feature and new env var. |
| docker-compose.yml | Passes SUGGESTIONS_NEIGHBOR_WINDOW_HOURS to backend container. |
| docker-compose.prod.yml | Passes SUGGESTIONS_NEIGHBOR_WINDOW_HOURS to backend container (prod). |
| backend/types.go | Adds SecondsFromRef to LocationCluster and NeighborClusters to suggestions response. |
| backend/suggestionService.go | Wires neighbor query into suggestion generation and builds per-asset neighbor points. |
| backend/suggestionService_test.go | Adds tests covering neighbor clusters ordering/window behavior; updates service constructor usage. |
| backend/main.go | Passes configured neighbor window hours into suggestion service construction. |
| backend/interfaces.go | Extends SuggestionStore with getNeighborAssets. |
| backend/handlers.go | Defines neighborLimit constant used for neighbor suggestions. |
| backend/handlers_test.go | Updates tests to use new suggestion service constructor; asserts non-nil neighbor clusters. |
| backend/database.go | Implements getNeighborAssets with window filtering and closest-first ordering. |
| backend/database_test.go | Adds test for neighbor window filtering, ordering, and limit behavior. |
| backend/config.go | Adds NeighborWindowHours config/env var with validation. |
| backend/config_test.go | Adds test for neighbor window env override. |
| .env.example | Documents SUGGESTIONS_NEIGHBOR_WINDOW_HOURS. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+81
to
+85
| if neighborAssets, err := s.db.getNeighborAssets(ctx, userID, *dateRef, s.neighborWindow, neighborLimit); err != nil { | ||
| log.Printf("[Suggest] Failed to get neighbor assets: %v", err) | ||
| } else if parseErr == nil { | ||
| response.NeighborClusters = buildNeighborPoints(neighborAssets, refTime) | ||
| } |
Owner
|
Thank you for the PR! |
Majorfi
approved these changes
Jul 22, 2026
Majorfi
left a comment
Owner
There was a problem hiding this comment.
LGTM! Great job, thank you for the contribution!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a "Nearby in time" suggestion category: the geolocated photos closest in time to the selected photo, shown as individual points ordered by proximity and labeled with their time distance (for example, "2 min before").
Changes
Backend:
getNeighborAssetsquery,neighborClusterslist in the suggestions response, with a positive or negative secondsFromRef per pointFrontend:
Closes #58