Skip to content

Add multiple editor tabs with independent connections (#14)#31

Open
muk2 wants to merge 1 commit intomainfrom
feature/issue-14-editor-tabs
Open

Add multiple editor tabs with independent connections (#14)#31
muk2 wants to merge 1 commit intomainfrom
feature/issue-14-editor-tabs

Conversation

@muk2
Copy link
Owner

@muk2 muk2 commented Feb 19, 2026

Summary

  • Refactors App to support multiple editor tabs via a new EditorTab struct, each with its own editor buffer, database connection, query results, sidebar state, and query history
  • Adds a tab bar (visible when 2+ tabs exist) showing connection status indicator and database name for each tab
  • Supports keyboard shortcuts: Ctrl+T (new tab), Ctrl+W (close tab), Alt+Left/Right (cycle tabs), Alt+1..9 (jump to tab N)

Changes

  • src/ui/app.rs: Created EditorTab struct encapsulating per-tab state; refactored App to hold Vec<EditorTab> and active_tab; added tab()/tab_mut() accessors; added new_tab()/close_tab()/next_tab()/prev_tab() methods; updated all input handlers and business logic to use tab-based state
  • src/ui/components.rs: Added draw_tab_bar() function; updated layout to conditionally include tab bar row; updated all rendering functions to read from app.tab() instead of direct app.* fields; added tab shortcuts to help overlay; added tab position to status bar

Design Decisions

  • Per-tab state extracted into EditorTab to cleanly separate concerns
  • Connection dialog remains shared (one dialog at a time) but connects to the active tab
  • Tab bar only shows when there are 2+ tabs to avoid wasting space in single-tab mode
  • Closing the last tab replaces it with a fresh empty tab (never zero tabs)
  • Esc in connection dialog for an unconnected tab with other tabs open closes the tab instead of quitting

Test plan

  • cargo check passes
  • cargo clippy passes with no warnings
  • cargo fmt produces no changes
  • All 124 tests pass
  • Manual testing: Ctrl+T creates new tab with connection dialog
  • Manual testing: Connect different databases in different tabs
  • Manual testing: Alt+Left/Right and Alt+1..9 switch tabs
  • Manual testing: Ctrl+W closes tab, last tab creates fresh one
  • Manual testing: Tab bar shows correct connection indicators

Closes #14

🤖 Generated with Claude Code

Refactors App to support multiple tabs, each with its own editor
buffer, database connection, query results, and sidebar state.

Features:
- EditorTab struct encapsulates per-tab state (connection, editor,
  results, sidebar, query history)
- Tab bar renders above main content when multiple tabs exist,
  showing connection indicator (●/○) and database name
- Ctrl+T creates a new tab, Ctrl+W closes current tab
- Alt+Left/Right cycles between tabs
- Alt+1..9 jumps directly to tab N
- Each tab maintains independent connection and schema browser
- Closing last tab replaces it with a fresh empty tab
- Esc in connection dialog closes empty tab if other tabs exist
- Status bar shows current tab position (Tab N/M)

Closes #14

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Feature: Multiple editor tabs with separate connections

1 participant