# Reducing the frequency of display for the warning "Draft is being edited in another window."

**URL:** https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826
**Category:** Feature
**Created:** [May 8, 2020, 12:33pm UTC](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826 "2020-05-08T12:33:53Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![xan2622](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xan2622/32/156912_2.png) [@xan2622](https://meta.discourse.org/u/xan2622)
#### Post date: [May 8, 2020, 12:33pm UTC](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826/1 "2020-05-08T12:33:53Z")

</div>

Hi.

I am a member of a Discourse forum ([BlenderArtists.org](https://blenderartists.org/)) and I have a 4K monitor which allows me to have two pages of the forum placed side-by-side.

Sometimes, when I plan to write a long comment, when I prepare my answer (with several quotes from current long thread), I open the _Message Editor_ on the left page and I browse the same thread on the right page.

But when I do that, this message appears very often:

> Draft is being edited in another window. Please reload this page.

I am not against this warning (I am sure it is useful in some circumstances).

But **would it be possible to add an option in the user preferences** to disable it? Or **to set the frequency of display** (the timer)?

This warning message prevents to write the message peacefully.

Thank you for considering to add this option.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 8, 2020, 10:09pm UTC](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826/2 "2020-05-08T22:09:12Z")

</div>

Sorry, we had too many support requests on this, so the nagging is intentional. It’s a very risky workflow and you may lose your entire post..

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 8, 2020, 10:12pm UTC](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826/3 "2020-05-08T22:12:45Z")

</div>

One sec are you actually editing it in two places, what is the exact repro

Just opening and browsing should not cause this warning, you got to be editing from 2 windows

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [May 8, 2020, 10:32pm UTC](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826/4 "2020-05-08T22:32:18Z")

</div>

We automatically (try to) open the draft for editing when you enter a topic. Even if you immediately minimize the composer, it’s still live and conflicting.

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [May 8, 2020, 11:01pm UTC](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826/5 "2020-05-08T23:01:15Z")

</div>

> [@riking](#):
>
> Even if you immediately minimize the composer, it’s still live and conflicting.

Yeah, I’ve hit this. Definitely annoying when it happens, but I agree with Jeff we need to be cautious here due to the historical issues.

My solution is usually to open the topic in two tabs, and only after both are loaded do I start composing.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 8, 2020, 11:11pm UTC](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826/6 "2020-05-08T23:11:11Z")

</div>

This is certainly a bug, the guard should only kick in when you start typing

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 8, 2020, 11:31pm UTC](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826/7 "2020-05-08T23:31:33Z")

</div>

Good, if we have a repro, we can fix it.

---

<div class="post-metadata">

### Author: ![seanblue](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@seanblue](https://meta.discourse.org/u/seanblue)
#### Post date: [May 9, 2020, 1:02am UTC](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826/8 "2020-05-09T01:02:37Z")

</div>

> [@riking](#):
>
> We automatically (try to) open the draft for editing when you enter a topic. Even if you immediately minimize the composer, it’s still live and conflicting.

I’ve been bitten by the draft auto-opening as well, but it’s worse than just getting the warning message. I’ve gone back to typing my post and then gotten the popup later, trying to direct me back to the other tab that has an _older_ draft. At that point if I refresh the page I only get the older version of my draft, so in that sense this feature isn’t really preventing what it’s trying to prevent.

> [@sam](#):
>
> This is certainly a bug, the guard should only kick in when you start typing

I’m not sure if it happens before you start typing. I just tried reproducing on meta, and it only happened when I started typing in the second tab. I tend to trigger this shortly after duplicating my tab to cross-reference what I’m writing. I lose track of which tab I started in, and when I start typing in the second tab by mistake the warning appears.

Would it be possible/reasonable to detect if another tab already has the composer open for the given topic and if so not open the composer for the new tab?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 11, 2020, 12:30am UTC](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826/9 "2020-05-11T00:30:45Z")

</div>

> [@seanblue](#):
>
> Would it be possible/reasonable to detect if another tab already has the composer open for the given topic and if so not open the composer for the new tab?

Too complicated really… there may be something we can do with web workers, but it is an enormous change I would not like to do.

> [@seanblue](#):
>
> At that point if I refresh the page I only get the older version of my draft,

I need an exact step by step repro, our warning kicks in really early, at worst you would lose a few words. I guess if you are offline then stuff can get weird, but that is a big edge case … work around is cut-and-paste.

I just had a look at the OP.

> [@xan2622](#):
>
> Sometimes, when I plan to write a long comment, when I prepare my answer (with several quotes from current long thread), I open the _Message Editor_ on the left page and I browse the same thread on the right page.
> 
> But when I do that, this message appears very often:

I can not repro this, can you provide exact steps that lead to this incorrect message. If you are not editing there is only 1 edge case where you get this message arguably incorrectly. But it is a very minor edge case.

1. Open tab 1 … start composing reply
2. Open tab 2 … browse around
3. On tab 1 … continue composing
4. On tab 2 … minimize composer (you get a warning message… but only once)

What can happen which may be tripping you:

1. Open tab 1 … start composing reply
2. Open tab 2 … by mistake quote something for reply
3. On tab 1 … continue composing … warning is there … persistently (cause we would be throwing away the quote from (2))

I am just not sure what to fix here… I need repros.

---

<div class="post-metadata">

### Author: ![seanblue](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@seanblue](https://meta.discourse.org/u/seanblue)
#### Post date: [May 11, 2020, 1:54am UTC](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826/10 "2020-05-11T01:54:01Z")

</div>

> [@sam](#):
>
> I need an exact step by step repro, our warning kicks in really early, at worst you would lose a few words

I’ve definitely had times where I lost a significant amount of content. For that reason though, I’ve been careful not to trigger this warning, so I don’t remember the exact steps that caused the significant loss at this point.

> [@sam](#):
>
> Open tab 2 … by mistake quote something for reply

I think the problem might be if this saves a draft, overwriting what you did in tab 1. If that happens, that could result in significant loss of content. That’s just speculation for now, but I’ll see if I can reproduce the issue that way and let you know.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 11, 2020, 2:18am UTC](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826/11 "2020-05-11T02:18:31Z")

</div>

> [@seanblue](#):
>
> If that happens, that could result in significant loss of content.

It can not, please … I need repros … every time a draft is saved a conflict change test is performed.

I need a step by step repro for any significant content loss

---

<div class="post-metadata">

### Author: ![seanblue](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@seanblue](https://meta.discourse.org/u/seanblue)
#### Post date: [May 11, 2020, 2:48am UTC](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826/12 "2020-05-11T02:48:41Z")

</div>

I understand that you need repro steps. I set a reminder (🎉) to look tomorrow night. It would help to know (at a high level) how the conflict test works. Is there a unique identifier generated on page load or something like that?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 11, 2020, 2:49am UTC](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826/13 "2020-05-11T02:49:27Z")

</div>

> [@seanblue](#):
>
> Is there a unique identifier generated on page load or something like that?

Each draft is strongly associated with the composer via a unique id. This only roles forward.

---

<div class="post-metadata">

### Author: ![seanblue](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@seanblue](https://meta.discourse.org/u/seanblue)
#### Post date: [May 11, 2020, 2:58am UTC](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826/14 "2020-05-11T02:58:34Z")

</div>

> [@sam](#):
>
> This only roles forward.

What do you mean by this?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 11, 2020, 3:08am UTC](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826/15 "2020-05-11T03:08:31Z")

</div>

I basically mean that if there is a race … and two composers are replying to the same topic for the same user … only 1 ever wins. Each time we save an owner is picked.

---

<div class="post-metadata">

### Author: ![seanblue](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@seanblue](https://meta.discourse.org/u/seanblue)
#### Post date: [May 11, 2020, 9:11pm UTC](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826/16 "2020-05-11T21:11:58Z")

</div>

Alright @sam, I’ve got steps to reproduce. No idea if this is related to OP’s original issue (since this conversation has veered off a bit), but either way here’s what I have. Basically, if you open tab 2 **but continue typing in tab 1 before tab 2 has fully loaded** the new page gets into a bad state. If you continue typing in tab 1 while tab 2 is still loading, tab 2 will load the draft from tab 1 as it was when the page was opened, but you will still be able to edit in tab 2 even after tab 1 has saved additional changes (thus overwriting those changes). Here are steps to reproduce:

1. Open topic A and start composing a reply.
2. Stop typing so the draft is saved.
3. Open topic A in a new tab (Duplicate tab or right/center clicking the topic title is the easiest way to reproduce since they have to do a full page load and are therefore slower).
4. **Immediately** continue composing the reply in tab 1, _before_ tab 2 has finished loading.
5. Stop typing so the the draft is saved again (this will succeed, as expected).
6. Go to tab 2 and type in the composer.
7. Stop typing. The draft will be saved even though the warning should appear. This will overwrite all the additional changes you made in tab 1 from step #4. (If you get the warning as expected you probably waited too long to start typing in step #4.) Note that at this point you also cannot type in tab 1 again without refreshing that tab.

Note that in step #4, you don’t actually need to stop typing and save a draft before tab 2 finishes loading. Just starting to type is what gets everything in a bad state. It’s actually not unreasonable to open a duplicate tab in the background to check stuff later and continue typing in tab 1 in the meantime. But doing that too quickly will get the tabs in a bad state and allow you to accidentally overwrite what you added in tab 1. Of course, minimizing the composer also saves a draft, so once you get into this bad state just minimizing the composer in tab 2 to get it out of your way will overwrite your latest draft from tab 1.

At this point if you go back to tab 1 where you originally were composing your message, you can no longer type and will get the warning that should have shown up in tab 2. If you realize that your draft was lost you can of course copy the contents of the composer from tab 1. But if you didn’t realize and reload the page (following the instructions of the warning), you will lose the changes you made and have no way of getting them back.

Let me know if you still have trouble reproducing the issue with those steps. I can reproduce the issue pretty consistently following those steps (occasionally switching to new topics to get fresh drafts), so hopefully that’s enough information.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 12, 2020, 7:01am UTC](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826/18 "2020-05-12T07:01:11Z")

</div>

OK, I have a fix here:

[https://github.com/discourse/discourse/commit/a29ae17d3a57c6cd92716b53bbab5b9a229f77e7](https://github.com/discourse/discourse/commit/a29ae17d3a57c6cd92716b53bbab5b9a229f77e7)

Thank you so much for the repro here it was spectacular and helped me isolate the issue quickly.

I feel like I had a bit of a hand-wavy answer to how we keep track of draft versions, I think it boils down to me being a bit too naive **and fancy** in my algorithm. That is a deadly combo. The new algorithm is far easier to explain.

- Whenever the client saves a draft, it tells the server what “sequence number it has”

- If the sequence number **matches** , server will increase the sequence number by 1 and give it back to the client (our new sequence number)

- If the sequence number **does not match** , the server will tell the client there is a conflict and not save the draft

- On page reload / load the server tell the client what the current sequence number is

My previous implementation was too fancy, it tried avoiding increasing the sequence number under lots of conditions by tracking owner of a sequence. Your test case showed how bad that is and how it can cause content loss.

This should be live on meta, let me know if you can find more edges in this system.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 13, 2020, 6:58am UTC](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826/19 "2020-05-13T06:58:01Z")

</div>

> [@sam](#):
>
> Thank you so much for the repro here it was spectacular

That’s quite a compliment @seanblue you should be proud of this one 🎉

---

<div class="post-metadata">

### Author: ![Pad\_Pors](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pad_pors/32/52016_2.png) [@Pad\_Pors](https://meta.discourse.org/u/Pad_Pors)
#### Post date: [June 1, 2020, 11:04am UTC](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826/20 "2020-06-01T11:04:24Z")

</div>

facing the same issue here in **meta** :

- I opened a composer, and write the title.
- to take an screenshot for [this bug](https://meta.discourse.org/t/cant-go-back-from-creating-a-new-message-to-create-a-new-topic-in-editor/153453/2), I changed it from a “new topic” to “a new message”.
- I cancel the topic (i.e. the message) as I couldn’t change it back into a topic,
- I started a new topic.

a warning was shown incorrectly (since **I already canceled the message** ):

 ![image](https://global.discourse-cdn.com/meta/original/3X/9/e/9eb8dc1d9d47fa36f291dfd9f0ea749c81a04903.png)

now even when I chose to “ **abandon it** ”, every 10-20 seconds I got this message:

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/e/cea9ebfbe1efb17d20f735d1dac429a945cdf069.png)

while there is **no other tab**.

this only happens if I change from a topic to a message. it seems the cancellation of a massage doesn’t really cancel it.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [June 2, 2020, 6:02am UTC](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826/21 "2020-06-02T06:02:41Z")

</div>

This requires quite a bit of work, shuffling between tabs in the browser but yeah … the abandon is certainly failing to abandon in this case, we should fix that.

[Next page](https://meta.discourse.org/t/reducing-the-frequency-of-display-for-the-warning-draft-is-being-edited-in-another-window/150826.md?page=2)
