Skip to content

Commit 8283659

Browse files
committed
Remove Audio SFX Copy JSON fallback path - PR_26145_020-audio-sfx-remove-copy-json-fallback
1 parent fbb1f4e commit 8283659

2 files changed

Lines changed: 41 additions & 26 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# PR_26145_020 Audio / SFX Remove Copy JSON Fallback
2+
3+
Date: 2026-05-25
4+
5+
## Targeted validation
6+
7+
- `node --check tools/audio-sfx-playground-v2/js/AudioSfxPlaygroundV2App.js` passed.
8+
- JSON parse validation passed for `tools/schemas/tools/audio-sfx-playground-v2.schema.json`.
9+
- HTML external asset guard passed for `tools/audio-sfx-playground-v2/index.html`.
10+
- Static grep verified no `execCommand`, hidden `textarea`, fallback, or legacy browser copy path remains in `AudioSfxPlaygroundV2App.js`.
11+
12+
## npm run test:workspace-v2
13+
14+
Blocked by local Playwright browser installation:
15+
16+
```text
17+
browserType.launch: Executable doesn't exist at C:\Users\DavidQ\AppData\Local\ms-playwright\chromium-1217\chrome-win64\chrome.exe
18+
```
19+
20+
The one-failure run confirmed the missing bundled Chromium cache before Workspace V2 tests could execute.
21+
22+
## Focused Playwright validation
23+
24+
Ran a focused Playwright script with installed Microsoft Edge.
25+
26+
Validated:
27+
28+
- Copy JSON succeeds through `navigator.clipboard.writeText`.
29+
- Copied JSON parses and contains the current exported toolState payload.
30+
- Copy JSON failure shows a visible Status error with the recovery action to allow clipboard access or use Export JSON.
31+
- Copy JSON failure does not silently copy through a fallback path.
32+
- Copy JSON does not mark Workspace dirty.
33+
- Valid Import JSON still marks Workspace dirty.
34+
- No console errors during launch, successful copy, failed copy, or import validation.
35+
36+
Result: focused impacted validation passed.

tools/audio-sfx-playground-v2/js/AudioSfxPlaygroundV2App.js

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -470,35 +470,14 @@ export class AudioSfxPlaygroundV2App {
470470
}
471471

472472
async writeClipboardText(text) {
473-
if (typeof this.window.navigator?.clipboard?.writeText === "function") {
474-
try {
475-
await this.window.navigator.clipboard.writeText(text);
476-
return;
477-
} catch {
478-
// Fall back to the legacy copy command below when browser permission blocks the async Clipboard API.
479-
}
480-
}
481-
482-
const documentRef = this.window.document;
483-
if (!documentRef?.body || typeof documentRef.execCommand !== "function") {
484-
throw new Error("Clipboard API is unavailable.");
473+
if (typeof this.window.navigator?.clipboard?.writeText !== "function") {
474+
throw new Error("Clipboard API is unavailable. Use Export JSON instead.");
485475
}
486476

487-
const textArea = documentRef.createElement("textarea");
488-
textArea.value = text;
489-
textArea.setAttribute("readonly", "");
490-
textArea.style.position = "fixed";
491-
textArea.style.left = "-9999px";
492-
textArea.style.top = "0";
493477
try {
494-
documentRef.body.append(textArea);
495-
textArea.focus();
496-
textArea.select();
497-
if (!documentRef.execCommand("copy")) {
498-
throw new Error("Browser copy command returned false.");
499-
}
500-
} finally {
501-
textArea.remove();
478+
await this.window.navigator.clipboard.writeText(text);
479+
} catch (error) {
480+
throw new Error(`Clipboard API copy was blocked. Allow clipboard access or use Export JSON instead. ${error.message}`);
502481
}
503482
}
504483

0 commit comments

Comments
 (0)