Repository navigation
Summary: a kind can count its items by a key - #226
Open
agorischek wants to merge 1 commit into
Open
agorischek wants to merge 1 commit into
agorischek wants to merge 1 commit into
Conversation
A renderer's nouns may now give a kind a SummaryKindCount, {noun, distinct},
so items that share a key count once (a tool's several schemas are one tool):
distinct keys on After, with the keys that arrived, left, or stayed with
changed items. The docs now say plainly that false hides a kind's count.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Host aggregation and renderer checks do not preserve distinct-counting semantics, producing incorrect totals, and noun change detection ignores replacement grouping callbacks.
2 open issues
What changed in this PR
Adds opt-in distinct-key counting to the renderer SDK’s summary API, allowing several items of a kind to represent one logical item.
Changes:
- Extends
SummaryNounswithSummaryKindCount, including optional custom wording. - Computes distinct totals and added, removed and modified key counts, with SDK test coverage.
- Documents keyed counting and clarifies that
falsehides a kind’s count.
| File | Description |
|---|---|
| packages/renderers/sdk/test/summary.test.mjs | Tests keyed counts, function-form configuration and hidden kinds. |
| packages/renderers/sdk/src/summary.ts | Integrates keyed counting into summary generation. |
| packages/renderers/sdk/src/summary-distinct.ts | Defines keyed-count options and calculates distinct totals and changes. |
| docs/reference/renderer-sdk.md | Updates SDK signatures and documents SummaryKindCount. |
| docs/reference/renderer-kit.md | Updates kit API signatures to accept keyed-count options. |
| docs/guides/renderer-kit-components.md | Adds a keyed-count example and clarifies count visibility. |
Review effort: Balanced
Comment on lines
+120
to
+122
| const counted = isKindCount(entry) ? distinctCounts(subject, count, entry.distinct) : count | ||
| const words = (isKindCount(entry) ? entry.noun : entry) ?? humanizeKind(count.kind) | ||
| items.push({type: 'count', ...counted, noun: {singular: clip(words.singular), plural: clip(words.plural)}}) |
| export type SummaryNouns = | ||
| | Readonly<Record<string, SummaryNoun | false>> | ||
| | ((kind: string, collection: 'entities' | 'relationships') => SummaryNoun | false | undefined) | ||
| | Readonly<Record<string, SummaryNoun | SummaryKindCount | false>> |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
140f24c0014a6ff7c155534a48398a3a2d604bddSummaryNounorfalse) take the same path as before.↑ SDK test covers count, added, removed and modified by key, the function form, and hiding a kind; kit and every renderer that declares nouns type-check.
↓ No built-in counts by key yet, so there's no browser coverage.
Superego feedback item 23: summary counts.
Count distinct items by key. A kind's entry in
SummaryNounsmay be aSummaryKindCount,{noun?, distinct: item => key}, so items that share a key count once. For example,{'tool-schema': {noun: {singular: 'tool', plural: 'tools'}, distinct: item => item.data?.name}}counts a tool's several schemas as one tool. The figure counts:added: keys only After has;removed: keys only Before has;modified: keys both have whose items the comparison changed.It works in the object and function forms of
SummaryNouns, and keeps the host's words whennounis left out.Hide a kind's count. This already works:
falseleaves a kind out of the summary. The docs now say so plainly ("falsehides a kind's count"), where before they described it only as a way to omit structural kinds.Documented in the components guide (Summary bar, Kinds) and the agent authoring guide.