Skip to content

Studio: keep messages from another window when deleting in a stale one - #16926

Merged
danielhanchen merged 5 commits into
unslothai:mainfrom
NilayYadav:stale-window-delete-wipes-other
Nov 7, 2026
Merged

danielhanchen merged 5 commits into
unslothai:mainfrom
NilayYadav:stale-window-delete-wipes-other

Conversation

@NilayYadav

@NilayYadav NilayYadav commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

With the same chat open in two windows, a turn sent in one window often never shows up in the other. That happens for turns with an image, audio or video, Connected provider turns, browser tool turns and Continue. Deleting any message in the window that never saw that turn then deleted it from the database too. If the other window reloaded or closed before its next full save, the question and its reply were gone everywhere, with no warning.

A delete now removes only the messages the user deleted. Deleting a question still removes its replies, including ones the deleting window never saw, the same as the client does. Other messages the deleting window did not know about are kept, and if one of them hung off a deleted message it is attached to the nearest message that is left. Saves that do not name what was deleted work as before.

A stale window bringing back messages that were deleted in another window is a separate, known issue and is not changed here.

@NilayYadav NilayYadav self-assigned this Nov 6, 2026
@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

1 similar comment
@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T21:50:14.064705Z a392a16 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: ab60951ab0

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

Comment thread studio/backend/storage/studio_db.py Outdated
# Repair research parents the prune deletes, walking the stored chain (dangling parent breaks import).
# Batch-written ids are excluded so an authorized reparent is not overwritten.
reseat_candidates = managed_ids - {str(m["id"]) for m in messages}
reseat_candidates = (managed_ids | unseen_ids) - {str(m["id"]) for m in messages}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Exclude pruned rows from the parent-reseat candidates

When prune_missing=True is used without explicit deletion IDs, unseen_ids contains the rows being deleted. Including those rows here makes _surviving_parent_id repeatedly traverse the same deleted prefixes of a parent-linked transcript, performing O(n²) SQL reads for rows that need no repair. In a local storage-only reproduction, pruning a 2,000-message chain to [] took approximately 8.6 seconds versus 0.04 seconds before this change. This work holds the BEGIN IMMEDIATE write lock, so other writes to the same database can exceed the default five-second timeout. Exclude pruned from the candidates so only retained messages are repaired.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in a392a16: rows the prune deletes are no longer reseat candidates, with a test that the walk is skipped.

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: a392a16163

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

@danielhanchen danielhanchen self-assigned this Nov 7, 2026
@danielhanchen
danielhanchen merged commit 634b4f4 into unslothai:main Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants