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

## 2026-06-11 - [Avoid Inline Dynamic Type Imports]
**Learning:** Adding inline dynamic type imports (e.g., `import('../../types/auth').ProviderKey[]`) to avoid modifying imports at the top of the file creates ugly, unmaintainable code that violates readability guidelines, and will lead to PR rejection.
**Action:** When fixing typing errors, always use standard static `import type` statements at the top of the file.

## 2026-06-11 - [Avoid Over-Optimizing Small Arrays]
**Learning:** Refactoring simple array map and filter operations into verbose `for...of` loops on inherently small arrays (like social login providers) degrades readability without providing any measurable performance benefit.
**Action:** Do not optimize array iteration methods unless the array is known to be large or the operation happens frequently in a critical path.
17 changes: 14 additions & 3 deletions src/hooks/app-route-actions/publishRouteAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,23 @@ export function createPublishRouteHandler({
}
}

// Optimization: Use findIndex instead of unconditional .map()
// to prevent O(N) memory allocation and maintain referential
// equality when the target session is not found, reducing React re-renders.
let nextTravelSessions = current.travelSessions;
const sessionIndex = current.travelSessions.findIndex((session) => session.id === payload.travelSessionId);
if (sessionIndex !== -1) {
nextTravelSessions = [...current.travelSessions];
nextTravelSessions[sessionIndex] = {
...current.travelSessions[sessionIndex],
publishedRouteId: createdRoute.id,
};
}

return {
...current,
routes: nextRoutes,
travelSessions: current.travelSessions.map((session) =>
session.id === payload.travelSessionId ? { ...session, publishedRouteId: createdRoute.id } : session,
),
travelSessions: nextTravelSessions,
stats: {
...current.stats,
routeCount: routeExists ? current.stats.routeCount : current.stats.routeCount + 1,
Expand Down
Loading