Skip to content

Commit 2bd4c24

Browse files
delkcclaude
andauthored
Inbox refactor (#2045)
## Why The Inbox mixed overlapping feed categories with personal work queues, so **All** was not actually comprehensive and several filters did not make it clear why an item appeared. Threads and DMs could produce one row per event instead of one row per conversation, drafts were hidden until selected, and reminders appeared through multiple competing presentations. This refactor makes the **Inbox** a focused, conversation-oriented place to catch up on work relevant to you. It is intentionally not a mirror of every unread event in every channel. ## What changed - Keep the destination named **Inbox** and use the standard Lucide bell icon. - Refocus **All** on DMs, mentions, thread replies, needs-action items, replies from agents the user owns or controls, due reminders, and active drafts. - Exclude generic top-level channel traffic and updates from agents the user does not own or control. - Group each thread or DM into one row, sorted by latest activity. - Resume an unread conversation at its oldest unread message while opening the full thread or DM in the detail pane. - Reuse the existing **New** divider at the unread boundary. - Make the detail title a direct link to the canonical conversation. - Give Reminders and Drafts the same list/detail interaction and location metadata as conversation rows. - Separate Reminders and Drafts from message filters with a subtle divider, without adding another labeled section. - Put reminder and draft counts beside their corresponding filter labels instead of on the generic filter button. - Preserve the selected conversation when switching filters if it remains valid; otherwise select a valid replacement without flashing stale detail. - Use filter-specific empty states and rename the options toggle to **Show unread only**. - Ship the focused behavior directly. The earlier experiment gate, Custom view, and default-view controls have been removed from this PR to keep the first pass focused. ## Filter model | Filter | What appears | | --- | --- | | **All** | One row per personally relevant conversation, plus due reminders and active drafts. Includes DMs, mentions, thread replies, explicit needs-action items, and replies from agents the current user owns or controls. Excludes generic top-level channel traffic, other agents' updates, and reminders that are not due yet. | | **Mentions** | Conversations containing a direct mention. Each conversation appears once and opens with full context. | | **Threads** | Conventional threaded replies, grouped to one row per thread. Broadcast replies are not treated as conventional thread replies. | | **Needs action** | Feed items explicitly classified as requiring action. | | **Agents** | Conversations whose representative response was authored by an agent the current user owns or controls, including top-level DM responses. If a human replies afterward, the conversation leaves this filter until an owned agent responds again. | | **Reminders** | All pending reminders, including upcoming reminders that stay out of **All** until they are due. | | **Drafts** | Active drafts, ordered by their last real edit time. | ## Grouping, ordering, and state - A thread or DM creates one Inbox row rather than one row per event. - An unread conversation resumes at its oldest unread message so intervening context is not skipped. - Conversation rows still sort by their latest activity. - The detail pane opens the full available conversation and shows the shared **New** divider before the first unread message. - Upcoming reminders appear only in **Reminders**. - When a reminder becomes due, it enters **All** at its trigger time. If its source conversation is already represented, the reminder state merges into that row instead of creating a duplicate; otherwise it appears as a standalone reminder row. - A due reminder can enrich a row in another relative filter when that conversation already qualifies for the filter. Reminder lifecycle remains separate from message read state. - Drafts appear in **All** by their last real edit time. Opening an unchanged draft does not move it to the top. - Reminder and draft rows show their location as `In #channel` or `In DM with <name>`. - **Show unread only** hides reminder and draft work queues because they do not share message unread semantics. ## Removed or narrowed - **Remove the old Activity filter.** It overlapped with All while still omitting items All now includes. - **Narrow Agents.** It no longer gathers every agent participating in a shared thread or subsequent human follow-ups. - **Remove duplicate reminder presentations.** The aggregate pending-reminders jump and duplicate generic feed rows are replaced by one list/detail model. - **Remove Custom and default-view settings from this pass.** They added considerable state and UI before the core model had been validated. - **Do not add section labels for Reminders and Drafts.** A divider communicates the distinction without creating another hierarchy in the menu. ## Risk assessment Medium implementation risk because this changes composition, grouping, ordering, read behavior, and personal queues in a primary desktop view. The implementation is scoped to the desktop UI and its local feed projection; it does not change relay schemas or public APIs. ## Testing - Desktop formatting, lint, file-size, text-size, and TypeScript checks passed. - Desktop unit suite: **3,663 passed, 0 failed**. - Desktop E2E production build passed. - Playwright smoke coverage across every spec touching this surface (`channels`, `smoke`, `profile`, `project-inbox`, `community-rail`, `integration`, `drafts-screenshots`): **118 passed, 0 failed**. - Full Playwright smoke project: **732 passed, 1 skipped**. Three local failures were investigated and cleared — `community-rail` keyboard reorder passed on re-run (flaky), while `relay-reconnect:97` and `video-attachment:223` are untouched by this commit (the only change to shared `tests/helpers/bridge.ts` is a comment) and pass in CI. - Unit coverage includes focused All matching, owned-agent filtering, conversation grouping, oldest-unread selection, selection stability, chronological reminder/draft composition, trigger-time reminder ordering, and duplicate reminder suppression. ## Update: July 27, 2026 The naming decision is settled: the surface stays **Inbox**. An earlier pass in this branch had renamed it to **Activity**; that rename has been reverted in `9c00d2d6e`, which is naming-only and changes no behavior. The revert covers file names, component/hook/type/constant identifiers, the sidebar label and tooltip, the `Inbox options` and `Filter inbox:` aria-labels, and the corresponding test names, test ids, and fixture ids. Three things were deliberately left as `activity`: - **The feed API contract** — the `activity` / `agent_activity` categories, the `feed.activity` and `feed.agentActivity` keys, and the `types=` query parameter. These are the server's names, not the surface's. - **Plain-noun usage** — empty states such as "No activity yet", plus `latestActivityAt` and `PROJECT_ACTIVITY_KINDS`. - **Pre-existing agent, project, and profile activity code**, which refers to a different concept entirely. The earlier experiment-gate approach has also been dropped, so `tests/helpers/bridge.ts` no longer claims that an Activity preview feature exists — `preview-features.json` has no such entry and the seed helper enables every desktop feature. Generated with Codex --------- Signed-off-by: Clay Delk <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
1 parent 99da5b7 commit 2bd4c24

43 files changed

Lines changed: 3533 additions & 660 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎AGENTS.md‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,19 @@ Add specs to `desktop/tests/e2e/` and register them in `playwright.config.ts`
343343
(`smoke` project `testMatch`). Every test calls `installMockBridge(page)` for
344344
mock Tauri IPC. Mock pubkey, channel names, and UUIDs live in `e2eBridge.ts`.
345345

346+
**Always build with `pnpm build:e2e`, never `pnpm run build`.** The mock Tauri
347+
bridge is compiled in only for `--mode e2e` (see `installE2eBridgeIfConfigured`
348+
in `desktop/src/main.tsx`). A plain `pnpm run build` strips it, so
349+
`window.__TAURI_INTERNALS__` is never defined and **every** mock-mode spec fails
350+
with `Cannot read properties of undefined (reading 'invoke')` — the app renders
351+
"Community connection failed" instead of the UI under test. That looks exactly
352+
like a product bug rather than a build mistake, so it burns real time.
353+
`pnpm test:e2e:smoke` and `pnpm test:e2e:integration` run the right build for
354+
you; prefer them over a manual build plus `playwright test`.
355+
346356
**Stale server:** `reuseExistingServer: true` means a previous build's server
347-
serves old code. Kill port 4173 and `pnpm run build` before re-running tests
348-
after code changes.
357+
serves old code. Kill port 4173 and re-run `pnpm build:e2e` before re-running
358+
tests after code changes.
349359

350360
**`addInitScript` before bridge:** `page.addInitScript` (localStorage seeding)
351361
must run BEFORE `installMockBridge(page)` — React reads state on mount, the

‎desktop/playwright.config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export default defineConfig({
103103
"**/project-pr-review.spec.ts",
104104
"**/persona-model-combobox-screenshots.spec.ts",
105105
"**/drafts-screenshots.spec.ts",
106+
"**/inbox-refactor-screenshots.spec.ts",
106107
"**/buzz-theme-screenshots.spec.ts",
107108
"**/channel-sort.spec.ts",
108109
"**/identity-lost.spec.ts",

‎desktop/src/app/AppShell.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ import { useMessageDeepLinks } from "@/shared/useMessageDeepLinks";
9696
import { SidebarInset, SidebarProvider } from "@/shared/ui/sidebar";
9797
import { RelayConnectionOverlay } from "@/app/RelayConnectionOverlay";
9898
import { useSidebarRelayConnectionCard } from "@/features/sidebar/ui/useSidebarRelayConnectionCard";
99+
99100
const LazySettingsScreen = React.lazy(async () => {
100101
const module = await import("@/features/settings/ui/SettingsScreen");
101102
return { default: module.SettingsScreen };
@@ -105,7 +106,6 @@ export function AppShell() {
105106
useWebviewZoomShortcuts();
106107
useTauriWindowDrag();
107108
useWebviewScrollBoundaryLock();
108-
109109
const communitiesHook = useCommunities();
110110
const hasCommunityRail = communitiesHook.communities.length > 1;
111111
const addCommunityDialog = useAddCommunityDialogState();

‎desktop/src/app/useThreadActivityFeedItems.test.mjs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,18 @@ test("channel-presence fence applies before mute filter — unknown channel + mu
113113

114114
assert.deepEqual(items, []);
115115
});
116+
117+
test("top-level DM activity is included in Activity", () => {
118+
const dmItem = threadActivityItem({
119+
id: "agent-dm-reply",
120+
tags: [["h", CHANNEL_ID]],
121+
});
122+
const channels = [{ id: CHANNEL_ID, name: "Agent DM", channelType: "dm" }];
123+
124+
assert.deepEqual(
125+
buildThreadActivityFeedItems([dmItem], new Set(), channels).map(
126+
(item) => item.id,
127+
),
128+
["agent-dm-reply"],
129+
);
130+
});

‎desktop/src/app/useThreadActivityFeedItems.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export function buildThreadActivityFeedItems(
1717
// is present in the active community's channel set. Rows persisted under
1818
// a different relay's scope key should never reach this function, but
1919
// this filter is the last line of defense against cross-community leaks.
20-
if (channelById.get(item.channelId) === undefined) return false;
20+
const channel = channelById.get(item.channelId);
21+
if (channel === undefined) return false;
2122
const rootId = getThreadReference(item.tags).rootId;
2223
return !rootId || !mutedRootIds.has(rootId);
2324
})

‎desktop/src/features/agents/knownAgentPubkeys.test.mjs‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import assert from "node:assert/strict";
22
import test from "node:test";
33

4-
import { mergeKnownAgentPubkeys } from "./knownAgentPubkeys.ts";
4+
import {
5+
mergeKnownAgentPubkeys,
6+
mergeOwnedAgentPubkeys,
7+
} from "./knownAgentPubkeys.ts";
58

69
const MANAGED =
710
"1111111111111111111111111111111111111111111111111111111111111111";
@@ -34,3 +37,26 @@ test("normalisesCaseAndWhitespace_dedupingAcrossSources", () => {
3437

3538
assert.deepEqual([...merged], [MANAGED]);
3639
});
40+
41+
test("owned agents include managed and profile-declared agents", () => {
42+
const merged = mergeOwnedAgentPubkeys(
43+
[{ pubkey: MANAGED }],
44+
{
45+
[RELAY]: { ownerPubkey: " owner " },
46+
other: { ownerPubkey: "somebody-else" },
47+
},
48+
"OWNER",
49+
);
50+
51+
assert.deepEqual([...merged].sort(), [MANAGED, RELAY].sort());
52+
});
53+
54+
test("owned agents exclude agents controlled by somebody else", () => {
55+
const merged = mergeOwnedAgentPubkeys(
56+
undefined,
57+
{ [RELAY]: { ownerPubkey: "somebody-else" } },
58+
"owner",
59+
);
60+
61+
assert.equal(merged.size, 0);
62+
});

‎desktop/src/features/agents/knownAgentPubkeys.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,34 @@ export function mergeKnownAgentPubkeys(
2222
return pubkeys;
2323
}
2424

25+
/** Agent identities controlled by the current user. */
26+
export function mergeOwnedAgentPubkeys(
27+
managedAgents: readonly { pubkey: string }[] | undefined,
28+
profiles:
29+
| Readonly<Record<string, { ownerPubkey?: string | null }>>
30+
| undefined,
31+
currentPubkey: string | null | undefined,
32+
): ReadonlySet<string> {
33+
const pubkeys = new Set<string>();
34+
for (const agent of managedAgents ?? []) {
35+
pubkeys.add(normalizePubkey(agent.pubkey));
36+
}
37+
38+
if (!currentPubkey) return pubkeys;
39+
40+
const ownerPubkey = normalizePubkey(currentPubkey);
41+
for (const [pubkey, profile] of Object.entries(profiles ?? {})) {
42+
if (
43+
profile.ownerPubkey &&
44+
normalizePubkey(profile.ownerPubkey) === ownerPubkey
45+
) {
46+
pubkeys.add(normalizePubkey(pubkey));
47+
}
48+
}
49+
50+
return pubkeys;
51+
}
52+
2553
/**
2654
* Channel-scoped variant: the managed ∪ relay baseline plus this channel's
2755
* bot members (role `bot` or `isAgent`), so member-only agents are included.

‎desktop/src/features/channels/useLiveChannelUpdates.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ export function isChannelUnreadTriggerKind(kind: number, isDmChannel: boolean) {
8888
: UNREAD_TRIGGER_KINDS.has(kind);
8989
}
9090

91+
export function isHomeActivityEvent(
92+
isDmChannel: boolean,
93+
isThreadedReply: boolean,
94+
) {
95+
return isThreadedReply || isDmChannel;
96+
}
97+
9198
export function withChannelTagFallback(
9299
event: RelayEvent,
93100
channelId: string,
@@ -278,7 +285,7 @@ export function useLiveChannelUpdates(
278285
}
279286
} else {
280287
options.onChannelMessage?.(channelId, event);
281-
if (isThreadedReply) {
288+
if (isHomeActivityEvent(isDmChannel, isThreadedReply)) {
282289
options.onThreadReplyNotification?.(channelId, event);
283290
}
284291
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import type { InboxItem } from "@/features/home/lib/inbox";
2+
3+
export function getHomeMessageCapabilities(
4+
item: InboxItem | null,
5+
currentPubkey: string | undefined,
6+
availableChannelIds: ReadonlySet<string>,
7+
) {
8+
const canReact = Boolean(
9+
item?.item.channelId && availableChannelIds.has(item.item.channelId),
10+
);
11+
const canReply =
12+
canReact && item?.item.kind !== 45001 && item?.item.kind !== 45003;
13+
const disabledReplyReason =
14+
canReply || !item
15+
? null
16+
: item.item.channelId
17+
? availableChannelIds.has(item.item.channelId)
18+
? "This item does not support inline replies yet."
19+
: "Open the linked channel to reply."
20+
: "This inbox item does not have a reply target.";
21+
22+
return {
23+
canDelete:
24+
item !== null &&
25+
currentPubkey?.trim().toLowerCase() ===
26+
item.item.pubkey.trim().toLowerCase(),
27+
canReact,
28+
canReply,
29+
disabledReplyReason,
30+
};
31+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { INBOX_COLUMN_MIN_WIDTH_PX } from "@/features/home/useResizableInboxListWidth";
2+
3+
type HomePaneLayoutOptions = {
4+
hasAuxiliaryPane: boolean;
5+
homeWidthPx: number;
6+
inboxListWidthPx: number;
7+
isDrafts: boolean;
8+
isMessagesMode: boolean;
9+
isNarrow: boolean;
10+
isReminders: boolean;
11+
isSinglePanelAuxiliaryView: boolean;
12+
selectedDraft: boolean;
13+
selectedEvent: boolean;
14+
selectedReminder: boolean;
15+
threadPanelWidthPx: number;
16+
};
17+
18+
export function getHomePaneLayout(options: HomePaneLayoutOptions) {
19+
const singleMessage =
20+
options.isMessagesMode &&
21+
options.isNarrow &&
22+
options.selectedEvent &&
23+
!options.isSinglePanelAuxiliaryView;
24+
const singleDraft =
25+
options.isDrafts &&
26+
options.isNarrow &&
27+
options.selectedDraft &&
28+
!options.isSinglePanelAuxiliaryView;
29+
const singleReminder =
30+
options.isReminders &&
31+
options.isNarrow &&
32+
options.selectedReminder &&
33+
!options.isSinglePanelAuxiliaryView;
34+
const showList =
35+
!singleMessage &&
36+
!singleDraft &&
37+
!singleReminder &&
38+
!options.isSinglePanelAuxiliaryView;
39+
const showDetail =
40+
!options.isSinglePanelAuxiliaryView &&
41+
((options.isMessagesMode && (!options.isNarrow || singleMessage)) ||
42+
(options.isDrafts && (!options.isNarrow || singleDraft)) ||
43+
(options.isReminders && (!options.isNarrow || singleReminder)));
44+
const auxiliaryWidth = options.isSinglePanelAuxiliaryView
45+
? options.homeWidthPx
46+
: options.threadPanelWidthPx;
47+
const maxListWidth =
48+
options.homeWidthPx > 0
49+
? Math.max(
50+
INBOX_COLUMN_MIN_WIDTH_PX,
51+
options.homeWidthPx -
52+
INBOX_COLUMN_MIN_WIDTH_PX -
53+
(options.hasAuxiliaryPane ? auxiliaryWidth : 0),
54+
)
55+
: undefined;
56+
57+
return {
58+
auxiliaryPaneWidthPx: auxiliaryWidth,
59+
effectiveInboxListWidthPx:
60+
options.homeWidthPx > 0
61+
? Math.min(
62+
options.inboxListWidthPx,
63+
maxListWidth ?? options.inboxListWidthPx,
64+
)
65+
: options.inboxListWidthPx,
66+
isSinglePanelDetailView: singleMessage,
67+
isSinglePanelDraftDetailView: singleDraft,
68+
isSinglePanelReminderDetailView: singleReminder,
69+
showDetailPane: showDetail,
70+
showListPane: showList,
71+
};
72+
}

0 commit comments

Comments
 (0)