-
Notifications
You must be signed in to change notification settings - Fork 1
feat(workspace): name tonight's first come-in on the map #1098
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
7
commits into
develop
Choose a base branch
from
feat/workspace-first-come-in
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
7 commits
Select commit
Hold shift + click to select a range
504beae
feat(workspace): name tonight's first come-in on the map
seonghobae fe1bf0b
test(workspace): reproduce repeated-label come-in gap
seonghobae fd776f8
fix(workspace): track come-ins by section identity
seonghobae a0bd5f9
test(workspace): reject conflicting come-in evidence
seonghobae 5ed7ed3
fix(workspace): reject conflicting come-in evidence
seonghobae 2aa834a
test(workspace): reject untrusted come-in role authority
seonghobae be6067f
fix(workspace): fail closed on untrusted come-in names
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
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
37 changes: 37 additions & 0 deletions
37
apps/desktop/src/features/workspace/firstComeIn.conflict.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,37 @@ | ||
| import { createDemoRehearsalSong, type RehearsalSong } from "@bandscope/shared-types"; | ||
| import { describe, expect, it } from "vitest"; | ||
| import { firstComeIn } from "./firstComeIn"; | ||
|
|
||
| function songWithSameSectionConflict(reverse: boolean): RehearsalSong { | ||
| const seed = createDemoRehearsalSong(); | ||
| const template = seed.sections[0]!; | ||
| const bass = template.partGraph.find((node) => node.role_id === "bass-guitar")!; | ||
| const others = template.partGraph.filter((node) => node.role_id !== "bass-guitar"); | ||
| const inactiveBass = { ...bass, is_active: false }; | ||
| const activeBass = { ...bass, is_active: true }; | ||
| const conflict = { | ||
| ...template, | ||
| id: "verse-conflict", | ||
| label: "verse" as RehearsalSong["sections"][number]["label"], | ||
| timeRange: { start: 0, end: 20 }, | ||
| partGraph: [ | ||
| ...others, | ||
| ...(reverse ? [activeBass, inactiveBass] : [inactiveBass, activeBass]) | ||
| ] | ||
| }; | ||
| const later = { | ||
| ...template, | ||
| id: "verse-later", | ||
| label: "verse" as RehearsalSong["sections"][number]["label"], | ||
| timeRange: { start: 20, end: 40 } | ||
| }; | ||
| return { ...seed, sections: [conflict, later] }; | ||
| } | ||
|
|
||
| describe("firstComeIn conflicting section evidence", () => { | ||
| it("fails closed for false/true and true/false duplicates before a later active section", () => { | ||
| for (const reverse of [false, true]) { | ||
| expect(firstComeIn(songWithSameSectionConflict(reverse), "bass-guitar")).toBeNull(); | ||
| } | ||
| }); | ||
| }); |
194 changes: 194 additions & 0 deletions
194
apps/desktop/src/features/workspace/firstComeIn.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,194 @@ | ||
| import { createDemoRehearsalSong, type RehearsalSong } from "@bandscope/shared-types"; | ||
| import { describe, expect, it } from "vitest"; | ||
| import { fillRangeCopy } from "./firstRangeSqueeze"; | ||
| import { firstComeIn } from "./firstComeIn"; | ||
|
|
||
| function withChorus(song: RehearsalSong): RehearsalSong { | ||
| const verse = song.sections[0]!; | ||
| const chorus = { | ||
| ...verse, | ||
| id: "chorus-1", | ||
| label: "chorus" as RehearsalSong["sections"][number]["label"], | ||
| timeRange: { | ||
| start: verse.timeRange.end, | ||
| end: verse.timeRange.end + 20 | ||
| } | ||
| }; | ||
| return { ...song, sections: [verse, chorus] }; | ||
| } | ||
|
|
||
| function withSitOutThenComeIn( | ||
| song: RehearsalSong, | ||
| roleId: string, | ||
| sitOutActive: boolean | "omit" = false | ||
| ): RehearsalSong { | ||
| const twoSection = withChorus(song); | ||
| return { | ||
| ...twoSection, | ||
| sections: twoSection.sections.map((section, index) => | ||
| index === 0 | ||
| ? { | ||
| ...section, | ||
| partGraph: section.partGraph.map((node) => { | ||
| if (node.role_id !== roleId) { | ||
| return node; | ||
| } | ||
| if (sitOutActive === "omit") { | ||
| const rest: Record<string, unknown> = { | ||
| role_id: node.role_id, | ||
| handoff_to: node.handoff_to, | ||
| handoff_from: node.handoff_from | ||
| }; | ||
| return rest as RehearsalSong["sections"][number]["partGraph"][number]; | ||
| } | ||
| return { ...node, is_active: sitOutActive }; | ||
| }) | ||
| } | ||
| : section | ||
| ) | ||
| }; | ||
| } | ||
|
|
||
| describe("firstComeIn", () => { | ||
| it("returns null on the demo song where every graph node is active", () => { | ||
| expect(firstComeIn(createDemoRehearsalSong())).toBeNull(); | ||
| expect(firstComeIn(withChorus(createDemoRehearsalSong()))).toBeNull(); | ||
| }); | ||
|
|
||
| it("names the first explicit return from existing part-graph evidence", () => { | ||
| expect(firstComeIn(withSitOutThenComeIn(createDemoRehearsalSong(), "keys-right"))).toEqual({ | ||
| sectionLabel: "chorus", | ||
| roleName: "Keyboard 1 Right Hand", | ||
| fromSectionLabel: "verse" | ||
| }); | ||
| }); | ||
|
|
||
| it("keeps the first return when a later section repeats the sit-out label", () => { | ||
| const song = withSitOutThenComeIn(createDemoRehearsalSong(), "keys-right"); | ||
| const repeatedVerse = { | ||
| ...song.sections[1]!, | ||
| id: "verse-2", | ||
| label: "verse" as RehearsalSong["sections"][number]["label"] | ||
| }; | ||
| const laterChorus = { | ||
| ...song.sections[1]!, | ||
| id: "chorus-2", | ||
| timeRange: { | ||
| start: song.sections[1]!.timeRange.end, | ||
| end: song.sections[1]!.timeRange.end + 20 | ||
| } | ||
| }; | ||
| song.sections = [song.sections[0]!, repeatedVerse, laterChorus]; | ||
|
|
||
| expect(firstComeIn(song)).toEqual({ | ||
| sectionLabel: "verse", | ||
| roleName: "Keyboard 1 Right Hand", | ||
| fromSectionLabel: "verse" | ||
| }); | ||
| }); | ||
|
|
||
| it("skips blank come-in labels until a named return exists", () => { | ||
| const song = withSitOutThenComeIn(createDemoRehearsalSong(), "keys-right"); | ||
| song.sections[1] = { | ||
| ...song.sections[1]!, | ||
| label: "none" as RehearsalSong["sections"][number]["label"] | ||
| }; | ||
| expect(firstComeIn(song)).toBeNull(); | ||
| }); | ||
|
|
||
| it("keeps the selected active part on tonight's first come-in", () => { | ||
| const song = withSitOutThenComeIn(createDemoRehearsalSong(), "lead-vocal"); | ||
| expect(firstComeIn(song, "lead-vocal")).toEqual({ | ||
| sectionLabel: "chorus", | ||
| roleName: "Lead Vocal", | ||
| fromSectionLabel: "verse" | ||
| }); | ||
| expect(firstComeIn(song, "bass-guitar")).toBeNull(); | ||
| }); | ||
|
|
||
| it("ignores inherited is_active evidence", () => { | ||
| const song = withChorus(createDemoRehearsalSong()); | ||
| const inherited = Object.create({ | ||
| is_active: false, | ||
| role_id: "keys-right" | ||
| }) as RehearsalSong["sections"][number]["partGraph"][number]; | ||
| song.sections[0] = { | ||
| ...song.sections[0]!, | ||
| partGraph: [inherited, ...song.sections[0]!.partGraph] | ||
| }; | ||
| expect(firstComeIn(song)).toBeNull(); | ||
| }); | ||
|
|
||
| it("does not treat a missing is_active flag as a sit-out", () => { | ||
| expect(firstComeIn(withSitOutThenComeIn(createDemoRehearsalSong(), "keys-right", "omit"))).toBeNull(); | ||
| }); | ||
|
|
||
| it("does not treat the song's opening entrance as a come-in", () => { | ||
| expect(firstComeIn(withSitOutThenComeIn(createDemoRehearsalSong(), "keys-right", true))).toBeNull(); | ||
| }); | ||
|
|
||
| it("fails closed when the return section has no named role", () => { | ||
| const song = withSitOutThenComeIn(createDemoRehearsalSong(), "keys-right"); | ||
| song.sections[1] = { | ||
| ...song.sections[1]!, | ||
| roles: song.sections[1]!.roles.map((role) => | ||
| role.id === "keys-right" ? { ...role, name: " " } : role | ||
| ) | ||
| }; | ||
| expect(firstComeIn(song)).toBeNull(); | ||
| }); | ||
|
|
||
| it("rejects inherited return-section roles as naming authority", () => { | ||
| const song = withSitOutThenComeIn(createDemoRehearsalSong(), "keys-right"); | ||
| const returnSection = song.sections[1]!; | ||
| const returnWithoutOwnRoles = { ...returnSection } as Record<string, unknown>; | ||
| delete returnWithoutOwnRoles.roles; | ||
| song.sections[1] = Object.assign( | ||
| Object.create({ roles: returnSection.roles }), | ||
| returnWithoutOwnRoles | ||
| ) as RehearsalSong["sections"][number]; | ||
|
|
||
| expect(firstComeIn(song)).toBeNull(); | ||
| }); | ||
|
|
||
| it("fails closed when the first active return has no trustworthy role name", () => { | ||
| const song = withSitOutThenComeIn(createDemoRehearsalSong(), "keys-right"); | ||
| const chorus = song.sections[1]!; | ||
| const unnamedChorus = { | ||
| ...chorus, | ||
| roles: chorus.roles.map((role) => | ||
| role.id === "keys-right" ? { ...role, name: " " } : role | ||
| ) | ||
| }; | ||
| const bridge = { | ||
| ...chorus, | ||
| id: "bridge-1", | ||
| label: "bridge" as RehearsalSong["sections"][number]["label"], | ||
| timeRange: { | ||
| start: chorus.timeRange.end, | ||
| end: chorus.timeRange.end + 20 | ||
| } | ||
| }; | ||
| song.sections = [song.sections[0]!, unnamedChorus, bridge]; | ||
|
|
||
| expect(firstComeIn(song)).toBeNull(); | ||
|
devin-ai-integration[bot] marked this conversation as resolved.
|
||
| }); | ||
|
|
||
| it("fails closed on malformed runtime roots", () => { | ||
| for (const malformed of [null, {}, { sections: {} }, { sections: [null] }]) { | ||
| expect(firstComeIn(malformed as unknown as RehearsalSong)).toBeNull(); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| describe("come-in copy filling", () => { | ||
| it("keeps rehearsal values literal", () => { | ||
| expect( | ||
| fillRangeCopy("{roleName} comes in on {sectionLabel} after {fromSectionLabel}.", { | ||
| roleName: "Bass {sectionLabel}", | ||
| sectionLabel: "chorus", | ||
| fromSectionLabel: "verse" | ||
| }) | ||
| ).toBe("Bass {sectionLabel} comes in on chorus after verse."); | ||
| }); | ||
| }); | ||
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.