Skip to content

Commit 4960020

Browse files
tulsi-builderBasilBotclaude
committed
fix(inbox): read a Solo chat's timeline row in one save
Every incoming top-level Solo message is now Inbox evidence, so the flat row's explicit read took one durable save per retained message, and a reader catch-up between steps could expire the action. The row now reads with one `markTimelineRead`: the channel catch-up mark covers ordinary responses, as at the live bottom, and still-unread mentions, broadcasts and marked messages are read individually in the same save. Thread rows stay unread. Archive recognizes the row by the new `timeline` flag. Co-authored-by: BasilBot <399581b6165ab01343e3a1324774b1024d76942aea563468f93c975e5ee5193c@buzz.block.builderlab.xyz> Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: tulsi <[email protected]>
1 parent 6ff11d2 commit 4960020

8 files changed

Lines changed: 178 additions & 30 deletions

File tree

‎docs/inbox.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ Inbox now renders chat-only DMs, Solo conversations, mentions and participating
2424
`session.unread.inbox()`, with independent Activity type and Sender filters and
2525
an independent Unread only toggle. Sender classification uses `session.agentChoices` and
2626
cached/profile-backed identity evidence, never a new inventory or name heuristic.
27-
The Mentions activity filter uses explicit mention messages for each conversation's preview, sender, ordering, resume point and unread count. A later ordinary reply does not make a read mention unread again. DMs remain direct activity rather than mentions merely because their recipient is tagged. All activity and Threads retain their conversation-wide projections. A row shows its newest message and sender, matching its time, while opening it still resumes at the oldest unread message. A Solo chat's top-level row shows the newest top-level message from anyone else, even one that is not Inbox evidence, and is ordered by it. It skips messages addressed only to agents and roots that have their own thread row; unread counts still come only from evidence.
27+
The Mentions activity filter uses explicit mention messages for each conversation's preview, sender, ordering, resume point and unread count. A later ordinary reply does not make a read mention unread again. DMs remain direct activity rather than mentions merely because their recipient is tagged. All activity and Threads retain their conversation-wide projections. A row shows its newest message and sender, matching its time, while opening it still resumes at the oldest unread message. A Solo chat's top-level row shows the newest top-level message from anyone else and is ordered by it. It skips messages addressed only to agents and roots that have their own thread row.
2828
Rows retain exact IDs and current names while `inboxFeed.incomplete` marks only specific group members awaiting their stored edit/deletion closure. Those rows say “Preview updating…” or “Preview unavailable. Retry inbox.”; other rows stay usable. This is a visible completeness warning, not a guarantee that the relay did not change after verification. A failed read exposes Retry above the list. Retry stays focusable while pending; successful recovery returns focus to the Show filter only if Retry still owned focus when its alert was removed.
2929

30-
The list is the Inbox page's first tab, in the host tab workspace behind `conversation.ui.Tabs`. Opening a row shows its conversation beside the list in the side tab pane, with the same reader and composer as Channels tabs: a thread at its exact message, revealed even outside the newest bounded page, or a whole DM or session conversation where its Channels tab would open. A plain open replaces the tab the previous one added, so one tab follows the selection; a tab moved to the main pane stays. The tab's right-click menu offers Open in channel, which opens its conversation in Channels; a thread opens there at the same message. A thread also names its conversation above its original message, as the rows do (`#channel` or `DM · names`); that name is a link that does the same. The pane resizes, closes and handles Escape as Channels' does. A late verified root can regroup a conversation without changing its open tab. Inbox tabs do not enter a channel visit, so showing one preserves forced-unread intent. Reading is saved by the shared unread owner, through the reader's dwell and the row's explicit read. As in a plain channel visit, the visible selected side tab reads while focus stays anywhere on the page, such as on the row that opened it; a tab moved to the main pane reads only by its own focus. Failed read actions retain their captured Retry unless access, the session or a newer intent retires it. A DM Retry reuses the original channel cutoff and manual-clear keys, not the retry-time clock or later arrivals. Re-clicking the selected row reselects its tab without repeating its read. Closing the tab ends the selection, so reopening the row reads it again. Archiving the selected conversation's channel, or its room becoming a Huddle, closes its tab and returns focus it held to the filters, and restoring the channel does not reopen it; other retained tabs follow Channels' unavailable placeholder, and focus their reader held moves to the tab. Re-clicking the selected row reveals its current message in its tab; a session mention that regrouped into a thread reselects its timeline tab. Context menus allow device-local Mark unread. Row accessible descriptions reuse the visible safe preview or incomplete placeholder; Show more follows the filtered result count. `NavigationItem` owns selected styling and `aria-current`. No Inbox-owned session, parallel fold, composer or outbox.
30+
The list is the Inbox page's first tab, in the host tab workspace behind `conversation.ui.Tabs`. Opening a row shows its conversation beside the list in the side tab pane, with the same reader and composer as Channels tabs: a thread at its exact message, revealed even outside the newest bounded page, or a whole DM or session conversation where its Channels tab would open. A plain open replaces the tab the previous one added, so one tab follows the selection; a tab moved to the main pane stays. The tab's right-click menu offers Open in channel, which opens its conversation in Channels; a thread opens there at the same message. A thread also names its conversation above its original message, as the rows do (`#channel` or `DM · names`); that name is a link that does the same. The pane resizes, closes and handles Escape as Channels' does. A late verified root can regroup a conversation without changing its open tab. Inbox tabs do not enter a channel visit, so showing one preserves forced-unread intent. Reading is saved by the shared unread owner, through the reader's dwell and the row's explicit read. A Solo chat's top-level row reads in one save, as its live bottom does: the channel catch-up mark reads its ordinary responses, and mentions are read individually, so its thread rows stay unread. As in a plain channel visit, the visible selected side tab reads while focus stays anywhere on the page, such as on the row that opened it; a tab moved to the main pane reads only by its own focus. Unlike a restored Channels side tab, an Inbox tab restored on returning to Inbox also reads, since it is still the selected conversation. Failed read actions retain their captured Retry unless access, the session or a newer intent retires it. A DM Retry reuses the original channel cutoff and manual-clear keys, not the retry-time clock or later arrivals. Re-clicking the selected row reselects its tab without repeating its read. Closing the tab ends the selection, so reopening the row reads it again. Archiving the selected conversation's channel, or its room becoming a Huddle, closes its tab and returns focus it held to the filters, and restoring the channel does not reopen it; other retained tabs follow Channels' unavailable placeholder, and focus their reader held moves to the tab. Re-clicking the selected row reveals its current message in its tab; a session mention that regrouped into a thread reselects its timeline tab. Context menus allow device-local Mark unread. Row accessible descriptions reuse the visible safe preview or incomplete placeholder; Show more follows the filtered result count. `NavigationItem` owns selected styling and `aria-current`. No Inbox-owned session, parallel fold, composer or outbox.
3131

3232
Solo chats include ordinary incoming top-level messages, excluding agent-only coordination and system events. Their flat rows appear under All, not DMs, matching the sidebar's separate Solo and Direct messages sections; nested threads stay separate. Reading in Channels or Inbox clears the same evidence.
3333

‎src/bundled/inbox/InboxPage.test.tsx‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3807,6 +3807,19 @@ it("a Solo chat row includes ordinary agent responses under All, not DMs, keepin
38073807
await waitFor(() => expect(rows()[0]).toHaveTextContent("Agent progress"));
38083808
expect(rows()[1]).toHaveTextContent("A thread update");
38093809
expect(screen.queryByText("Please review this")).not.toBeInTheDocument();
3810+
// Opening the timeline row reads it with one channel catch-up mark, leaving
3811+
// its separate thread row unread.
3812+
const before = h.journal()?.revision ?? 0;
3813+
fireEvent.click(
3814+
within(rows()[0] as HTMLElement).getByRole("button", { name: /^Open / }),
3815+
);
3816+
await waitFor(() =>
3817+
expect(h.journal()?.state.frontiers["activity:room"]).toBe(30),
3818+
);
3819+
expect(h.journal()?.revision).toBe(before + 1);
3820+
expect(
3821+
within(rows()[1] as HTMLElement).getByRole("img", { name: "Unread" }),
3822+
).toBeInTheDocument();
38103823
// The sidebar keeps Solo chats apart from direct messages; so does Inbox.
38113824
await chooseFilter("DMs");
38123825
expect(screen.queryByText("Agent progress")).not.toBeInTheDocument();

‎src/bundled/inbox/InboxPage.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,9 @@ function InboxList({
841841
else if (item.target.kind === "channel") {
842842
readChannel ??= session.unread.prepareChannelRead(item.channelId);
843843
await readChannel();
844-
} else
844+
} else if (item.timeline)
845+
await session.unread.markTimelineRead(item.channelId, item.messageIds);
846+
else
845847
while (remaining.length) {
846848
// Close/Escape retires undispatched steps, not the admitted save.
847849
// Its genuine storage/access rejection still propagates through run.

‎src/bundled/inbox/archive.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ it("keeps a Solo chat mention visible when an earlier archive covers only part o
287287
const merged: InboxItem = {
288288
...archived,
289289
id: "chat:chat",
290+
timeline: true,
290291
messageIds: [...kept.messageIds, ...archived.messageIds],
291292
messages: [...kept.messages, ...archived.messages],
292293
};
@@ -620,11 +621,12 @@ it("reports a genuine reopening write failure without retiring the archive", ()
620621
expect(viewRevision(h.scope, archiveKey)).toBe(revision);
621622
});
622623

623-
it("reopens a flat Solo conversation on an ordinary response with message read targets", () => {
624+
it("reopens a flat Solo conversation on an ordinary response", () => {
624625
const h = fixture();
625626
const item = {
626627
...h.item,
627628
id: "room:room",
629+
timeline: true as const,
628630
mentioned: false,
629631
messages: h.item.messages.map((entry) => ({ ...entry, mentioned: false })),
630632
};

‎src/bundled/inbox/archive.ts‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,10 @@ function matches(index: ArchiveIndex, item: InboxItem) {
7070
}
7171

7272
// The shared Inbox projection groups DMs under a channel read target,
73-
// including top-level messages and replies. Solo flat rows use the same
74-
// channel coordinate but keep individual message read targets.
73+
// including top-level messages and replies, and a Solo chat's top-level
74+
// messages into one timeline row.
7575
const ordinaryActivity = (item: InboxItem) =>
76-
item.thread ||
77-
item.target.kind === "channel" ||
78-
item.id === `${item.channelId}:${item.channelId}`;
76+
item.thread || item.target.kind === "channel" || !!item.timeline;
7977

8078
function renewed(archive: Archive, item: InboxItem, mentionsOnly = false) {
8179
const observed = new Set(archive.messageIds);
@@ -92,7 +90,7 @@ function renewed(archive: Archive, item: InboxItem, mentionsOnly = false) {
9290
const partial = (entries: readonly Archive[], item: InboxItem) => {
9391
const observed = new Set(entries.flatMap((archive) => archive.messageIds));
9492
return (
95-
item.id === `${item.channelId}:${item.channelId}` &&
93+
!!item.timeline &&
9694
entries.some((archive) => archive.id !== item.id) &&
9795
!item.messageIds.every((id) => observed.has(id))
9896
);

‎src/features/relay/inbox.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ export type InboxItem = Readonly<{
2929
thread: boolean;
3030
unreadCount: number;
3131
manual: boolean;
32+
/** A session's top-level timeline row: its explicit read is one
33+
* `markTimelineRead` over `messageIds`, and `readThrough` is empty. */
34+
timeline?: true;
3235
/** Explicit prefixes; a thread prefix never acknowledges its top-level root. */
3336
readThrough: readonly Readonly<{ target: ReadTarget; messageId: string }>[];
3437
}>;

‎src/features/relay/unread.test.ts‎

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2734,11 +2734,12 @@ it("inbox groups a Solo chat's top-level timeline into one conversation, keeping
27342734
target: { kind: "message", channelId: "chat", messageId: second.id },
27352735
messageIds: [first.id, second.id],
27362736
thread: false,
2737+
timeline: true,
2738+
readThrough: [],
27372739
unreadCount: 2,
27382740
}),
27392741
]);
2740-
for (const step of chat()[1]?.readThrough ?? [])
2741-
await h.session.unread.markThrough(step.target, step.messageId);
2742+
await h.session.unread.markTimelineRead("chat", chat()[1]?.messageIds ?? []);
27422743
expect(chat().map((item) => item.unreadCount)).toEqual([1, 0]);
27432744
const incoming = message(h.alice, "chat", "New response", 26);
27442745
const bottom = message(h.alice, "chat", "Quiet", 28, [
@@ -2753,6 +2754,59 @@ it("inbox groups a Solo chat's top-level timeline into one conversation, keeping
27532754
lease.dispose();
27542755
});
27552756

2757+
it("reading a Solo chat's timeline row takes one save however many responses it retains", async () => {
2758+
const h = setup();
2759+
h.grant("chat");
2760+
h.emit([
2761+
metadata(h.relay, "chat", "Solo chat", 11, [
2762+
["t", "stream"],
2763+
["private"],
2764+
["t", SOLO_LABEL],
2765+
]),
2766+
]);
2767+
const responses = Array.from({ length: 150 }, (_, index) =>
2768+
message(h.alice, "chat", `Response ${index}`, 20 + index),
2769+
);
2770+
const ping = message(h.alice, "chat", "Ping", 200, [["p", h.viewer.pubkey]]);
2771+
const root = message(h.viewer, "chat", "My thread", 201);
2772+
const reply = message(h.alice, "chat", "Reply", 202, [
2773+
["e", root.id, "", "reply"],
2774+
]);
2775+
const last = message(h.alice, "chat", "Last", 203);
2776+
h.emit([...responses, ping, root, reply, last]);
2777+
const chat = () =>
2778+
h.session.unread.inbox().items.filter((item) => item.channelId === "chat");
2779+
const row = () => chat().find((item) => item.timeline);
2780+
// A read response the viewer marked unread stays in the row's one save.
2781+
const [marked] = responses;
2782+
if (!marked) throw new Error("missing response");
2783+
await h.session.unread.markMessageRead("chat", marked.id);
2784+
await h.session.unread.markUnreadLocal({
2785+
kind: "message",
2786+
channelId: "chat",
2787+
messageId: marked.id,
2788+
});
2789+
expect(row()).toMatchObject({
2790+
unreadCount: 152,
2791+
manual: true,
2792+
readThrough: [],
2793+
});
2794+
const before = h.journal()?.revision ?? 0;
2795+
await h.session.unread.markTimelineRead("chat", row()?.messageIds ?? []);
2796+
expect(h.journal()?.revision).toBe(before + 1);
2797+
expect(row()).toMatchObject({ unreadCount: 0, manual: false });
2798+
expect(chat().find((item) => item.thread)?.unreadCount).toBe(1);
2799+
const marks = h.journal()?.state.frontiers ?? {};
2800+
expect(marks["activity:chat"]).toBe(203);
2801+
expect(marks[`msg:${ping.id}`]).toBe(200);
2802+
// The catch-up mark covers ordinary responses, so none keeps its own mark.
2803+
expect(Object.keys(marks)).toEqual(
2804+
expect.not.arrayContaining(responses.map(({ id }) => `msg:${id}`)),
2805+
);
2806+
expect(h.session.unread.attention("chat", marked.id).unread).toBe(false);
2807+
expect(h.journal()?.localUnread).toEqual({});
2808+
});
2809+
27562810
it("inbox describes a Solo chat row by its newest top-level message, not only its Inbox evidence", () => {
27572811
const h = setup();
27582812
h.grant("chat");

0 commit comments

Comments
 (0)