Skip to content

RI-8162: load sample vector set#5934

Open
dantovska wants to merge 11 commits into
mainfrom
fe/feature/RI-8162/load-sample-vector-set
Open

RI-8162: load sample vector set#5934
dantovska wants to merge 11 commits into
mainfrom
fe/feature/RI-8162/load-sample-vector-set

Conversation

@dantovska
Copy link
Copy Markdown
Contributor

@dantovska dantovska commented May 18, 2026

What

  • Enable the Load sample dataset option on the Add Key → Vector Set form. Selecting it swaps the manual element-entry inputs for a hardcoded Preview + Info panel, auto-fills the key name with vec2word, and locks it.
  • On submit, the existing useLoadData hook hits POST /bulk-actions/import/vector-collection with { collectionName: "vec2word" } — same path bikes/movies use. Pre-flights with a KEY_INFO check so an already-loaded vec2word shows an info toast instead of re-running VADD.
  • Adds an optional keyNameDisabled prop on AddKeyCommonFields so subforms can lock the parent-owned key-name input from the outside.
Light Dark
image image

Testing

  1. Open Add Key → Vector Set, pick Load sample dataset → key name auto-fills to vec2word, input locks, preview + info panel renders.
  2. Click Add Key → key list refreshes with the new vec2word vector set; in redis-cli, VCARD vec2word100, VEMB vec2word king → 300 floats.
  3. Click Add Key again → info toast "Sample dataset already loaded" appears, no second import.
  4. Switch back to Create manually → key name clears and unlocks.

Note

Medium Risk
Adds a new sample-dataset creation path that triggers bulk import API calls and modifies Add Key form state, which could affect key creation UX and list refresh behavior if edge cases or API errors occur.

Overview
Enables a new "Load sample dataset" mode when creating a Vector Set key, swapping the manual element-entry form for a preview/info panel and auto-setting the key name to the fixed vec2word value.

Submitting in sample mode now preflights for an existing vec2word key, runs the bulk import via useLoadData, splices the created key into the browser key list, and shows success/info/error toasts; manual mode continues to dispatch addVectorSetKey.

Adds a keyNameDisabled capability to AddKeyCommonFields so subforms (Vector Set sample mode) can lock the shared key-name input, plus related styling and expanded test coverage for the new flows.

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

@dantovska dantovska self-assigned this May 18, 2026
@dantovska dantovska requested a review from a team as a code owner May 18, 2026 14:53
@jit-ci
Copy link
Copy Markdown

jit-ci Bot commented May 18, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

} catch {
dispatch(addMessageNotification(loadSampleDatasetFailedNotification()))
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Button not disabled during async preflight check

Medium Severity

The submitSampleDataset function performs an async checkVec2WordExists call before invoking loadSampleDataset. The button's disabled/loading state is driven by isLoadingSampleDataset, which only becomes true once loadSampleDataset starts executing. During the preflight checkVec2WordExists network call, the button remains fully clickable, allowing repeated clicks to spawn concurrent submissions that could both pass the existence check and trigger duplicate bulk imports. The analogous useCreateIndexFlow in vector-search avoids this by setting a local loading state at the very start of its async flow.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 98c5472. Configure here.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a38f7ef. Configure here.

dantovska added 8 commits May 19, 2026 09:52
Add an optional `keyNameDisabled` prop on AddKeyCommonFields that ORs
into the existing `loading` gate on the key-name TextInput, and hoist a
matching `keyNameDisabled` state in the parent AddKey form so subforms
can lock the input from the outside (used by the upcoming vector-set
"Load sample dataset" flow).
New presentational component that renders the two-column "Preview + Info"
panel for the bundled vec2word dataset (three example entries on the
left, dataset metadata on the right). All data is hardcoded per the
spec. Co-locates the `vec2word` collection-name constant, the
already-loaded / failure toast factories, and a `checkVec2WordExists`
helper that issues a single KEY_INFO request and returns whether the
key is already present in the connected database. Component is not yet
consumed; wiring lands in a follow-up commit.
Render the LoadSampleDataset panel in place of the manual element form
when the user selects "Load sample dataset" mode, and branch the submit
handler so it pre-flights with `checkVec2WordExists` then calls
`useLoadData.load(_, 'vec2word')` instead of `addVectorSetKey`. On
success: close the dialog. On existing key: surface the info toast.
On failure: surface the danger toast. The component drives the
parent-owned key-name input via the new `setKeyName` / `setKeyNameDisabled`
callbacks — Sample mode populates 'vec2word' and locks the input,
Manual / unmount-from-Sample clears + unlocks it.
Remove the `disabled: true` flag from the Sample populate-mode option so
the user can actually select it. With the integration from the previous
commit, clicking it now swaps the form to the LoadSampleDataset panel,
auto-fills the key name, locks the input, and routes submit through the
bulk-actions import endpoint.
…n checks

The action creator is a plain slice reducer (not a thunk), so we don't
need to mock the module to assert it was dispatched — `mockedStore`
already records every dispatched action. Inspect the actions list for
the expected `notifications/addMessageNotification` payload instead,
removing one of the four jest.mock setups at the top of the spec.

The three remaining mocks are kept:
- `addVectorSetKey` (thunk — needs synthetic action so we can assert args)
- `useLoadData` (hook — needs controllable resolve/reject)
- `checkVec2WordExists` (helper — needs controllable resolve true/false)
The KEY_INFO pre-flight only verifies that a key with the target name
exists — not that it holds the bundled sample dataset. The previous
"Sample dataset already loaded" title overstated what we know. Use a
generic "Key already exists" instead and rename the helper to match
(`loadSampleDatasetAlreadyExistsNotification` → `keyAlreadyExistsNotification`).
@dantovska dantovska force-pushed the fe/feature/RI-8162/load-sample-vector-set branch from a38f7ef to b13f3c8 Compare May 19, 2026 06:55
valkirilov
valkirilov previously approved these changes May 19, 2026
Copy link
Copy Markdown
Member

@valkirilov valkirilov left a comment

Choose a reason for hiding this comment

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

=

dantovska added 2 commits May 19, 2026 10:15
…ta load

After a successful bulk-import of the vec2word dataset, dispatch
`loadKeys()` so the Browser key list refreshes and the new key shows up
immediately (matching how the default sample-data flow behaves on a
blank database). Also dispatch a green success toast — "Sample dataset
loaded" — so the user gets explicit confirmation rather than just the
Add Key panel closing silently.
Title: "Sample dataset loaded" → "Sample vector set added"
Body:  "The 'vec2word' vector set is ready to query."
    →  "The 'vec2word' sample vector set has been successfully added."
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 19, 2026

Code Coverage - Frontend unit tests

St.
Category Percentage Covered / Total
🟢 Statements 82.86% 24696/29806
🟡 Branches 68.04% 10362/15229
🟡 Functions 78.08% 6678/8553
🟢 Lines 83.31% 24112/28942

Test suite run success

6964 tests passing in 802 suites.

Report generated by 🧪jest coverage report action from baf9448

`loadKeys` is a reducer that only flips `state.loading = true` — without
a paired `loadKeysSuccess` it leaves the Browser progress bar stuck on.
Switch to `addKeyIntoList({ key, keyType: KeyTypes.VectorSet })`, the
same primitive `addTypedKey` uses for every manual key creation. It's
filter/search/view-aware, prepends the new key into the in-memory list
synchronously, and never triggers a fetch — no spinner, instant.
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