Skip to content

Add a logical database picker to the connection form and instance header - #6507

Open
xiajingg wants to merge 3 commits into
redis:mainfrom
xiajingg:feat/db-index-dropdown
Open

xiajingg wants to merge 3 commits into
redis:mainfrom
xiajingg:feat/db-index-dropdown

Conversation

@xiajingg

@xiajingg xiajingg commented Sep 19, 2026 •

Copy link
Copy Markdown

What

The logical database index had to be typed by hand — once in the connection
form, and again in the browser header — with no indication of how many
databases the server actually has.

Both places now use a select:

  • the connection form's Select Logical Database field is a select instead
    of a numeric input
  • the browser header replaces its inline number editor with the same select,
    so the index can be changed without reopening the connection form

The options come from the database count reported by the connection test
(databases in the connection info), so the list matches the server. Until a
connection has been tested, the default of 16 databases is used as a fallback.

Why

Typing the index makes it easy to pick a database that does not exist, and the
UI gives no hint of the valid range.

Changes

  • api/.../database.service.ts — testConnection() now returns the
    connection info instead of void, so the UI learns the real database count.
    A private getConnectionInfo() does the work.
  • api/.../database.controller.ts — the two connection-test endpoints return
    the info.
  • ui/.../form/DbIndex.tsx — NumericInput → RiSelect.
  • ui/.../instance-header/InstanceHeader.tsx — inline number editor →
    RiSelect.
  • ui/.../instancesService.ts, ui/.../slices/instances/instances.ts —
    plumb the connection info through.

Tests

  • DbIndex.spec.tsx (new, 5 cases): the control is a select rather than an
    input, the option count follows the reported database count, and the
    fallback is 16 when no connection has been tested.
  • slices/tests/instances — 176 tests pass.
  • npm run i18n:check, npm run lint:ui, npm run type-check — clean.

Screenshots

Connection form with the picker open (db0…db15, no db16):

db picker

The same control in the browser header (top left):

instance header


Note

Medium Risk
Connection-test API response shape changes and each successful test may open an extra Redis client; UI/state changes affect db index selection on connect and in the header but not auth or persistence logic.

Overview
Connection test endpoints now return Redis instance info (including logical databases count) instead of an empty success, via a follow-up getConnectionInfo read on a short-lived client after createDatabaseModel succeeds; failures to read info are swallowed and sentinel “master required” still yields null.

The UI replaces free-form numeric db index fields with RiSelect pickers in the manual connection form (DbIndex) and browser instance header, building options from the tested/connected instance’s database count (default 16 before test, 1 for cluster). Redux adds testedInstanceInfo (cleared on new tests and when opening the connection form) so unsaved connection tests don’t mix with the connected instance’s instanceInfo.

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

The database index had to be typed by hand, both in the connection form and again in the browser header, with no way to tell how many databases the server actually has.

Both places now use a select instead:
- the connection form's 'Select Logical Database' field is a select rather than a numeric input
- the browser header replaces its inline number editor with the same select, so the index can be changed without reopening the connection form

The options come from the database count reported by the connection test, so they match the server. Until a connection has been tested the default of 16 databases is used as a fallback.
@xiajingg
xiajingg requested a review from a team as a code owner September 19, 2026 08:13
@CLAassistant

CLAassistant commented Sep 19, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cursor cursor 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.

Stale Bugbot comment from a previous run.

Comment thread redisinsight/ui/src/pages/home/components/form/DbIndex.tsx Outdated
Comment thread redisinsight/api/src/modules/database/database.service.ts Outdated

@cursor cursor 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.

Stale Bugbot comment from a previous run.

Comment thread redisinsight/ui/src/pages/home/components/form/DbIndex.tsx
Comment thread redisinsight/ui/src/pages/home/components/form/DbIndex.tsx Outdated
…nto the connected instance

Two problems reported by the automated review of the logical database picker:

- `createDatabaseModel` resolves the credentials onto the model it returns and leaves the caller object untouched, so `getConnectionInfo` built its client from an object without the resolved credentials (Azure Entra ID, access keys) and the info read failed silently.
- `DbIndex` took its database count from `connectedInstanceInfoSelector`, which describes the instance that is actually connected. The picker inherited the count of a previously connected server instead of falling back to 16, and testing a new server overwrote the connected instance info.

The test result now lives in its own `testedInstanceInfo` slice field, is cleared whenever a connection form opens, and `DbIndex` reads only that.
@xiajingg
xiajingg force-pushed the feat/db-index-dropdown branch from 10d32b1 to dbe4829 Compare September 29, 2026 03:18

@cursor cursor 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.

Stale Bugbot comment from a previous run.

Comment thread redisinsight/ui/src/components/instance-header/InstanceHeader.tsx Outdated
…d range

Follow-up on the review of the previous fix:

- The picker kept the selected index when the option list shrank after a connection test, so the form could submit a database the server does not have. The value is now clamped to the available options.
- A cluster reports no database count, so the picker fell back to the 16 offered before testing. Redis Cluster only implements db0, so it now offers exactly one option.
- The header used the reported count as a hard option list. That count can be a keyspace-derived lower bound, which hid the index the instance is connected to; the connected index is always kept in the list.

Also updates InstanceHeader.spec.tsx, which still targeted the removed inline number editor.

@cursor cursor 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.

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

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 1927f6f. Configure here.

if (selected >= databasesCount) {
formik.setFieldValue('db', databasesCount - 1)
}
}, [databasesCount])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Picker silently overwrites the selected index

Medium Severity

The new clamp rewrites db whenever it is at or above databasesCount. That count is a keyspace lower bound when CONFIG GET databases is denied, so a successful test (or the pre-test fallback of 16) can silently replace a chosen or cloned index with a smaller one. The header already keeps the current index in range; the form does not.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1927f6f. Configure here.

This branch has not been deployed

No deployments
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