Open Schema and History queries in their own tab #10

Merged
claude-bot merged 1 commit from fix/schema-history-own-tab into main 2026-11-20 14:00:16 +00:00
Collaborator

Problem

The Schema tab buttons (▶ SELECT * LIMIT 100, SUMMARIZE, DESCRIBE) and History's ▶ Load & Run / Load into Editor called set_text on the active editor, replacing whatever document was open. #7 fixed the same problem for data file queries.

Fix

  • New open_generated_tab_in(buffers, title, sql, ...), shared by all generated queries:
    • It reuses an unsaved, unedited generated tab with the same title and replaces its text.
    • Otherwise it replaces the untouched start-up scratch buffer.
    • Otherwise it appends a new tab.
  • New SqlBuffer::is_generated marks tabs QryDuck created. User buffers are never reused, even when the title matches.
  • ResultsAction::RunQuickSql(sql) / ReplaceEditorSql(sql) became RunInTab { title, sql } / OpenInTab { title, sql }:
    • Schema buttons use <table>.sql.
    • History uses history.sql.
    • Data file queries (query_data_file) use the same helper.
  • Documented in AGENTS.md.

The only remaining set_text on a user document is :e reloading the file from disk.

Testing

  • cargo test passes (35 tests), including 3 new tests: edited generated tabs are never overwritten, a user buffer with the same title isn't reused, and the untouched scratch buffer is replaced.
  • Not yet checked by hand in the Windows GUI.

🤖 Generated with Claude Code

## Problem The Schema tab buttons (`▶ SELECT * LIMIT 100`, `SUMMARIZE`, `DESCRIBE`) and History's `▶ Load & Run` / `Load into Editor` called `set_text` on the active editor, replacing whatever document was open. #7 fixed the same problem for data file queries. ## Fix - New `open_generated_tab_in(buffers, title, sql, ...)`, shared by all generated queries: - It reuses an unsaved, unedited generated tab with the same title and replaces its text. - Otherwise it replaces the untouched start-up scratch buffer. - Otherwise it appends a new tab. - New `SqlBuffer::is_generated` marks tabs QryDuck created. User buffers are never reused, even when the title matches. - `ResultsAction::RunQuickSql(sql)` / `ReplaceEditorSql(sql)` became `RunInTab { title, sql }` / `OpenInTab { title, sql }`: - Schema buttons use `<table>.sql`. - History uses `history.sql`. - Data file queries (`query_data_file`) use the same helper. - Documented in `AGENTS.md`. The only remaining `set_text` on a user document is `:e` reloading the file from disk. ## Testing - `cargo test` passes (35 tests), including 3 new tests: edited generated tabs are never overwritten, a user buffer with the same title isn't reused, and the untouched scratch buffer is replaced. - Not yet checked by hand in the Windows GUI. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The Schema tab buttons (SELECT * LIMIT 100, SUMMARIZE, DESCRIBE) and
History's Load & Run / Load into Editor replaced the active document's
text. Schema queries now open in a tab named after the table (e.g.
users.sql) and History in a history.sql tab, using the same generated
tab logic as data file queries (open_generated_tab_in).

Generated tabs are marked with SqlBuffer::is_generated and are reused
for the next query with the same title only while unsaved and
unedited. User buffers are never reused, even with a matching title.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude-bot deleted branch fix/schema-history-own-tab 2026-11-20 14:00:17 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
daniel/qry-duck!10
No description provided.