Skip to content
Closed
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
4 changes: 4 additions & 0 deletions .Jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ Action: Updated `collectItems` in `src/utils/whats-new-glance.ts` to iterate ove
2026-09-08 - Zero-Allocation Reverse Array Scan for Chat Follow-up Prompts
Learning: Dynamic shallow array copying and array reversal (`[...messages].reverse().find(...)`) on every UI update creates unnecessary temporary heap allocations and garbage collection overhead in client-side scripts. Replacing array copy/reverse with a reverse indexed `for` loop eliminates dynamic array allocations completely and stops scanning as soon as the first matching element is found.
Action: Refactored `showFollowUps()` in `src/components/Chat.astro` to use an indexed reverse `for` loop.

2026-09-09 - Zero-Allocation ISO Date Formatting & Hoisted List Marker Parsing
Learning: Calling `date.toISOString().split('T')[0]` in Edge SSR utility helpers allocates an unnecessary two-element string array on every request. Replacing `.split('T')[0]` with `.slice(0, 10)` extracts the YYYY-MM-DD date substring directly without heap array allocation. Additionally, hoisting list marker regexes (`/^[-*+]\s+/`) to module-level constants avoids inline RegExp object re-evaluation inside line scanning loops.
Action: Updated `formatReleaseDate` to use `date.toISOString().slice(0, 10)` and hoisted `LIST_MARKER_REGEX` in `src/utils/github-releases.ts`.
7 changes: 4 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"vitest": "^4.1.2"
},
"overrides": {
"devalue": "5.9.1",
"brace-expansion": "5.0.9",
"postcss": "8.5.26",
"yaml": "2.8.3",
Expand Down
19 changes: 11 additions & 8 deletions src/utils/github-releases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ export async function fetchGitHubReleases(

/**
* Formats an ISO date string into a YYYY-MM-DD format.
* @param {string | null} dateString - The raw date string from the API.
* @returns {string} The formatted date, or 'Unknown date' if invalid.
* Uses string slicing instead of `.split('T')[0]` to eliminate intermediate array allocations on Edge SSR requests.
* @param dateString - The raw date string from the API.
* @returns The formatted date, or 'Unknown date' if invalid.
*/
export function formatReleaseDate(dateString: string | null): string {
if (!dateString) return 'Unknown date';
Expand All @@ -176,7 +177,8 @@ export function formatReleaseDate(dateString: string | null): string {
return 'Unknown date';
}

return date.toISOString().split('T')[0];
// Slice YYYY-MM-DD directly from ISO string to eliminate 2-element array allocation on edge runtimes
return date.toISOString().slice(0, 10);
}

/**
Expand Down Expand Up @@ -204,6 +206,7 @@ export function parseReleaseItem(line: string): ReleaseItem {
}

const INTERNAL_CHANGELOG_ITEM = /\bjules\b|\bagent[- ]farm\b|\bjohan nits\b/i;
const LIST_MARKER_REGEX = /^[-*+]\s+/;

export function isPublicChangelogItem(item: ReleaseItem): boolean {
return !INTERNAL_CHANGELOG_ITEM.test(item.message);
Expand All @@ -213,9 +216,9 @@ export function isPublicChangelogItem(item: ReleaseItem): boolean {
* Splits a release body into individual, formatted ReleaseItem objects.
* Filters for lines starting with list markers (-, *, +).
* Drops Jules, agent-farm, and Johan-nits internals from the public list.
* Uses pointer-based line scanning (`indexOf('\n', startPos)`) to eliminate dynamic line array allocations on edge runtimes.
* @param {string} body - The full Markdown body of a GitHub release.
* @returns {ReleaseItem[]} An array of parsed release items.
* Uses pointer-based line scanning (`indexOf('\n', startPos)`) and hoisted regexes to eliminate dynamic allocations on edge runtimes.
* @param body - The full Markdown body of a GitHub release.
* @returns An array of parsed release items.
*/
export function splitReleaseBody(body: string): ReleaseItem[] {
const items: ReleaseItem[] = [];
Expand All @@ -235,9 +238,9 @@ export function splitReleaseBody(body: string): ReleaseItem[] {
startPos = nextNewline + 1;

const trimmed = line.trim();
if (!/^[-*+]\s+/.test(trimmed)) continue;
if (!LIST_MARKER_REGEX.test(trimmed)) continue;

const rawMessage = trimmed.replace(/^[-*+]\s+/, '');
const rawMessage = trimmed.replace(LIST_MARKER_REGEX, '');
const item = parseReleaseItem(rawMessage);
if (isPublicChangelogItem(item)) {
items.push(item);
Expand Down
Loading