fix(web): fix Mark unread that was immediately reseting on the active thread
What Changed
Stops the active chat view from reacting to manual unread timestamp changes. The visit effect now runs only when the active server thread or its update timestamp changes.
Why
Marking a thread unread changes its last-visited timestamp. The active chat subscribed to that same value, which retriggered the visit effect and immediately marked the thread as read again.
The existing store action already validates and deduplicates visit timestamps, so the extra subscription and guard were unnecessary. Opening the thread again or receiving a newer thread update still marks it as read normally.
Fixes #4873
UI Changes
Before
https://github.com/user-attachments/assets/802f83c4-40d2-4d31-ab53-eb28b00aa080
Mark the currently open thread unread. The local unread timestamp changes. That change retriggers the active thread’s “visited” effect. It instantly becomes read again, forcing you to leave the thread first.
After
https://github.com/user-attachments/assets/400edbba-d930-4096-9b5b-8776df9c099d
You can mark the active thread unread without leaving it. It immediately keeps the visible unread/Done state. Ordinary rerenders do not clear it. It clears when you leave and reopen the thread, or when genuinely new thread activity arrives.
Validation
vp test run apps/web/src/uiStateStore.test.ts apps/web/src/components/ChatView.logic.test.tsvp run --filter @t3tools/web typecheckvp fmt --check apps/web/src/components/ChatView.tsxvp lint apps/web/src/components/ChatView.tsx --report-unused-disable-directivesgit diff --check origin/main...HEAD- Desktop dev build and launch
Checklist
- [x] This PR is small and focused
- [x] I explained what changed and why
- [x] I included before/after evidence for the UI change
- [x] I included a video for the interaction change
[!NOTE] Low Risk Small UI-state fix in ChatView with existing store deduplication; no auth, data, or API changes.
Overview Fixes Mark unread on the currently open thread being undone immediately.
ChatViewno longer subscribes tothreadLastVisitedAtByIdfor the active route. The visituseEffectalso drops the guard that skippedmarkThreadVisitedwhen the stored last-visited time was already at or pastserverThread.updatedAt.The effect now runs only when the active server thread’s id, environment, or
updatedAtchanges, and always delegates tomarkThreadVisited(which already ignores backwards or invalid timestamps). Manual unread updates no longer retrigger the effect, so the thread stays unread until you leave/reopen or newer server activity bumpsupdatedAt.Reviewed by Cursor Bugbot for commit ef8d1499997f041e1ed07769d87e334a98d41883. Bugbot is set up for automated code reviews on this repo. Configure here.
[!NOTE]
Fix "Mark unread" immediately resetting on the active thread in ChatView
The
ChatViewContentcomponent was comparinglastVisitedAtagainstserverThread.updatedAtbefore callingmarkThreadVisited, which caused a mark-unread action to be immediately overwritten when the thread was active. The fix removes this comparison somarkThreadVisitedis called unconditionally whenever a server thread with an id is present, regardless of any previously recorded timestamp.Macroscope summarized ef8d149.
[!IMPORTANT]
Review skipped
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
9e57e250-1751-4896-bdc8-ed98c52318b2You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
- [ ] 🔍 Trigger review
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Approvability
Verdict: Approved bc49293
Straightforward bug fix that removes a conditional check which was causing 'Mark unread' to immediately reset when viewing a thread. The change is small, focused, and has clear intent.
You can customize Macroscope's approvability policy. Learn more.
hi @juliusmarminge could we take a quick look at this ? its a super tiny change with a significant ux gain for me
closing as superseded by #5486. that merged change removes the visit effect which immediately reset unread state on the active thread, addressing the bug through explicit thread actions instead. thanks for the fix.