Skip to content

feat: multi-tab query editor#413

Open
shaunpatterson wants to merge 1 commit into
dgraph-io:mainfrom
shaunpatterson:sp/multi-tab-editor
Open

feat: multi-tab query editor#413
shaunpatterson wants to merge 1 commit into
dgraph-io:mainfrom
shaunpatterson:sp/multi-tab-editor

Conversation

@shaunpatterson

Copy link
Copy Markdown
Contributor

What

Adds browser-style tabs to the query editor: a slim tab strip above the editor toolbar with per-tab query text, query/mutate action, and query variables. + adds a tab, × closes one (hidden when only one tab remains), double-click renames inline (Enter/blur commits, Escape cancels).

Design

The existing top-level query/action/queryVars/allQueries fields in the query reducer remain the live state for the active tab, so every existing consumer — EditorPanel, frames actions, history loading via updateQueryAndAction — works unchanged. Switching tabs saves the live fields into the departing tab and loads the target's. The reducer also syncs the active tab's snapshot on every action, so loading a query from history updates the active tab and persisted snapshots are never stale.

  • Persistence/migration: the query slice is already redux-persist-whitelisted. Legacy persisted state (no tabs) hydrates into a single "Query 1" tab seeded from the current fields via an unconditional reducer guard, so old state can never crash; a dangling activeTabId is repaired the same way.
  • Closing the active tab activates its neighbor; closing the last tab resets to one empty tab; per-tab allQueries keeps the query/mutate text memory isolated between tabs.
  • Tab ids come from the existing uuid dependency (same pattern as frames).

Testing

15 reducer tests (~45 assertions) through real action creators: add/switch/close/rename, neighbor selection in both directions, close-last reset, unknown-id no-ops, empty-rename ignored, legacy migration (query and mutate mode), switch-preserves-edits, history loads targeting the active tab, counter numbering. npm run build passes.

🤖 Generated with Claude Code

Adds a tab strip above the query editor so multiple queries can be
drafted side by side. Tab state lives in the query reducer: the
existing top-level fields remain the live (active-tab) fields, and
switching tabs saves/restores them, so all existing consumers are
untouched. Legacy persisted state without tabs hydrates into a single
tab containing the current query.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@shaunpatterson shaunpatterson requested a review from a team as a code owner June 12, 2026 17:36
@shaunpatterson

Copy link
Copy Markdown
Contributor Author
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant