Skip to content

Chat sidebar: client-side read/unread marker - #309

Open
arsenmuk wants to merge 1 commit into
arsenmuk/session-hierarchyfrom
arsenmuk/session-read-unread
Open

Chat sidebar: client-side read/unread marker#309
arsenmuk wants to merge 1 commit into
arsenmuk/session-hierarchyfrom
arsenmuk/session-read-unread

Conversation

@arsenmuk

Copy link
Copy Markdown
Member

Marks sessions that updated and stopped since you last opened them — bold title + a small dot in the sidebar. Client-only, no server change.

How it works

  • Unread = !active && !running && updated_at > max(lastSeen[id], baseline).
  • Per-session lastSeen + a first-run baseline in localStorage (readStorage.ts, mirrors draftStorage); the baseline keeps a fresh browser from flagging every pre-existing session.
  • Opening a session — or leaving one you were viewing — marks it read (switchSession).
  • handleSessionRunning refreshes the list when a backgrounded feed session stops, so updated_at and the marker stay timely.
  • Scoped to the conversation feed (system/archived/search unaffected); cleared on logout.

Build green (tsc -b && vite build), tests 99/99.

Stacked on #305.

A session shows an unread marker (bold title + accent dot) when its updated_at is newer than the last time you opened it and it isn't running -- i.e. it updated and stopped while you were elsewhere. Read-state is derived and client-only: per-session last-seen stamps + a first-run baseline in localStorage (readStorage.ts), no server change. Opening a session (or leaving one you were viewing) marks it read; the baseline keeps pre-existing sessions from all showing unread on first load.

handleSessionRunning refreshes the session list when a backgrounded feed session stops, so its updated_at -- and the marker -- is timely. Scoped to the conversation feed; system/archived/search rows are unaffected.

Copilot AI 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.

Pull request overview

Adds client-side read/unread tracking to the conversation sidebar.

Changes:

  • Persists per-session read timestamps and a baseline in localStorage.
  • Refreshes sessions when background runs stop.
  • Displays bold titles and unread dots; clears stored state on logout.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
readStorage.ts Implements read-state persistence.
sessionHandlers.ts Refreshes sessions after background runs.
chatStore.ts Tracks and updates read state.
authStore.ts Clears persisted read data on logout.
SessionSidebar.tsx Renders unread styling and markers.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

// browser. Only on a *deliberate* logout — an expired session must never
// take your unsent work with it.
clearAllDrafts();
clearAllReads();
Comment on lines +284 to +287
if (!msg.is_running
&& msg.session_id !== get().activeSession
&& get().sessions.some(sess => sess.id === msg.session_id)) {
get().loadSessions();
Comment on lines +1123 to +1125
<span title="Unread — updated since you last opened it" className="shrink-0 flex items-center">
<span className="h-2 w-2 rounded-full bg-accent" />
</span>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants