Add Tokenizer Mode Support for Seshat Search Index#2753
Conversation
567a3db to
edc0d00
Compare
edc0d00 to
cfa845c
Compare
|
This needs the other two PRs to land first (which will need a look from product). |
| @@ -0,0 +1,29 @@ | |||
| /* | |||
| Copyright 2025 New Vector Ltd. | |||
There was a problem hiding this comment.
I interpreted your comment as asking for my name in the copyright header. I kept “New Vector Ltd.” because that seems to be the existing convention in this repo (and CONTRIBUTING.md points to the CLA). If you want individual author names on new files instead, I can update them.
There was a problem hiding this comment.
Yep, it's New Vector Ltd on most of the files because most of it was written by New Vector employees, but since this is your work, you own the copyright.
| // Schema mismatch or other errors - delete and recreate the database | ||
| console.warn("Failed to open Seshat database, deleting and recreating:", e); | ||
| await deleteContents(eventStorePath); | ||
| try { | ||
| eventIndex = new Seshat(eventStorePath, { passphrase, ...seshatConfig }); | ||
| // Return that the database was recreated so element-web can re-add checkpoints | ||
| ret = { wasRecreated: true }; | ||
| } catch (e2) { | ||
| sendError(payload.id, <Error>e2); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Not sure I understand why this change is relevant to this PR or why it's better
There was a problem hiding this comment.
This change is needed because changing the n-gram/tokenizer configuration makes the existing Seshat database incompatible. With this fallback, re-indexing will rebuild the index.
There was a problem hiding this comment.
Ah okay. I was going to suggest putting this in a comment but the code seems to be gone now?
| @@ -0,0 +1,40 @@ | |||
| /* | |||
| Copyright 2025 New Vector Ltd. | |||
| }, | ||
| ], | ||
| }, | ||
| }; |
There was a problem hiding this comment.
Unfortunately we're really trying to move away from jest so it would be much better to use vitest if we're introducing unit tests to the desktop package.
- Add tokenizerMode option to EventIndex initialization - Accept tokenizerMode from element-web via IPC - Support both N-gram and language-based tokenization modes - Default to language-based tokenization for backward compatibility
cfa845c to
15331c1
Compare
|
Also if you could please avoid force pushing: it makes it very hard to review a PR if we can't see what is changing. |
|
What's the status of this PR? It looks like you removed the |
So this desktop PR is backward-compatible and safe to merge now; One question on tests, so I can align with your preference: I’ll add follow-up commits only (no force-push). |
|
Thanks for doing that. If it is possible to add a minimal vitest test then that would be ideal - since this previously added a jest test, I assume this shouldn't be too problematic (hopefully?). Much appreciated! |
|
Added minimal Vitest coverage.
The |
dbkr
left a comment
There was a problem hiding this comment.
Thanks for doing this, great to have vitests for desktop too.
… into shinaoka/ngram2 # Conflicts: # pnpm-lock.yaml
|
Sorry this repo has been merged into element-web so you will need to merge your changes into element-hq/element-web#31540 |
element-meta Issue #2883: i18n support for full-text search in encrypted rooms
Summary
This PR adds tokenizer mode support to element-desktop, enabling users to choose between standard (language-based) and N-gram tokenization for the local message search index.
Changes
tokenizerModeoption to EventIndex initializationtokenizerModefrom element-web via IPCFiles Changed
src/@types/matrix-seshat.d.ts- Add TypeScript types for tokenizer optionssrc/seshat.ts- Pass tokenizerMode to Seshat, handle IPC from element-webDependencies
Merge Order
Checklist
public/exportedsymbols have accurate TSDoc documentation.