-
Notifications
You must be signed in to change notification settings - Fork 1
feat(workspace): name tonight's first unlogged practice pass #1148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bbf0cf6
f88acba
dc65cc7
26ac2a2
81b661d
f38dd6d
898394f
c7b1ca4
e35d408
51e0296
b721ea7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ import { SectionRoadmap } from "./SectionRoadmap"; | |
| import { GrooveMap } from "./GrooveMap"; | ||
| import { PracticeProgress } from "./PracticeProgress"; | ||
| import { fillRangeCopy, firstRangeSqueeze } from "./firstRangeSqueeze"; | ||
| import { fillUnloggedPracticeCopy, firstUnloggedPractice } from "./firstUnloggedPractice"; | ||
| import { createTranslator, detectPreferredLocale } from "../../i18n"; | ||
| import { generateCueSheetCsv, generateChartSummaryJson, generateMetadataHandoffJson, sanitizeFilename } from "../../lib/export"; | ||
| import { Button } from "@/components/ui/button"; | ||
|
|
@@ -163,6 +164,18 @@ export function Workspace({ song, sourceBootstrap = null, onSongUpdate }: Worksp | |
| } | ||
| ) | ||
| : t("workspaceFirstRangeMissing"); | ||
| const firstUnlogged = useMemo(() => firstUnloggedPractice(song, activeRole), [activeRole, song]); | ||
| const firstUnloggedCopy = | ||
| firstUnlogged.kind === "unlogged" | ||
| ? fillUnloggedPracticeCopy(t("workspaceFirstUnloggedPracticeCheck"), { | ||
| roleName: firstUnlogged.roleName, | ||
| sectionLabel: firstUnlogged.sectionLabel | ||
| }) | ||
| : firstUnlogged.kind === "selected-logged" | ||
| ? t("workspaceFirstUnloggedPracticeSelectedReady") | ||
|
Comment on lines
+174
to
+175
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Logged selections invent a next pass When the selected part is logged, Prompt for agentsWas this helpful? React with 👍 or 👎 to provide feedback. |
||
| : firstUnlogged.kind === "all-logged" | ||
| ? t("workspaceFirstUnloggedPracticeMissing") | ||
| : t("workspaceFirstUnloggedPracticeUnavailable"); | ||
|
Comment on lines
+167
to
+178
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| /** Handle the practice progress change internally by immutably updating the song state. */ | ||
| const handlePracticeProgressChange = (newProgress: number) => { | ||
|
|
@@ -310,6 +323,15 @@ export function Workspace({ song, sourceBootstrap = null, onSongUpdate }: Worksp | |
| <p className="mt-2 text-sm leading-6 text-slate-100">{firstRangeCopy}</p> | ||
| </section> | ||
|
|
||
| <section | ||
| className="rounded-2xl border border-indigo-300/20 bg-indigo-300/[0.08] p-4" | ||
| data-testid="first-unlogged-practice" | ||
| aria-label={t("workspaceFirstUnloggedPracticeTitle")} | ||
| > | ||
| <p className="text-xs font-black uppercase tracking-[0.24em] text-indigo-200">{t("workspaceFirstUnloggedPracticeTitle")}</p> | ||
| <p className="mt-2 text-sm leading-6 text-slate-100">{firstUnloggedCopy}</p> | ||
| </section> | ||
|
|
||
| <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> | ||
|
|
@@ -512,4 +534,4 @@ export function Workspace({ song, sourceBootstrap = null, onSongUpdate }: Worksp | |
| </Card> | ||
| </div> | ||
| ); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,181 @@ | ||
| import { createDemoRehearsalSong, type RehearsalSong } from "@bandscope/shared-types"; | ||
| import { describe, expect, it } from "vitest"; | ||
| import { | ||
| fillUnloggedPracticeCopy, | ||
| firstUnloggedPractice, | ||
| hasLoggedPracticeProgress | ||
| } from "./firstUnloggedPractice"; | ||
|
|
||
| describe("hasLoggedPracticeProgress", () => { | ||
| it("admits only 0–100 integers", () => { | ||
| expect(hasLoggedPracticeProgress(0)).toBe(true); | ||
| expect(hasLoggedPracticeProgress(100)).toBe(true); | ||
| expect(hasLoggedPracticeProgress(40)).toBe(true); | ||
| expect(hasLoggedPracticeProgress(undefined)).toBe(false); | ||
| expect(hasLoggedPracticeProgress(40.5)).toBe(false); | ||
| expect(hasLoggedPracticeProgress(-1)).toBe(false); | ||
| expect(hasLoggedPracticeProgress(101)).toBe(false); | ||
| expect(hasLoggedPracticeProgress("40")).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe("firstUnloggedPractice", () => { | ||
| it("names the first demo part that still has no practice mark", () => { | ||
| expect(firstUnloggedPractice(createDemoRehearsalSong())).toEqual({ | ||
| kind: "unlogged", | ||
| sectionLabel: "verse", | ||
| roleName: "Bass Guitar" | ||
| }); | ||
| }); | ||
|
|
||
| it("skips parts that already own a 0–100 mark", () => { | ||
| const song = createDemoRehearsalSong(); | ||
| song.sections[0]!.roles[0] = { | ||
| ...song.sections[0]!.roles[0]!, | ||
| practiceProgress: 40 | ||
| }; | ||
|
|
||
| expect(firstUnloggedPractice(song)).toEqual({ | ||
| kind: "unlogged", | ||
| sectionLabel: "verse", | ||
| roleName: "Keyboard 1 Right Hand" | ||
| }); | ||
| }); | ||
|
|
||
| it("limits the callout to the selected unlogged part", () => { | ||
| expect(firstUnloggedPractice(createDemoRehearsalSong(), "lead-vocal")).toEqual({ | ||
| kind: "unlogged", | ||
| sectionLabel: "verse", | ||
| roleName: "Lead Vocal" | ||
| }); | ||
| }); | ||
|
|
||
| it("distinguishes a selected part with a trustworthy practice mark", () => { | ||
| const song = createDemoRehearsalSong(); | ||
| song.sections[0]!.roles[2] = { | ||
| ...song.sections[0]!.roles[2]!, | ||
| practiceProgress: 0 | ||
| }; | ||
|
|
||
| expect(firstUnloggedPractice(song, "lead-vocal")).toEqual({ kind: "selected-logged" }); | ||
| }); | ||
|
|
||
| it("skips malformed marks and duplicate role ids inside one section", () => { | ||
| const song = createDemoRehearsalSong(); | ||
| song.sections[0]!.roles[0] = { | ||
| ...song.sections[0]!.roles[0]!, | ||
| practiceProgress: 150 as unknown as number | ||
| }; | ||
| song.sections[0]!.roles[1] = { | ||
| ...song.sections[0]!.roles[1]!, | ||
| id: "bass-guitar" | ||
| }; | ||
|
|
||
| expect(firstUnloggedPractice(song)).toEqual({ | ||
| kind: "unlogged", | ||
| sectionLabel: "verse", | ||
| roleName: "Lead Vocal" | ||
| }); | ||
| }); | ||
|
|
||
| it("treats the same named role across sections as one part", () => { | ||
| const song = createDemoRehearsalSong(); | ||
| const verse = song.sections[0]!; | ||
| song.sections.push({ | ||
| ...structuredClone(verse), | ||
| id: "chorus-1", | ||
| label: "chorus", | ||
| timeRange: { start: 30, end: 50 } | ||
| }); | ||
|
|
||
| expect(firstUnloggedPractice(song)).toEqual({ | ||
| kind: "unlogged", | ||
| sectionLabel: "verse", | ||
| roleName: "Bass Guitar" | ||
| }); | ||
| }); | ||
|
|
||
| it("reports unavailable when repeated section copies disagree about selected practice state", () => { | ||
| const song = createDemoRehearsalSong(); | ||
| const verse = song.sections[0]!; | ||
| const chorus = structuredClone(verse); | ||
| chorus.id = "chorus-1"; | ||
| chorus.label = "chorus"; | ||
| chorus.timeRange = { start: 30, end: 50 }; | ||
| chorus.roles[0] = { | ||
| ...chorus.roles[0]!, | ||
| practiceProgress: 40 | ||
| }; | ||
| song.sections.push(chorus); | ||
|
|
||
| expect(firstUnloggedPractice(song, "bass-guitar")).toEqual({ kind: "unavailable" }); | ||
| }); | ||
|
|
||
| it("reports unavailable for a selected malformed practice mark instead of claiming it is logged", () => { | ||
| const song = createDemoRehearsalSong(); | ||
| song.sections[0]!.roles[2] = { | ||
| ...song.sections[0]!.roles[2]!, | ||
| practiceProgress: 150 as unknown as number | ||
| }; | ||
|
|
||
| expect(firstUnloggedPractice(song, "lead-vocal")).toEqual({ kind: "unavailable" }); | ||
| }); | ||
|
|
||
| it("returns all-logged only when every named role has trustworthy consistent marks", () => { | ||
| const song = createDemoRehearsalSong(); | ||
| song.sections[0]!.roles = song.sections[0]!.roles.map((role, index) => ({ | ||
| ...role, | ||
| practiceProgress: index * 40 | ||
| })); | ||
|
|
||
| expect(firstUnloggedPractice(song)).toEqual({ kind: "all-logged" }); | ||
| }); | ||
|
|
||
| it("reports unavailable rather than all-logged when the remaining evidence is malformed", () => { | ||
| const song = createDemoRehearsalSong(); | ||
| song.sections[0]!.roles = song.sections[0]!.roles.map((role, index) => ({ | ||
| ...role, | ||
| practiceProgress: index === 2 ? (150 as unknown as number) : index * 40 | ||
| })); | ||
|
|
||
| expect(firstUnloggedPractice(song)).toEqual({ kind: "unavailable" }); | ||
| }); | ||
|
|
||
| it("rejects inherited identity and practice evidence", () => { | ||
| const inheritedRole = Object.create({ | ||
| id: "ghost-role", | ||
| name: "Ghost Role", | ||
| practiceProgress: 40 | ||
| }) as Record<string, unknown>; | ||
| const song = { | ||
| sections: [ | ||
| { | ||
| label: "verse", | ||
| roles: [inheritedRole] | ||
| } | ||
| ] | ||
| } as unknown as RehearsalSong; | ||
|
|
||
| expect(firstUnloggedPractice(song)).toEqual({ kind: "unavailable" }); | ||
| }); | ||
|
|
||
| it("fails closed on malformed runtime roots and collections", () => { | ||
| for (const malformed of [null, {}, { sections: null }, { sections: [null] }]) { | ||
| expect(firstUnloggedPractice(malformed as unknown as RehearsalSong)).toEqual({ kind: "unavailable" }); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| describe("fillUnloggedPracticeCopy", () => { | ||
| it("replaces tokens without inheriting object members", () => { | ||
| expect( | ||
| fillUnloggedPracticeCopy("{roleName} in {sectionLabel} before {sectionLabel}.", { | ||
| roleName: "Bass Guitar", | ||
| sectionLabel: "verse" | ||
| }) | ||
| ).toBe("Bass Guitar in verse before verse."); | ||
| expect(fillUnloggedPracticeCopy("Check {toString} before {missingToken}.", { roleName: "Bass Guitar" })).toBe( | ||
| "Check {toString} before {missingToken}." | ||
| ); | ||
| }); | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.