Skip to content

Commit 0828992

Browse files
Bartok9Bartok9
authored andcommitted
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]> (cherry picked from commit f372981) Signed-off-by: Bartok9 <[email protected]>
1 parent a567dfc commit 0828992

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
@@ -135,10 +135,17 @@ pub async fn get_feed(
135135
let mention_owner_pubkeys = fetch_agent_owner_pubkeys(&state, &mention_events).await;
136136
let suppressed_mentions =
137137
link_preview_suppression_targets(&mention_events, &mention_edits, &mention_owner_pubkeys);
138+
// Category must be the singular `"mention"` to match the `FeedItemCategory`
139+
// union in desktop/src/shared/api/types.ts and every frontend comparison
140+
// (feed.ts / inbox.ts) as well as the e2e bridge, which already emits the
141+
// singular. Emitting "mentions" here made native mention items fall through
142+
// to the needs-action fallback title (#2106). The `types` request filter
143+
// keyword ("mentions") is a separate API surface and is intentionally
144+
// left unchanged.
138145
let mentions: Vec<FeedItemInfo> = mention_events
139146
.iter()
140147
.map(|ev| {
141-
let mut item = feed_item_from_event(ev, "mentions");
148+
let mut item = feed_item_from_event(ev, "mention");
142149
apply_link_preview_suppression(&mut item.tags, &item.id, &suppressed_mentions);
143150
item
144151
})

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

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

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

0 commit comments

Comments
 (0)