Repository navigation
fix(people): correct social analytics and activity counts - #290
NeerajCodz wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b8ebc0ff4d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let cursor: string | null = null; | ||
| let done = false; | ||
| while (!done && !unreadCapped) { | ||
| const page = await messageQuery.paginate({ numItems: 50, cursor }); |
There was a problem hiding this comment.
Replace repeated pagination in the hub query
Convex permits only one .paginate() invocation during a query execution, but this call runs once per conversation inside candidates.map; a user with two direct conversations therefore hits an exception on the second invocation. A single conversation can also fail when the loop requests a second page after scanning 50 mostly self-sent messages. As a result, peopleHub and the network screens backed by it fail for ordinary multi-conversation accounts; use bounded non-paginated reads or paginate across separate query executions.
Useful? React with 👍 / 👎.
| .withIndex('by_conversation_createdAt', (q) => | ||
| q.eq('conversationId', scope.id).gt('createdAt', lastReadAt), | ||
| ) | ||
| .collect() |
There was a problem hiding this comment.
Keep unread-total reads bounded
When an account has accumulated enough unread messages, this .collect() loads every unread document in every DM, while the group branch does the same for every group. The previous badge queries bounded each thread's reads, but this replacement can exceed Convex's per-query document or byte limits, causing the globally mounted unread-count query to fail for busy or long-unread accounts. Preserve bounded reads or maintain a denormalized aggregate rather than collecting the complete history.
Useful? React with 👍 / 👎.
| lastSeenAt: (settings?.showLastSeen ?? true) ? (presence?.lastSeenAt ?? null) : null, | ||
| days, | ||
| totalMessages: total, | ||
| totalMessagesCapped, |
There was a problem hiding this comment.
Surface capped message totals to analytics consumers
For conversations with more than 2,000 messages in the 30-day window, the query now returns totalMessagesCapped: true and totalMessages: 2000, but none of the web, native, or profile analytics consumers include this new field in their data types or rendering; they continue displaying “2000 messages” as an exact result. Propagate the flag so capped totals and charts are identified as lower bounds, such as 2000+.
Useful? React with 👍 / 👎.
| Number(item.occurredAt ?? 0) >= startAt && | ||
| Number(item.occurredAt ?? 0) < endAt, |
There was a problem hiding this comment.
Recompute the recent-expense window after module initialization
The newly added filter uses startAt and endAt, which are computed once at module initialization. If the SPA remains loaded and a shared expense is created later, or the user returns to this page without a hard reload, its occurredAt can be at or beyond the stale endAt, so it disappears from the “Last 90 days” count and list even though local records contain it. Compute the bounds per page load/render or refresh them when the range is fetched.
Useful? React with 👍 / 👎.
| ...[...convLow, ...convHigh].map((conversation) => ({ | ||
| type: 'direct' as const, | ||
| id: conversation._id, | ||
| })), |
There was a problem hiding this comment.
Exclude deleted peers from the unread aggregate
When the other participant has soft-deleted their account, their conversation and messages remain in the database, so this scope construction still includes their unread messages. peopleHub filters that deleted user out, leaving no visible conversation through which the viewer can discover or clear the count, while the People badge remains nonzero. Resolve each conversation's peer and omit deleted users, matching the hub's visibility rules.
Useful? React with 👍 / 👎.
| {person.id && | ||
| (sharedGroups.length > 0 || | ||
| status === 'friends' || | ||
| Boolean(analytics?.conversationId)) ? ( |
There was a problem hiding this comment.
Honor server-reported shared groups when gating analytics
If relationship.sharedGroups reports a shared group but the local group/member cache is still loading, incomplete, or unavailable, personAnalytics is valid and groupCount is nonzero, yet this condition checks only sharedGroups.length. For people who are neither friends nor direct-message contacts, that hides the analytics link despite the server-confirmed shared relationship; gate on the combined/server group result instead.
Useful? React with 👍 / 👎.
| const candidates = [...peerIds] | ||
| .sort( | ||
| (a, b) => | ||
| (conversationByPeer.get(b)?.updatedAt ?? 0) - | ||
| (conversationByPeer.get(a)?.updatedAt ?? 0) || | ||
| a.localeCompare(b), | ||
| ) | ||
| .slice(0, PEOPLE_HUB_LIMIT * 2); |
There was a problem hiding this comment.
Rank unread conversations before truncating candidates
For accounts with more than 120 peers, this truncates solely by conversation.updatedAt before unread counts are loaded. An older conversation with unread messages is therefore omitted entirely when 120 newer conversations exist, even though the query's documented and final ordering puts unread conversations first; the aggregate badge can indicate unread messages while the People hub offers no corresponding row. Include unread state in candidate selection or avoid truncating before the unread-first ranking.
Useful? React with 👍 / 👎.
| let validZone: string | undefined; | ||
| for (const candidate of [timeZone, actorSettings?.timezone, actor.timezone]) { | ||
| if (!candidate) continue; | ||
| try { | ||
| new Intl.DateTimeFormat('en-US', { timeZone: candidate }); | ||
| validZone = candidate; | ||
| break; | ||
| } catch { | ||
| continue; | ||
| } | ||
| } | ||
| const { starts, endAt } = activityDayStarts(now, validZone, tzOffsetMinutes); |
There was a problem hiding this comment.
Honor caller-provided timezone offsets
All existing web, mobile, and MCP callers provide tzOffsetMinutes, but authenticated users normally have userSettings.timezone, so this precedence always selects the stored zone and silently ignores the supplied offset. When the current device or requested MCP timezone differs from the saved profile zone, message buckets shift to different calendar days while UI date labels still use the device timezone; the MCP tool also violates its contract that the offset controls day buckets. Use the stored zone only when the caller supplies neither an IANA zone nor an offset, or update callers and renderers to use the selected zone consistently.
Useful? React with 👍 / 👎.
- Count unread messages only when expiry metadata is a valid timestamp.
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
- Close the message loop before returning the unread total.
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Changes
Issues
Fixes #213
Fixes #214
Fixes #215
Fixes #216
Fixes #217
Fixes #218
Fixes #219
Fixes #221
Fixes #222