-
Notifications
You must be signed in to change notification settings - Fork 1
feat(workspace): name tonight's first score check on the map #1092
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
13
commits into
develop
Choose a base branch
from
feat/workspace-first-score-check
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
13 commits
Select commit
Hold shift + click to select a range
72b04a0
feat(workspace): name tonight's first score check on the map
seonghobae 2316aa2
test(workspace): reproduce native-valid score metadata rejection
seonghobae fd2c3a9
fix(workspace): preserve native-valid score display names
seonghobae b433028
test(workspace): reproduce reopened score openability gap
seonghobae 77db6cd
fix(workspace): require live score workspace before open guidance
seonghobae 1372424
fix(workspace): gate score-open guidance on live project context
seonghobae dd17feb
test(workspace): cover reopened score fallback
seonghobae 35dc521
test(workspace): require semantic trusted score metadata
seonghobae 8cd6756
fix(workspace): translate score attachment wire names
seonghobae 5af64f5
docs(score): state live workspace fallback contract
seonghobae 5a2abb1
docs(score): align agent score-open contract
seonghobae 893b87a
docs(score): document unavailable score fallback
seonghobae 8099e3b
docs(score): align Claude score-open contract
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 |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ import { SectionRoadmap } from "./SectionRoadmap"; | |
| import { GrooveMap } from "./GrooveMap"; | ||
| import { PracticeProgress } from "./PracticeProgress"; | ||
| import { fillRangeCopy, firstRangeSqueeze } from "./firstRangeSqueeze"; | ||
| import { firstScoreCheck } from "./firstScoreCheck"; | ||
| import { createTranslator, detectPreferredLocale } from "../../i18n"; | ||
| import { generateCueSheetCsv, generateChartSummaryJson, generateMetadataHandoffJson, sanitizeFilename } from "../../lib/export"; | ||
| import { Button } from "@/components/ui/button"; | ||
|
|
@@ -163,6 +164,30 @@ export function Workspace({ song, sourceBootstrap = null, onSongUpdate }: Worksp | |
| } | ||
| ) | ||
| : t("workspaceFirstRangeMissing"); | ||
| const scoreWorkspaceAvailable = useMemo( | ||
| () => safeProjectBootstrapSummary(sourceBootstrap) !== null, | ||
| [sourceBootstrap] | ||
| ); | ||
| const firstScore = useMemo( | ||
| () => firstScoreCheck(song, activeRole, scoreWorkspaceAvailable), | ||
| [activeRole, scoreWorkspaceAvailable, song] | ||
| ); | ||
| const firstScoreCopy = firstScore | ||
| ? fillRangeCopy( | ||
| t( | ||
| firstScore.sectionLabel | ||
| ? "workspaceFirstScoreCheck" | ||
| : "workspaceFirstScoreCheckNoRange" | ||
| ), | ||
| { | ||
| fileName: firstScore.fileName, | ||
| roleName: firstScore.roleName ?? "", | ||
| lowestNote: firstScore.lowestNote ?? "", | ||
| highestNote: firstScore.highestNote ?? "", | ||
| sectionLabel: firstScore.sectionLabel ?? "" | ||
| } | ||
| ) | ||
|
Comment on lines
+175
to
+189
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. |
||
| : t("workspaceFirstScoreMissing"); | ||
|
|
||
| /** Handle the practice progress change internally by immutably updating the song state. */ | ||
| const handlePracticeProgressChange = (newProgress: number) => { | ||
|
|
@@ -309,6 +334,14 @@ export function Workspace({ song, sourceBootstrap = null, onSongUpdate }: Worksp | |
| <p className="text-xs font-black uppercase tracking-[0.24em] text-fuchsia-200">{t("workspaceFirstRangeTitle")}</p> | ||
| <p className="mt-2 text-sm leading-6 text-slate-100">{firstRangeCopy}</p> | ||
| </section> | ||
| <section | ||
| className="rounded-2xl border border-sky-300/20 bg-sky-300/[0.07] p-4" | ||
| data-testid="first-score-check" | ||
| aria-label={t("workspaceFirstScoreTitle")} | ||
| > | ||
| <p className="text-xs font-black uppercase tracking-[0.24em] text-sky-200">{t("workspaceFirstScoreTitle")}</p> | ||
| <p className="mt-2 text-sm leading-6 text-slate-100">{firstScoreCopy}</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"> | ||
|
|
@@ -512,4 +545,4 @@ export function Workspace({ song, sourceBootstrap = null, onSongUpdate }: Worksp | |
| </Card> | ||
| </div> | ||
| ); | ||
| } | ||
| } | ||
184 changes: 184 additions & 0 deletions
184
apps/desktop/src/features/workspace/firstScoreCheck.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,184 @@ | ||
| import { createDemoRehearsalSong, type RehearsalSong } from "@bandscope/shared-types"; | ||
| import { describe, expect, it } from "vitest"; | ||
| import { | ||
| firstScoreCheck, | ||
| trustedScoreAttachment, | ||
| trustedScoreFileName | ||
| } from "./firstScoreCheck"; | ||
| import { fillRangeCopy } from "./firstRangeSqueeze"; | ||
|
|
||
| const TRUSTED_SCORE_ID = "3f2c8f0e-1a2b-4c3d-8e9f-001122334455"; | ||
|
|
||
| function songWithAttachments( | ||
| attachments: unknown, | ||
| song: RehearsalSong = createDemoRehearsalSong() | ||
| ): RehearsalSong { | ||
| return { | ||
| ...song, | ||
| scoreAttachments: attachments as RehearsalSong["scoreAttachments"] | ||
| }; | ||
| } | ||
|
|
||
| function blankRoleRange(song: RehearsalSong): RehearsalSong { | ||
| return { | ||
| ...song, | ||
| sections: song.sections.map((section) => ({ | ||
| ...section, | ||
| roles: section.roles.map((role) => ({ | ||
| ...role, | ||
| range: { lowestNote: "", highestNote: "" }, | ||
| overlapWarnings: [] | ||
| })) | ||
| })) | ||
| }; | ||
| } | ||
|
|
||
| describe("trustedScoreFileName", () => { | ||
| it("admits a PDF basename", () => { | ||
| expect(trustedScoreFileName("opener.pdf")).toBe("opener.pdf"); | ||
| expect(trustedScoreFileName("Late Night Set.PDF")).toBe("Late Night Set.PDF"); | ||
| }); | ||
|
|
||
| it("keeps native-valid display basenames instead of hiding attached scores", () => { | ||
| for (const value of [ | ||
| " opener.pdf", | ||
| "opener.pdf ", | ||
| "mix..final.pdf", | ||
| "CON.pdf", | ||
| `${"a".repeat(120)}.pdf` | ||
| ]) { | ||
| expect(trustedScoreFileName(value)).toBe(value); | ||
| } | ||
| }); | ||
|
|
||
| it("fails closed on blank, path, control, and non-PDF names", () => { | ||
| for (const value of [ | ||
| "", | ||
| "pdf", | ||
| ".pdf", | ||
| "opener.pdf/", | ||
| "../opener.pdf", | ||
| "folder/opener.pdf", | ||
| "folder\\opener.pdf", | ||
| "open\ner.pdf", | ||
| "open\u0000er.pdf", | ||
| "opener.docx" | ||
| ]) { | ||
| expect(trustedScoreFileName(value)).toBeNull(); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| describe("trustedScoreAttachment", () => { | ||
| it("translates persisted generic attachment keys into semantic score metadata", () => { | ||
| expect( | ||
| trustedScoreAttachment({ id: TRUSTED_SCORE_ID, fileName: "opener.pdf" }) | ||
| ).toEqual({ scoreId: TRUSTED_SCORE_ID, scoreFileName: "opener.pdf" }); | ||
| }); | ||
|
|
||
| it("fails closed on extra keys, inherited members, and malformed ids", () => { | ||
| expect(trustedScoreAttachment(null)).toBeNull(); | ||
| expect(trustedScoreAttachment({ fileName: "opener.pdf" })).toBeNull(); | ||
| expect( | ||
| trustedScoreAttachment({ | ||
| id: TRUSTED_SCORE_ID, | ||
| fileName: "opener.pdf", | ||
| extra: true | ||
| }) | ||
| ).toBeNull(); | ||
| expect( | ||
| trustedScoreAttachment({ | ||
| id: "3F2C8F0E-1A2B-4C3D-8E9F-001122334455", | ||
| fileName: "opener.pdf" | ||
| }) | ||
| ).toBeNull(); | ||
| expect( | ||
| trustedScoreAttachment({ | ||
| id: "../../etc/passwd-aaaa-bbbb-cccc-dddddddddddd", | ||
| fileName: "opener.pdf" | ||
| }) | ||
| ).toBeNull(); | ||
| expect( | ||
| trustedScoreAttachment(Object.create({ id: TRUSTED_SCORE_ID, fileName: "opener.pdf" })) | ||
| ).toBeNull(); | ||
| }); | ||
| }); | ||
|
|
||
| describe("firstScoreCheck", () => { | ||
| it("returns null when no trusted score is attached", () => { | ||
| expect(firstScoreCheck(createDemoRehearsalSong())).toBeNull(); | ||
| expect(firstScoreCheck(songWithAttachments(null))).toBeNull(); | ||
| expect(firstScoreCheck(songWithAttachments([]))).toBeNull(); | ||
| expect(firstScoreCheck(songWithAttachments([{ id: "bad", fileName: "opener.pdf" }]))).toBeNull(); | ||
| }); | ||
|
|
||
| it("skips malformed attachments and names the first trusted score with tonight's range", () => { | ||
| const check = firstScoreCheck( | ||
| songWithAttachments([ | ||
| { id: "bad", fileName: "skip.pdf" }, | ||
| { id: TRUSTED_SCORE_ID, fileName: "opener.pdf" } | ||
| ]) | ||
| ); | ||
|
|
||
| expect(check).toEqual({ | ||
| fileName: "opener.pdf", | ||
| sectionLabel: "verse", | ||
| roleName: "Bass Guitar", | ||
| lowestNote: "C#2", | ||
| highestNote: "E3" | ||
| }); | ||
| }); | ||
|
|
||
| it("does not advertise openability without a live project workspace", () => { | ||
| expect( | ||
| firstScoreCheck( | ||
| songWithAttachments([{ id: TRUSTED_SCORE_ID, fileName: "opener.pdf" }]), | ||
| null, | ||
| false | ||
| ) | ||
| ).toBeNull(); | ||
| }); | ||
|
|
||
| it("still names the score when the selected part has no playable span", () => { | ||
| expect( | ||
| firstScoreCheck( | ||
| songWithAttachments( | ||
| [{ id: TRUSTED_SCORE_ID, fileName: "opener.pdf" }], | ||
| blankRoleRange(createDemoRehearsalSong()) | ||
| ) | ||
| ) | ||
| ).toEqual({ fileName: "opener.pdf" }); | ||
| }); | ||
|
|
||
| it("limits the paired range to the selected role", () => { | ||
| expect( | ||
| firstScoreCheck( | ||
| songWithAttachments([{ id: TRUSTED_SCORE_ID, fileName: "opener.pdf" }]), | ||
| "lead-vocal" | ||
| ) | ||
| ).toEqual({ | ||
| fileName: "opener.pdf", | ||
| sectionLabel: "verse", | ||
| roleName: "Lead Vocal", | ||
| lowestNote: "G#3", | ||
| highestNote: "C#5" | ||
| }); | ||
| }); | ||
|
|
||
| it("fails closed on malformed runtime roots", () => { | ||
| for (const malformed of [null, {}, { scoreAttachments: {} }]) { | ||
| expect(firstScoreCheck(malformed as unknown as RehearsalSong)).toBeNull(); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| describe("score check copy filling", () => { | ||
| it("keeps the attached file name literal", () => { | ||
| expect( | ||
| fillRangeCopy("Open {fileName} in Score before the {sectionLabel}.", { | ||
| fileName: "Bass $& {sectionLabel}.pdf", | ||
| sectionLabel: "verse" | ||
| }) | ||
| ).toBe("Open Bass $& {sectionLabel}.pdf in Score before the 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.
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.
📝 Info: Availability matches Score actions
scoreWorkspaceAvailablefollows the bootstrap state that enables Score actions. Live results retain it; reopened project files clear it and receive fallback guidance.Was this helpful? React with 👍 or 👎 to provide feedback.