Two editors share one project
A user can duplicate a tab, change the prompt in one and change the reference in another. If each tab saves a whole draft blindly, the second save erases the first change. This application problem is separate from AISwapLab's generation request contract.
What to do next
- 01
Make writes conditional
Return a draft revision when loading your project. Save with that expected revision and update only if the stored revision still matches, using a transaction or atomic conditional update in your own database.
- 02
Offer a real conflict choice
When a save loses the race, show the local draft alongside the saved version. Let the user reload, copy their text or merge reviewed changes; do not silently turn the losing save into a new generation.
- 03
Use tab signals as hints
A BroadcastChannel message may tell another tab that a project changed. Still check the server revision because messages can be missed and editors can be open on entirely different devices.
A concrete example
Illustrative example: both tabs load revision 7. Tab A saves revision 8 with a new portrait. Tab B's save based on 7 is refused, preserving the portrait and offering its unsaved prompt for an explicit merge.
Before you call it ready
- Save from both tabs simultaneously.
- Close the signaling tab mid-save.
- Verify stale writes cannot alter the project.
A locally executed, reproducible check
A stale revision cannot overwrite a newer saved draft when the update compares revisions.
We executed this exact synthetic fixture on November 16, 2026 with Python 3.12.10 and SQLite 3.49.1. It ran locally with no network requests, account data or model generation. The recorded output below is an observation from that environment, not a platform benchmark. Copy the code into a separate Python file to repeat it in a suitable local environment; compare the mechanism and check your runtime version.
import sqlite3
c=sqlite3.connect(':memory:')
c.execute('CREATE TABLE draft(id TEXT PRIMARY KEY,revision INTEGER,text TEXT)')
c.execute("INSERT INTO draft VALUES('d1',7,'original')")
first=c.execute("UPDATE draft SET revision=8,text='tab A' WHERE id='d1' AND revision=7").rowcount
second=c.execute("UPDATE draft SET revision=8,text='tab B' WHERE id='d1' AND revision=7").rowcount
print('first save rows:',first)
print('stale save rows:',second)
print('stored:',c.execute('SELECT revision,text FROM draft').fetchone())
Recorded output and interpretation
This is a deterministic comparison of two saves, not a live browser concurrency or transport test. A rejected save needs a useful conflict interface; the experiment does not choose how to merge creative text.
A matching local output establishes only the illustrated library or database behavior under these inputs. It does not certify a production integration. Preserve the approved action, authorization boundaries and current AISwapLab request contract when applying the idea.
first save rows: 1
stale save rows: 0
stored: (8, 'tab A')
When to stop or choose another method
Stop automatic merging when both versions change the same creative field; preserve each draft until the user resolves the conflict.
