From 4faeac5eae6eb6cf9eb599f060692786976afd24 Mon Sep 17 00:00:00 2001
From: seonghobae <8172694+seonghobae@users.noreply.github.com>
Date: Mon, 31 Aug 2026 23:24:35 +0000
Subject: [PATCH 1/6] feat(workspace): copy tonight's first check for the band
chat
The ready map already names tonight's first playable range. Players still
had to retype that sentence into KakaoTalk, Discord, or Messages. Copy the
same localized next-action sentence onto the clipboard, fail closed on
blank payloads, and name a manual copy when the window blocks the write.
---
AGENTS.md | 2 +-
ARCHITECTURE.md | 2 +-
CHANGELOG.md | 1 +
CLAUDE.md | 2 +-
.../src/features/workspace/Workspace.test.tsx | 100 +++++++++++++++++-
.../src/features/workspace/Workspace.tsx | 40 ++++++-
.../workspace/copyFirstRangeAction.test.ts | 90 ++++++++++++++++
.../workspace/copyFirstRangeAction.ts | 95 +++++++++++++++++
apps/desktop/src/locales/en/common.json | 3 +
apps/desktop/src/locales/ko/common.json | 3 +
docs/architecture/overview.md | 2 +-
docs/doctoring/copy-first-range-action.md | 51 +++++++++
12 files changed, 384 insertions(+), 7 deletions(-)
create mode 100644 apps/desktop/src/features/workspace/copyFirstRangeAction.test.ts
create mode 100644 apps/desktop/src/features/workspace/copyFirstRangeAction.ts
create mode 100644 docs/doctoring/copy-first-range-action.md
diff --git a/AGENTS.md b/AGENTS.md
index b9a67ce17..13e909d22 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -1,7 +1,7 @@
# AGENTS.md
## Project overview
-- BandScope is a local-first desktop app for rehearsal prep: a practical song view with likely harmony by section and by instrument or vocal role, form and groove cues, stems, playable ranges, simplification guidance, transposition or setup cues, part-overlap cues, visible confidence, and rehearsal priorities.
+- BandScope is a local-first desktop app for rehearsal prep: a practical song view with likely harmony by section and by instrument or vocal role, form and groove cues, stems, playable ranges, simplification guidance, transposition or setup cues, part-overlap cues, visible confidence, and rehearsal priorities. The ready workspace names tonight's first playable range and lets the player copy that instrument check for the band chat.
- Authoritative delivery rules live in `ARCHITECTURE.md`, `docs/plans/`, and the root verification scripts.
- Brand, tone, UX copy, and prioritization rules live in `docs/brand-story.md` and must be applied to PRDs, TRDs, UI copy, onboarding, empty states, and error messages.
- App security rules live in `docs/security/app-security.md` and must be applied to file handling, URL intake, subprocesses, IPC, WebView usage, model loading, updates, logging, cache handling, and export behavior.
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index ca0df5ac4..a836830f1 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -82,7 +82,7 @@ Last updated: 2026-03-11
- likely harmony by section and by role
- section roadmap with entries, dropouts, pickups, stops, tags, and handoffs
- groove and timing cues relevant to locking the band together
- - playable ranges and density or overlap warnings, with the ready workspace naming tonight's first span and the next instrument check
+ - playable ranges and density or overlap warnings, with the ready workspace naming tonight's first span, the next instrument check, and a copy of that check for the band chat
- simplification, transposition, capo, tuning, or setup cues where applicable
- role-specific rehearsal priorities and confidence flags
- cue-sheet or chart-style exports that summarize the analysis in rehearsal-friendly form
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0b6f7e784..c66c5e156 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
### Added
+- Copy tonight's first instrument check from the ready rehearsal map so a player can paste it in the band chat before the first section.
- Name tonight's first playable range on the ready rehearsal map and tell the player to check that span on their instrument before the section.
- Display the analyzed song tempo (BPM) as a badge in the rehearsal workspace.
- 각 합주 역할(Role)별 개인 연습 진행도를 0~100% 범위로 기록 및 시각화할 수 있는 연습 진척도(`practiceProgress`) 트래커 기능 추가. UI 컨트롤(슬라이더 및 +/- 버튼)과 한/영 다국어 지원 포함.
diff --git a/CLAUDE.md b/CLAUDE.md
index b5a34c1fa..5a8c4c3d5 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -51,7 +51,7 @@ BandScope is a local-first desktop app for rehearsal prep: it turns a song into
Three layers, decoupled through shared contracts:
-- `apps/desktop` — Tauri 2 + Vite + React 19 shell (Tailwind 4, Base UI, Storybook). Feature screens live in `src/features/` (home, workspace, chords, ranges, player, settings). The ready workspace names tonight's first playable range and the next instrument check. `src/lib/analysis.ts` and `src/lib/job_runner.ts` call typed Tauri IPC commands, with a browser fallback that serves demo data when not running inside Tauri.
+- `apps/desktop` — Tauri 2 + Vite + React 19 shell (Tailwind 4, Base UI, Storybook). Feature screens live in `src/features/` (home, workspace, chords, ranges, player, settings). The ready workspace names tonight's first playable range, the next instrument check, and a copy of that check for the band chat. `src/lib/analysis.ts` and `src/lib/job_runner.ts` call typed Tauri IPC commands, with a browser fallback that serves demo data when not running inside Tauri.
- `apps/desktop/src-tauri/src/main.rs` — the Rust orchestration boundary. Tauri commands (`start_analysis_job`, `get_analysis_job_status`, `select_local_audio_source`, `import_youtube_url`) validate untrusted input (project IDs, file paths, URLs) and spawn the Python engine as a subprocess. There is no loopback HTTP listener and no network path for local analysis.
- `services/analysis-engine` — Python package `bandscope_analysis` (librosa/numpy). Entry point `cli.py` reads a JSON job request on stdin and prints a structured job-status JSON envelope on stdout (`--progress-jsonl` streams progress lines). `api.py` orchestrates the pipeline across the `separation`, `sections`, `roles`, `chords`, `ranges`, `temporal`, `transcription`, and `youtube` modules.
diff --git a/apps/desktop/src/features/workspace/Workspace.test.tsx b/apps/desktop/src/features/workspace/Workspace.test.tsx
index 7837bf80e..ffa21733c 100644
--- a/apps/desktop/src/features/workspace/Workspace.test.tsx
+++ b/apps/desktop/src/features/workspace/Workspace.test.tsx
@@ -1,4 +1,4 @@
-import { fireEvent, render, screen } from "@testing-library/react";
+import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { createDemoRehearsalSong, type ProjectBootstrapSummary, type RehearsalSong } from "@bandscope/shared-types";
import { afterEach, describe, expect, it, vi } from "vitest";
import { Workspace } from "./Workspace";
@@ -8,6 +8,7 @@ import { generateMetadataHandoffJson } from "../../lib/export";
const originalLanguage = navigator.language;
const originalCreateObjectUrl = URL.createObjectURL;
const originalRevokeObjectUrl = URL.revokeObjectURL;
+const originalClipboard = navigator.clipboard;
function setNavigatorLanguage(language: string) {
Object.defineProperty(navigator, "language", {
@@ -20,6 +21,10 @@ describe("Workspace", () => {
afterEach(() => {
setNavigatorLanguage(originalLanguage);
vi.restoreAllMocks();
+ Object.defineProperty(navigator, "clipboard", {
+ configurable: true,
+ value: originalClipboard
+ });
Object.defineProperty(URL, "createObjectURL", {
configurable: true,
value: originalCreateObjectUrl
@@ -28,6 +33,7 @@ describe("Workspace", () => {
configurable: true,
value: originalRevokeObjectUrl
});
+ Reflect.deleteProperty(document, "execCommand");
});
it("updates practice progress immutably through onSongUpdate", () => {
@@ -196,6 +202,76 @@ describe("Workspace", () => {
);
});
+ it("copies tonight's first check for the band chat", async () => {
+ setNavigatorLanguage("en-US");
+ const writeText = vi.fn().mockResolvedValue(undefined);
+ Object.defineProperty(navigator, "clipboard", {
+ configurable: true,
+ value: { writeText }
+ });
+ const song = createDemoRehearsalSong();
+
+ render();
+ fireEvent.click(screen.getByRole("button", { name: "Copy tonight's first check" }));
+
+ await waitFor(() => {
+ expect(writeText).toHaveBeenCalledWith(
+ "Bass Guitar sits C#2–E3 in verse. Hear that clash on your instrument before the verse."
+ );
+ });
+ expect(screen.getByTestId("first-range-copy-status")).toHaveTextContent(
+ "Copied. Paste it in the band chat before the first section."
+ );
+ });
+
+ it("names a next action when clipboard write is blocked without exposing the failure", async () => {
+ setNavigatorLanguage("en-US");
+ const writeText = vi.fn().mockRejectedValue(new Error("/Users/md/secret-job.json"));
+ Object.defineProperty(navigator, "clipboard", {
+ configurable: true,
+ value: { writeText }
+ });
+ Object.defineProperty(document, "execCommand", {
+ configurable: true,
+ writable: true,
+ value: vi.fn().mockReturnValue(false)
+ });
+
+ render();
+ fireEvent.click(screen.getByRole("button", { name: "Copy tonight's first check" }));
+
+ await waitFor(() => {
+ expect(screen.getByTestId("first-range-copy-status")).toHaveTextContent(
+ "Clipboard is blocked in this window. Select tonight's first check and copy it before the first section."
+ );
+ });
+ expect(screen.queryByText(/secret-job/i)).toBeNull();
+ });
+
+ it("copies the missing-range next action when no named span exists", async () => {
+ setNavigatorLanguage("en-US");
+ const writeText = vi.fn().mockResolvedValue(undefined);
+ Object.defineProperty(navigator, "clipboard", {
+ configurable: true,
+ value: { writeText }
+ });
+ const song = createDemoRehearsalSong();
+ song.sections[0]!.roles = song.sections[0]!.roles.map((role) => ({
+ ...role,
+ range: { lowestNote: "", highestNote: "none" },
+ overlapWarnings: []
+ }));
+
+ render();
+ fireEvent.click(screen.getByRole("button", { name: "Copy tonight's first check" }));
+
+ await waitFor(() => {
+ expect(writeText).toHaveBeenCalledWith(
+ "Tonight's first range still needs an ear check. Confirm the high and low notes on the selected part before the first section."
+ );
+ });
+ });
+
it("falls back from blank planning copy and tolerates partial collaboration payloads", () => {
setNavigatorLanguage("en-US");
const song = createDemoRehearsalSong();
@@ -325,5 +401,27 @@ describe("Workspace", () => {
expect(screen.getByText("스템")).toBeTruthy();
expect(screen.getByText("합주 우선순위")).toBeTruthy();
expect(screen.getByText("역할과 화성")).toBeTruthy();
+ expect(screen.getByRole("button", { name: "오늘 첫 확인 복사" })).toBeTruthy();
+ });
+
+ it("copies the Korean first-check sentence for the band chat", async () => {
+ setNavigatorLanguage("ko-KR");
+ const writeText = vi.fn().mockResolvedValue(undefined);
+ Object.defineProperty(navigator, "clipboard", {
+ configurable: true,
+ value: { writeText }
+ });
+
+ render();
+ fireEvent.click(screen.getByRole("button", { name: "오늘 첫 확인 복사" }));
+
+ await waitFor(() => {
+ expect(writeText).toHaveBeenCalledWith(
+ "verse의 Bass Guitar은 C#2–E3이고 다른 파트와 겹칩니다. verse 들어가기 전에 그 충돌을 악기로 들어 보세요."
+ );
+ });
+ expect(screen.getByTestId("first-range-copy-status")).toHaveTextContent(
+ "복사했습니다. 첫 구간 전에 밴드 채팅에 붙여 넣으세요."
+ );
});
});
diff --git a/apps/desktop/src/features/workspace/Workspace.tsx b/apps/desktop/src/features/workspace/Workspace.tsx
index d44e20777..01332e614 100644
--- a/apps/desktop/src/features/workspace/Workspace.tsx
+++ b/apps/desktop/src/features/workspace/Workspace.tsx
@@ -1,15 +1,16 @@
-import { useState, useMemo, memo, type MouseEvent } from "react";
+import { useState, useMemo, memo, useEffect, type MouseEvent } from "react";
import { parseProjectBootstrapSummary, type ProjectBootstrapSummary, type RehearsalSong, type RehearsalRole } from "@bandscope/shared-types";
import { RoleSwitcher } from "./RoleSwitcher";
import { SectionRoadmap } from "./SectionRoadmap";
import { GrooveMap } from "./GrooveMap";
import { PracticeProgress } from "./PracticeProgress";
import { fillRangeCopy, firstRangeSqueeze } from "./firstRangeSqueeze";
+import { copyFirstRangeAction, type FirstRangeCopyResult } from "./copyFirstRangeAction";
import { createTranslator, detectPreferredLocale } from "../../i18n";
import { generateCueSheetCsv, generateChartSummaryJson, generateMetadataHandoffJson, sanitizeFilename } from "../../lib/export";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardDescription } from "@/components/ui/card";
-import { Download, CheckCheck, ClipboardList, MessageSquareMore, CloudOff, Music4 } from "lucide-react";
+import { Download, CheckCheck, ClipboardList, MessageSquareMore, CloudOff, Music4, Copy } from "lucide-react";
interface WorkspaceProps {
song: RehearsalSong;
@@ -121,6 +122,7 @@ const SongStructure = memo(function SongStructure({ sections, t }: { sections: R
/** Documented. */
export function Workspace({ song, sourceBootstrap = null, onSongUpdate }: WorkspaceProps) {
const [activeRole, setActiveRole] = useState(null);
+ const [copyStatus, setCopyStatus] = useState("idle");
const t = useMemo(() => createTranslator(detectPreferredLocale()), []);
// Extract all unique roles from the song's sections
@@ -164,6 +166,15 @@ export function Workspace({ song, sourceBootstrap = null, onSongUpdate }: Worksp
)
: t("workspaceFirstRangeMissing");
+ useEffect(() => {
+ setCopyStatus("idle");
+ }, [firstRangeCopy]);
+
+ /** Copy tonight's first instrument check for a band chat paste. */
+ const handleCopyFirstRange = async () => {
+ setCopyStatus(await copyFirstRangeAction(firstRangeCopy));
+ };
+
/** Handle the practice progress change internally by immutably updating the song state. */
const handlePracticeProgressChange = (newProgress: number) => {
if (!activeRole || !onSongUpdate) return;
@@ -308,6 +319,31 @@ export function Workspace({ song, sourceBootstrap = null, onSongUpdate }: Worksp
>