Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion frontend/src/scenes/retention/retentionLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,28 @@ export const retentionLogic = kea<retentionLogicType>([
const cellDate = dayjs(result.date).tz(timezone).add(index, periodUnit)
const now = dayjs().tz(timezone)

// For custom brackets, a cell is in-progress when the bracket's
// END period hasn't elapsed yet (not just its start). Individual
// periods use the standard same-period check.
const customBrackets = retentionFilter?.retentionCustomBrackets
let isCurrentPeriod: boolean
if (customBrackets && customBrackets.length > 0 && index > 0) {
// Sum bracket sizes up to this index to get the end period offset.
// e.g. brackets [1,3,4,8] at index 4 → offset 16 → ends at cohort+16 periods
const bracketEndOffset = customBrackets
.slice(0, index)
.reduce((acc: number, size: number) => acc + size, 0)
const bracketEndDate = dayjs(result.date).tz(timezone).add(bracketEndOffset, periodUnit)
isCurrentPeriod = bracketEndDate.isAfter(now)
Comment on lines +198 to +205

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Multiple brackets marked in-progress simultaneously

For custom brackets, bracketEndDate.isAfter(now) will be true for every bracket whose end period is still in the future — not just the bracket currently straddling today. For example, with brackets [1, 3, 4, 8] and a cohort from 2 weeks ago, both the third and fourth brackets would have isCurrentPeriod = true. Individual periods only ever mark one cell in-progress. This may be intentional (all open windows should grey out), but worth confirming the UI handles multiple isCurrentPeriod = true values in the same row gracefully.

Prompt To Fix With AI
This is a comment left during a code review.
Path: frontend/src/scenes/retention/retentionLogic.ts
Line: 198-205

Comment:
**Multiple brackets marked in-progress simultaneously**

For custom brackets, `bracketEndDate.isAfter(now)` will be `true` for every bracket whose end period is still in the future — not just the bracket currently straddling today. For example, with brackets `[1, 3, 4, 8]` and a cohort from 2 weeks ago, both the third and fourth brackets would have `isCurrentPeriod = true`. Individual periods only ever mark one cell in-progress. This may be intentional (all open windows should grey out), but worth confirming the UI handles multiple `isCurrentPeriod = true` values in the same row gracefully.

How can I resolve this? If you propose a fix, please make it concise.

} else {
isCurrentPeriod = cellDate.isSame(now, periodUnit)
}

return {
...value,
percentage,
cellDate,
isCurrentPeriod: cellDate.isSame(now, periodUnit),
isCurrentPeriod,
isFuture: cellDate.isAfter(now),
}
}),
Expand Down