Skip to content

Commit f372981

Browse files
author
Bartok9
committed
fix(desktop): emit singular "mention" feed category to match frontend contract
Native `get_feed` emitted feed items with `category: "mentions"` (plural), but the `FeedItemCategory` union (shared/api/types.ts) and every frontend comparison (feed.ts, inbox.ts) use the singular `"mention"` — as does the e2e bridge. The mismatch made native mention items fall through to the needs-action fallback, so a mention toasted as "Needs Action in #channel" instead of "X mentioned you in #channel" (observed live in block#2105), and inbox labeling/priority misclassified them. Emit the singular `"mention"` to match the declared contract. The `types` request-filter keyword ("mentions") is a separate API surface and is left unchanged. Adds a regression test asserting the emitted category. Refs block#2106 Signed-off-by: Bartok9 <[email protected]>
1 parent df9e773 commit f372981

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

‎desktop/src-tauri/src/commands/messages.rs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,17 @@ pub async fn get_feed(
132132
let mention_owner_pubkeys = fetch_agent_owner_pubkeys(&state, &mention_events).await;
133133
let suppressed_mentions =
134134
link_preview_suppression_targets(&mention_events, &mention_edits, &mention_owner_pubkeys);
135+
// Category must be the singular `"mention"` to match the `FeedItemCategory`
136+
// union in desktop/src/shared/api/types.ts and every frontend comparison
137+
// (feed.ts / inbox.ts) as well as the e2e bridge, which already emits the
138+
// singular. Emitting "mentions" here made native mention items fall through
139+
// to the needs-action fallback title (#2106). The `types` request filter
140+
// keyword ("mentions") is a separate API surface and is intentionally
141+
// left unchanged.
135142
let mentions: Vec<FeedItemInfo> = mention_events
136143
.iter()
137144
.map(|ev| {
138-
let mut item = feed_item_from_event(ev, "mentions");
145+
let mut item = feed_item_from_event(ev, "mention");
139146
apply_link_preview_suppression(&mut item.tags, &item.id, &suppressed_mentions);
140147
item
141148
})

‎desktop/src-tauri/src/commands/messages_tests.rs‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,19 @@ fn legacy_managed_agent_auth_tag_skips_self_attestation() {
217217

218218
assert_eq!(tag, None);
219219
}
220+
221+
#[test]
222+
fn feed_item_category_matches_frontend_union_singular() {
223+
// The desktop `FeedItemCategory` union (shared/api/types.ts) and every
224+
// frontend comparison (feed.ts / inbox.ts) plus the e2e bridge use the
225+
// SINGULAR "mention". get_feed must emit that exact value so native
226+
// mention items render the "X mentioned you" title instead of falling
227+
// through to the needs-action fallback (#2106).
228+
let keys = nostr::Keys::generate();
229+
let ev = nostr::EventBuilder::text_note("hi")
230+
.sign_with_keys(&keys)
231+
.expect("sign");
232+
let item = feed_item_from_event(&ev, "mention");
233+
assert_eq!(item.category, "mention");
234+
assert_ne!(item.category, "mentions", "must not emit the plural form");
235+
}

0 commit comments

Comments
 (0)