-
Notifications
You must be signed in to change notification settings - Fork 1
feat(workspace): lead the cue sheet with tonight's first action #1114
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
Open
seonghobae
wants to merge
8
commits into
develop
Choose a base branch
from
feat/workspace-cuesheet-first-action
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f1c22ea
feat(workspace): lead the cue sheet with tonight's first action
seonghobae 89cb029
test(workspace): pin cue-sheet lead to repeated section
seonghobae 363d616
fix(workspace): retain first-range target identity
seonghobae 2f66afe
fix(workspace): use exact cue-sheet range target
seonghobae 95ddbf7
test(workspace): preserve cue-sheet none values
seonghobae f177efa
fix(workspace): preserve cue-sheet none values
seonghobae 2b90c34
test(workspace): reject stale cue-sheet role filters
seonghobae c9965e5
fix(workspace): ignore stale cue-sheet role filters
seonghobae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
apps/desktop/src/features/workspace/Workspace.cuesheet-stale-role.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| 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 cue-sheet role filter lifecycle", () => { | ||
| afterEach(() => { | ||
| setNavigatorLanguage(originalLanguage); | ||
| vi.restoreAllMocks(); | ||
| Object.defineProperty(URL, "createObjectURL", { | ||
| configurable: true, | ||
| value: originalCreateObjectUrl | ||
| }); | ||
| Object.defineProperty(URL, "revokeObjectURL", { | ||
| configurable: true, | ||
| value: originalRevokeObjectUrl | ||
| }); | ||
| }); | ||
|
|
||
| it("exports the new song's first action when the previous role filter no longer exists", async () => { | ||
| setNavigatorLanguage("en-US"); | ||
| const firstSong = createDemoRehearsalSong(); | ||
| const nextSong = createDemoRehearsalSong(); | ||
| nextSong.id = "next-project"; | ||
| nextSong.title = "Next Project"; | ||
| nextSong.sections = nextSong.sections.map((section) => ({ | ||
| ...section, | ||
| roles: section.roles.filter((role) => role.id !== "lead-vocal"), | ||
| partGraph: section.partGraph.filter((node) => node.role_id !== "lead-vocal") | ||
| })); | ||
|
|
||
| const createObjectUrl = vi.fn(() => "blob:next-cuesheet"); | ||
| vi.spyOn(HTMLAnchorElement.prototype, "click").mockImplementation(() => undefined); | ||
| Object.defineProperty(URL, "createObjectURL", { | ||
| configurable: true, | ||
| value: createObjectUrl | ||
| }); | ||
| Object.defineProperty(URL, "revokeObjectURL", { | ||
| configurable: true, | ||
| value: vi.fn() | ||
| }); | ||
|
|
||
| const { rerender } = render(<Workspace song={firstSong} />); | ||
| fireEvent.click(screen.getByRole("tab", { name: "Lead Vocal" })); | ||
|
|
||
| rerender(<Workspace song={nextSong} />); | ||
| fireEvent.click( | ||
| screen.getByRole("button", { name: "Download tonight's first-action sheet" }) | ||
| ); | ||
|
|
||
| const blob = createObjectUrl.mock.calls[0]?.[0] as Blob; | ||
| const lines = (await blob.text()).split("\n"); | ||
| expect(lines[0]).toBe("Section,Groove,Role,Harmony,Cue,Priority,Notes"); | ||
| expect(lines[1]).toMatch(/^Tonight first,/); | ||
| expect(lines[1]).toContain(",Bass Guitar,"); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
apps/desktop/src/features/workspace/firstCueSheetLead.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| import { createDemoRehearsalSong, type RehearsalSong } from "@bandscope/shared-types"; | ||
| import { describe, expect, it } from "vitest"; | ||
| import { createTranslator } from "../../i18n"; | ||
| import { firstCueSheetLead } from "./firstCueSheetLead"; | ||
|
|
||
| describe("firstCueSheetLead", () => { | ||
| const t = createTranslator("en"); | ||
|
|
||
| it("leads with the first clashing span and the instrument-check next action", () => { | ||
| expect(firstCueSheetLead(createDemoRehearsalSong(), null, t)).toEqual({ | ||
| section: "Tonight first", | ||
| groove: "Straight eighths with a late snare feel", | ||
| role: "Bass Guitar", | ||
| harmony: "C#m7", | ||
| cue: "Hold through the pickup before the downbeat.", | ||
| priority: "high", | ||
| notes: "Bass Guitar sits C#2–E3 in verse. Hear that clash on your instrument before the verse." | ||
| }); | ||
| }); | ||
|
|
||
| it("limits the lead row to the selected part", () => { | ||
| const lead = firstCueSheetLead(createDemoRehearsalSong(), "lead-vocal", t); | ||
|
|
||
| expect(lead?.role).toBe("Lead Vocal"); | ||
| expect(lead?.harmony).toBe("C#m7"); | ||
| expect(lead?.notes).toBe( | ||
| "Lead Vocal sits G#3–C#5 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(firstCueSheetLead(song, null, t)?.notes).toBe( | ||
| "Bass Guitar sits C#2–E3 in verse. Check that span on your instrument before the verse." | ||
| ); | ||
| }); | ||
|
|
||
| it("keeps the lead row on the exact repeated section selected by the squeeze", () => { | ||
| const song = createDemoRehearsalSong(); | ||
| const section = song.sections[0]!; | ||
| const bass = section.roles[0]!; | ||
|
|
||
| song.sections = [ | ||
| { | ||
| ...section, | ||
| id: "repeat-verse-earlier", | ||
| label: "verse", | ||
| groove: "Earlier groove", | ||
| roles: [ | ||
| { | ||
| ...bass, | ||
| harmony: { ...bass.harmony, chord: "Am7" }, | ||
| cue: { ...bass.cue, value: "Earlier cue" }, | ||
| rehearsalPriority: "low", | ||
| overlapWarnings: [] | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| ...section, | ||
| id: "repeat-verse-later", | ||
| label: "verse", | ||
| groove: "Later clash groove", | ||
| roles: [ | ||
| { | ||
| ...bass, | ||
| harmony: { ...bass.harmony, chord: "D7" }, | ||
| cue: { ...bass.cue, value: "Later cue" }, | ||
| rehearsalPriority: "high", | ||
| overlapWarnings: ["Register clash"] | ||
| } | ||
| ] | ||
| } | ||
| ]; | ||
|
|
||
| expect(firstCueSheetLead(song, "bass-guitar", t)).toMatchObject({ | ||
| groove: "Later clash groove", | ||
| harmony: "D7", | ||
| cue: "Later cue", | ||
| priority: "high" | ||
| }); | ||
| }); | ||
|
|
||
| it("preserves literal none values from the selected source row", () => { | ||
| const song = createDemoRehearsalSong(); | ||
| const section = song.sections[0]!; | ||
| const bass = section.roles[0]!; | ||
|
|
||
| song.sections[0] = { | ||
| ...section, | ||
| groove: "none", | ||
| roles: [ | ||
| { | ||
| ...bass, | ||
| harmony: { ...bass.harmony, chord: "none" }, | ||
| cue: { ...bass.cue, value: "none" }, | ||
| rehearsalPriority: "none" | ||
| }, | ||
| ...section.roles.slice(1) | ||
| ] | ||
| }; | ||
|
|
||
| expect(firstCueSheetLead(song, "bass-guitar", t)).toMatchObject({ | ||
| groove: "none", | ||
| harmony: "none", | ||
| cue: "none", | ||
| priority: "none" | ||
| }); | ||
| }); | ||
|
|
||
| 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(firstCueSheetLead(song, null, t)).toBeNull(); | ||
| }); | ||
|
|
||
| it("fails closed on malformed runtime collections after a squeeze match is impossible", () => { | ||
| expect(firstCueSheetLead(null as unknown as RehearsalSong, null, t)).toBeNull(); | ||
| }); | ||
|
|
||
| it("keeps formula-shaped harmony literal so CSV escaping can neutralize it later", () => { | ||
| const song = createDemoRehearsalSong(); | ||
| song.sections[0]!.roles[0] = { | ||
| ...song.sections[0]!.roles[0]!, | ||
| harmony: { chord: "=Cmaj7", functionLabel: "vi pedal anchor", source: "model" } | ||
| }; | ||
|
|
||
| expect(firstCueSheetLead(song, "bass-guitar", t)?.harmony).toBe("=Cmaj7"); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Stale role desynchronizes action card
When a replacement song lacks the selected role,
currentSongRoleFilterclears it only for export. ThefirstRangecard still reports no playable range.Was this helpful? React with 👍 or 👎 to provide feedback.