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
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ This section applies to any agent (Claude, Codex, Cursor, opencode, ...) working
- Keep UI and analysis engine decoupled through shared contracts.
- Prefer minimal, test-first changes for production code.
- Prefer practical, friendly, rehearsal-first wording over academic or authority-heavy language.
- Name tonight's first labeled verse with the holding part when an active role is corroborated, the labeled story line, and the time so the next action is obvious.
- Do not reduce the product to a chord analyzer when form, timing, player coordination, playable ranges, simplification, and setup cues are the real rehearsal blockers.
- Do not frame usability as a reason to accept weak analysis quality; BandScope should aim for both easy use and high accuracy.

Expand Down
1 change: 1 addition & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Last updated: 2026-03-11

- Product identity, UX tone, copy rules, and prioritization tie-breakers live in `docs/brand-story.md`.
- Future PRDs, TRDs, onboarding copy, empty states, error messages, and marketing copy should use that document as the single brand source of truth.
- Workspace and player copy for tonight's first labeled verse must name the holding part when corroborated, the labeled story line, and the time so the next action is obvious.

## Security source

Expand Down
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@

### Added

- Name tonight's first labeled verse on the workspace and player so the room can learn the first line; the workspace action opens the matching map section, while the player exposes a Hear action only when its owning playback surface supplies a seek callback.
- 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 컨트롤(슬라이더 및 +/- 버튼)과 한/영 다국어 지원 포함.

### Changed

- Pinned npm `10.9.9` as the approved lockfile generator, activated it through Node-bundled Corepack before dependency consumption, and fail closed unless its bundled `tar` is at least `7.5.19`; primary CI still consumes the committed lock only through frozen `npm ci` validation, rejects mutable npm resolution in the lock gate, requires integrity evidence for public-registry lock entries, and preserves generator-sensitive root `@esbuild/*` peer metadata.
- Upgraded the local score PDF parser to `pdfjs-dist` 6.2.108, pinned Undici 7.29.0 across the workspace, and constrained PDF loading to copied in-memory bytes with a same-origin bundled worker and npm-generated lock provenance.

### Fixed

- Upgraded the local score PDF parser to `pdfjs-dist` 6.2.108, pinned Undici 7.29.0 across the workspace, and constrained PDF loading to copied in-memory bytes with a same-origin bundled worker and npm-generated lock provenance.
- Reset first-verse action completion when the runtime song object changes, so a replacement song cannot inherit success-shaped Open/Hear guidance merely because both songs have malformed or missing ids and the same verse metadata.

## [0.1.3] - 2026-04-29

Expand Down Expand Up @@ -74,4 +76,4 @@

- `ChordsFeature` (코드 분석) 화면에서 각 파트(Role)의 `transpositionPlan`(이조/조옮김 계획)을 표시하는 기능을 추가했습니다.
- `RangesFeature` (음역대 분석) 화면에서 겹침 경고(Overlap warning) 외에 해당 파트의 채보(Transcription) 가능 노드 수를 요약하여 보여주는 기능을 추가했습니다.
- 신규 UI 요소에 대한 단위 테스트를 추가했습니다 (`apps/desktop/src/features/chords/index.test.tsx`, `apps/desktop/src/features/ranges/index.test.tsx`).
- 신규 UI 요소에 대한 단위 테스트를 추가했습니다 (`apps/desktop/src/features/chords/index.test.tsx`, `apps/desktop/src/features/ranges/index.test.tsx`).
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). Workspace and player name tonight's first labeled verse so the room can learn the first line; the workspace action opens the matching map section, while the player exposes a Hear action only when its owning playback surface supplies a seek callback. The ready workspace also 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/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
97 changes: 97 additions & 0 deletions apps/desktop/src/features/player/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import { fireEvent, render, screen } from "@testing-library/react";
import { createDemoRehearsalSong } from "@bandscope/shared-types";
import { describe, expect, it, vi } from "vitest";
import { PlayerFeature } from "./index";

function songWithVerse() {
const song = createDemoRehearsalSong();
const seed = song.sections[0]!;
const verse = structuredClone(seed);
verse.id = "verse-1";
verse.label = "verse";
verse.timeRange = { start: 10, end: 30 };
verse.roles = [
{
...seed.roles[2]!,
id: "lead-vocal",
name: "Lead Vocal",
rehearsalPriority: "high"
}
];
verse.partGraph = [
{
role_id: "lead-vocal",
is_active: true,
handoff_to: [],
handoff_from: []
}
];
song.sections = [verse];
return song;
}

describe("PlayerFeature", () => {
it("asks the room to analyze first when no song is loaded", () => {
render(<PlayerFeature title="Player" />);
expect(
screen.getByText("Analyze tonight's song first, then hear the first verse from this player.")
).toBeTruthy();
});

it("keeps the verse hear action unavailable without a player playback callback", () => {
render(<PlayerFeature title="Player" song={songWithVerse()} />);

expect(screen.queryByRole("button", { name: "Hear Lead Vocal verse at 0:10" })).toBeNull();
expect(screen.getByText("Lead Vocal carries the verse at 0:10.")).toBeTruthy();
});

it("delegates the verse hear action to the owning player callback", () => {
const onPlayFromSeconds = vi.fn();
render(<PlayerFeature title="Player" song={songWithVerse()} onPlayFromSeconds={onPlayFromSeconds} />);

fireEvent.click(screen.getByRole("button", { name: "Hear Lead Vocal verse at 0:10" }));

expect(onPlayFromSeconds).toHaveBeenCalledTimes(1);
expect(onPlayFromSeconds).toHaveBeenCalledWith(10);
});

it("renders a safe empty summary when the runtime section collection is not an array", () => {
const song = songWithVerse();
(song as unknown as { sections: unknown }).sections = null;

render(<PlayerFeature title="Player" song={song} />);

expect(screen.getByText("No verse yet. Stay on tonight's map until the first verse is labeled.")).toBeTruthy();
expect(screen.getByText("0 sections")).toBeTruthy();
});

it("renders a safe empty summary when the runtime section collection is sparse", () => {
const song = songWithVerse();
const sparseSections: typeof song.sections = new Array(2);
sparseSections[1] = song.sections[0]!;
song.sections = sparseSections;

render(<PlayerFeature title="Player" song={song} />);

expect(screen.getByText("No verse yet. Stay on tonight's map until the first verse is labeled.")).toBeTruthy();
expect(screen.getByText("0 sections")).toBeTruthy();
});

it("omits malformed runtime section elements without crashing the player summary", () => {
const song = songWithVerse();
song.sections = [null, song.sections[0]!] as unknown as typeof song.sections;

render(<PlayerFeature title="Player" song={song} />);

expect(screen.getByText("1 section")).toBeTruthy();
expect(screen.getByText("verse")).toBeTruthy();
});

it("does not pass an object-valued runtime song title into React copy", () => {
const song = songWithVerse();
(song as unknown as { title: unknown }).title = { unsafe: "not-copy" };

expect(() => render(<PlayerFeature title="Player" song={song} />)).not.toThrow();
expect(screen.queryByText("not-copy")).toBeNull();
});
});
70 changes: 60 additions & 10 deletions apps/desktop/src/features/player/index.tsx
Original file line number Diff line number Diff line change
@@ -1,46 +1,96 @@
import type { RehearsalSong } from "@bandscope/shared-types";
import {
SECTION_FORM_LABELS,
type RehearsalSection,
type RehearsalSong,
type SectionFormLabel
} from "@bandscope/shared-types";
import { FirstVerseCallout } from "../workspace/FirstVerseCallout";
import { createTranslator, detectPreferredLocale } from "../../i18n";

/** Documented. */
export function PlayerFeature(props: { title: string; song?: RehearsalSong | null }) {
const { title, song } = props;
type PlayerFeatureProps = {
title: string;
song?: RehearsalSong | null;
onPlayFromSeconds?: (startSeconds: number) => void;
};

/** Return whether one runtime section is safe to summarize in the player. */
function isPlayerSummarySection(value: unknown): value is RehearsalSection {
if (value === null || typeof value !== "object") {
return false;
}
const section = value as Partial<RehearsalSection>;
return (
typeof section.id === "string" &&
section.id.trim().length > 0 &&
typeof section.label === "string" &&
SECTION_FORM_LABELS.includes(section.label as SectionFormLabel)
);
}

/** Return dense, individually valid sections without trusting runtime collection metadata. */
function playerSummarySections(song: RehearsalSong): RehearsalSection[] {
const sections = song.sections as unknown;
if (!Array.isArray(sections)) {
return [];
}
const length = Number(sections.length);
if (!Number.isSafeInteger(length) || length < 0 || length > 0xffffffff) {
return [];
}
for (let index = 0; index < length; index += 1) {
if (!(index in sections)) {
return [];
}
}
return sections.filter(isPlayerSummarySection);
}
Comment thread
seonghobae marked this conversation as resolved.

/** Player surface that names tonight's first labeled verse and delegates playback to the owning player. */
export function PlayerFeature({ title, song, onPlayFromSeconds }: PlayerFeatureProps) {
const t = createTranslator(detectPreferredLocale());

if (!song) {
return (
<section style={{ padding: "24px" }}>
<h2>{title}</h2>
<p style={{ color: "#999" }}>No song loaded. Start an analysis to use the player.</p>
<p style={{ color: "#999" }}>{t("firstVerseNeedsSong")}</p>
</section>
);
}

const sections = playerSummarySections(song);
const songTitle = typeof song.title === "string" ? song.title : "";

return (
<section style={{ padding: "24px" }}>
<h2>{title}</h2>
<FirstVerseCallout song={song} actionMode="callback-only" onHearVerse={onPlayFromSeconds} />
<div
style={{
padding: "16px",
backgroundColor: "#fafafa",
borderRadius: "8px",
border: "1px solid #e8e8e8",
marginTop: "16px"
}}
>
<div style={{ marginBottom: "12px" }}>
<strong>{song.title}</strong>
<strong>{songTitle}</strong>
<span style={{ color: "#666", marginLeft: "8px" }}>
{song.sections.length} {song.sections.length === 1 ? "section" : "sections"}
{sections.length} {sections.length === 1 ? "section" : "sections"}
</span>
</div>
<div style={{ display: "flex", gap: "8px", flexWrap: "wrap" }}>
{song.sections.map((section) => (
{sections.map((section, sectionIndex) => (
<span
key={section.id}
key={`${section.id}-${sectionIndex}`}
style={{
padding: "4px 12px",
borderRadius: "16px",
backgroundColor: "#fff",
border: "1px solid #d9d9d9",
fontSize: "0.85em",
textTransform: "capitalize",
textTransform: "capitalize"
}}
>
{section.label}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { render, screen } from "@testing-library/react";
import { createDemoRehearsalSong } from "@bandscope/shared-types";
import { afterEach, describe, expect, it, vi } from "vitest";
import { FirstVerseCallout } from "./FirstVerseCallout";

describe("FirstVerseCallout Korean role copy", () => {
afterEach(() => {
vi.unstubAllGlobals();
});

it("keeps vowel-ending dynamic role names particle-safe", () => {
vi.stubGlobal("navigator", { language: "ko-KR" });
const song = createDemoRehearsalSong();
const seed = song.sections[0]!;
const verse = structuredClone(seed);
verse.id = "verse-particle";
verse.label = "verse";
verse.timeRange = { start: 10, end: 30 };
verse.roles = [{ ...seed.roles[0]!, id: "piano", name: "피아노", rehearsalPriority: "high" }];
verse.partGraph = [
{ role_id: "piano", is_active: true, handoff_to: [], handoff_from: [] }
];
song.sections = [verse];

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

expect(screen.getByText("0:10 벌스에서 피아노 파트가 첫 소절을 잡습니다.")).toBeTruthy();
expect(screen.queryByText("피아노이 0:10 벌스에서 첫 소절을 잡습니다.")).toBeNull();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { fireEvent, render, screen } from "@testing-library/react";
import { createDemoRehearsalSong } from "@bandscope/shared-types";
import { afterEach, describe, expect, it, vi } from "vitest";
import { FirstVerseCallout } from "./FirstVerseCallout";

function songWithVerse() {
const song = createDemoRehearsalSong();
const seed = song.sections[0]!;
const verse = structuredClone(seed);
verse.id = "verse-1";
verse.label = "verse";
verse.timeRange = { start: 10, end: 30 };
verse.roles = [
{
...seed.roles[2]!,
id: "lead-vocal",
name: "Lead Vocal",
rehearsalPriority: "high"
}
];
verse.partGraph = [
{
role_id: "lead-vocal",
is_active: true,
handoff_to: [],
handoff_from: []
}
];
song.sections = [verse];
return song;
}

describe("FirstVerseCallout reduced motion", () => {
afterEach(() => {
vi.unstubAllGlobals();
});

it("scrolls immediately when the operating system requests reduced motion", () => {
vi.stubGlobal("matchMedia", (query: string) => ({
matches: query === "(prefers-reduced-motion: reduce)",
media: query,
onchange: null,
addListener: vi.fn(),
removeListener: vi.fn(),
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
dispatchEvent: vi.fn()
}));

const grid = document.createElement("div");
grid.dataset.testid = "song-structure-grid";
const target = document.createElement("div");
const scrollIntoView = vi.fn();
Object.defineProperty(target, "scrollIntoView", {
configurable: true,
value: scrollIntoView
});
grid.appendChild(target);
document.body.appendChild(grid);

render(<FirstVerseCallout song={songWithVerse()} />);
fireEvent.click(screen.getByRole("button", { name: "Open Lead Vocal verse at 0:10" }));
expect(scrollIntoView).toHaveBeenCalledWith({ block: "nearest", behavior: "auto" });

grid.remove();
});
});
Loading
Loading