Fill free slots when pinned entities do not all fit

When the pinned entities use more slots than the limit, the ones that
fit can still leave a free slot. For example, two pinned cameras with
a limit of 3. The section now checks the size of the pinned entities
that fit, and fills the free slot with a suggestion.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EzDS5HYRVdFHKnLsjPaoyy
This commit is contained in:
Claude committed 2026-11-14 18:26:46 +00:00
1 parent 3478368ed5
commit df676dfbe5
1 file changed
+3 -2
@@ -87,9 +87,10 @@ export class CommonControlsSectionStrategy extends ReactiveElement {
);
// Pinned entities already fill the section, skip the prediction call.
if (computeFavoriteCardsSize(includedEntities) >= limit) {
const fittedIncludedEntities = fitToLimit(includedEntities, limit);
if (computeFavoriteCardsSize(fittedIncludedEntities) >= limit) {
section.cards!.push(
...fitToLimit(includedEntities, limit).map(computeFavoriteCardConfig)
...fittedIncludedEntities.map(computeFavoriteCardConfig)
);
return section;
}