Skip to content

Editor tabs never become clean again once edited #855

Closed

Description

@EVWorth

Severity: P2.

A query tab's isDirty flag is set on the first edit and is never cleared afterwards. The unsaved-changes dot on the tab, the update guard (src/lib/update-guard.ts), the favorites check (QueryFavorites.tsx) and the new close confirmation (#843) all read this flag. So all of them treat a tab as unsaved for good after a single keystroke, even after its SQL has been saved to a file or to a favorite.

How to see it

$ grep -rn "setTabDirty" src --include='*.ts*' | grep -v __tests__
src/stores/editorStore.ts:36:  setTabDirty: (tabId: string, dirty: boolean) => void;
src/stores/editorStore.ts:185:  setTabDirty: (tabId, dirty) =>

setTabDirty exists, but nothing outside the tests calls it. updateContent (editorStore.ts:162) sets isDirty: true on every change.

Fix

  • Clear the flag wherever the tab's content becomes saved: Save / Save As to a file, and saving to a favorite.
  • Alternatively, define dirty as "content differs from the last saved content": keep a savedContent on the tab and compare against it, so undoing back to the saved text also counts as clean.

Found while fixing #843.

Activity

  1. EVWorth commented on Oct 23, 2026

    @EVWorth
    OwnerAuthor

    This also has the opposite effect. editor-session.ts:43 restores every tab with isDirty: false. The close confirmation from #843 (PR #856) only asks when isDirty is set. So after a restart, closing a tab whose SQL exists nowhere else gives no prompt.

    The fix should settle on one definition of "unsaved" and carry it across a restart. Persisting the saved content, as suggested above, would cover both cases.


    Generated by Claude Code

  2. added a commit that references this issue on Oct 29, 2026
    c74a002
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions