Skip to content

fix(images): identify image results by the image, not its page - #3313

Closed
noahkhomer18 wants to merge 1 commit into
felladrin:mainfrom
noahkhomer18:fix/3294-image-identity
Closed

noahkhomer18 wants to merge 1 commit into
felladrin:mainfrom
noahkhomer18:fix/3294-image-identity

Conversation

@noahkhomer18

Copy link
Copy Markdown

Description

Fixes #3294.

Image results were identified by their page URL in every step that compares them, so several images from one gallery page collapsed into the first. They are now identified by the image itself: getImageIdentity in shared/imageIdentity.ts returns the full-size source, then the thumbnail, then the page URL. Text results still deduplicate by URL.

Where the identity is now used:

  • Server: openableUniqueResults deduplicates image searches by identity (text searches are unchanged), and the image branch of searchEndpointServerHook ranks by identity and maps each ranked entry back to its own row, so two images on one page no longer both resolve to the first.
  • Client: refreshImageSearchResults and startImageSearch merge new images into the ones on screen through one helper, imagesNotIn in client/modules/imageResults.ts. mergeSearchImageResults in history.ts merges stored images the same way. ImageResultsList keys tiles, thumbnail sources and failed-thumbnail state by identity.

One existing test changed

Three refreshImageSearchResults tests gave every row the same placeholder image ("thumb", "source"). Under the new identity that made rows from different pages the same image, so they would collapse. Each row now has its own image (https://<host>/thumb.jpg, https://<host>/full.jpg). What the tests assert is unchanged.

How to test

$ npx vitest run
 Test Files  138 passed (138)
      Tests  2009 passed (2009)

$ npm run lint      # biome, tsc (all three configs), knip, jscpd, the three repo scripts: exit 0

New tests, one per place the identity is used: deduplication in webSearchService, reranking in searchEndpointServerHook, merging on screen in chatHelpers and textGeneration, merging into history in history, and tile keys in ImageResultsList. With the six source files put back to main, all six fail (6 failed, 224 passed in those files). With this branch they pass.

To see it in the app:

  1. Have SearXNG return two image rows with the same url (https://example.com/gallery) and different img_src.
  2. Turn on image search and search.
  3. Both images show in the carousel, and each opens its own full-size image.

Not tested: against a live SearXNG instance. The rows above come from the unit tests' stubs.

Image results were deduplicated, reranked, merged into history and keyed on screen by their page URL, so several images from one gallery page collapsed into the first. Identify an image by its full-size source, then its thumbnail, then its page, through one shared helper, everywhere those steps happen. Text results still deduplicate by URL.

Three existing refreshImageSearchResults tests gave every row the same placeholder image ("thumb", "source"), which under the new identity made different pages one image; they now give each row its own image.

Fixes felladrin#3294

Signed-off-by: Noah Khomer <108771853+noahkhomer18@users.noreply.github.com>
@ghfind-review ghfind-review Bot added the review: no-score ghfind author score missing (not zero) label Nov 27, 2026
@felladrin

Copy link
Copy Markdown
Owner

@noahkhomer18 Thanks a lot for this, and sorry for the wasted effort! #3312 fixed the same issue a few minutes earlier, and it's now merged (ee2a4bf), so I'm closing this one as a duplicate. Your single shared getImageIdentity in shared/ is a better shape than the three copies of the rule that main has now; if you'd like, a follow-up PR that moves them into one shared function would be very welcome. (One thing to keep from #3312: the reranker should keep getting the page URL, because its authority boost reads the host.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: no-score ghfind author score missing (not zero)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Different images from the same source page are merged into one

2 participants