Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# AGENTS.md

## Project overview
- BandScope is a local-first desktop app for rehearsal prep: a practical song view with likely harmony by section and by instrument or vocal role, form and groove cues, stems, playable ranges, simplification guidance, transposition or setup cues, part-overlap cues, visible confidence, and rehearsal priorities.
- BandScope is a local-first desktop app for rehearsal prep: a practical song view with likely harmony by section and by instrument or vocal role, form and groove cues, stems, playable ranges, simplification guidance, transposition or setup cues, part-overlap cues, visible confidence, and rehearsal priorities. The ready workspace names tonight's first playable range and offers a download of tonight's first-action chart, so the chart file starts with what to play first.
- Authoritative delivery rules live in `ARCHITECTURE.md`, `docs/plans/`, and the root verification scripts.
- Brand, tone, UX copy, and prioritization rules live in `docs/brand-story.md` and must be applied to PRDs, TRDs, UI copy, onboarding, empty states, and error messages.
- App security rules live in `docs/security/app-security.md` and must be applied to file handling, URL intake, subprocesses, IPC, WebView usage, model loading, updates, logging, cache handling, and export behavior.
Expand Down
4 changes: 2 additions & 2 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ Last updated: 2026-03-11
- likely harmony by section and by role
- section roadmap with entries, dropouts, pickups, stops, tags, and handoffs
- groove and timing cues relevant to locking the band together
- playable ranges and density or overlap warnings, with the ready workspace naming tonight's first span and the next instrument check
- playable ranges and density or overlap warnings, with the ready workspace naming tonight's first span, the next instrument check, and a download of tonight's first-action chart
- simplification, transposition, capo, tuning, or setup cues where applicable
- role-specific rehearsal priorities and confidence flags
- cue-sheet or chart-style exports that summarize the analysis in rehearsal-friendly form
- cue-sheet or chart-style exports that summarize the analysis in rehearsal-friendly form, with the chart JSON leading with tonight's first playable-range action

## Confidence, edits, and provenance

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Added

- Lead the chart JSON with tonight's first playable-range action and name that download on the rehearsal map.
- Name tonight's first playable range on the ready rehearsal map and tell the player to check that span on their instrument before the section.
- Display the analyzed song tempo (BPM) as a badge in the rehearsal workspace.
- 각 합주 역할(Role)별 개인 연습 진행도를 0~100% 범위로 기록 및 시각화할 수 있는 연습 진척도(`practiceProgress`) 트래커 기능 추가. UI 컨트롤(슬라이더 및 +/- 버튼)과 한/영 다국어 지원 포함.
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ BandScope is a local-first desktop app for rehearsal prep: it turns a song into

Three layers, decoupled through shared contracts:

- `apps/desktop` — Tauri 2 + Vite + React 19 shell (Tailwind 4, Base UI, Storybook). Feature screens live in `src/features/` (home, workspace, chords, ranges, player, settings). The ready workspace names tonight's first playable range and the next instrument check. `src/lib/analysis.ts` and `src/lib/job_runner.ts` call typed Tauri IPC commands, with a browser fallback that serves demo data when not running inside Tauri.
- `apps/desktop` — Tauri 2 + Vite + React 19 shell (Tailwind 4, Base UI, Storybook). Feature screens live in `src/features/` (home, workspace, chords, ranges, player, settings). The ready workspace names tonight's first playable range, the next instrument check, and a download of tonight's first-action chart. `src/lib/analysis.ts` and `src/lib/job_runner.ts` call typed Tauri IPC commands, with a browser fallback that serves demo data when not running inside Tauri.
- `apps/desktop/src-tauri/src/main.rs` — the Rust orchestration boundary. Tauri commands (`start_analysis_job`, `get_analysis_job_status`, `select_local_audio_source`, `import_youtube_url`) validate untrusted input (project IDs, file paths, URLs) and spawn the Python engine as a subprocess. There is no loopback HTTP listener and no network path for local analysis.
- `services/analysis-engine` — Python package `bandscope_analysis` (librosa/numpy). Entry point `cli.py` reads a JSON job request on stdin and prints a structured job-status JSON envelope on stdout (`--progress-jsonl` streams progress lines). `api.py` orchestrates the pipeline across the `separation`, `sections`, `roles`, `chords`, `ranges`, `temporal`, `transcription`, and `youtube` modules.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { fireEvent, render, screen } from "@testing-library/react";
import { createDemoRehearsalSong } from "@bandscope/shared-types";
import { afterEach, describe, expect, it, vi } from "vitest";
import { Workspace } from "./Workspace";

const originalLanguage = navigator.language;
const originalCreateObjectUrl = URL.createObjectURL;
const originalRevokeObjectUrl = URL.revokeObjectURL;

function setNavigatorLanguage(language: string) {
Object.defineProperty(navigator, "language", {
configurable: true,
value: language
});
}

describe("Workspace chart export contract", () => {
afterEach(() => {
setNavigatorLanguage(originalLanguage);
vi.restoreAllMocks();
Object.defineProperty(URL, "createObjectURL", {
configurable: true,
value: originalCreateObjectUrl
});
Object.defineProperty(URL, "revokeObjectURL", {
configurable: true,
value: originalRevokeObjectUrl
});
});

it("keeps the full-band chart lead stable when the UI role changes", async () => {
setNavigatorLanguage("en-US");
const song = createDemoRehearsalSong();
const createObjectUrl = vi.fn(() => "blob:full-band-chart");
vi.spyOn(HTMLAnchorElement.prototype, "click").mockImplementation(() => undefined);
Object.defineProperty(URL, "createObjectURL", {
configurable: true,
value: createObjectUrl
});
Object.defineProperty(URL, "revokeObjectURL", {
configurable: true,
value: vi.fn()
});

render(<Workspace song={song} />);
fireEvent.click(screen.getByRole("tab", { name: "Lead Vocal" }));
fireEvent.click(screen.getByRole("button", { name: "Download tonight's first-action chart" }));

const blob = createObjectUrl.mock.calls[0]?.[0] as Blob;
const payload = JSON.parse(await blob.text()) as {
firstAction?: { role?: string };
sections?: Array<{ roles?: Array<{ name?: string }> }>;
};

expect(payload.firstAction?.role).toBe("Bass Guitar");
expect(payload.sections?.[0]?.roles?.map((role) => role.name)).toEqual(
expect.arrayContaining(["Bass Guitar", "Lead Vocal"])
);
});
});
63 changes: 63 additions & 0 deletions apps/desktop/src/features/workspace/Workspace.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,68 @@ describe("Workspace", () => {
);
});

it("names tonight's first-action chart download and leads the file with that action", async () => {
setNavigatorLanguage("en-US");
const song = createDemoRehearsalSong();
const createObjectUrl = vi.fn(() => "blob:chart");
const revokeObjectUrl = vi.fn();
const click = vi.spyOn(HTMLAnchorElement.prototype, "click").mockImplementation(() => undefined);
Object.defineProperty(URL, "createObjectURL", {
configurable: true,
value: createObjectUrl
});
Object.defineProperty(URL, "revokeObjectURL", {
configurable: true,
value: revokeObjectUrl
});

render(<Workspace song={song} />);

const download = screen.getByRole("button", { name: "Download tonight's first-action chart" });
fireEvent.click(download);

const blob = createObjectUrl.mock.calls[0]?.[0] as Blob;
const payload = JSON.parse(await blob.text());
expect(Object.keys(payload)[1]).toBe("firstAction");
expect(payload.firstAction).toEqual({
section: "verse",
role: "Bass Guitar",
lowestNote: "C#2",
highestNote: "E3",
next: "Bass Guitar sits C#2–E3 in verse. Hear that clash on your instrument before the verse."
});
expect(click).toHaveBeenCalledTimes(1);
expect(revokeObjectUrl).toHaveBeenCalledWith("blob:chart");
});

it("does not invent a first-action chart lead when the first range still needs an ear check", async () => {
setNavigatorLanguage("en-US");
const song = createDemoRehearsalSong();
song.sections[0]!.roles = song.sections[0]!.roles.map((role) => ({
...role,
range: { lowestNote: "", highestNote: "none" },
overlapWarnings: []
}));
const createObjectUrl = vi.fn(() => "blob:chart-missing");
vi.spyOn(HTMLAnchorElement.prototype, "click").mockImplementation(() => undefined);
Object.defineProperty(URL, "createObjectURL", {
configurable: true,
value: createObjectUrl
});
Object.defineProperty(URL, "revokeObjectURL", {
configurable: true,
value: vi.fn()
});

render(<Workspace song={song} />);
fireEvent.click(screen.getByRole("button", { name: "Download tonight's first-action chart" }));

const blob = createObjectUrl.mock.calls[0]?.[0] as Blob;
const payload = JSON.parse(await blob.text());
expect(payload.firstAction).toBeUndefined();
expect(Object.keys(payload)).toEqual(["title", "headline", "sections"]);
});
Comment thread
seonghobae marked this conversation as resolved.

it("falls back from blank planning copy and tolerates partial collaboration payloads", () => {
setNavigatorLanguage("en-US");
const song = createDemoRehearsalSong();
Expand Down Expand Up @@ -325,5 +387,6 @@ describe("Workspace", () => {
expect(screen.getByText("스템")).toBeTruthy();
expect(screen.getByText("합주 우선순위")).toBeTruthy();
expect(screen.getByText("역할과 화성")).toBeTruthy();
expect(screen.getByRole("button", { name: "오늘 먼저 할 일 차트 받기" })).toBeTruthy();
});
});
5 changes: 3 additions & 2 deletions apps/desktop/src/features/workspace/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { SectionRoadmap } from "./SectionRoadmap";
import { GrooveMap } from "./GrooveMap";
import { PracticeProgress } from "./PracticeProgress";
import { fillRangeCopy, firstRangeSqueeze } from "./firstRangeSqueeze";
import { firstChartAction } from "./firstChartAction";
import { createTranslator, detectPreferredLocale } from "../../i18n";
import { generateCueSheetCsv, generateChartSummaryJson, generateMetadataHandoffJson, sanitizeFilename } from "../../lib/export";
import { Button } from "@/components/ui/button";
Expand Down Expand Up @@ -234,7 +235,7 @@ export function Workspace({ song, sourceBootstrap = null, onSongUpdate }: Worksp

/** Documented. */
const handleExportChart = () => {
const json = generateChartSummaryJson(song);
const json = generateChartSummaryJson(song, { firstAction: firstChartAction(song, activeRole, t) });
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
downloadTextFile(json, "application/json;charset=utf-8;", `${sanitizeFilename(song.title)}_chart.json`);
};

Expand Down Expand Up @@ -285,7 +286,7 @@ export function Workspace({ song, sourceBootstrap = null, onSongUpdate }: Worksp
className="min-h-10 border-white/10 bg-white/5 font-semibold text-slate-100 shadow-sm hover:bg-white/10 hover:text-white"
>
<Download className="mr-2 size-4 text-slate-300" aria-hidden="true" />
Export Chart (JSON)
{t("workspaceFirstRangeDownloadChart")}
</Button>
<Button
variant="outline"
Expand Down
69 changes: 69 additions & 0 deletions apps/desktop/src/features/workspace/firstChartAction.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { createDemoRehearsalSong, type RehearsalSong } from "@bandscope/shared-types";
import { describe, expect, it } from "vitest";
import { createTranslator } from "../../i18n";
import { firstChartAction } from "./firstChartAction";

describe("firstChartAction", () => {
const t = createTranslator("en");

it("leads with the first clashing span and the instrument-check next action", () => {
expect(firstChartAction(createDemoRehearsalSong(), null, t)).toEqual({
section: "verse",
role: "Bass Guitar",
lowestNote: "C#2",
highestNote: "E3",
next: "Bass Guitar sits C#2–E3 in verse. Hear that clash on your instrument before the verse."
});
});

it("keeps the full-band lead when a UI role is selected", () => {
const action = firstChartAction(createDemoRehearsalSong(), "lead-vocal", t);

expect(action?.role).toBe("Bass Guitar");
expect(action?.lowestNote).toBe("C#2");
expect(action?.highestNote).toBe("E3");
expect(action?.next).toBe(
"Bass Guitar sits C#2–E3 in verse. Hear that clash on your instrument before the verse."
);
});

it("uses the check copy when the first span has no clash", () => {
const song = createDemoRehearsalSong();
song.sections[0]!.roles = song.sections[0]!.roles.map((role) => ({
...role,
overlapWarnings: []
}));

expect(firstChartAction(song, null, t)?.next).toBe(
"Bass Guitar sits C#2–E3 in verse. Check that span on your instrument before the verse."
);
});

it("returns null when no named span exists", () => {
const song = createDemoRehearsalSong();
song.sections[0]!.roles = song.sections[0]!.roles.map((role) => ({
...role,
range: { lowestNote: "", highestNote: "none" },
overlapWarnings: []
}));

expect(firstChartAction(song, null, t)).toBeNull();
});

it("fails closed on malformed runtime collections", () => {
expect(firstChartAction(null as unknown as RehearsalSong, null, t)).toBeNull();
});

it("keeps formula-shaped role names literal so JSON encoding can neutralize them later", () => {
const song = createDemoRehearsalSong();
song.sections[0]!.roles[0] = {
...song.sections[0]!.roles[0]!,
name: "=HYPERLINK(\"http://evil\")"
};

expect(firstChartAction(song, "bass-guitar", t)).toMatchObject({
role: "=HYPERLINK(\"http://evil\")",
next: "=HYPERLINK(\"http://evil\") sits C#2–E3 in verse. Hear that clash on your instrument before the verse."
});
});
});
43 changes: 43 additions & 0 deletions apps/desktop/src/features/workspace/firstChartAction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { RehearsalSong } from "@bandscope/shared-types";
import type { TranslationKey } from "../../i18n";
import type { ChartFirstAction } from "../../lib/export";
import { fillRangeCopy, firstRangeSqueeze } from "./firstRangeSqueeze";

/** Documented. */
type Translator = (key: TranslationKey) => string;

/**
* Build tonight's first-action lead for the full-band rehearsal chart JSON.
*
* Uses the same playable-span authority as the ready map. Values stay
* literal so JSON encoding, not this helper, is the serialization boundary.
* Malformed songs and unnamed spans fail closed instead of inventing a lead.
*/
export function firstChartAction(
song: RehearsalSong,
activeRole: string | null,
t: Translator
): ChartFirstAction | null {
// The chart body always contains the full band, so a transient UI role filter must not alter its lead.
void activeRole;
const squeeze = firstRangeSqueeze(song, null);
if (!squeeze) {
return null;
}

return {
section: squeeze.sectionLabel,
role: squeeze.roleName,
lowestNote: squeeze.lowestNote,
highestNote: squeeze.highestNote,
next: fillRangeCopy(
t(squeeze.overlapWarning ? "workspaceFirstRangeClash" : "workspaceFirstRangeCheck"),
{
roleName: squeeze.roleName,
lowestNote: squeeze.lowestNote,
highestNote: squeeze.highestNote,
sectionLabel: squeeze.sectionLabel
}
)
};
}
28 changes: 28 additions & 0 deletions apps/desktop/src/lib/export.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ describe("export generation", () => {
const parsed = JSON.parse(jsonStr);
expect(parsed.title).toBe("Test");
expect(parsed.sections[0].roles[0].chord).toBe("=Cmaj7");
expect(parsed.firstAction).toBeUndefined();
});

it("generates chart summary JSON when headline is missing", () => {
Expand All @@ -143,6 +144,33 @@ describe("export generation", () => {
expect(parsed.headline).toBe("");
});

it("leads the chart JSON with tonight's first action when a lead is provided", () => {
const jsonStr = generateChartSummaryJson(mockSong, {
firstAction: {
section: "verse",
role: "=HYPERLINK(\"http://evil\")",
lowestNote: "C2",
highestNote: "C3",
next: "=HYPERLINK(\"http://evil\") sits C2–C3 in verse. Check that span on your instrument before the verse."
}
});
const parsed = JSON.parse(jsonStr);
expect(Object.keys(parsed)).toEqual(["title", "firstAction", "headline", "sections"]);
expect(parsed.firstAction).toEqual({
section: "verse",
role: "=HYPERLINK(\"http://evil\")",
lowestNote: "C2",
highestNote: "C3",
next: "=HYPERLINK(\"http://evil\") sits C2–C3 in verse. Check that span on your instrument before the verse."
});
expect(parsed.sections[0].roles[0].chord).toBe("=Cmaj7");
});

it("does not invent a first action when the lead is omitted or null", () => {
expect(JSON.parse(generateChartSummaryJson(mockSong)).firstAction).toBeUndefined();
expect(JSON.parse(generateChartSummaryJson(mockSong, { firstAction: null })).firstAction).toBeUndefined();
});

it("generates a metadata-only local handoff without source paths or transcription data", () => {
const sourceBootstrap: ProjectBootstrapSummary = {
projectId: "project-1",
Expand Down
Loading
Loading