feat(editor): warn on app exit when query editors have unsaved changes (#121)#135
Conversation
#121) Closes #121. Intercept window close (X / Alt+F4 / Cmd+Q) via `getCurrentWindow().onCloseRequested` and, when any query tab is dirty, preventDefault and show a confirm dialog listing the dirty tab names. Discard → `window.destroy()`. Cancel → keep the app open. Dirty detection is a new pure helper `src/utils/editorDirty.ts` keyed off a per-tab `originalQuery` snapshot — set on tab creation and refreshed on Ctrl+S save. Untitled+empty tabs stay clean; untitled tabs with typed content are dirty; saved tabs are dirty iff text diverges.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Closes #121.
Summary
Currently, closing the app window (X / Alt+F4 / Cmd+Q) with typed-but-unsaved query content silently discards the work. This adds an "Unsaved queries" confirm dialog that lists the dirty tabs by name and offers Discard / Cancel before letting the window die.
src/utils/editorDirty.tswith 8 Vitest cases covering untitled+empty (clean), untitled+content (dirty), saved+unmodified (clean), saved+modified (dirty), plus legacy-undefinedoriginalQueryfallback and whitespace-sensitivity.originalQuery: stringtoQueryTab(insrc/components/layout/MainContent.tsx). Set when the tab is created inaddNewTaband refreshed when the active tab is saved via Ctrl+S. Empty-tab default keeps blank tabs clean.useEffectinMainContentlazy-imports@tauri-apps/api/window'sgetCurrentWindow().onCloseRequested(...),event.preventDefault()s when there are dirty tabs, and routes through the existinguseConfirmDialog(already in the provider tree). Discard →window.destroy(). Cancel → no-op.Design constraints (scope-check)
These are deliberately fixed for this PR — see my reply on #121:
Test plan
Pure-function coverage runs in CI:
npm test(137/137 passing including 8 neweditorDirtytests)npx tsc --noEmit(clean)Manual verification (couldn't run
npm run tauri devreliably in this worktree — maintainer please confirm in a local dev build):Follow-ups (not in this PR)
originalQuerynow snapshotted per tab, an autosave timer can update it on every persistence cycle and the prompt naturally degrades to "no autosaved tabs are dirty".