Skip to content

🤖 fix: a creation-draft delete retry deletes only the record it knew - #7722

Merged
ThomasK33 merged 7 commits into
mainfrom
fix/creation-draft-delete-retry-condition
Oct 29, 2026
Merged

ThomasK33 merged 7 commits into
mainfrom
fix/creation-draft-delete-retry-condition

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Summary

After a draft delete fails in one window, another window's saved draft text is no longer lost later. A delete retry (the backoff timer, or the resend on a new connection) now deletes the record only while it still holds what the deleting window last knew. The first delete stays unconditional, as delete()'s doc says.

Fixes #7719. Refs #7559.

Background

#7559 added the retry so a sent draft does not come back after a failed delete (#7551). The retry sent the same unconditional deleteCreation. So when window A's delete failed and window B then saved new text (confirmed, the record still existed), A's later retry deleted B's text with no error.

Implementation

  1. deleteCreation takes an optional ifStored: the whole record without its id. CreationDraftService.delete reads the record inside its file lock and keeps it when it differs. A kept record counts as done for the caller (no error, no further retry).
  2. Compared payload: every stored field except the id (projectPath, subProjectPath, createdAt, text, attachments, manualName, ai, intent, auto, execution). I chose the whole record, not the text, because window B can change any of those fields. Both sides go through the same parse as a read (staged attachments dropped, schema), and they compare in JSON form so an absent optional field equals an undefined one.
  3. CreationDraftStore keeps Entry.stored: the record as this window last knew it. A read sets it, and so does a save that landed or may have landed (a lost reply, recorded even when a delete already removed the entry). delete() takes it after the in-flight save settles. pendingDeletes maps each id to that snapshot and to whether its first request was sent. Only requests after the first one (backoff retries, resends on a new client) pass it as ifStored. A delete made while disconnected is still a first request on reconnect.
  4. No new persisted field. ifStored is a request field only.

A wrong snapshot fails safe: the retry keeps the record, which is the pre-#7559 behavior (the sent draft shows again in other windows, and the deleting window still hides it). The likely case is a retry after this window's own save lost its reply and did not land.

delete() waits until no save is in flight, including one that a running flush() starts. A second delete() of the same id keeps the first one's snapshot and sent flag.

Known limit

A window that never opened the draft (a sidebar Delete of an unopened row) has no snapshot. Its retries stay unconditional, exactly as on main, so #7551's retry still works there. In that narrow case, the retry can still remove a save that another window made after the failed first request. #7728 tracks it, with a server-side version in list rows and reads as the candidate fix.

Validation

  • Red on main: a delete retry does not remove text another window saved after the failed delete (backoff path) and a delete resent on reconnect does not remove settings another window saved meanwhile (resend path, B changes manualName only) both fail on main's store and service, with the record gone. Both pass with the fix.
  • a first delete removes the record whatever it holds (no condition) covers the unconditional first try, also from a window that never opened the draft. I checked by hand that it fails when the first try is made conditional.
  • Codex round 1 findings, each with a test that fails on the round-1 head: a delete made while disconnected is still a first delete on reconnect and a delete retry removes what a save racing the delete wrote (its reply lost).
  • Codex round 2 findings, each with a test that fails on the round-2 head: a second delete of the same draft keeps the first one's condition, a delete waits for every save a running flush starts and a failed delete of a draft this window never opened is retried (#7728).
  • The 🤖 bug: a creation draft whose delete fails comes back with the sent text (#6620 dropped the retry) #7551 retry tests still pass. One of them now saves an attachment first, so a snapshot with an attachment still matches the stored record.
  • make static-check, make lint-eslint and make dry-check pass. make mutate-check reports survivors (it warns, not blocks). In the new code, the ones left are the backoff count (attempt + 1, 0 -> 1) and a guard for a client present with no pending delete.

Risks

Low. Creation-draft deletes only (Send success and sidebar Delete). The first delete is unchanged, so the normal path behaves as before.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $241.16

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

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 ✅ Completed 2026-10-29T16:43:59.011584Z 3bea37c New commits
🔒 Security Review ✅ Completed 2026-10-29T17:00:43.917279Z 3bea37c Manual request
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ddd105ca9d

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e stories (Haiku): 14 passed

22 agent steps · 7 replayed from cache · 15 model calls · 46.5k tokens (24% cached)
Spend: $0.09 of the $1.00 cap (proxy ledger)

All 14 tests in 9 files
Test Agent Time
🟢 chatRestart.e2e.ts · 1 passed 1 step · 1 call 6.5s
🟢 a chat survives a restart of the server 1 step · 1 call 6.5s
🟢 compaction.e2e.ts · 1 passed 1 step · 1 call 4.4s
🟢 /compact replaces the old chat with a summary 1 step · 1 call 4.4s
🟢 pluginTrustRestart.e2e.ts · 1 passed 4 steps · 2 calls 10.4s
🟢 a trusted plugin hook stays trusted after the server restarts 4 steps · 2 calls 10.4s
🟢 settingsRoundTrip.e2e.ts · 1 passed 2 steps · 1 call 9.8s
🟢 a chat survives trips through Settings 2 steps · 1 call 9.8s
🟢 sidebarPerWorkspace.e2e.ts · 1 passed 4 steps · 1 call 5.1s
🟢 a new workspace starts with its right sidebar collapsed while another keeps it open 4 steps · 1 call 5.1s
🟢 smoke.e2e.ts · 1 passed 2 steps · 1 call 2.9s
🟢 the agent opens the playground workspace 2 steps · 1 call 2.9s
🟢 streamErrors.e2e.ts · 1 passed 1 step · 1 call 7.2s
🟢 stream errors show in the chat, and the chat recovers 1 step · 1 call 7.2s
🟢 todoNudge.e2e.ts · 1 passed 1 step · 1 call 3.3s
🟢 the agent finishes open TODO items after the turn-end nudge 1 step · 1 call 3.3s
🟢 touchAlignment.e2e.ts · 6 passed 6 steps · 6 calls 24.4s
🟢 the Settings close button is level with the title on a touch screen 390px wide 1 step · 1 call 3.7s
🟢 the Settings close button is level with the title on a touch screen 768px wide 1 step · 1 call 4.6s
🟢 Backup settings checkboxes are small and level with their labels on a touch phone 1 step · 1 call 5.2s
🟢 the heartbeat checkbox is small and level with its label on a touch phone 1 step · 1 call 4.5s
🟢 a reply's model and time stay on one line on a touch phone 1 step · 1 call 3.3s
🟢 the workspace actions menu stays on the title row on a touch phone 1 step · 1 call 3.0s

e2e 0.20.0 · 1m 18s · web · run artifacts

🟢 e2e Electron stories (Haiku): 3 passed

3 agent steps · 3 model calls · 7.9k tokens (22% cached)
Spend: $0.02 of the $1.00 cap (proxy ledger)

All 3 tests in 3 files
Test Agent Time
🟢 electron/deepLink.e2e.ts · 1 passed 1 step · 1 call 8.1s
🟢 a deep link of a second launch starts a chat in the running app 1 step · 1 call 8.1s
🟢 electron/menuBar.e2e.ts · 1 passed 1 step · 1 call 10.5s
🟢 the workspace menu bar is the desktop title bar 1 step · 1 call 10.5s
🟢 electron/smoke.e2e.ts · 1 passed 1 step · 1 call 6.3s
🟢 Xum Electron opens the playground workspace 1 step · 1 call 6.3s

e2e 0.20.0 · 27.6s · electron · run artifacts

🟢 e2e agent repros (Haiku): no tests selected

Spend: $0.00 of the $1.00 cap (proxy ledger)

e2e 0.20.0 · 6.9s · 2 targets (web, phone) · run artifacts

Retries and reconnect resends send ifStored; the service compares the whole
stored record inside its file lock and keeps it when it changed. The first
delete stays unconditional. Fixes #7719.
…napshot

- Track whether the first delete request was sent: a delete made while
  disconnected is sent unconditionally on reconnect.
- Record a lost-reply save's snapshot before the entry check, so a delete
  that removed the entry while waiting for that save sees it.
@ThomasK33
ThomasK33 force-pushed the fix/creation-draft-delete-retry-condition branch from ddd105c to 5fb574a Compare October 29, 2026 13:28
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 59b5bebc6c

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 59b5bebc6c

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…#7728)

- A second delete() of the same id keeps the first one's snapshot and sent flag.
- delete() waits until no save is in flight, including one a running flush starts.
- A delete without a snapshot retries without a condition, as main does.
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: cb56ea7b89

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: cb56ea7b89

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ThomasK33

Copy link
Copy Markdown
Member Author

Closing and reopening to start a new pull_request run on a merge ref that includes #7729 (616277e).

@ThomasK33 ThomasK33 closed this Oct 29, 2026
@ThomasK33 ThomasK33 reopened this Oct 29, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3bea37c033

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 3bea37c033

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@ThomasK33
ThomasK33 added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit da7b705 Oct 29, 2026
63 of 66 checks passed
@ThomasK33
ThomasK33 deleted the fix/creation-draft-delete-retry-condition branch October 29, 2026 17:22
yermakoffivan pushed a commit to yermakoffivan/mux that referenced this pull request Oct 29, 2026
…receipt for the head (coder#7729)

## Summary

The `Codex Comments` gate (and so `Required`) no longer fails on a PR
where Codex's security review found nothing but finished with null
findings flags. The gate accepts that one state only beside a clean
security receipt for the current head, with no open Codex thread. Every
other unknown state still blocks.

Fixes coder#7727.

## Background

Since about 2026-10-28, Codex's summary board can record a finished
security review as `{"has_any_findings": null,
"has_unresolved_findings": null, "status": "completed"}`.
`codex_summary_status` accepted null flags only while a review runs, so
it returned unknown, and the board counted as an unresolved Codex
comment. Rerunning the job could not help. Open PRs coder#7722, coder#7724, coder#7723,
coder#7721 and coder#7717 all had this state on their latest board. coder#7722 is the
observed fixture.

## Implementation

`codex_summary_status` accepts a completed `security_review` with both
flags null only when ALL of these hold:

1. The review state's `commit_sha` is the PR's current head.
2. The board's security metadata line says `status: completed` for the
current head, with `mergeGateEnabled: false`.
3. The board has no `### Security findings` or advisory section.
4. An unminimized Codex comment is the clean security receipt ("Security
review completed. No security issues were found in this pull request.")
and names a reviewed commit that matches the current head. A receipt
without a commit line does not count here.
5. No Codex review thread is unresolved.

`check_codex_comments.sh` computes 4 and 5 and passes them as
`.clean_security_receipt`. A caller that does not set it gets the old
fail-closed behavior. The receipt regex moved into one shared
`codex_clean_security_receipt` def, so the informational check and this
check use the same text.

## Why the gate stays safe

- Null flags still block in every other case: a code review, an older
head, no receipt, a receipt for another commit, a minimized receipt, an
advisory section, the merge gate on, or an open Codex thread.
- The receipt is Codex's own verdict for that exact commit. It carries
no finding by construction: the regex is anchored and accepts only fixed
text.
- Findings never depend on the flags alone. Code and security findings
are review threads, and the gate counts open Codex threads separately.
Advisory findings are board bullets, and they block as before.
- A running review with null flags is unchanged: it still exits 10 (in
progress).

## Validation

- New test
`test_null_security_flags_pass_only_with_a_clean_receipt_for_this_head`,
run against the real shell entrypoint with the observed coder#7722 board and
receipt as fixtures (with and without the cached payload). Cases: clean
receipt for this head passes (0); no receipt (1); an open Codex thread
(1); a receipt for an older head (1); board and receipt for an older
head (1); an advisory section (1); the merge gate on (1); running with
null flags (10); a minimized receipt (1).
- On main, only the "clean receipt for this head" case fails (1 instead
of 0). Every blocking case blocks before and after.
- `make test-codex-comments` passes in full.
- A live run of `./scripts/check_codex_comments.sh 7722` with this
change: "No unresolved Codex comments found".

---

_Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking:
`high` • Cost: `$248.33`_

<!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=high
costs=248.33 -->
yermakoffivan pushed a commit to yermakoffivan/mux that referenced this pull request Nov 1, 2026
…oder#7864)

## Summary

After window A sends a creation draft whose first delete fails, the
delete retry now removes the record even when window B changed other
fields before A's last save. Before, the sent text could show up in the
list again, so the user could send it twice.

Refs coder#7728 (case 1). The unopened-draft case of coder#7728 stays open.

## Background

coder#7722 made delete retries conditional: a retry deletes only while the
stored record equals `Entry.stored`, this window's last known copy. But
`CreationDraftStore.save` set `stored` to its own local draft, and the
backend merges only the fields a save sends. Example: B saves a name,
then A saves only its text. The stored record has B's name, while A's
copy does not. If A's first delete fails, the retry sees a mismatch, and
the backend keeps the record with A's sent text.

## Implementation

- `drafts.updateCreation` output gets one added field, `record`: the
stored record after the merge, without its content fields. One mask,
`CREATION_DRAFT_CONTENT_FIELDS` (`text`, `attachments`), names them,
because each can be megabytes and every debounced save would echo them.
`creationDraftMetadata` builds the reply. Existing fields are unchanged.
No persisted field is added.
- The store fills each content field of the condition from this window's
own save, else its last stored copy (`storedAfterSave`).
- `CreationDraftService.update` returns it, and
`CreationDraftStore.save` keeps `reply.record` as `Entry.stored`.
- A reply without `record` (an older backend, when the renderer skipped
its bundle reload) keeps the old behavior: the condition is this
window's full copy.
- The stories mock and the `useCreationWorkspace` test double return the
record too.

## Known limit

A save that fails with no reply (the reply was lost) keeps today's
behavior: the store records its attempted local draft as `stored`,
because no merged record arrived. If that save did not land, or merged
with another window's fields, a later retry keeps the record. That is
the pre-coder#7559 outcome (the draft shows again, no text is lost). coder#7728
case 2 tracks it.

If another window changed the text or the attachments, this window's
condition has stale content, so a delete retry keeps the record. That
also fails safe.

## Validation

New test `a delete retry removes a record another window changed before
this window's last save (coder#7728)`. On main it fails at the final
assertion, because the record is still stored:

```
error: expect(received).toBeNull()

Received: {
  ...
  text: "sent",
  manualName: "named-in-b",
  ...
}
  at CreationDraftStore.test.ts:774
```

With this change it passes. The test draft has an attachment. A second
test covers a save that carries no content fields: both come from the
last stored copy (it fails when that fill-in is removed). The service
test checks that the reply's record has no text and no attachments. The
`CreationDraftStore`, `creationDraftService` and `useCreationWorkspace`
tests pass (82). `make static-check` and `make lint-eslint` pass.

---

_Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking:
`high` • Cost: `$290.25`_

<!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=high
costs=290.25 -->
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.

🤖 Creation drafts: a delete retry removes text another window saved after the failed delete

1 participant