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
5 changes: 5 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@

**Learning:** When attempting to optimize an O(N^2) array spread operation (`[...existing, talk]`) inside a grouping loop in `groupTalksByTrack`, the purely functional/immutable constraint specified by the team (and the lack of `Map.groupBy` support in Node 20.x Jest environments) means that we must fall back to immutable reductions.
**Action:** When constraints require strict immutability without mutation of objects, use `reduce` with object and array spreads (e.g., `{ ...acc, [key]: [...(acc[key] || []), item] }`) even if it introduces O(N^2) overhead for large arrays. Avoid using `push()` or modifying accumulators directly. Always run Prettier/formatting checks before merge to resolve CI failures.

## 2026-04-29 - Formatting matters for comments

**Learning:** When adding multi-line comments in `/* */` style in Next.js codebases, always ensure the text begins on a new line after the opening `/*` (e.g., `/*\n * text\n */`) to avoid 'Expected a linebreak after /\*' and consecutive single-line comment errors.
**Action:** Validate comment structures via `npm run lint` closely when documenting Bolt optimizations.
Comment on lines +21 to +24
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.

medium

While documenting learning is valuable, this entry includes a specific date. Per the project guidelines, we should avoid referencing specific dates in non-code areas unless strictly necessary for versioning or legal requirements. Consider removing the date from the header to keep the log focused on the technical learning.

8 changes: 7 additions & 1 deletion components/schedule/ScheduleContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ export default function ScheduleContainer({ initialSchedule, year }: Readonly<Sc
return initialSchedule;
}

const filterSessions = (sessions: GridSession[]) => sessions.filter((s) => savedSessionIds.includes(s.id) || s.isServiceSession);
/*
* ⚑ Bolt: Optimize array lookup from O(N*M) to O(N+M)
* By converting the saved sessions array to a Set before filtering,
* we prevent O(N^2) time complexity when filtering large session lists
*/
const savedSessionIdsSet = new Set(savedSessionIds);
const filterSessions = (sessions: GridSession[]) => sessions.filter((s) => savedSessionIdsSet.has(s.id) || s.isServiceSession);
Comment on lines +23 to +29
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.

πŸ› οΈ Refactor suggestion | 🟠 Major

Remove or simplify the explanatory comment.

The comment explains what the code does (converting to Set, O(N*M) β†’ O(N+M)), but the coding guidelines specify that code should be self-documenting and comments should only explain why non-obvious decisions were made. The Set conversion and its performance benefits are evident from the code itself.

As per coding guidelines: "Code must be self-documenting. Only explain why non-obvious decisions were made in comments. DO NOT add inline comments explaining what code does."

♻️ Proposed fix to remove the explanatory comment
-    /*
-     * ⚑ Bolt: Optimize array lookup from O(N*M) to O(N+M)
-     * By converting the saved sessions array to a Set before filtering,
-     * we prevent O(N^2) time complexity when filtering large session lists
-     */
     const savedSessionIdsSet = new Set(savedSessionIds);
     const filterSessions = (sessions: GridSession[]) => sessions.filter((s) => savedSessionIdsSet.has(s.id) || s.isServiceSession);
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/*
* ⚑ Bolt: Optimize array lookup from O(N*M) to O(N+M)
* By converting the saved sessions array to a Set before filtering,
* we prevent O(N^2) time complexity when filtering large session lists
*/
const savedSessionIdsSet = new Set(savedSessionIds);
const filterSessions = (sessions: GridSession[]) => sessions.filter((s) => savedSessionIdsSet.has(s.id) || s.isServiceSession);
const savedSessionIdsSet = new Set(savedSessionIds);
const filterSessions = (sessions: GridSession[]) => sessions.filter((s) => savedSessionIdsSet.has(s.id) || s.isServiceSession);
πŸ€– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/schedule/ScheduleContainer.tsx` around lines 23 - 29, Remove the
explanatory comment block above the savedSessionIdsSet and filterSessions
declarations; leave the code as-is (keep const savedSessionIdsSet = new
Set(savedSessionIds) and const filterSessions = (sessions: GridSession[]) =>
sessions.filter((s) => savedSessionIdsSet.has(s.id) || s.isServiceSession)). If
you want a brief why, replace the block with a one-line comment explaining the
non-obvious rationale only (e.g., "Use Set for faster membership checks"), but
do not include the current multi-line "what it does" explanation.


return initialSchedule.map((day) => ({
...day,
Expand Down
8 changes: 7 additions & 1 deletion hooks/useTalks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,13 @@ export const groupTalksByTrack = (talks: Talk[]): Map<string, Talk[]> => {
*/
export const getTalkSpeakersWithDetails = async (year: string | number, speakerIds: string[]): Promise<Speaker[]> => {
const speakers = await getSpeakers(year);
return speakers.filter((s) => speakerIds.includes(s.id));
/*
* ⚑ Bolt: Optimize array lookup from O(N*M) to O(N+M)
* Converting speakerIds to a Set to prevent nested iterations
* when matching speakers against the main speaker list
*/
const speakerIdsSet = new Set(speakerIds);
return speakers.filter((s) => speakerIdsSet.has(s.id));
Comment on lines +132 to +138
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.

πŸ› οΈ Refactor suggestion | 🟠 Major

Remove or simplify the explanatory comment.

Similar to the change in ScheduleContainer.tsx, this comment explains what the code does (converting to Set, preventing nested iterations) rather than why a non-obvious decision was made. The Set conversion and its performance benefits are evident from the code itself.

As per coding guidelines: "Code must be self-documenting. Only explain why non-obvious decisions were made in comments. DO NOT add inline comments explaining what code does."

♻️ Proposed fix to remove the explanatory comment
-  /*
-   * ⚑ Bolt: Optimize array lookup from O(N*M) to O(N+M)
-   * Converting speakerIds to a Set to prevent nested iterations
-   * when matching speakers against the main speaker list
-   */
   const speakerIdsSet = new Set(speakerIds);
   return speakers.filter((s) => speakerIdsSet.has(s.id));
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/*
* ⚑ Bolt: Optimize array lookup from O(N*M) to O(N+M)
* Converting speakerIds to a Set to prevent nested iterations
* when matching speakers against the main speaker list
*/
const speakerIdsSet = new Set(speakerIds);
return speakers.filter((s) => speakerIdsSet.has(s.id));
const speakerIdsSet = new Set(speakerIds);
return speakers.filter((s) => speakerIdsSet.has(s.id));
πŸ€– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@hooks/useTalks.ts` around lines 132 - 138, Remove the explanatory inline
comment above the Set conversion in useTalks (the block describing "Optimize
array lookup..." and why it prevents nested iterations); leave the code as-is
using speakerIds, speakerIdsSet, and return speakers.filter((s) =>
speakerIdsSet.has(s.id)); if a comment is needed, replace it with a brief
"Explain why: use Set for membership check" or a one-line rationale about intent
only (not the what), referencing speakerIdsSet and speakers.

};

export const getRelatedTalksByTrack = async (year: string | number, track: string, excludeTalkId: string, limit: number = 5): Promise<Talk[]> => {
Expand Down
Loading