@@ -23,7 +23,7 @@ const BACKEND_DEFAULT = "http://127.0.0.1:5679";
2323const BACKEND_MAX_PORT = 5689 ;
2424const POLL_INTERVAL_MS = 1200 ;
2525const HEALTH_CHECK_MS = 8000 ;
26- const VERSION = "1.5.0 " ;
26+ const VERSION = "1.5.1 " ;
2727
2828async function detectBackend ( ) {
2929 // Try ports 5679-5689 like CEP panel does
@@ -185,7 +185,7 @@ const BackendClient = (() => {
185185 async function call ( method , endpoint , body = null ) {
186186 const url = BACKEND + endpoint ;
187187 const headers = { "Content-Type" : "application/json" } ;
188- if ( csrfToken ) headers [ "X-CSRF -Token" ] = csrfToken ;
188+ if ( csrfToken ) headers [ "X-OpenCut -Token" ] = csrfToken ;
189189
190190 const opts = { method, headers } ;
191191 if ( body && method !== "GET" ) opts . body = JSON . stringify ( body ) ;
@@ -232,13 +232,13 @@ const BackendClient = (() => {
232232 * Fetch CSRF token from /csrf or /api/csrf.
233233 */
234234 async function fetchCsrf ( ) {
235- const r = await get ( "/csrf " ) ;
236- if ( r . ok && r . data && r . data . token ) {
237- csrfToken = r . data . token ;
235+ const r = await get ( "/health " ) ;
236+ if ( r . ok && r . data && r . data . csrf_token ) {
237+ csrfToken = r . data . csrf_token ;
238238 }
239239 }
240240
241- return { call, get, post, del, checkHealth, fetchCsrf } ;
241+ return { call, get, post, del : del , checkHealth, fetchCsrf } ;
242242} ) ( ) ;
243243
244244// ─────────────────────────────────────────────────────────────
@@ -273,7 +273,7 @@ const JobPoller = (() => {
273273 }
274274
275275 async function pollJob ( jobId , onProgress , onComplete , onError ) {
276- const r = await BackendClient . get ( `/jobs /${ jobId } ` ) ;
276+ const r = await BackendClient . get ( `/status /${ jobId } ` ) ;
277277 if ( ! r . ok ) {
278278 onError ( r . error ?? "Polling error" ) ;
279279 activeJobId = null ;
@@ -309,7 +309,7 @@ const JobPoller = (() => {
309309
310310 async function cancel ( ) {
311311 if ( ! activeJobId ) return ;
312- await BackendClient . del ( `/jobs /${ activeJobId } ` ) ;
312+ await BackendClient . post ( `/cancel /${ activeJobId } ` , { } ) ;
313313 activeJobId = null ;
314314 }
315315
@@ -1372,7 +1372,9 @@ function pad(n) { return String(n).padStart(2, "0"); }
13721372// ─────────────────────────────────────────────────────────────
13731373async function checkConnection ( ) {
13741374 UIController . setConnection ( "connecting" ) ;
1375- const alive = await BackendClient . checkHealth ( ) ;
1375+ const r = await BackendClient . get ( "/health" ) ;
1376+ const alive = r . ok ;
1377+ if ( alive && r . data ?. csrf_token ) csrfToken = r . data . csrf_token ;
13761378 UIController . setConnection ( alive ? "connected" : "disconnected" ) ;
13771379 if ( alive ) {
13781380 UIController . setStatus ( "Server online" ) ;
@@ -1507,15 +1509,15 @@ function bindSliders() {
15071509// ─────────────────────────────────────────────────────────────
15081510async function loadLlmSettings ( ) {
15091511 try {
1510- const resp = await BackendClient . fetch ( "GET" , "/settings/llm" ) ;
1511- if ( resp && ! resp . error ) {
1512+ const resp = await BackendClient . get ( "/settings/llm" ) ;
1513+ if ( resp . ok && resp . data ) {
15121514 // Store globally for use in feature functions
1513- window . _llmSettings = resp ;
1515+ window . _llmSettings = resp . data ;
15141516 // If there's a provider select in settings tab, populate it
15151517 const provSel = document . getElementById ( "llmProvider" ) ;
1516- if ( provSel && resp . provider ) provSel . value = resp . provider ;
1518+ if ( provSel && resp . data . provider ) provSel . value = resp . data . provider ;
15171519 const modInp = document . getElementById ( "llmModel" ) ;
1518- if ( modInp && resp . model ) modInp . value = resp . model ;
1520+ if ( modInp && resp . data . model ) modInp . value = resp . data . model ;
15191521 }
15201522 } catch ( e ) {
15211523 console . warn ( "Could not load LLM settings:" , e ) ;
0 commit comments