Skip to content

fix: surface search hit titles instead of dropping them - #88

Open
ayushsingh82 wants to merge 1 commit into
supermemoryai:mainfrom
ayushsingh82:fix/search-title-field
Open

fix: surface search hit titles instead of dropping them#88
ayushsingh82 wants to merge 1 commit into
supermemoryai:mainfrom
ayushsingh82:fix/search-title-field

Conversation

@ayushsingh82

Copy link
Copy Markdown
Contributor

Summary

Another of the smaller gaps flagged in #86 that isn't covered by #83.

search()'s mapper never included title, even though getProfile()'s mapper already does. But it turns out neither formatSearchResults() (used by search-memory.cjs) nor formatContext() (used for the injected recall context) ever read .title in the first place — so titles were being silently dropped in every path, including the one where the field was already being mapped. Titles are generated from the first line of saved content and are currently the only thing that could disambiguate two similar-looking results, per the original report.

This PR:

  • adds title: r.title to search()'s mapper, for parity with getProfile()
  • makes formatSearchResults() and formatContext() actually prefix a result line with its title when present (Title: memory text [pct%]), and leaves output unchanged when there's no title

Test plan

  • npm test passes, including new cases in test/unit.mjs:
    • formatSearchResults labels a hit with its title when present
    • formatSearchResults output is unchanged when there's no title
    • formatContext's "Relevant Memories" section also picks up the title
  • npm run lint passes
  • plugin/scripts/*.cjs rebuilt via npm run build and committed alongside the src/ changes

search()'s mapper discarded the title field even though getProfile()
already returned it, and neither formatSearchResults() nor
formatContext() ever rendered it - so titles were dropped everywhere,
even where the API already provided them. Titles are generated from
the first line of saved content and are the only thing that
distinguishes similar-looking results.

- search() now maps title alongside memory/chunk
- formatSearchResults() and formatContext() prefix a result line with
  its title when present, and are unaffected when it's absent

Related to supermemoryai#86.
@ayushsingh82

Copy link
Copy Markdown
Contributor Author

@Dhravya fixes search hit titles being silently dropped. Please take a look.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants