Skip to content

fix(framework): digest filter renders "and 0 others" when maxNames covers all items - #11984

Merged
scopsy merged 1 commit into
novuhq:nextfrom
winklemad:fix-digest-filter-maxnames-overflow
Jul 19, 2026
Merged

scopsy merged 1 commit into
novuhq:nextfrom
winklemad:fix-digest-filter-maxnames-overflow

Conversation

@winklemad

@winklemad winklemad commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

The digest Liquid filter only listed all names for exactly 3 items; for 4+ items where maxNames >= values.length it fell through to the overflow branch and appended a redundant "and 0 others" — or a negative count when maxNames > length.

{{ actors | digest: 5 }}   // 4 actors -> "A, B, C, D and 0 others"
{{ actors | digest: 10 }}  // 5 actors -> "A, B, C, D, E and -5 others"

Since maxNames is set by the template author while the digested item count is variable at runtime, any digest that yields <= maxNames items (4+ total) renders broken copy to subscribers.

Generalized the "show all names" guard to maxNames >= values.length, mirroring the sibling toSentence filter which already guards limit >= wordsLength. This subsumes and preserves the existing 3-item behavior. Added regression tests (equal-to, exceeds, no "0 others", no negative count, custom separator). Swept the class: digest and toSentence are the only overflow-suffix filters, and toSentence was already correct.

Greptile Summary

This PR fixes the digest filter boundary case for covered item counts. The main changes are:

  • Lists every value when maxNames is equal to or greater than the number of values.
  • Avoids rendering 0 others or negative “others” counts.
  • Adds tests for equal and greater maxNames values, custom separators, and overflow copy checks.

Confidence Score: 5/5

Safe to merge with minimal risk.

The change is narrow, preserves existing short-array behavior, and tests the reported boundary cases.

No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • The repository’s digest tests were executed using Vitest against the digest.test.ts file.
  • The digest test run completed with exit code 0, confirming a successful test outcome.
  • The verbose per-test digest log shows that all explicit regression cases ran and passed.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
packages/framework/src/filters/digest.ts Generalizes the all-items branch so digest lists every value whenever maxNames covers the array.
packages/framework/src/filters/digest.test.ts Adds tests for equal and excessive maxNames, zero or negative overflow copy, and custom separators.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Template as Liquid template
participant Digest as digest filter
participant Values as values array
Template->>Digest: "actors | digest: maxNames"
Digest->>Values: extract values/keyPath
alt "values.length <= 2"
    Digest-->>Template: return simple name(s)
else "maxNames >= values.length"
    Digest-->>Template: join all names with separator + "and"
else "maxNames < values.length"
    Digest-->>Template: join shown names + "and N others"
end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Template as Liquid template
participant Digest as digest filter
participant Values as values array
Template->>Digest: "actors | digest: maxNames"
Digest->>Values: extract values/keyPath
alt "values.length <= 2"
    Digest-->>Template: return simple name(s)
else "maxNames >= values.length"
    Digest-->>Template: join all names with separator + "and"
else "maxNames < values.length"
    Digest-->>Template: join shown names + "and N others"
end
Loading

Reviews (1): Last reviewed commit: "fix(framework): digest filter renders 'a..." | Re-trigger Greptile

…vers all items

The digest Liquid filter only listed every name for the special case of
exactly three items. For four or more items it always fell through to the
overflow branch, so when maxNames was greater than or equal to the number
of items it appended a redundant "and 0 others" (or a negative count when
maxNames exceeded the item count), e.g. {{ actors | digest: 5 }} on four
actors produced "A, B, C, D and 0 others".

Show all items whenever maxNames covers them, mirroring the toSentence
filter, and reserve the overflow suffix for when maxNames is actually
smaller than the list.
@netlify

netlify Bot commented Jul 18, 2026

Copy link
Copy Markdown

👷 Deploy request for dashboard-v2-novu-staging pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit e450af1

@scopsy
scopsy merged commit ab5e7ed into novuhq:next Jul 19, 2026
30 checks passed
@scopsy

scopsy commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Thank you 🙏

This branch was previously deployed

1 inactive deployment
Linting — e450af18 Deployed Jul 19, 2026 by winklemad via Dependency review #22444
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