Skip to content

fix(id/web): cancel() disposes AutoSaveManager — no saves after editor close (#2437) - #5042

Merged
dezren39 merged 1 commit into
mainfrom
queue/7942-2437-autosave-cancel-guard
Nov 3, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/7942-2437-autosave-cancel-guard

Conversation

@dezren39

@dezren39 dezren39 commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Fixes #2437.

AutoSaveManager.cancel() cleared timers but did nothing about a save already in flight: its completion could schedule a rate-limit retry, run the coalesced follow-up save, and write the shared #save-btn indicator — all after the editor closed and the manager was dropped. Because saveFile() resolves its target from live app state, that post-cancel save acts on the newly opened document and breaks the #1440 one-save-in-flight serialization.

Change (manager lifecycle only — no main.ts change needed)

  • New disposed flag, set at the top of cancel().
  • onSaveResult() returns immediately when disposed: a completing in-flight save schedules nothing, flips no state, and writes no indicator.
  • triggerSave() returns immediately when disposed, so any timer callback or completion path still queued at cancel time can never start a save.

Tests (pkgs/id/web/src/auto-save.test.ts, fake timers + deferred saveFn, mirroring the issue's probe)

Verification

Queue: task 7942 (repo-health-code-pilot), lane code-o.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 3, 2026 17:33
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-03T17:33:36.887361Z
We couldn’t complete this review. Comment @codex review to try again.
54f5687 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 34 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f49562b6-ea31-4d21-afbf-5f4fbe27275b
Commits

Reviewing files that changed from the base of the PR and between 8e151e8 and 54f5687.

Files selected for processing: 2
  • pkgs/id/web/src/auto-save.test.ts
  • pkgs/id/web/src/auto-save.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@developing-today

Copy link
Copy Markdown
Contributor

Codex disposition (task 7942, lane code-o): the Codex code review on 54f5687 failed at 2026-11-03T17:33Z — the connector reports the account's Codex usage limits for code reviews are reached. There are no inline Codex findings on this PR (zero review comments), so there is nothing to fix or rebut; the failed-review summary is the whole of it. CodeRabbit completed NEUTRAL with no inline comments. Proceeding on the strength of the local verification in the PR body (10/10 targeted tests with the fix; exactly the 3 new tests fail without it).

@dezren39
dezren39 merged commit 18797f2 into main Nov 3, 2026
2 checks passed
@dezren39
dezren39 deleted the queue/7942-2437-autosave-cancel-guard branch November 3, 2026 17:39
@developing-today

Copy link
Copy Markdown
Contributor

Salvage note (protocol §8) — duplicate PR #3434 diffed against this merged PR: PR #3434 (queue/5325-2437-autosave-cancel-fix, opened 2026-11-01 by task 5325) implements the same fix for issue #2437: a disposed flag with guards in onSaveResult() and triggerSave(), and the same three cancel-during-flight test scenarios. I read its full diff before closing it. The only delta beyond what merged here is defense-in-depth: additional disposed early-returns in onContentChange(), onNewVersion(), saveNow(), updateIndicator() (with disposed set at the end of cancel(), after its own indicator reset), and indicator-write assertions in all three of its tests instead of one. Salvage judgment: nothing required is unique to PR #3434. After cancel() the owner drops the manager (closeEditor() in main.ts), cancel() clears every timer, and no code path calls the dropped manager again, so those entry-point guards are unreachable in the app's lifecycle; the acceptance criteria for issue #2437 (no retry, no follow-up, no indicator writes from a completing in-flight save) are fully met by what merged here. The extra guards remain visible in PR #3434's diff if a future change ever resurrects a cancelled manager and wants them. PR #3434 is being closed as superseded by this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant