-
Notifications
You must be signed in to change notification settings - Fork 0
feat(workspace): name tonight's first swell plan on the map #1045
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
28
commits into
develop
Choose a base branch
from
feat/workspace-first-swell-plan
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
28 commits
Select commit
Hold shift + click to select a range
3eb3676
feat(workspace): name tonight's first swell plan on the map
seonghobae 3e5d775
fix(ci): wrap swell regression assertion
seonghobae f41b5e0
style(analysis): apply pinned ruff formatting
seonghobae 8ea3b6c
style(analysis): format extractor source
seonghobae 7d6db4b
fix(coverage): remove unreachable swell branches
seonghobae ec9f3bf
test(review): preserve document body in swell cleanup
seonghobae 46f772d
test(review): disarm swell after navigation failure
seonghobae 6c4edeb
fix(review): disarm swell on navigation failure
seonghobae db73b7a
test(review): reject swell copy without provenance
seonghobae 6c0fafc
test(review): reject native swell copy without provenance
seonghobae 9bff468
test(review): keep drum source changes unnamed
seonghobae 88c2c74
fix(contract): require provenance for swell plan copy
seonghobae f2542ed
fix(analysis): preserve raw source continuity for swells
seonghobae e4ad759
style(analysis): format swell source continuity
seonghobae ac5631e
style(analysis): normalize source-set comprehension
seonghobae 5acb401
style(analysis): match pinned Ruff line fit
seonghobae cfa4c91
test(analysis): reject non-finite swell energy
seonghobae 8c4827e
fix(analysis): fail closed on non-finite swell energy
seonghobae bad930f
test(roles): prevent cross-section role aliasing
seonghobae f50dc24
fix(analysis): isolate section role payloads
seonghobae ee7e5ae
fix(workspace): require swell plan provenance
seonghobae cd4c955
refactor(analysis): remove redundant role copy
seonghobae cfbffa3
fix(cache): invalidate stale swell results
seonghobae aeede66
test(cache): cover current schema misses
seonghobae 284d0a3
test(cache): preserve stems across result schema bumps
seonghobae 2c3e19e
fix(cache): keep feature paths across result schema bumps
seonghobae 995e3fc
fix(api): type swell role payload fields
seonghobae 0b03fb7
fix(contract): align swell plan validation
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| use bandscope_desktop_core::project_payload_from_content; | ||
| use serde_json::{json, Value}; | ||
|
|
||
| fn song_with_swell_plan() -> Value { | ||
| json!({ | ||
| "id": "analyzed-song", | ||
| "title": "Late Night Set", | ||
| "sections": [ | ||
| { | ||
| "id": "chorus-1", | ||
| "label": "chorus", | ||
| "groove": "Lifted chorus downbeat", | ||
| "timeRange": { "start": 30, "end": 46 }, | ||
| "confidence": { | ||
| "level": "high", | ||
| "source": "model", | ||
| "notes": "Stem energy corroborates the swell." | ||
| }, | ||
| "roles": [ | ||
| { | ||
| "id": "lead-vocal", | ||
| "name": "Lead Vocal", | ||
| "roleType": "vocal", | ||
| "harmony": { | ||
| "chord": "C#m7", | ||
| "functionLabel": "vi landing", | ||
| "source": "model" | ||
| }, | ||
| "cue": { | ||
| "kind": "transition", | ||
| "value": "Grow into the next downbeat." | ||
| }, | ||
| "range": { | ||
| "lowestNote": "G#3", | ||
| "highestNote": "C#5" | ||
| }, | ||
| "confidence": { | ||
| "level": "high", | ||
| "source": "model", | ||
| "notes": "Vocal stays while the lift grows." | ||
| }, | ||
| "rehearsalPriority": "high", | ||
| "simplification": "Hold the landing syllable.", | ||
| "setupNote": "Keep the attack short.", | ||
| "manualOverrides": [], | ||
| "overlapWarnings": [], | ||
| "swellPlan": "Swell this part; grow into the next downbeat.", | ||
| "swellPlanSource": "model" | ||
| } | ||
| ], | ||
| "partGraph": [ | ||
| { | ||
| "role_id": "lead-vocal", | ||
| "is_active": true, | ||
| "handoff_to": [], | ||
| "handoff_from": [] | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "exportSummary": { | ||
| "format": "cue-sheet", | ||
| "headline": "Grow the chorus swell together.", | ||
| "focusSections": ["chorus-1"] | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| #[test] | ||
| fn project_contract_round_trips_swell_plan_provenance() { | ||
| let payload = song_with_swell_plan(); | ||
| let content = serde_json::to_string(&payload).expect("fixture should serialize"); | ||
|
|
||
| let parsed = project_payload_from_content(&content) | ||
| .expect("native project contract must accept shared swell-plan fields"); | ||
| let serialized = | ||
| serde_json::to_value(parsed).expect("native project contract should serialize"); | ||
|
|
||
| assert_eq!( | ||
| serialized["sections"][0]["roles"][0]["swellPlan"], | ||
| payload["sections"][0]["roles"][0]["swellPlan"] | ||
| ); | ||
| assert_eq!( | ||
| serialized["sections"][0]["roles"][0]["swellPlanSource"], | ||
| json!("model") | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn project_contract_rejects_swell_plan_source_without_swell_plan() { | ||
| let mut payload = song_with_swell_plan(); | ||
| payload["sections"][0]["roles"][0] | ||
| .as_object_mut() | ||
| .expect("role fixture should be an object") | ||
| .remove("swellPlan"); | ||
| let content = serde_json::to_string(&payload).expect("fixture should serialize"); | ||
|
|
||
| assert!( | ||
| project_payload_from_content(&content).is_err(), | ||
| "native persisted contract must reject provenance without the value it describes" | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn project_contract_rejects_swell_plan_without_source() { | ||
| let mut payload = song_with_swell_plan(); | ||
| payload["sections"][0]["roles"][0] | ||
| .as_object_mut() | ||
| .expect("role fixture should be an object") | ||
| .remove("swellPlanSource"); | ||
| let content = serde_json::to_string(&payload).expect("fixture should serialize"); | ||
|
|
||
| assert!( | ||
| project_payload_from_content(&content).is_err(), | ||
| "native persisted contract must reject swell-plan copy without provenance" | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn project_contract_rejects_invalid_swell_plan_copy_with_source() { | ||
| for swell_plan in [ | ||
| "", | ||
| " ", | ||
| "\u{00A0}\u{2003}\u{3000}", | ||
| "swell here\nthen hold", | ||
| "swell here\rthen hold", | ||
| "swell here\u{0085}then hold", | ||
| "swell here\u{2028}then hold", | ||
| "swell here\u{2029}then hold", | ||
| ] { | ||
| let mut payload = song_with_swell_plan(); | ||
| payload["sections"][0]["roles"][0]["swellPlan"] = json!(swell_plan); | ||
| let content = serde_json::to_string(&payload).expect("fixture should serialize"); | ||
|
|
||
| assert!( | ||
| project_payload_from_content(&content).is_err(), | ||
| "native persisted contract must reject blank or multiline sourced swell-plan copy" | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| #[test] | ||
| fn project_contract_rejects_unknown_swell_plan_source() { | ||
| let mut payload = song_with_swell_plan(); | ||
| payload["sections"][0]["roles"][0]["swellPlanSource"] = json!("legacy"); | ||
| let content = serde_json::to_string(&payload).expect("fixture should serialize"); | ||
|
|
||
| assert!( | ||
| project_payload_from_content(&content).is_err(), | ||
| "native persisted contract must reject provenance outside model/user" | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn project_contract_preserves_padded_single_line_swell_copy() { | ||
| let mut payload = song_with_swell_plan(); | ||
| payload["sections"][0]["roles"][0]["swellPlan"] = json!(" Grow together. \u{00A0}"); | ||
| payload["sections"][0]["roles"][0]["swellPlanSource"] = json!("user"); | ||
| let content = serde_json::to_string(&payload).expect("fixture should serialize"); | ||
|
|
||
| let parsed = project_payload_from_content(&content) | ||
| .expect("native persisted contract must preserve padded single-line copy"); | ||
| let serialized = | ||
| serde_json::to_value(parsed).expect("native project contract should serialize"); | ||
|
|
||
| assert_eq!( | ||
| serialized["sections"][0]["roles"][0]["swellPlan"], | ||
| payload["sections"][0]["roles"][0]["swellPlan"] | ||
| ); | ||
| } |
87 changes: 87 additions & 0 deletions
87
apps/desktop/src/features/workspace/FirstSwellPlanCallout.custom-guidance.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,87 @@ | ||
| import { fireEvent, render, screen } from "@testing-library/react"; | ||
| import { createDemoRehearsalSong } from "@bandscope/shared-types"; | ||
| import { afterEach, describe, expect, it, vi } from "vitest"; | ||
| import { FirstSwellPlanCallout } from "./FirstSwellPlanCallout"; | ||
|
|
||
| const appendedSongStructureTargets = new Set<HTMLElement>(); | ||
|
|
||
| function songWithCustomSwellPlan(source: "model" | "user" | undefined, text: string) { | ||
| const song = createDemoRehearsalSong(); | ||
| const verse = song.sections[0]!; | ||
| verse.partGraph = verse.partGraph.map((node) => ({ ...node, is_active: true })); | ||
| const chorus = structuredClone(verse); | ||
| chorus.id = "chorus-1"; | ||
| chorus.label = "chorus"; | ||
| chorus.timeRange = { start: verse.timeRange.end, end: verse.timeRange.end + 16 }; | ||
| chorus.partGraph = chorus.partGraph.map((node) => ({ ...node, is_active: true })); | ||
| const vocal = chorus.roles.find((role) => role.id === "lead-vocal")!; | ||
| vocal.swellPlan = text; | ||
| if (source) { | ||
| vocal.swellPlanSource = source; | ||
| } | ||
| song.sections = [verse, chorus]; | ||
| return song; | ||
| } | ||
|
|
||
| function appendSongStructureTarget() { | ||
| const timeline = document.createElement("div"); | ||
| const grid = document.createElement("div"); | ||
| grid.dataset.testid = "song-structure-grid"; | ||
| const target = document.createElement("div"); | ||
| target.dataset.sectionIndex = "1"; | ||
| Object.defineProperty(target, "scrollIntoView", { | ||
| configurable: true, | ||
| value: vi.fn() | ||
| }); | ||
| grid.appendChild(target); | ||
| timeline.appendChild(grid); | ||
| document.body.appendChild(timeline); | ||
| appendedSongStructureTargets.add(timeline); | ||
| } | ||
|
|
||
| describe("FirstSwellPlanCallout custom guidance", () => { | ||
| afterEach(() => { | ||
| for (const timeline of appendedSongStructureTargets) { | ||
| timeline.remove(); | ||
| } | ||
| appendedSongStructureTargets.clear(); | ||
| }); | ||
|
|
||
| it("preserves user-authored swell guidance verbatim", () => { | ||
| render( | ||
| <FirstSwellPlanCallout | ||
| song={songWithCustomSwellPlan("user", "Grow on the snare; don't rush the last eighth.")} | ||
| /> | ||
| ); | ||
| expect(screen.getByText("Grow on the snare; don't rush the last eighth.")).toBeTruthy(); | ||
| }); | ||
|
|
||
| it("keeps user-authored guidance in the plain body after opening the swell", () => { | ||
| appendSongStructureTarget(); | ||
| render( | ||
| <FirstSwellPlanCallout | ||
| song={songWithCustomSwellPlan("user", "Grow on the snare; don't rush the last eighth.")} | ||
| /> | ||
| ); | ||
|
|
||
| fireEvent.click(screen.getByRole("button", { name: "Open Lead Vocal swell at 0:30" })); | ||
|
|
||
| expect(screen.getByText("Lead Vocal swells the chorus at 0:30.")).toBeTruthy(); | ||
| expect(screen.getByText("Grow on the snare; don't rush the last eighth.")).toBeTruthy(); | ||
| expect(screen.queryByText(/Swell Lead Vocal together at 0:30 so the lift is audible./)).toBeNull(); | ||
| }); | ||
|
|
||
| it("fails closed for custom copy without provenance", () => { | ||
| render( | ||
| <FirstSwellPlanCallout | ||
| song={songWithCustomSwellPlan(undefined, "Stack the last bar and grow together.")} | ||
| /> | ||
| ); | ||
| expect( | ||
| screen.getByText( | ||
| "No swell plan is available. Stay on tonight's map for the next rehearsal cue." | ||
| ) | ||
| ).toBeTruthy(); | ||
| expect(screen.queryByText("Stack the last bar and grow together.")).toBeNull(); | ||
| }); | ||
| }); |
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.