Skip to content

chore(KNO-11486): exclude metadata when refetching feed after new message received#853

Open
mattmikolay wants to merge 17 commits intomattmik-kno-11394-support-compact-mode-for-feedsfrom
mattmik-kno-11486-sdks-update-js-sdks-to-exclude-branch-count-when-refetching
Open

chore(KNO-11486): exclude metadata when refetching feed after new message received#853
mattmikolay wants to merge 17 commits intomattmik-kno-11394-support-compact-mode-for-feedsfrom
mattmik-kno-11486-sdks-update-js-sdks-to-exclude-branch-count-when-refetching

Conversation

@mattmikolay
Copy link
Contributor

@mattmikolay mattmikolay commented Feb 4, 2026

Description

This PR updates the client SDK so that:

  • The feed client supports the exclude option, used to exclude specified fields from the list feed items response payload
  • When a new socket event of type "new-message" is received, the request we make to the list feed items endpoint automatically excludes the meta field from its response. meta contains the badge counts, which are already present on the socket event payload, so querying for meta is redundant.

Todos

  • Merge knocklabs/switchboard#5467
  • Merge knocklabs/switchboard#5478

Checklist

  • Tests have been added for new features or major refactors to existing features.

Loom demo

https://www.loom.com/share/56c2bb427c31485ea8b837c3c416be04

@vercel
Copy link

vercel bot commented Feb 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
javascript-ms-teams-connect-example Ready Ready Preview, Comment Feb 5, 2026 10:53pm
javascript-nextjs-example Ready Ready Preview, Comment Feb 5, 2026 10:53pm
javascript-slack-connect-example Ready Ready Preview, Comment Feb 5, 2026 10:53pm
javascript-slack-kit-example Ready Ready Preview, Comment Feb 5, 2026 10:53pm

Request Review

@linear
Copy link

linear bot commented Feb 4, 2026

@changeset-bot
Copy link

changeset-bot bot commented Feb 4, 2026

🦋 Changeset detected

Latest commit: f71b7c7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@knocklabs/client Minor
client-example Patch
guide-example Patch
@knocklabs/expo Patch
@knocklabs/react-core Patch
@knocklabs/react-native Patch
@knocklabs/react Patch
@knocklabs/expo-example Patch
ms-teams-connect-example Patch
nextjs-app-dir-example Patch
nextjs-example Patch
slack-connect-example Patch
slack-kit-example Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mattmikolay mattmikolay changed the title Update feed client to support exclude chore(KNO-11486): Feb 4, 2026
Copy link
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@mattmikolay
Copy link
Contributor Author

@cursor review

@mattmikolay
Copy link
Contributor Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@mattmikolay mattmikolay marked this pull request as ready for review February 5, 2026 19:34

// Always include the default params, if they have been set
const queryParams: FetchFeedOptionsForRequest = {
...this.defaultOptions,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it okay we are not using mergedOptions here? i.e. we don't include options.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. This was working because the destructure of ...mergeDateRangeParams(options) accomplishes the same thing. But I think it’s better if we use mergedOptions everywhere, so I made that change.

@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.58%. Comparing base (db04746) to head (f71b7c7).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@                                 Coverage Diff                                  @@
##           mattmik-kno-11394-support-compact-mode-for-feeds     #853      +/-   ##
====================================================================================
+ Coverage                                             68.45%   68.58%   +0.12%     
====================================================================================
  Files                                                   193      193              
  Lines                                                  8062     8088      +26     
  Branches                                               1065     1076      +11     
====================================================================================
+ Hits                                                   5519     5547      +28     
+ Misses                                                 2518     2516       -2     
  Partials                                                 25       25              
Files with missing lines Coverage Δ
packages/client/src/clients/feed/feed.ts 82.47% <100.00%> (+0.65%) ⬆️
packages/client/src/clients/feed/store.ts 100.00% <100.00%> (ø)
packages/client/src/clients/feed/utils.ts 100.00% <100.00%> (ø)

Comment on lines +84 to +87
"inserted_at.gte"?: string;
"inserted_at.lte"?: string;
"inserted_at.gt"?: string;
"inserted_at.lt"?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we mean to add these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it’s a mistake that they weren’t already in the FetchFeedOptionsForRequest type.

FetchFeedOptionsForRequest is meant to represent the params included in the API request. Notice that the mergeDateRangeParams function transforms the inserted_at_date_range option on FeedClientOptions into the appropriate date params, e.g. inserted_at.gte, inserted_at.lte, etc.

export function mergeDateRangeParams(options: FeedClientOptions) {
const { inserted_at_date_range, ...rest } = options;
if (!inserted_at_date_range) {
return rest;
}
const dateRangeParams: Record<string, string> = {};
// Determine which operators to use based on the inclusive flag
const isInclusive = inserted_at_date_range.inclusive ?? false;
// For start date: use gte if inclusive, gt if not
if (inserted_at_date_range.start) {
const startOperator = isInclusive ? "inserted_at.gte" : "inserted_at.gt";
dateRangeParams[startOperator] = inserted_at_date_range.start;
}
// For end date: use lte if inclusive, lt if not
if (inserted_at_date_range.end) {
const endOperator = isInclusive ? "inserted_at.lte" : "inserted_at.lt";
dateRangeParams[endOperator] = inserted_at_date_range.end;
}
return { ...rest, ...dateRangeParams };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants