Skip to content

feat(connections): add environment label to saved connections - #515

Open
maximumbreak wants to merge 3 commits into
TabularisDB:mainfrom
maximumbreak:feat/connection-environment-label
Open

feat(connections): add environment label to saved connections#515
maximumbreak wants to merge 3 commits into
TabularisDB:mainfrom
maximumbreak:feat/connection-environment-label

Conversation

@maximumbreak

Copy link
Copy Markdown
Contributor

Demo

Screen.Recording.2569-07-23.at.07.14.58.mov

Summary

  • Add an optional environment field to saved connections (local, development, testing, staging, uat, production, or a free-form custom name) via a dropdown on the General tab of the connection form.
  • Custom values are remembered and suggested across connections (scanned from existing saved connections, no separate storage).
  • Show the active environment as a [environment] suffix on every window-title path: the main window title, the Editor page's own title effect (tab/split-view aware), and the standalone ER/schema diagram window.
  • Show the environment on the Explorer sidebar header once connected, and as a plain badge on each connection's card/row in the connections dashboard (grid and list view).
  • Purely a display label — no color-coding and no confirmation/safety behavior (e.g. for production) is tied to it.

Test plan

  • cargo check / cargo test --lib (backend, incl. new serde roundtrip + backward-compat tests)
  • tsc -b --noEmit (frontend types)
  • pnpm vitest run — full suite passes (3069 tests), incl. new tests/utils/environments.test.ts

maximumbreak and others added 3 commits July 22, 2026 20:30
Lets a connection be tagged with an environment (local, development,
testing, staging, uat, production, or a free-form custom name) from
the General tab of the connection form. The active environment is
shown as a suffix on the OS window title and the Explorer sidebar
header once connected, and as a plain badge on each connection's
card/row in the connections dashboard. Purely a display label — no
color-coding or destructive-query safeguards are tied to it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The window title was only patched in DatabaseProvider's title effect,
but two other title-setting spots were missed: the Editor page runs
its own more specific title effect (reacting to tab/split-view
changes) that overwrites it, and the standalone ER/schema diagram
window sets its title once at creation with no environment support.
Both now include the same "[environment]" suffix.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
const activeDriver = activeData?.driver ?? null;
const activeCapabilities = activeData?.capabilities ?? null;
const activeConnectionName = activeData?.connectionName ?? null;
const activeEnvironment = activeData?.environment ?? null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WARNING: activeEnvironment derives from connectionDataMap, which is only populated during connect. When a connection's environment is edited and saved, loadConnections refreshes the connections list but not connectionDataMap, so the window title and sidebar header show the stale environment until the connection is disconnected and reconnected.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

const [dbSearchQuery, setDbSearchQuery] = useState("");
const [detectJsonInTextColumns, setDetectJsonInTextColumns] = useState(false);
// "" = none, one of ENVIRONMENT_PRESETS, or "custom" (free text in environmentCustomValue)
const [environmentPreset, setEnvironmentPreset] = useState("");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WARNING: These new environment states are reset when the modal opens, but handleDriverChange does not reset them. When switching from edit mode to a new connection via the catalogue without closing the modal, stale environment values persist and can be accidentally saved to the original connection.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

{t("newConnection.environment", { defaultValue: "Environment" })}
</label>
<Select
value={environmentPreset || null}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SUGGESTION: value={environmentPreset || null} converts "" to null, which prevents the "None" option from being highlighted in the Select dropdown (the component compares value === option).

Suggested change
value={environmentPreset || null}
value={environmentPreset}

Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
WARNING 2
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
src/contexts/DatabaseProvider.tsx 80 activeEnvironment derives from connectionDataMap, which is only populated during connect. When a connection's environment is edited and saved, loadConnections refreshes the connections list but not connectionDataMap, so the window title and sidebar header show the stale environment until reconnect.
src/components/modals/NewConnectionModal.tsx 319 New environment states are reset on modal open, but handleDriverChange does not reset them. Switching from edit mode to a new connection via the catalogue without closing the modal leaves stale environment values that can be accidentally saved to the original connection.

SUGGESTION

File Line Issue
src/components/modals/NewConnectionModal.tsx 2206 `value={environmentPreset
Files Reviewed (17 files)
  • src/utils/environments.ts - New file
  • src/contexts/DatabaseContext.ts
  • src/contexts/DatabaseProvider.tsx
  • src/pages/Editor.tsx
  • src/components/layout/ExplorerSidebar.tsx
  • src/components/connections/ConnectionCard.tsx
  • src/components/connections/ConnectionListItem.tsx
  • src/components/modals/NewConnectionModal.tsx
  • src-tauri/src/commands.rs
  • src-tauri/src/models.rs
  • src-tauri/src/connection_cache_tests.rs
  • src-tauri/src/connection_import/analyzer.rs
  • src-tauri/src/connection_import/convert.rs
  • src-tauri/src/connection_import/tabularis.rs
  • src-tauri/src/export_import_tests.rs
  • src/i18n/locales/en.json
  • tests/utils/environments.test.ts

Fix these issues in Kilo Cloud


Reviewed by step-3.7-flash · Input: 203.4K · Output: 41.6K · Cached: 3.3M

@maximumbreak
maximumbreak force-pushed the feat/connection-environment-label branch from 8918e52 to 79df2ad Compare July 23, 2026 03:06
@debba

debba commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Hey @maximumbreak ,
looks very similar to #473 ,
Will review both ASAP

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