# Spooky tracking happenings 👻

**URL:** https://meta.discourse.org/t/spooky-tracking-happenings-ghost/61255
**Category:** Bug
**Created:** [April 19, 2017, 1:59pm UTC](https://meta.discourse.org/t/spooky-tracking-happenings-ghost/61255 "2017-04-19T13:59:28Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [April 19, 2017, 1:59pm UTC](https://meta.discourse.org/t/spooky-tracking-happenings-ghost/61255/1 "2017-04-19T13:59:28Z")

</div>

There are things like the following I’ve been noticing for months, but never filed a report for, because I could never reproduce them consistently. But, finally, accidentally, I’ve caught one on camera! (So please forgive the pausing and confusion reflected in my cursor movements.)

[![](https://global.discourse-cdn.com/meta/original/4X/5/7/3/573f294947088ceadfd08e937ec3abfdf8d1d42b.jpeg "2017 04 19 14 22 26") ](https://www.youtube.com/watch?v=cM8cPvhCCxY)

The things to look out for are:

1. Unread being empty
2. #Contribute > Feature showing as ‘Normal’ (despite being tracked, as shown in my preferences) and only showing as ‘Tracked’ on a refresh
3. A topic mysteriously appearing in unread (from days ago, from the howto category)

The 2nd point is somewhat similar to a common bug I see (but have never been able to reproduce on video) where I’ll click on a topic from new in a category I’m tracking, but its own status won’t show as tracked unless I refresh the page. [(I wonder if that’s related to this.)](https://meta.discourse.org/t/unread-topics-in-query-link-lists-tracking-watching/55861)

Just before recording this I was trying to reproduce that bug by tracking #Contribute > Bug, and then clicking on one of it’s topics from the unread tab. I couldn’t, but upon un-tracking #Contribute > Bug, my unread tab was filled with about 20 closed topics in #Contribute > Bug from around 2015, which seems to be the same bug as point 3.

I don’t understand why this could be happening. 👻

---

<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: [April 19, 2017, 8:13pm UTC](https://meta.discourse.org/t/spooky-tracking-happenings-ghost/61255/2 "2017-04-19T20:13:39Z")

</div>

What are the repro steps?

---

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [April 20, 2017, 10:31am UTC](https://meta.discourse.org/t/spooky-tracking-happenings-ghost/61255/3 "2017-04-20T10:31:35Z")

</div>

There are two bugs here.

I can’t consistently reproduce the first, where the correct notification level is only shown after a refresh (of a category, or a topic). It’s been happening to me for months, but whenever I try to reproduce it, it doesn’t happen.

The second, which I think is a bit more minor, but still a nuisance can be reproduced (for a limited time only) like so:

1. Clear `/unread`
2. Track a category currently set to ‘Normal’
3. Go back to `/unread` and observe posts not previously in it

I’ve been able to do this with a number of categories, but only once for each. Once I’ve dismissed the posts from unread, they never appear again.

Consistently reproducing it takes a little more work, so hold onto your hats, it’s gonna get a bit crazy:

- Go to unread in a category of your choosing which has a notification level of “Normal”, observe nothing there:

 ![](https://global.discourse-cdn.com/meta/original/3X/a/8/a847068c809c188f0149591e899379adaea0a015.png)

- List all the currently tracked topics in that category (and remember, or take a screenshot of them):

 ![](https://global.discourse-cdn.com/meta/original/3X/6/9/69ed66a3eaf58215fd6470ff01d1c52fa08e9269.png)

- Enter a topic from that category not on that list:

 ![](https://global.discourse-cdn.com/meta/original/3X/9/7/97bfb4e77a2ad589a59889e6b5fcbd55e331364c.png)

- Start tracking the category
- Again list tracked topics in that category
- Observe the topic you just opened in that list:

 ![](https://global.discourse-cdn.com/meta/original/3X/a/2/a25e51c4b3f78bdf84647f1c6d6554f017fb36dc.png)

- Go to unread, and again observe that topic in the list:

 ![](https://global.discourse-cdn.com/meta/original/3X/6/6/6649f635b45067b9d414a7dff396dab8ce1cc87d.png)

* * *

**TL;DR**

So, the bug here is that previously opened topics in a category become tracked, and appear in unread (unless previously dismissed), when the category is tracked, whereas nothing happens to old not-opened-before topics.

To me, what should happen is either:

- Nothing changes about the notification status of old topics in a category when it becomes tracked, previously opened or not.

or

- All old topics become tracked when the category is tracked, but are automatically dismissed, so only new activity appears in the unread tab.

I lean towards the second solution, provided explicitly set notification levels on topics are kept.

I haven’t investigated how this works with other notification levels, I imagine its the same, but I feel it would confuse things for the time being.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [April 20, 2017, 11:05am UTC](https://meta.discourse.org/t/spooky-tracking-happenings-ghost/61255/4 "2017-04-20T11:05:44Z")

</div>

So in relation to

> [@Watching and tracking implementation for tags and categories](https://meta.discourse.org/t/watching-and-tracking-implementation-for-tags-and-categories/46987):
>
> I just revised the implementation of “tracking” and “watching” of tags and categories: Watching categories and tags has always been a rather limited feature. When you started watching a category you would only watch topics in that category from that time on. (with an edge case that allowed you to also watch recategorized old topics) This limitation was … hmm … limiting. Start watching #Bug and you would not be notified on a large amount of current #Bug discussion on historic topics. T…

What part is considered as “not working as expected”?

---

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [April 20, 2017, 5:51pm UTC](https://meta.discourse.org/t/spooky-tracking-happenings-ghost/61255/5 "2017-04-20T17:51:38Z")

</div>

> [@cpradio](#):
>
> What part is considered as “not working as expected”?

2 parts:

The first would be topics not being properly implicitly tracked. If they were, all of the topics from #Community Building > Praise should appear in this step:

> [@LeoMcA](#):
>
> Observe the topic you just opened in that list:

It seems like that list is just showing topics with a tracking record of “tracked”, and that’s not working as expected. What would be, would be showing all topics with a tracking record of “tracked”, and all topics which are in a tracked category. (The same would go for watching.)

Furthermore, while this makes sense:

> [@Watching and tracking implementation for tags and categories](https://meta.discourse.org/t/watching-and-tracking-implementation-for-tags-and-categories/46987/1):
>
> Topics with missing state are watched implicitly, a tracking record is created when we notify users.

It seems like the same functionality is missing when a user tracks a category. Shouldn’t a tracking record also be created when there is a new post in a topic?

The second would be the appearance of seemingly arbitrary topics in unread when you track a category, (I assume a side effect of changing the tracking state of past topics from regular to tracked), which could be fixed by automatically dismissing those topics from unread.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [April 20, 2017, 6:23pm UTC](https://meta.discourse.org/t/spooky-tracking-happenings-ghost/61255/6 "2017-04-20T18:23:06Z")

</div>

What are your Preferences → Other  
Consider topics new when  
and  
Automatically track topics I enter  
settings?

---

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [April 20, 2017, 9:02pm UTC](https://meta.discourse.org/t/spooky-tracking-happenings-ghost/61255/7 "2017-04-20T21:02:13Z")

</div>

> [@Mittineague](#):
>
> Consider topics new when

I haven’t viewed them yet

> [@Mittineague](#):
>
> Automatically track topics I enter

never

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [April 20, 2017, 9:36pm UTC](https://meta.discourse.org/t/spooky-tracking-happenings-ghost/61255/8 "2017-04-20T21:36:13Z")

</div>

> [@LeoMcA](#):
>
> So, the bug here is that previously opened topics in a category become tracked, and appear in unread (unless previously dismissed), when the category is tracked, whereas nothing happens to old not-opened-before topics.

This is something I found a while ago, and a thread can be found [here](https://meta.discourse.org/t/watching-tracking-old-topics/51606) (not entirely sure why it got moved from #Contribute > Bug to #Contribute > Feature).

The thread is quite confusing as I originally thought the problem was caused by the initial import from phpBB. So here’s an attempt to summarise:

It comes down to the fact that a topic cannot be both `new` and `unread` simultaneously:

- Even though it’s implicitly tracked, topic does not show up in `unread` because the user has never viewed it
- Topic does not show up in `new` because it is beyond the threshold of whatever your “Consider topics new when” setting is

It’s a hard problem to solve, because having every single old topic in a category appear in your ‘unread’ tab is really not a good user experience.

“Automatically dismissing” them is quite expensive database-wise (a new TopicUser record would have to be created for every single topic in the category you just tracked).

We didn’t really come up with a tidy idea to solve the problem, and the discussion kinda died. One option that @sam came up with was

> [@Watching/Tracking old Topics](https://meta.discourse.org/t/watching-tracking-old-topics/51606/7):
>
> Perhaps, one thing that is “cheap” that we could do.
> 
> If a topic in a tracked category is bumped, add it back to “new” for whatever the new duration is.
> 
> Still would feel somewhat odd.

At the time, I thought this might be a good idea:

> [@Watching/Tracking old Topics](https://meta.discourse.org/t/watching-tracking-old-topics/51606/13):
>
> At the moment, the “new” tab is sorted by “topic.bumped\_at”, but filtered by “topic.created\_at”. What’s the thinking behind this? It seems a little un-intuitive that topics don’t “drop off the bottom” of the list once they’re no longer declared new. What would be quite nice, at least for my forum, would be to filter them by “topic.bumped\_at”.

But

> [@Watching/Tracking old Topics](https://meta.discourse.org/t/watching-tracking-old-topics/51606/15):
>
> The problem with a change like that is that lots of users will get very confused about how to kick stuff out of new list.

**TL;DR** : I don’t have a solution, but hopefully this makes the problem clearer 😉

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [April 20, 2017, 9:48pm UTC](https://meta.discourse.org/t/spooky-tracking-happenings-ghost/61255/9 "2017-04-20T21:48:56Z")

</div>

And for the other issue in this thread:

> [@LeoMcA](#):
>
> I can’t consistently reproduce the first, where the correct notification level is only shown after a refresh (of a category, or a topic). It’s been happening to me for months, but whenever I try to reproduce it, it doesn’t happen.

I can reproduce this consistently here on meta for categories. Repro steps:

1. Go to your user preferences, remove all tracked categories
2. Go to a category page, e.g. #meta, and observe that the ‘notification level’ indicator is “normal”
3. Go immediately to your user preferences, by clicking your avatar in the top right, then the cog
4. Add the category you just visited, e.g. #meta, to your “tracking” categories
5. Press “save changes”
6. Press the **back button** in your browser to return to #meta, and observe that the ‘notification level’ indicator is still “normal”
7. Refresh the page, and observe that the ‘notification level’ is now “tracked”

If you replace step 6 with visiting the category page by some other route, the tracking status appears correctly.

---

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [April 21, 2017, 8:15am UTC](https://meta.discourse.org/t/spooky-tracking-happenings-ghost/61255/10 "2017-04-21T08:15:08Z")

</div>

> [@david](#):
>
> It comes down to the fact that a topic cannot be both new and unread simultaneously:

From a practical perspective, that doesn’t make sense to me. If I buy a book and put it on my shelf having not opened it, it is both new and unread.

> [@david](#):
>
> having every single old topic in a category appear in your ‘unread’ tab is really not a good user experience.

Wouldn’t it be possible to have an old topic (with no tracking record) only appear in unread when there’s new activity on it?

> [@Watching and tracking implementation for tags and categories](https://meta.discourse.org/t/watching-and-tracking-implementation-for-tags-and-categories/46987/1):
>
> When a user watches a category/tag:
> 
> […]
> 
> - Topics with missing state are watched implicitly, a tracking record is created when we notify users.

So, just as a tracking record is created on new activity for topics in watched categories, a tracking record would be created on new activity for topics in tracked categories.

> [@david](#):
>
> “Automatically dismissing” them is quite expensive database-wise (a new TopicUser record would have to be created for every single topic in the category you just tracked).

Combined with the above, couldn’t we just dismiss topics where the tracking record has been changed to “tracking” as a result of tracking the category, which would mean the same user experience, without any additional database writes? (If I understand how tracking records, dismissing and TopicUser relate.)

This way, it seems to me, we could have a mailing list experience for tracking too! 😄

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [April 21, 2017, 8:20am UTC](https://meta.discourse.org/t/spooky-tracking-happenings-ghost/61255/11 "2017-04-21T08:20:34Z")

</div>

> [@LeoMcA](#):
>
> From a practical perspective, that doesn’t make sense to me.

Sure, I agree. I was talking purely about how it currently works in discourse.

> [@LeoMcA](#):
>
> Wouldn’t it be possible to have an old topic (with no tracking record) only appear in unread when there’s new activity on it?

I believe @sam thought this would have major performance issues

> [@LeoMcA](#):
>
> So, just as a tracking record is created on new activity for topics in watched categories, a tracking record would be created on new activity for topics in tracked categories.

I’m 99% sure a new record isn’t created for tracked topics - @sam said “created when we notify users”, and tracking doesn’t cause notifications. Maybe fixing this is the solution 🙂

---

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [April 21, 2017, 8:38am UTC](https://meta.discourse.org/t/spooky-tracking-happenings-ghost/61255/12 "2017-04-21T08:38:15Z")

</div>

> [@david](#):
>
> I was talking purely about how it currently works in discourse.

Do you know if there’s an architectural issue which means the new/unread either/or has to be the case?

> [@david](#):
>
> I’m 99% sure a new record isn’t created for tracked topics - @sam said “created when we notify users”, and tracking doesn’t cause notifications. Maybe fixing this is the solution 🙂

Indeed, I was proposing this as a solution which seems to not have any major performance issues.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [April 21, 2017, 8:40am UTC](https://meta.discourse.org/t/spooky-tracking-happenings-ghost/61255/13 "2017-04-21T08:40:47Z")

</div>

> [@LeoMcA](#):
>
> Do you know if there’s an architectural issue which means the new/unread either/or has to be the case?

I assume it’s by design - having a topic listed on the new tab and the unread tab would be a bit weird.

Taking your book analogy, while it can be both unread and new, you can’t put it on your “new” shelf and your “unread” shelf simultaneously 😉

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [April 21, 2017, 10:57am UTC](https://meta.discourse.org/t/spooky-tracking-happenings-ghost/61255/14 "2017-04-21T10:57:05Z")

</div>

Ok… I’ve done some testing in my dev environment. As a simplest possible repro:

1. Set `previous visit timeout hours` site setting to 0, to make testing quicker

- User A sets “Consider topics new when” to “created since I was last here”
- User A sets `Category1` to `tracked`
- User B posts in Category1
- User A observes the topic in ‘new’, but does not open it
- User A leaves the site
- User A comes back to the site later, and User B’s post is gone from the ‘new’ tab
- User B posts again in the same topic
- The topic does not appear in either ‘new’ or ‘unread’ for User A, even though they are tracking the topic

That same repro works for ‘watching’ a category as well. A notification is sent, but no TopicUser row is created (checked on the rails console). It seems that this:

> [@LeoMcA](#):
>
> a tracking record is created when we notify users.

is not happening for some reason, both for watched and tracked categories.

---

<div class="post-metadata">

### Author: ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)
#### Post date: [April 21, 2017, 11:22am UTC](https://meta.discourse.org/t/spooky-tracking-happenings-ghost/61255/15 "2017-04-21T11:22:20Z")

</div>

> [@david](#):
>
> having a topic listed on the new tab and the unread tab would be a bit weird.

Would it though? We already have topics listed in the latest tab and the new/unread tabs simultaneously. And the two (new and unread) are for different purposes: new is “show me the newest topics on this site” and unread is “show me topics I’ve expressed an interest in, but haven’t (finished) read(ing)”. For new to achieve its purpose it has to have unread topics in it which are new, and for unread to achieve its purpose it needs to have new topics in it which are unread.

Currently the unread tab is rather dysfunctional.

> [@david](#):
>
> It seems that this:
> 
> a tracking record is created when we notify users.
> 
> is not happening for some reason, both for watched and tracked categories.

Interesting, thanks for doing all this investigation! So it would seem like if this did actually happen (or more specifically, a TopicUser row was created on topic update, rather than notification, to include tracked categories), then our problems here would be solved. @sam thoughts?

---

<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: [November 10, 2018, 9:58pm UTC](https://meta.discourse.org/t/spooky-tracking-happenings-ghost/61255/16 "2018-11-10T21:58:37Z")

</div>

I am fine to change the semantics of “tracked category” so it means, if a category is tracked it will unconditionally show up in new regardless of your new duration, it does not mean this now.
