Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
**Learning:** `Date.parse(value)` returns the timestamp primitive directly, while `new Date(value).getTime()` also constructs a `Date` object. Both use the same ECMAScript string-parsing semantics for these call sites.

**Action:** In frequently executed paths that only need a timestamp primitive, prefer `Date.parse(value)`. Treat the allocation reduction as a bounded micro-optimization unless a committed benchmark establishes a larger runtime effect.

## 2026-10-09 - `Math.max` array spread optimization with `useMemo`

**Learning:** When using `Math.max(...array)` on potentially large arrays within React components, it triggers the spread operator on every render, which can lead to 'Maximum call stack size exceeded' for very large arrays, and recalculates unnecessarily.

**Action:** In React components that render lists or depend on max value calculations from array props, use `.reduce()` instead of the spread operator to prevent call stack issues, and wrap the calculation with `useMemo` to prevent recalculation on every render.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function MembersTable({
const removeMember = useRemoveMember(orgSlug)
const [errorByUser, setErrorByUser] = useState<Record<string, string>>({})

const maxCost = Math.max(...members.map((m) => m.sevenDayCostUsd), 0)
const maxCost = members.reduce((max, m) => Math.max(max, m.sevenDayCostUsd), 0)
const canChangeToOwner = currentRole === 'OWNER'
const adminCount = members.filter(
(m) => m.role === 'OWNER' || m.role === 'MANAGER'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function DelegationInsight({ insight, orgSlug }: DelegationInsightProps)
)
}

const maxCount = Math.max(1, ...insight.topAgents.map((a) => a.callCount))
const maxCount = insight.topAgents.reduce((max, a) => Math.max(max, a.callCount), 1)

return (
<ChartCard
Expand Down
Loading