diff --git a/.jules/bolt.md b/.jules/bolt.md
index 38d4b732..e78a4156 100644
--- a/.jules/bolt.md
+++ b/.jules/bolt.md
@@ -41,3 +41,7 @@
## 2025-02-15 - Replace Array.from(map.values()).map with a for...of loop
**Learning:** Using `Array.from(map.values()).map(...)` creates an unnecessary intermediate array which wastes memory allocation and garbage collection time, particularly for frequently re-rendered components handling large collections.
**Action:** Use a `for...of` loop over `map.values()` to iterate and push mapped elements directly into the final array for O(1) memory and avoiding intermediate array allocations.
+
+## 2026-07-04 - Short-circuit extremum bound search
+**Learning:** Using `.reduce()` unconditionally to find a minimum or maximum value with a known absolute bound incurs O(N) overhead.
+**Action:** Replace `.reduce()` with a `for...of` loop and an early `break` when searching for a bounded extremum to transform an unconditional O(N) operation into one that can short-circuit.
diff --git a/apps/desktop/src-tauri/icons/128x128@2x.png b/apps/desktop/src-tauri/icons/128x128@2x.png
new file mode 100644
index 00000000..e28bc8c0
Binary files /dev/null and b/apps/desktop/src-tauri/icons/128x128@2x.png differ
diff --git a/apps/desktop/src-tauri/tauri.conf.json b/apps/desktop/src-tauri/tauri.conf.json
index 8efaf48c..2a18e0b5 100644
--- a/apps/desktop/src-tauri/tauri.conf.json
+++ b/apps/desktop/src-tauri/tauri.conf.json
@@ -22,6 +22,13 @@
},
"bundle": {
"active": true,
- "targets": "all"
+ "targets": "all",
+ "icon": [
+ "icons/32x32.png",
+ "icons/128x128.png",
+ "icons/128x128@2x.png",
+ "icons/icon.icns",
+ "icons/icon.ico"
+ ]
}
}
diff --git a/apps/desktop/src/App.test.tsx b/apps/desktop/src/App.test.tsx
index c039dfba..ba41c7ee 100644
--- a/apps/desktop/src/App.test.tsx
+++ b/apps/desktop/src/App.test.tsx
@@ -293,6 +293,33 @@ describe("App", () => {
expect(screen.getAllByText(/2 sections/i).length).toBeGreaterThan(0);
});
+ it("summarizes confidence with early exit on low confidence section", async () => {
+ const loadedProject = succeededResult().result;
+ // By adding a "low" confidence section and then another one, we ensure the loop
+ // encounters the "low" and breaks early, covering that explicit logic branch.
+ loadedProject.sections.push({
+ ...loadedProject.sections[0],
+ id: "bridge-1",
+ label: "bridge",
+ confidence: { level: "low", source: "model", notes: "Difficult section." }
+ });
+ loadedProject.sections.push({
+ ...loadedProject.sections[0],
+ id: "outro-1",
+ label: "outro",
+ confidence: { level: "high", source: "model", notes: "Easy outro." }
+ });
+ mockLoadProject.mockResolvedValueOnce(loadedProject);
+ render();
+
+ fireEvent.click(screen.getByRole("button", { name: /open project/i }));
+
+ await waitFor(() => {
+ expect(screen.getByText(/^Low$/i)).toBeTruthy();
+ });
+ expect(screen.getAllByText(/3 sections/i).length).toBeGreaterThan(0);
+ });
+
it("selects a local audio source and starts a local-audio analysis job", async () => {
tauriInvoke
.mockResolvedValueOnce(bootstrapResponse())
diff --git a/apps/desktop/src/App.tsx b/apps/desktop/src/App.tsx
index 24f5fb09..04dfff02 100644
--- a/apps/desktop/src/App.tsx
+++ b/apps/desktop/src/App.tsx
@@ -180,15 +180,20 @@ function MetricCard({
function ConfidenceMetric({ song }: { song: RehearsalSong | null }) {
const sectionCount = song?.sections.length ?? 0;
const confidenceOrder = { high: 3, medium: 2, low: 1 } as const;
- const lowestConfidence = song?.sections.reduce(
- (current, section) => {
- if (!current || confidenceOrder[section.confidence.level] < confidenceOrder[current]) {
- return section.confidence.level;
+
+ let lowestConfidence: RehearsalSong["sections"][number]["confidence"]["level"] | null = null;
+ // O(N) operation with early short-circuit for performance
+ if (song?.sections) {
+ for (const section of song.sections) {
+ if (!lowestConfidence || confidenceOrder[section.confidence.level] < confidenceOrder[lowestConfidence]) {
+ lowestConfidence = section.confidence.level;
}
- return current;
- },
- null
- );
+ if (lowestConfidence === "low") {
+ break;
+ }
+ }
+ }
+
const confidence = lowestConfidence ? `${lowestConfidence[0].toUpperCase()}${lowestConfidence.slice(1)}` : "Ready";
const detail = sectionCount > 0 ? `${sectionCount} section${sectionCount === 1 ? "" : "s"}` : "Local analysis";