Skip to content

Clear stored file handle when autosave is denied#593

Merged
tracygardner merged 1 commit into
mainfrom
codex/fix-save-prompt-behavior-on-cancel
Apr 30, 2026
Merged

Clear stored file handle when autosave is denied#593
tracygardner merged 1 commit into
mainfrom
codex/fix-save-prompt-behavior-on-cancel

Conversation

@tracygardner
Copy link
Copy Markdown
Contributor

@tracygardner tracygardner commented Apr 30, 2026

Motivation

  • Prevent repeated autosave failures when the File System Access API permission is revoked or user cancels the save operation.
  • Ensure the UI state is consistent by dropping the stored FileSystemFileHandle after a permission-related autosave error.

Description

  • Added a helper isFileAutosavePermissionError(error) that detects permission/abort/denied/cancel errors from the File System Access API.
  • Updated autoSaveToFile error handling to call clearFileHandle() when a permission-related error is detected so autosave will stop targeting an invalid handle.

Testing

  • Ran the automated test suite with npm test and linting with npm run lint, and all checks passed.

Codex Task

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced autosave functionality to better handle file permission and access errors, preventing repeated failed save attempts and improving reliability when files become inaccessible.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a6ff82fc-b7c2-449b-933b-a91ffe12cba3

📥 Commits

Reviewing files that changed from the base of the PR and between 2411051 and 0e269e8.

📒 Files selected for processing (1)
  • main/files.js

📝 Walkthrough

Walkthrough

Introduces error classification logic in autoSaveToFile to identify permission/abort errors and clear invalid file handles when they occur, preventing repeated autosave attempts against blocked file access.

Changes

Cohort / File(s) Summary
Autosave Error Handling
main/files.js
Added predicate to classify permission/abort errors via error.name and lowercased message keywords; clears currentFileHandle when such errors occur to prevent repeated autosave failures against invalid handles while preserving existing console logging.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A handle blocked, no autosave today,
So clear it quick and keep errors at bay,
No more repeated knocks on a door,
Just handle the halt and try nevermore! 📝✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly and clearly summarizes the main change: clearing a stored file handle when autosave permission is denied, which matches the primary objective of preventing repeated autosave failures.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-save-prompt-behavior-on-cancel

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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying flockxr with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0e269e8
Status: ✅  Deploy successful!
Preview URL: https://88806c7d.flockxr.pages.dev
Branch Preview URL: https://codex-fix-save-prompt-behavi.flockxr.pages.dev

View logs

@tracygardner tracygardner merged commit c5fce28 into main Apr 30, 2026
9 checks passed
tracygardner added a commit that referenced this pull request May 4, 2026
…vior-on-cancel

Clear stored file handle when autosave is denied
@tracygardner tracygardner deleted the codex/fix-save-prompt-behavior-on-cancel branch May 6, 2026 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant