Skip to content

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

Open
xiajingg wants to merge 1 commit into
redis:mainfrom
xiajingg:feat/db-index-dropdown
Open

xiajingg wants to merge 1 commit 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.tstestConnection() 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.tsxNumericInputRiSelect.
  • 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 responses now include a JSON body (behavior change for API clients), and the server performs an extra Redis read after each successful test.

Overview
Replaces free-form logical database index entry with select pickers in the connection form and instance header, so users only choose indexes the server actually exposes.

API: POST /databases/test and POST /databases/test/:id now return RedisDatabaseInfoResponse | null instead of an empty body. After a successful test, DatabaseService opens a short-lived Redis client via getConnectionInfo() to read general instance info (especially databases); failures there are logged and return null without failing the test. Sentinel autodiscovery still returns null instead of throwing.

UI: testInstanceConnection returns { success, data }; testConnectionSuccess merges that payload into instanceInfo so the form can size options before save. DbIndex and InstanceHeader build db0dbN-1 options from reported databases, with 16 as the pre-test default. The header uses pending state on the select while checkDatabaseIndexAction runs.

Tests: New DbIndex.spec.tsx; instances slice tests updated for the new testConnectionSuccess payload.

Reviewed by Cursor Bugbot for commit 1d9eca9. 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.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 1d9eca9. Configure here.

const id = useGenerateId('', ' over db')

const databasesCount =
databases && databases > 0 ? databases : DEFAULT_DATABASES_COUNT

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Form picker uses wrong database count

High Severity

The connection form picker reads databases from connectedInstanceInfoSelector, which is the currently connected instance’s instanceInfo and is never cleared when opening add or edit. A previous connection’s count is used instead of the documented fallback of 16, so the list can omit valid indexes or include ones the target server does not have. Testing another host also merges into that same global field, so a later form still shows the last test’s count.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1d9eca9. Configure here.

await this.databaseFactory.createDatabaseModel(sessionMetadata, database);

return;
return await this.getConnectionInfo(sessionMetadata, database);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Info fetch uses unresolved database model

Medium Severity

testConnection discards the model returned by createDatabaseModel and hands the original config to getConnectionInfo. That factory call resolves credentials onto a new object for Azure Entra ID and access-key strategies, so the follow-up client is created without those credentials. The info read is swallowed, and the picker never receives the real database count after a successful test.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1d9eca9. Configure here.

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