Skip to content

Commit ed69074

Browse files
committed
Reduce Inbox to chat activity and consolidate DM labels
Signed-off-by: tulsi <[email protected]>
1 parent 4d0feda commit ed69074

12 files changed

Lines changed: 219 additions & 519 deletions

File tree

‎docs/inbox.md‎

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ does not enable it.
1818
never guessed as Humans. Profiles load for bounded activity candidates even
1919
when the sender filter currently has no rows. Classification uses already-cached
2020
profiles for every evaluated author, including beyond that enrichment page.
21-
All keeps existing project and
22-
needs-action admission without offering separate filter choices.
21+
All includes only these chat conversations. Project and approval activity are
22+
outside this Inbox slice.
2323
- Incoming DMs grouped by channel; mentions and participating thread replies
2424
grouped by verified conversation. Each row shows its channel (#name) or DM
2525
participants in the same compact, muted highlight directly below the bold
2626
sender, without category tags; DMs show a text label without an extra icon.
2727
The lazy, finite viewer-addressed feed also
28-
supplies recent mentions and approval-related events. Own messages and generic
28+
supplies recent chat mentions. Own messages and generic
2929
channel traffic do not create rows. A mention may also match Threads.
3030
- Stable conversation IDs, newest relevant activity ordering and the oldest
3131
observed unread message as the opening anchor (latest when read). Selecting an
@@ -82,11 +82,10 @@ does not enable it.
8282
evidence and read actions. `session.inboxFeed` owns finite, verified addressed
8383
history and live reconciliation. Its admitted channel events contribute to the
8484
shared unread fold, never a second raw row projection that could resurrect
85-
own/deleted messages or invent unresolved conversation roots. Nonchat projection
86-
stays bounded and reprojects retained candidates on membership changes, including
87-
an empty admitted view becoming eligible after joining; this starts no new read.
88-
Project updates use the evidenced issue/PR root kind, otherwise
89-
open the repository rather than guessing an item type. Arrivals and admitted
85+
own/deleted messages or invent unresolved conversation roots. Inbox renders these
86+
shared conversation rows directly; there is no second project/approval row merge.
87+
The feed retains its existing bounded chat snapshot and membership reprojection,
88+
but that snapshot is not a separate row source or read-state owner. Arrivals and admitted
9089
deletions during a finite read are reconciled inside that attempt's bounds and
9190
generation. Inbox owns only presentation, filtering and selection. No parallel signing or persistence capability is added. Optional
9291
profile enrichment is background work; access, cache clear and session
@@ -103,8 +102,9 @@ disable read mutations. Saved frontiers are not proof of remote reconciliation.
103102

104103
This is **bounded recent evidence**, not a complete historical inbox. The unread
105104
owner retains at most 4,096 events / 8 MiB and observes up to 500 recent events
106-
per 128-channel roster batch; the addressed feed queries up to 50 mentions and
107-
20 approval events. Missing roots, participation, or older activity can omit
105+
per 128-channel roster batch; the addressed feed queries up to 50 chat mentions
106+
(kinds 9 and 40002) in one finite request. No project or approval kinds are
107+
requested. Missing roots, participation, or older activity can omit
108108
rows; an empty view does not mean all caught up. The UI initially renders 50
109109
conversations and Show more reveals the remaining rows in its current evidence.
110110
A ready Inbox has no permanent Refresh control. Failure offers local Retry;
@@ -135,9 +135,9 @@ is retryable, never proof of an empty thread. See
135135
Reminders and their NIP-ER lifecycle are **not included** in this change.
136136
The unfinished reminder prototype is preserved separately for later work,
137137
not shipped in the Inbox source or broker routes. Follow/mute Inbox policy,
138-
full backlog discovery and feed-only read-state parity need further work. Projects have preview/canonical navigation,
139-
but some approval rows lack useful detail. Removing their filter choices does not
140-
make All complete. Native/ACP packaged acceptance and human visual feedback
138+
full backlog discovery and nonchat activity are outside this slice. Project and
139+
approval queries, grouping, routing and detail presentation are deliberately
140+
excluded rather than presented as partial parity. Native/ACP packaged acceptance and human visual feedback
141141
remain open. Do not treat this as the full OG Inbox port.
142142

143143
## Verification and trying it
@@ -163,6 +163,13 @@ proves an old selected unread target outside the top-level head is focused and
163163
opens its exact canonical origin with one composer. These are fixture
164164
checks, not live acceptance.
165165

166+
The chat-only reduction removes the two project-root-routing tests with their
167+
removed implementation. Feed lifecycle coverage now uses chat events for the
168+
same finite/live arrival, deletion, revocation, cache reset, reconnect, pending
169+
disposal and membership transitions. Additional checks enforce one bounded
170+
chat-only query and no project/approval Inbox rows. Existing composer, draft
171+
storage, exact navigation, read-state and browser journeys remain.
172+
166173
In the agreed worktree, open the running isolated native Inbox Dev app (or its
167174
printed local URL). Choose a community and Inbox. Try both dropdowns and Unread
168175
only, then Drafts and Back to Inbox. Selecting an unread Inbox row changes real

‎src/bundled/inbox/DraftsView.tsx‎

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
listDraftViews,
2323
subscribeView,
2424
} from "../../shared/view-state";
25-
import { formatPublicKey } from "../../shared/identity/public-key";
2625
import { Avatar } from "../../shared/design-system/ui/Avatar";
2726
import { Button } from "../../shared/design-system/ui/Button";
2827
import { IconButton } from "../../shared/design-system/ui/IconButton";
@@ -33,6 +32,7 @@ import {
3332
XIcon,
3433
} from "../../shared/design-system/icons/index";
3534
import styles from "./Inbox.module.css";
35+
import { dmLabel } from "./dm-label";
3636

3737
export function DraftsView({
3838
session,
@@ -136,22 +136,7 @@ export function DraftsView({
136136
const destination = (channel: ChannelSummary | undefined) => {
137137
if (!channel) return "Unavailable conversation";
138138
if (channel.channelType !== "dm") return `#${channel.name}`;
139-
if (!channel.participants?.length) return "Notes to self";
140-
return (
141-
channel.participants
142-
.slice(0, 3)
143-
.map((id) =>
144-
name(
145-
id,
146-
profiles.get(id)?.name ?? formatPublicKey(id) ?? "Unknown person",
147-
channel.participants,
148-
),
149-
)
150-
.join(", ") +
151-
(channel.participants.length > 3
152-
? ` +${channel.participants.length - 3}`
153-
: "")
154-
);
139+
return dmLabel(channel.participants, profiles, name);
155140
};
156141
const activeChannel = active
157142
? channelFor(active.coordinates.channelId)

‎src/bundled/inbox/InboxDetail.tsx‎

Lines changed: 18 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@ import type { RelaySession } from "../../features/relay/session";
33
import type { NavigationScope } from "../../features/navigation/targets";
44
import type { Navigation } from "../../features/navigation/controller";
55
import type { ConversationExtensions } from "../../features/conversation/contracts";
6-
import type { InboxRow } from "./items";
6+
import type { InboxItem } from "../../features/relay/inbox";
77
import { ThreadPanel } from "../../features/messages/ThreadPanel";
88
import { ChannelPreview } from "./ChannelPreview";
99
import { useIdentityNames } from "../../features/identity-names/react";
1010
import { selectProfiles } from "../../features/relay/profile-selection";
11-
import { formatPublicKey } from "../../shared/identity/public-key";
12-
import { entityTarget } from "../../features/projects/routes";
1311
import { IconButton } from "../../shared/design-system/ui/IconButton";
1412
import {
1513
ArrowSquareOutIcon,
1614
XIcon,
1715
} from "../../shared/design-system/icons/index";
1816
import styles from "./Inbox.module.css";
17+
import { dmLabel } from "./dm-label";
1918

2019
export function InboxDetail({
2120
item,
@@ -27,7 +26,7 @@ export function InboxDetail({
2726
channelName,
2827
onBack,
2928
}: {
30-
item: InboxRow;
29+
item: InboxItem;
3130
anchor: string;
3231
session: RelaySession;
3332
scope: NavigationScope;
@@ -76,46 +75,24 @@ export function InboxDetail({
7675
.ensure(participantIds, "background")
7776
.catch(() => {});
7877
}, [session, participantIds, available, list.asOf]);
79-
const dmName =
80-
channel?.channelType === "dm"
81-
? channel.participants?.length
82-
? channel.participants
83-
.slice(0, 3)
84-
.map((id) =>
85-
name(
86-
id,
87-
profiles.get(id)?.name ??
88-
formatPublicKey(id) ??
89-
"Unknown person",
90-
channel.participants,
91-
),
92-
)
93-
.join(", ") +
94-
(channel.participants.length > 3
95-
? ` +${channel.participants.length - 3}`
96-
: "")
97-
: "Notes to self"
98-
: "";
78+
const dmName = dmLabel(channel?.participants, profiles, name);
9979
const open = async () => {
100-
const destination = item.project
101-
? entityTarget(item.project, scope)
102-
: {
103-
version: 1 as const,
104-
kind: "conversation" as const,
105-
scope,
106-
channelId: item.channelId,
107-
messageId: anchor,
108-
...(item.rootId ? { threadRootId: item.rootId } : {}),
109-
};
80+
const destination = {
81+
version: 1 as const,
82+
kind: "conversation" as const,
83+
scope,
84+
channelId: item.channelId,
85+
messageId: anchor,
86+
...(item.rootId ? { threadRootId: item.rootId } : {}),
87+
};
11088
const result = await navigator.open(destination);
11189
if (result.status === "failed")
11290
setError("This conversation could not be opened. Try again.");
11391
};
114-
const isProject = !!item.project;
11592
const openAction = (
11693
<IconButton
11794
size="toolbar"
118-
aria-label={isProject ? "Open in project" : "Open in channel"}
95+
aria-label="Open in channel"
11996
onClick={() => void open()}
12097
icon={<ArrowSquareOutIcon size={18} aria-hidden="true" />}
12198
/>
@@ -124,13 +101,11 @@ export function InboxDetail({
124101
<section className={styles.detail} aria-label="Inbox detail">
125102
<div className={styles.detailHeading}>
126103
<h2 className="text-label text-primary">
127-
{isProject
128-
? "Project update"
129-
: channel?.channelType === "dm"
130-
? `DM with ${dmName}`
131-
: `#${channelName}`}
104+
{channel?.channelType === "dm"
105+
? `DM with ${dmName}`
106+
: `#${channelName}`}
132107
</h2>
133-
{(isProject || !available) && (
108+
{!available && (
134109
<div className={styles.detailActions}>
135110
{openAction}
136111
<IconButton
@@ -148,14 +123,7 @@ export function InboxDetail({
148123
{error}
149124
</p>
150125
)}
151-
{isProject ? (
152-
<div className={styles.notice}>
153-
<p>{item.preview || "Project activity"}</p>
154-
<p className="text-body text-subtle">
155-
Open the project for its current review or task and actions.
156-
</p>
157-
</div>
158-
) : !available ? (
126+
{!available ? (
159127
<p role="status" className={styles.notice}>
160128
This conversation is unavailable. Open it in Channels to check
161129
access.

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,3 +2045,29 @@ it("hands keyboard focus into draft deletion and back on cancel without changing
20452045
"Keep this draft",
20462046
);
20472047
});
2048+
it("All activity stays chat-only when addressed project and approval evidence arrives", async () => {
2049+
const h = fixture();
2050+
const nonchat = [1621, 46010].map((kind) =>
2051+
signed(h.alice, {
2052+
kind,
2053+
content: `Not an Inbox conversation ${kind}`,
2054+
created_at: 40,
2055+
tags: [
2056+
["h", "room"],
2057+
["p", h.viewer.pubkey],
2058+
["a", `30617:${h.alice.pubkey}:repo`],
2059+
],
2060+
}),
2061+
);
2062+
h.events.push(...nonchat);
2063+
render(h.view);
2064+
await screen.findByText("Please review this");
2065+
await waitFor(() =>
2066+
expect(h.owner.session.inboxFeed.snapshot().status).toBe("ready"),
2067+
);
2068+
expect(rows()).toHaveLength(2);
2069+
act(() => h.emit(nonchat));
2070+
expect(rows()).toHaveLength(2);
2071+
expect(screen.queryByText(/Not an Inbox conversation/)).toBeNull();
2072+
expect(screen.queryByRole("button", { name: "Open in project" })).toBeNull();
2073+
});

‎src/bundled/inbox/InboxPage.tsx‎

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
import type { RelayData } from "../../features/relay/service";
99
import type { RelaySession } from "../../features/relay/session";
1010
import type { InboxItem } from "../../features/relay/inbox";
11-
import { mergeInboxItems, type InboxRow } from "./items";
1211
import { InboxDetail } from "./InboxDetail";
1312
import { DraftsView } from "./DraftsView";
1413
import type { ConversationExtensions } from "../../features/conversation/contracts";
@@ -34,6 +33,7 @@ import {
3433
MenuPopup,
3534
} from "../../shared/design-system/ui/Menu";
3635
import styles from "./Inbox.module.css";
36+
import { dmLabel } from "./dm-label";
3737

3838
type ActivityFilter = "all" | "dms" | "threads" | "mentions";
3939
type SenderFilter = "everyone" | "humans" | "agents";
@@ -49,20 +49,13 @@ const senders = [
4949
{ value: "agents", label: "Agents" },
5050
] as const;
5151
const matchesActivity = (
52-
item: InboxRow,
52+
item: InboxItem,
5353
filter: ActivityFilter,
5454
isDm: boolean,
5555
) => {
5656
switch (filter) {
5757
case "all":
58-
return !!(
59-
item.mentioned ||
60-
item.thread ||
61-
item.project ||
62-
item.needsAction ||
63-
item.agent ||
64-
item.target.kind === "channel"
65-
);
58+
return true;
6659
case "dms":
6760
return isDm;
6861
case "mentions":
@@ -193,7 +186,7 @@ export function InboxView({
193186
session.agentChoices.ensure();
194187
}
195188
}, [session, list.status, list.asOf, refreshAfterRoster]);
196-
const items = mergeInboxItems(inbox.items, feed, list.channels, session);
189+
const items = inbox.items;
197190
const activityItems = items.filter((item) =>
198191
matchesActivity(
199192
item,
@@ -574,33 +567,18 @@ export function InboxView({
574567
"Unknown sender",
575568
channel?.members,
576569
);
577-
const dmName = channel?.participants
578-
? channel.participants.length
579-
? channel.participants
580-
.slice(0, 3)
581-
.map((id) =>
582-
name(
583-
id,
584-
profiles.get(id)?.name ??
585-
formatPublicKey(id) ??
586-
"Unknown person",
587-
channel.participants,
588-
),
589-
)
590-
.join(", ") +
591-
(channel.participants.length > 3
592-
? ` +${channel.participants.length - 3}`
593-
: "")
594-
: "Notes to self"
595-
: (channel?.name ?? "Direct message");
570+
const dmName = dmLabel(
571+
channel?.participants,
572+
profiles,
573+
name,
574+
channel?.name ?? "Direct message",
575+
);
596576
const context =
597577
channel?.channelType === "dm"
598578
? `DM · ${dmName}`
599579
: channel
600580
? `#${channel.name}`
601-
: item.project
602-
? "Project update"
603-
: "Conversation";
581+
: "Conversation";
604582
const unread = hasUnread(item);
605583
return (
606584
<li

‎src/bundled/inbox/dm-label.test.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { expect, it, vi } from "vitest";
2+
import { dmLabel } from "./dm-label";
3+
import { publicKeyLabels } from "../../shared/identity/public-key";
4+
5+
it("keeps roster identity order, bounded labels, and the full namesake comparison set", () => {
6+
const keys = ["a", "b", "c", "d"].map((c) => c.repeat(64));
7+
const profiles = new Map(keys.map((key) => [key, { name: "Same" }]));
8+
const suffix = publicKeyLabels(keys);
9+
const resolve = vi.fn(
10+
(key: string, fallback: string) => `${fallback} · ${suffix.get(key)}`,
11+
);
12+
expect(dmLabel(keys, profiles, resolve)).toBe(
13+
`${keys
14+
.slice(0, 3)
15+
.map((key) => `Same · ${suffix.get(key)}`)
16+
.join(", ")} +1`,
17+
);
18+
expect(resolve).toHaveBeenCalledTimes(3);
19+
for (const key of keys.slice(0, 3))
20+
expect(resolve).toHaveBeenCalledWith(key, "Same", keys);
21+
});
22+
it("preserves missing-roster versus self-DM fallback and uses public labels for unnamed participants", () => {
23+
const key = "a".repeat(64),
24+
names = new Map();
25+
const resolve = (_key: string, fallback: string) => fallback;
26+
expect(dmLabel(undefined, names, resolve, "Room name")).toBe("Room name");
27+
expect(dmLabel([], names, resolve, "Room name")).toBe("Notes to self");
28+
expect(dmLabel(undefined, names, resolve)).toBe("Notes to self");
29+
expect(dmLabel([key], names, resolve)).toBe(publicKeyLabels([key]).get(key));
30+
});

0 commit comments

Comments
 (0)