V11 fix GUI silent-return: only skip load when path resolved; refresh bridge state via queryStatus and open GUI on any restored channel
This commit is contained in:
+25
-6
@@ -6547,7 +6547,7 @@ const loadVstToBridge = async (track) => {
|
||||
}
|
||||
// Đã load ĐÚNG path vào channel này rồi → skip (không LOAD trùng). Bỏ
|
||||
// early-return mù theo flag — flag sai khi C++ restore instrument khác.
|
||||
if (window.__bridgeLoadedPaths[bch] === knownPath) return true;
|
||||
if (knownPath && window.__bridgeLoadedPaths[bch] === knownPath) return true;
|
||||
// Có path đáng tin → load thẳng qua Tauri invoke (không cần POST/auth/CORS).
|
||||
if (knownPath) {
|
||||
const ok = await window.NativeBridgeService.loadInstrument(knownPath, btype, bch);
|
||||
@@ -6583,7 +6583,7 @@ const ensureAndOpenVstGui = async (track) => {
|
||||
const instrumentId = track.instrumentId || (track.synth_engine && track.synth_engine.plugin_id);
|
||||
if (!instrumentId || (typeof instrumentId === 'string' && instrumentId.startsWith('sf_'))) return;
|
||||
if (!window.__bridgeLoadedChannels) window.__bridgeLoadedChannels = {};
|
||||
const bch = (window.SonicMidiRouter && window.SonicMidiRouter.allocateChannel) ? window.SonicMidiRouter.allocateChannel(trackId, false) : 0;
|
||||
let bch = (window.SonicMidiRouter && window.SonicMidiRouter.allocateChannel) ? window.SonicMidiRouter.allocateChannel(trackId, false) : 0;
|
||||
// LAN/standalone (browser không Tauri): NativeBridgeService chỉ log, không
|
||||
// invoke được open_vst_gui → nhờ engine đẩy LOAD+OPEN_GUI vào SHM qua route
|
||||
// /bridge/gui (E6). GUI hiện trên desktop máy chạy server.
|
||||
@@ -6610,12 +6610,31 @@ const ensureAndOpenVstGui = async (track) => {
|
||||
// im lang. Chi chan khi channel THUC SU chua co instrument — mo GUI khi do
|
||||
// se mo cua plugin KHAC (V9 guard WaveObserver vs Nexus, giu nguyen).
|
||||
if (!loadOk && !window.__bridgeLoadedChannels[bch]) {
|
||||
// V10: loadVstToBridge fail (token hết hạn / path không resolve được) nhưng
|
||||
// V11: loadVstToBridge fail (token hết hạn / path không resolve được) nhưng
|
||||
// C++ ĐÃ restore ĐÚNG instrument từ state file → mở GUI thẳng, không cần
|
||||
// LOAD. Chỉ mở khi path khớp instrumentId (giữ V9 guard: không mở GUI của
|
||||
// plugin KHÁC — VD WaveObserver thay vì Nexus).
|
||||
const lc = (window.__bridgeLoadedState || []).find(x => x.channel === bch && _bridgeSafeVstPath(x.path, instrumentId));
|
||||
// LOAD. __bridgeLoadedState chỉ fetch 1 lần lúc init → refresh qua
|
||||
// queryStatus (Tauri invoke, không cần auth) trước khi tra. Tìm instrument
|
||||
// ở BẤT KỲ channel (restore sau restart có thể nằm channel khác channel
|
||||
// router allocate) → mở GUI đúng chỗ, hết silent-return. Giữ V9 guard:
|
||||
// chỉ mở khi path khớp instrumentId, không mở GUI của plugin KHÁC.
|
||||
let state = window.__bridgeLoadedState;
|
||||
try {
|
||||
const st = await window.NativeBridgeService.queryStatus();
|
||||
if (st && Array.isArray(st.loaded_channels)) state = st.loaded_channels;
|
||||
} catch (e) { console.warn('[Bridge] queryStatus refresh fail:', e); }
|
||||
const lc = (state || []).find(x => _bridgeSafeVstPath(x.path, instrumentId));
|
||||
if (!lc) return;
|
||||
if (lc.channel !== bch) {
|
||||
// Restore trên channel khác → thử LOAD bản vào bch (C++ guard skip nếu
|
||||
// đã có); fail thì mở GUI ngay trên chính channel restore.
|
||||
try {
|
||||
const ok = await window.NativeBridgeService.loadInstrument(lc.path, /\.dll$/i.test(lc.path) ? 'VST2' : 'VST3', bch);
|
||||
if (!ok) bch = lc.channel;
|
||||
} catch (e) {
|
||||
console.warn('[Bridge] re-load on bch fail:', e);
|
||||
bch = lc.channel;
|
||||
}
|
||||
}
|
||||
window.__bridgeLoadedChannels[bch] = true;
|
||||
window.__bridgeLoadedPaths[bch] = lc.path;
|
||||
}
|
||||
|
||||
+2077
-2056
File diff suppressed because one or more lines are too long
@@ -50,7 +50,7 @@
|
||||
<script src="/static/js/services/midiExtractor.js?v=202607281052"></script>
|
||||
<script src="/static/js/services/promptTemplateManager.js?v=202607281039"></script>
|
||||
<script src="/static/js/services/undoRedoEngine.js?v=202607290941"></script>
|
||||
<script src="/static/js/app.precompiled.js?v=202608182034" defer></script>
|
||||
<script src="/static/js/app.precompiled.js?v=202608182152" defer></script>
|
||||
<link rel="stylesheet" href="/static/css/styles.css?v=202607271016">
|
||||
<style>
|
||||
:root {
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user