Skip to content

Add feature flag to control file autosave behavior#650

Merged
tracygardner merged 2 commits into
mainfrom
claude/bold-goldberg-EfUcw
May 22, 2026
Merged

Add feature flag to control file autosave behavior#650
tracygardner merged 2 commits into
mainfrom
claude/bold-goldberg-EfUcw

Conversation

@tracygardner
Copy link
Copy Markdown
Contributor

@tracygardner tracygardner commented May 22, 2026

Summary

Introduces a feature flag AUTOSAVE_TO_FILE_ENABLED to control whether the application automatically saves to the last explicitly-saved file. This allows the autosave-to-file feature to be toggled independently while keeping localStorage autosave unaffected.

Changes

  • Added AUTOSAVE_TO_FILE_ENABLED feature flag in config.js (currently set to false)
  • Updated main.js to conditionally call autoSaveToFile() only when the feature flag is enabled
  • Updated files.js to conditionally apply the "no-autosave" CSS class based on both the feature flag and file handle state
  • Updated imports in both main.js and files.js to include the new config constant

Implementation Details

  • The feature flag is exported from config.js and imported where needed
  • The autosave-to-file logic is now gated behind the flag while the 30-second interval continues to run
  • The save button state indicator now only shows the "no-autosave" styling when the feature is enabled AND no file handle exists
  • localStorage autosave remains unaffected by this flag

https://claude.ai/code/session_014wjCBspKVYjB9pi4UXdbNw

Summary by CodeRabbit

  • New Features

    • Added a feature flag to control autosaving to file behavior (currently disabled).
  • Chores

    • Updated save button state management to respect the new autosave configuration.
    • Modified autosave loop to conditionally save to file based on the feature flag.

Review Change Stack

claude added 2 commits May 22, 2026 17:51
Autosaving to the last explicitly-saved file now requires the
AUTOSAVE_TO_FILE_ENABLED flag. localStorage autosave is unchanged.

https://claude.ai/code/session_014wjCBspKVYjB9pi4UXdbNw
The export button's no-autosave indicator is only meaningful when
autosave-to-file is enabled, so suppress it when the flag is off.

https://claude.ai/code/session_014wjCBspKVYjB9pi4UXdbNw
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 22, 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: 870c5e0c-2f3f-42c9-81e1-d4922fddd7d6

📥 Commits

Reviewing files that changed from the base of the PR and between bc1d9ea and 02ff1c7.

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

📝 Walkthrough

Walkthrough

A feature flag AUTOSAVE_TO_FILE_ENABLED is introduced and set to false to control whether autosaving writes to the last explicitly-saved file. The flag is wired into the autosave loop to conditionally call autoSaveToFile() and into the button state logic to reflect autosave availability.

Changes

Autosave-to-file gating feature

Layer / File(s) Summary
Feature flag definition
config.js
New exported boolean AUTOSAVE_TO_FILE_ENABLED (defaulting to false) controls file autosave behavior without affecting localStorage autosave.
Autosave loop conditional gating
main/main.js
The 30-second autosave loop is updated to always call saveWorkspace() but conditionally call autoSaveToFile() only when the feature flag is truthy.
Save button state update
main/files.js
The updateSaveButtonState() function updates the no-autosave class toggle to check both AUTOSAVE_TO_FILE_ENABLED and currentFileHandle presence.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • flipcomputing/flock#593: This PR gates autoSaveToFile() calls based on the new flag, complementing #593's error handling that clears currentFileHandle on permission-denied or cancel errors.

Suggested labels

codex

Poem

🐰 A flag hops in to take the stage,
Autosave tamed on the feature page—
Write to workspace, skip the file,
localStorage keeps its gentle smile!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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 title accurately summarizes the main change: adding a feature flag to control file autosave behavior, which is the central objective of the PR.
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 claude/bold-goldberg-EfUcw

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.

@tracygardner tracygardner merged commit 035930e into main May 22, 2026
13 checks passed
@tracygardner tracygardner deleted the claude/bold-goldberg-EfUcw branch May 22, 2026 18:05
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.

2 participants