Warn on window close with unsaved files, prompt to connect before querying #6

Merged
claude-bot merged 1 commit from feat/close-warning-and-connect-prompt into main 2026-11-19 13:08:34 +00:00
Collaborator

Stacked on #5. This branch is built on feat/per-document-results-tabs, so the diff also shows #5's commit until #5 is merged. Merge #5 first.

Unsaved changes on window close

  • QryDuckApp::update checks viewport().close_requested() every frame. If any buffer is_dirty(), it sends ViewportCommand::CancelClose and shows an Unsaved Changes modal listing the modified files: Save All & Quit, Quit Without Saving, Cancel.
  • Save All & Quit stays open if any save fails or an untitled buffer's Save As dialog is cancelled.
  • :qa / :quit / :quitall go through the same check. :qa! / :quit! / :quitall! quit without asking (EditorAction::QuitApp { force }).

Connect prompt before running a query

  • trigger_query holds the query back when no database file is connected and shows a No Database Connected modal:
    • the DuckDB files found in the workspace tree (collect_duckdb_files): click one to connect and run
    • Open Database File...: file picker, then connect and run
    • Create New Database...: the existing dialog, then the query runs on the new database
    • Run in Memory: runs in :memory: and doesn't ask again this session
    • Cancel
  • Direct data file queries (double-click or Query Data File on .parquet / .csv / .json) go through the new send_query and skip the prompt, since they are meant to run in memory.
  • Documented in AGENTS.md.

Testing

  • cargo test passes (23 tests), including new tests for the :qa / :qa! mapping and collect_duckdb_files.
  • The modals live in the eframe update loop and are not unit-tested. Not yet checked by hand in the Windows GUI.

🤖 Generated with Claude Code

> **Stacked on #5.** This branch is built on `feat/per-document-results-tabs`, so the diff also shows #5's commit until #5 is merged. Merge #5 first. ## Unsaved changes on window close - `QryDuckApp::update` checks `viewport().close_requested()` every frame. If any buffer `is_dirty()`, it sends `ViewportCommand::CancelClose` and shows an **Unsaved Changes** modal listing the modified files: `Save All & Quit`, `Quit Without Saving`, `Cancel`. - `Save All & Quit` stays open if any save fails or an untitled buffer's Save As dialog is cancelled. - `:qa` / `:quit` / `:quitall` go through the same check. `:qa!` / `:quit!` / `:quitall!` quit without asking (`EditorAction::QuitApp { force }`). ## Connect prompt before running a query - `trigger_query` holds the query back when no database file is connected and shows a **No Database Connected** modal: - the DuckDB files found in the workspace tree (`collect_duckdb_files`): click one to connect and run - `Open Database File...`: file picker, then connect and run - `Create New Database...`: the existing dialog, then the query runs on the new database - `Run in Memory`: runs in `:memory:` and doesn't ask again this session - `Cancel` - Direct data file queries (double-click or `Query Data File` on `.parquet` / `.csv` / `.json`) go through the new `send_query` and skip the prompt, since they are meant to run in memory. - Documented in `AGENTS.md`. ## Testing - `cargo test` passes (23 tests), including new tests for the `:qa` / `:qa!` mapping and `collect_duckdb_files`. - The modals live in the eframe update loop and are not unit-tested. Not yet checked by hand in the Windows GUI. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Results used to live in a single shared slot, so running a query from
another document replaced the previous document's results. Each SQL
buffer now gets a unique id that is passed through the engine with its
query and echoed back in QueryFinished. ResultsView keeps one tab per
source document: re-running replaces that document's tab, running from
a different document opens a new one. Each tab keeps its own filter,
sort, selected cell, column widths and scroll position. Switching
editor tabs brings that document's results forward, and tab titles
follow buffer renames.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closing the window (title bar, Alt+F4, :qa) with modified buffers now
cancels the close and shows an Unsaved Changes modal listing them, with
Save All & Quit, Quit Without Saving and Cancel. Save All stays open if
any save fails or a Save As dialog is cancelled. :qa! / :quit! skip the
warning.

Running a query with no database file connected no longer silently uses
the in-memory session. A No Database Connected modal offers the DuckDB
files in the workspace, Open Database File..., Create New Database...
(the query runs once connected), Run in Memory (don't ask again this
session) and Cancel. Direct data file queries still run in memory
without asking.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude-bot deleted branch feat/close-warning-and-connect-prompt 2026-11-19 13:08:34 +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!6
No description provided.