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
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 a selected part with a room-confirmed harmony override names that chord as the next lock-in.
- 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
2 changes: 1 addition & 1 deletion ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Last updated: 2026-03-11
## Rehearsal outputs

- Core rehearsal artifacts should include:
- likely harmony by section and by role
- likely harmony by section and by role, with a selected part naming a room-confirmed override chord as the next lock-in
- 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
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added

- 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.
- Name a selected part's room-confirmed harmony override and tell the player to lock that chord 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 and the next instrument check; a selected part with a room-confirmed harmony override also names that chord as the next lock-in. `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,53 @@
import { fireEvent, render, screen } from "@testing-library/react";
import { createDemoRehearsalSong } from "@bandscope/shared-types";
import { afterEach, describe, expect, it } from "vitest";
import { Workspace } from "./Workspace";

const originalLanguage = navigator.language;

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

describe("Workspace selected-part confirmed chord", () => {
afterEach(() => {
setNavigatorLanguage(originalLanguage);
});

it("stays hidden until a part with a room-confirmed chord is selected", () => {
setNavigatorLanguage("en-US");
render(<Workspace song={createDemoRehearsalSong()} />);

expect(screen.queryByTestId("selected-part-confirmed-chord")).toBeNull();

fireEvent.click(screen.getByRole("tab", { name: "Bass Guitar" }));
expect(screen.queryByTestId("selected-part-confirmed-chord")).toBeNull();
});

it("names the selected part's confirmed chord and the next lock-in action", () => {
setNavigatorLanguage("en-US");
render(<Workspace song={createDemoRehearsalSong()} />);

fireEvent.click(screen.getByRole("tab", { name: "Lead Vocal" }));

const callout = screen.getByTestId("selected-part-confirmed-chord");
expect(callout).toHaveTextContent("Tonight's confirmed chord");
expect(callout).toHaveTextContent(
"Lead Vocal uses the room's C#m11 in verse. Lock that chord before the verse."
);
});

it("keeps Korean copy particle-safe for Latin role names", () => {
setNavigatorLanguage("ko-KR");
render(<Workspace song={createDemoRehearsalSong()} />);

fireEvent.click(screen.getByRole("tab", { name: "Lead Vocal" }));

expect(screen.getByTestId("selected-part-confirmed-chord")).toHaveTextContent(
"verse의 Lead Vocal 파트는 방이 확인한 C#m11를 씁니다. verse 전에 그 코드를 고정하세요."
);
});
});
23 changes: 23 additions & 0 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 { fillConfirmedChordCopy, selectedPartConfirmedChord } from "./selectedPartConfirmedChord";
import { createTranslator, detectPreferredLocale } from "../../i18n";
import { generateCueSheetCsv, generateChartSummaryJson, generateMetadataHandoffJson, sanitizeFilename } from "../../lib/export";
import { Button } from "@/components/ui/button";
Expand Down Expand Up @@ -163,6 +164,17 @@ export function Workspace({ song, sourceBootstrap = null, onSongUpdate }: Worksp
}
)
: t("workspaceFirstRangeMissing");
const confirmedChord = useMemo(
() => selectedPartConfirmedChord(song, activeRole),
[activeRole, song]
);
const confirmedChordCopy = confirmedChord
? fillConfirmedChordCopy(t("workspaceConfirmedChordLock"), {
roleName: confirmedChord.roleName,
chord: confirmedChord.chord,
sectionLabel: confirmedChord.sectionLabel
})
: null;

/** Handle the practice progress change internally by immutably updating the song state. */
const handlePracticeProgressChange = (newProgress: number) => {
Expand Down Expand Up @@ -310,6 +322,17 @@ export function Workspace({ song, sourceBootstrap = null, onSongUpdate }: Worksp
<p className="mt-2 text-sm leading-6 text-slate-100">{firstRangeCopy}</p>
</section>

{confirmedChordCopy ? (
<section
className="rounded-2xl border border-indigo-300/20 bg-indigo-300/[0.07] p-4"
data-testid="selected-part-confirmed-chord"
aria-label={t("workspaceConfirmedChordTitle")}
>
<p className="text-xs font-black uppercase tracking-[0.24em] text-indigo-200">{t("workspaceConfirmedChordTitle")}</p>
<p className="mt-2 text-sm leading-6 text-slate-100">{confirmedChordCopy}</p>
</section>
) : null}

<div className="grid gap-4 md:grid-cols-2 xl:grid-cols-4">
<section className="rounded-2xl border border-cyan-300/20 bg-cyan-300/[0.06] p-4 md:col-span-2">
<p className="text-xs font-black uppercase tracking-[0.24em] text-cyan-300">{t("workspaceSongTimelineLabel")}</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
import { createDemoRehearsalSong, type RehearsalSong } from "@bandscope/shared-types";
import { describe, expect, it } from "vitest";
import {
fillConfirmedChordCopy,
selectedPartConfirmedChord
} from "./selectedPartConfirmedChord";

function withSelectedOverride(
song: RehearsalSong,
roleId: string,
chord: string | null,
extras: Partial<RehearsalSong["sections"][number]["roles"][number]> = {}
): RehearsalSong {
return {
...song,
sections: song.sections.map((section) => ({
...section,
roles: section.roles.map((role) => {
if (role.id !== roleId) {
return role;
}
return {
...role,
...extras,
manualOverrides:
chord === null
? []
: [
{
field: "harmony" as const,
value: {
chord,
functionLabel: "user confirmed",
source: "user" as const
},
source: "user" as const
}
]
};
})
}))
};
}

describe("selectedPartConfirmedChord", () => {
it("names the selected part's first own user harmony override", () => {
expect(selectedPartConfirmedChord(createDemoRehearsalSong(), "lead-vocal")).toEqual({
sectionLabel: "verse",
roleName: "Lead Vocal",
chord: "C#m11"
});
});

it("stays hidden until a named part is selected", () => {
expect(selectedPartConfirmedChord(createDemoRehearsalSong(), null)).toBeNull();
expect(selectedPartConfirmedChord(createDemoRehearsalSong(), " ")).toBeNull();
});

it("stays hidden when the selected part has no trusted override", () => {
expect(selectedPartConfirmedChord(createDemoRehearsalSong(), "bass-guitar")).toBeNull();
expect(
selectedPartConfirmedChord(withSelectedOverride(createDemoRehearsalSong(), "bass-guitar", "none"), "bass-guitar")
).toBeNull();
});

it("skips inherited, model, and non-harmony overrides", () => {
const song = createDemoRehearsalSong();
const bass = song.sections[0]!.roles[0]!;
const inherited = Object.create({
manualOverrides: [
{
field: "harmony",
value: { chord: "G", functionLabel: "inherited", source: "user" },
source: "user"
}
]
}) as typeof bass;
Object.assign(inherited, { ...bass, manualOverrides: undefined });
delete (inherited as { manualOverrides?: unknown }).manualOverrides;
song.sections[0]!.roles[0] = inherited;

expect(selectedPartConfirmedChord(song, "bass-guitar")).toBeNull();

const modelOnly = withSelectedOverride(createDemoRehearsalSong(), "bass-guitar", "E3");
modelOnly.sections[0]!.roles[0] = {
...modelOnly.sections[0]!.roles[0]!,
manualOverrides: [
{
field: "harmony",
value: {
chord: "Gmaj7",
functionLabel: "model leftover",
source: "model"
},
source: "model"
}
]
};

expect(selectedPartConfirmedChord(modelOnly, "bass-guitar")).toBeNull();
});

it("fails closed on conflicting role copies and sparse collections", () => {
const conflict = createDemoRehearsalSong();
conflict.sections.push({
...conflict.sections[0]!,
id: "verse-2",
roles: conflict.sections[0]!.roles.map((role) =>
role.id === "lead-vocal" ? { ...role, name: "Lead Vox" } : role
)
});
expect(selectedPartConfirmedChord(conflict, "lead-vocal")).toBeNull();

const chordConflict = createDemoRehearsalSong();
chordConflict.sections.push({
...chordConflict.sections[0]!,
id: "chorus-1",
label: "chorus",
roles: chordConflict.sections[0]!.roles.map((role) =>
role.id === "lead-vocal"
? {
...role,
manualOverrides: [
{
field: "harmony" as const,
value: {
chord: "Bmaj7",
functionLabel: "other copy",
source: "user" as const
},
source: "user" as const
}
]
}
: role
)
});
expect(selectedPartConfirmedChord(chordConflict, "lead-vocal")).toBeNull();

const sparse = createDemoRehearsalSong() as unknown as { sections: unknown[] };
sparse.sections = [];
sparse.sections[1] = createDemoRehearsalSong().sections[0];
expect(selectedPartConfirmedChord(sparse as unknown as RehearsalSong, "lead-vocal")).toBeNull();
});

it("fails closed on malformed roots, traps, and non-canonical labels", () => {
expect(selectedPartConfirmedChord(null as unknown as RehearsalSong, "lead-vocal")).toBeNull();
expect(selectedPartConfirmedChord({} as RehearsalSong, "lead-vocal")).toBeNull();

const trap = new Proxy(createDemoRehearsalSong(), {
has() {
throw new Error("has trap");
},
get(target, property, receiver) {
if (property === "sections") {
throw new Error("get trap");
}
return Reflect.get(target, property, receiver);
}
});
expect(selectedPartConfirmedChord(trap, "lead-vocal")).toBeNull();

const unknownLabel = createDemoRehearsalSong();
unknownLabel.sections[0] = { ...unknownLabel.sections[0]!, label: "vibe-check" as typeof unknownLabel.sections[0]["label"] };
expect(selectedPartConfirmedChord(unknownLabel, "lead-vocal")).toBeNull();
});
});

describe("fillConfirmedChordCopy", () => {
it("keeps placeholder-shaped chords literal", () => {
expect(
fillConfirmedChordCopy("{roleName} locks {chord} before {sectionLabel}.", {
roleName: "Lead Vocal",
chord: "C#m11 {sectionLabel}",
sectionLabel: "verse"
})
).toBe("Lead Vocal locks C#m11 {sectionLabel} before verse.");
});

it("does not satisfy tokens with inherited object members", () => {
expect(fillConfirmedChordCopy("Use {toString} in {missingToken}.", { chord: "C#m11" })).toBe(
"Use {toString} in {missingToken}."
);
});
});
Loading
Loading