From e3afe386974cae7129b0f85b877393f4dd93d0cc Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 28 May 2026 03:19:44 +0000 Subject: [PATCH] fix(premiere-plugin): suppress importFiles UI prompts + 60s timeout guard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit app.project.importFiles() can deadlock if a hidden Premiere modal appears (off-screen, behind window, etc) — the evalScript callback never fires and the panel spinner hangs forever. Two changes: 1) Pass suppressUI=true to all five importFiles call sites (main.js inline IIFE + 4 in premiere.jsx). Premiere proceeds even if it would have prompted (audio sample rate, project link, scale-to-frame, etc). 2) Wrap importFileToPremiereProject in a 60s timeout race so even if importFiles does block, the panel surfaces a real error instead of leaving the spinner stuck. Bumps to v1.2.2. --- services/premiere-plugin/CSXS/manifest.xml | 2 +- services/premiere-plugin/js/main.js | 16 +++++++++++++++- services/premiere-plugin/jsx/premiere.jsx | 8 ++++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/services/premiere-plugin/CSXS/manifest.xml b/services/premiere-plugin/CSXS/manifest.xml index 599a6ce..fd415c3 100644 --- a/services/premiere-plugin/CSXS/manifest.xml +++ b/services/premiere-plugin/CSXS/manifest.xml @@ -2,7 +2,7 @@ diff --git a/services/premiere-plugin/js/main.js b/services/premiere-plugin/js/main.js index 5e5d261..9187aa4 100644 --- a/services/premiere-plugin/js/main.js +++ b/services/premiere-plugin/js/main.js @@ -1964,6 +1964,17 @@ function importFileToPremiereProject(filePath) { return new Promise(function (resolve, reject) { var safePath = filePath.replace(/\\/g, '\\\\'); + // Premiere can deadlock on importFiles() if a hidden prompt appears + // (off-screen modal, etc.). The evalScript callback then never fires. + // Race the import against a 60s timeout so the user sees an error + // instead of a frozen spinner. + var done = false; + var timer = setTimeout(function () { + if (done) return; + done = true; + reject(new Error('ExtendScript importFiles() did not return within 60s — Premiere may have a hidden dialog')); + }, 60000); + var script = [ '(function() {', ' var result = { success: false, message: "" };', @@ -1977,7 +1988,7 @@ function importFileToPremiereProject(filePath) { ' result.message = "File not found: ' + safePath + '";', ' return JSON.stringify(result);', ' }', - ' app.project.importFiles(["' + safePath + '"]);', + ' app.project.importFiles(["' + safePath + '"], true);', ' result.success = true;', ' result.message = "Imported successfully";', ' } catch (e) {', @@ -1988,6 +1999,9 @@ function importFileToPremiereProject(filePath) { ].join('\n'); csInterface.evalScript(script, function (resultStr) { + if (done) return; + done = true; + clearTimeout(timer); try { var parsed = JSON.parse(resultStr); if (parsed.success) resolve(parsed); diff --git a/services/premiere-plugin/jsx/premiere.jsx b/services/premiere-plugin/jsx/premiere.jsx index 075cd1e..d3529da 100644 --- a/services/premiere-plugin/jsx/premiere.jsx +++ b/services/premiere-plugin/jsx/premiere.jsx @@ -37,7 +37,7 @@ function importFileToProject(filePath) { return JSON.stringify(result); } - app.project.importFiles([filePath]); + app.project.importFiles([filePath], true); result.success = true; result.message = "File imported successfully"; @@ -96,7 +96,7 @@ function insertClipToSequence(filePath, trackIndex) { return JSON.stringify(result); } - app.project.importFiles([filePath]); + app.project.importFiles([filePath], true); var file = new File(filePath); var fileName = file.displayName; @@ -596,7 +596,7 @@ function relinkClipToNewMedia(clipInstanceId, newMediaPath) { } // Import the new media file into the project - app.project.importFiles([newMediaPath]); + app.project.importFiles([newMediaPath], true); // Replace the clip source with the new project item var fileName = newFile.displayName; @@ -812,7 +812,7 @@ function replaceMediaPath(oldPath, newPath) { return JSON.stringify(result); } - app.project.importFiles([newPath]); + app.project.importFiles([newPath], true); var newName = oldFile.displayName; var rootBin = app.project.rootItem;