Skip to content

RI-8317 Detect and highlight large vector embeddings in the query editor#6215

Open
dantovska wants to merge 7 commits into
mainfrom
fe/feature/RI-8317/detect-large-vector-embeddings
Open

RI-8317 Detect and highlight large vector embeddings in the query editor#6215
dantovska wants to merge 7 commits into
mainfrom
fe/feature/RI-8317/detect-large-vector-embeddings

Conversation

@dantovska

@dantovska dantovska commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

What

Adds detection for large vector embeddings in the query editor, plus a subtle highlight so they're visible.

  • Pure detector (utils/monaco/vectorEmbeddingUtils.ts): detectVectorEmbeddings(query) scans query text and returns a mark per embedding. Two formats:
    • binary FLOAT32 \x blobs, validated with the existing isBinaryVector heuristic;
    • numeric arrays with ≥ 10 elements.
      Each mark carries range, format, byte size, dimensions, a first-3/last-2 preview, and the FT.SEARCH PARAMS argument name when applicable (located via splitQueryByArgs). Thresholds are named constants; marks/types live in their own file.
  • useVectorEmbeddingMarks hook exposes the marks, recomputed on query change.
  • VectorEmbeddingHighlight — a self-contained component (own styles + detection + Monaco decorations) rendered next to the editor in both Workbench and Vector Search. It paints a subtle grey background behind each embedding, with an i18n hover showing dimensions and byte size. The shared CodeEditor / useQueryEditor are left untouched so the embedding logic can grow independently.

Testing

Unit testsutils/tests/monaco/vectorEmbeddingUtils.spec.ts cover both formats, multiple embeddings in one query, threshold edges, non-vector strings, and PARAMS name extraction:

node node_modules/.bin/jest 'redisinsight/ui/src/utils/tests/monaco/vectorEmbeddingUtils.spec.ts' -c jest.config.cjs

Manual — open a database → Workbench or Vector Search editor and paste the query below:

FT.SEARCH idx:bikes_vss "*=>[KNN 3 @description_embeddings $my_blob AS score ]" RETURN 4 score brand type description PARAMS 2 my_blob "\x98=\xd0\xbb\x94\xeb\xdb<C\x85\xf3:@\xdf$=\xd8\xf5\xbf\xbc\xa2\xdb\x04=3\x10\x22<\x8f\xc0)\xbd" SORTBY score DIALECT 2

The my_blob embedding value should render with a subtle grey background (slightly greyed out on both light and dark themes), and hovering it should show the dimensions and byte size.


Closes #RI-8317


Note

Low Risk
Editor-only UI and pure string parsing; no server, auth, or query execution changes. Main risk is false-positive highlights on large numeric arrays or regex edge cases in unusual query text.

Overview
Adds detection and in-editor highlighting for large vector embeddings in Workbench and Vector Search query editors, without changing the shared CodeEditor / useQueryEditor lifecycle.

detectVectorEmbeddings scans query text for binary FLOAT32 \x blobs (via existing isBinaryVector) and numeric arrays with ≥10 elements, returning marks with range, dimensions, byte size, previews, and optional FT.SEARCH PARAMS argument names from splitQueryByArgs.

A self-contained VectorEmbeddingHighlight component (hooks + global .monaco-vector-embedding styles) applies Monaco inline decorations and an i18n hover (dimensions / byte size). It is mounted next to the editor in Workbench Query and VectorSearchEditor, sharing monacoObjects from query editor context.

Unit coverage lives in vectorEmbeddingUtils.spec.ts (thresholds, multiple embeddings, PARAMS mapping).

Reviewed by Cursor Bugbot for commit 415ca0c. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Code Coverage - Frontend unit tests

St.
Category Percentage Covered / Total
🟢 Statements 83.33% 27917/33503
🟡 Branches 69.33% 11943/17226
🟡 Functions 78.23% 7411/9473
🟢 Lines 83.77% 27169/32432

Test suite run success

7843 tests passing in 866 suites.

Report generated by 🧪jest coverage report action from 415ca0c

@dantovska
dantovska force-pushed the fe/feature/RI-8317/detect-large-vector-embeddings branch from d25aecb to 5a9bf1b Compare July 20, 2026 10:33
@dantovska dantovska self-assigned this Jul 20, 2026
Add a pure, source-agnostic detector that scans query text and returns
marks (range + metadata) for every large vector embedding it finds:
binary FLOAT32 "\x" blobs (validated with isBinaryVector) and numeric
arrays with >= 10 elements. Each mark carries range, format, byte size,
dimensions, a first-3/last-2 preview, and the FT.SEARCH PARAMS argument
name when applicable.

Expose the marks through a useVectorEmbeddingMarks hook composed inside
useQueryEditor, so both the Workbench and Vector Search editors receive
them with no extra wiring. Recomputes on query change. Data only, no
user-visible change yet; the collapse-rendering ticket consumes these
marks.

References: #RI-8317
Render a subtle inline background (plus a hover tooltip showing format,
dimensions and byte size) behind every embedding surfaced by
useVectorEmbeddingMarks. The new useVectorEmbeddingDecorations hook maps
each mark's character range to a Monaco range and applies decorations,
mirroring the existing useQueryDecorations pattern. Composed inside
useQueryEditor, so both the Workbench and Vector Search editors show the
highlight. Adds a themed .monaco-vector-embedding style.

References: #RI-8317
Move the embedding highlight out of the shared CodeEditor into a
self-contained VectorEmbeddingHighlight component (styles + detection +
decoration logic) so it can grow independently. CodeEditor and
useQueryEditor are no longer touched by embedding concerns; the component
is rendered next to the editor in Workbench and Vector Search.

Also move the VectorEmbeddingMark/VectorEmbeddingFormat types into a
dedicated vectorEmbeddingUtils.types.ts and trim non-essential comments.

References: #RI-8317
@dantovska
dantovska force-pushed the fe/feature/RI-8317/detect-large-vector-embeddings branch from 5a9bf1b to 5a97a26 Compare July 20, 2026 10:51
@dantovska dantovska removed the AI-Made label Jul 20, 2026
- i18n the embedding hover tooltip (en/bg) instead of a hardcoded
  English string, and stop exposing the raw format enum to users
- extract a buildMark helper to remove duplication between the two
  detection branches
- keep style import last and trim the highlight barrel to a single export

References: #RI-8317
@dantovska
dantovska force-pushed the fe/feature/RI-8317/detect-large-vector-embeddings branch from 5a97a26 to 5952bbb Compare July 20, 2026 11:00
Drop the border; keep just a neutral greyish background with a small
radius behind detected embeddings.

References: #RI-8317
@dantovska
dantovska marked this pull request as ready for review July 20, 2026 12:09
@dantovska
dantovska requested a review from a team as a code owner July 20, 2026 12:09

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 221b066167

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread redisinsight/ui/src/utils/monaco/vectorEmbeddingUtils.ts
PARAMS <nargs> counts the tokens that follow (each name and value), not
name/value pairs, so the PARAMS lookup must iterate nargs / 2 pairs.
Using nargs directly walked past the params list on multi-param queries
and could stamp a bogus paramName on an embedding outside PARAMS. Add
regression tests for multi-param and trailing non-param blobs.

References: #RI-8317
--monaco-color-bg: ${bgColor};
--monaco-color-params: ${colors.text.discovery200};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😀

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