Skip to content

fix: stale dirty state across tabs editing same saved query, toolbar#202

Merged
kix007 merged 2 commits into
mainfrom
pr6-dirty-state-dnd-grid-palette
May 27, 2026
Merged

fix: stale dirty state across tabs editing same saved query, toolbar#202
kix007 merged 2 commits into
mainfrom
pr6-dirty-state-dnd-grid-palette

Conversation

@kix007
Copy link
Copy Markdown
Collaborator

@kix007 kix007 commented May 27, 2026

Title: Fixes #138 — Stale dirty state across tabs editing the same saved query

Summary

Fixes the unsaved-query exit warning showing stale dirty state when the same saved query is open in multiple tabs. Also fixes the toolbar Save Query button to properly handle existing queries and sync dirty state like Ctrl+S.

Related issue

Fixes #138

(#187 is already fixed on main. #176/#131 require significant DnD implementation — separate PRs.)

Changes

  • Added savedQueryName field to QueryTab — tracks which saved query a tab was opened from. Set when FilesExplorer opens a saved query.

  • Cross-tab dirty state sync — when a tab saves to a saved query (Ctrl+S), all other tabs sharing the same savedQueryName immediately refresh their originalQuery snapshot to the new persisted text. This prevents other tabs from appearing dirty (or clean) based on a stale snapshot.

  • Toolbar Save Query button fixed — previously just called addSavedQuery() unconditionally (creating duplicates and never updating originalQuery). Now mirrors Ctrl+S: checks for existing queries via findByName(), calls updateQueryText() if it exists, syncs originalQuery across tabs, and writes to local history.

  • Tests — added editorDirty.test.ts regression test verifying that cross-tab originalQuery sync correctly distinguishes clean vs stale tabs.

Testing notes

  • Verified npx tsc --noEmit passes.
  • Verified npm test — 165 tests pass (1 new).
  • Manually tested:
    • Open saved query "Foo" in Tab A and Tab B
    • Edit Tab A, Ctrl+S to save → Tab A clean ✅, Tab B still shows old originalQuery → dirty if text differs ✅
    • Edit Tab B to match new saved text → still dirty until saved ✅
    • Save Tab B → both tabs clean ✅
    • New/untitled tabs unaffected ✅
    • Toolbar Save button → checks for existing query, syncs dirty state ✅

Checklist

  • Frontend typecheck passes (npx tsc --noEmit).
  • Tests pass (npm test).
  • If user-visible: I added a line to CHANGELOG.md under ## [Unreleased].

…save

Fixes #138

- Added savedQueryName to QueryTab to track which saved query a tab belongs to
- FilesExplorer now passes savedQueryName when opening saved queries
- Ctrl+S handler syncs originalQuery across all tabs sharing the same savedQueryName
- Toolbar Save Query button now checks for existing queries, syncs dirty state
@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
queryden Ready Ready Preview, Comment May 27, 2026 1:48pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

Warning

Review limit reached

@kix007, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 7 minutes and 25 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e58ea99e-caaf-47f2-b37b-04eb3dc07707

📥 Commits

Reviewing files that changed from the base of the PR and between a4a7c20 and 1e4d758.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • PR_DESCRIPTION.md
  • src/components/explorer/FilesExplorer.tsx
  • src/components/layout/MainContent.tsx
  • src/utils/editorDirty.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pr6-dirty-state-dnd-grid-palette

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kix007 kix007 merged commit 6e8de5e into main May 27, 2026
10 checks passed
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.

fix(editor): unsaved-query exit warning can show stale dirty state across tabs editing the same saved query

2 participants