@@ -40,8 +40,6 @@ function getTranslationConfig(file) {
4040
4141 const provider = DomHelpers . getValue ( 'llmProvider' ) ;
4242
43- // Build prompt options object
44- // Technical content protection is always enabled
4543 const promptOptions = {
4644 preserve_technical_content : true ,
4745 text_cleanup : DomHelpers . getElement ( 'textCleanup' ) ?. checked || false ,
@@ -62,27 +60,21 @@ function getTranslationConfig(file) {
6260 gemini_api_key : provider === 'gemini' ? ApiKeyUtils . getValue ( 'geminiApiKey' ) : '' ,
6361 openai_api_key : provider === 'openai' ? ApiKeyUtils . getValue ( 'openaiApiKey' ) : '' ,
6462 openrouter_api_key : provider === 'openrouter' ? ApiKeyUtils . getValue ( 'openrouterApiKey' ) : '' ,
65- // Advanced settings (chunk_size, timeout, context_window, max_attempts, retry_delay)
66- // are now controlled via .env only - server will use defaults from config.py
67- input_filename : file . name , // Store original filename for UI restoration after browser refresh
63+ input_filename : file . name ,
6864 output_filename : file . outputFilename ,
6965 file_type : file . fileType ,
7066 prompt_options : promptOptions ,
71- // Bilingual output (original + translation interleaved)
7267 bilingual_output : DomHelpers . getElement ( 'bilingualMode' ) ?. checked || false ,
73- // TTS configuration
7468 tts_enabled : ttsEnabled ,
7569 tts_voice : ttsEnabled ? ( DomHelpers . getValue ( 'ttsVoice' ) || '' ) : '' ,
7670 tts_rate : ttsEnabled ? ( DomHelpers . getValue ( 'ttsRate' ) || '+0%' ) : '+0%' ,
7771 tts_format : ttsEnabled ? ( DomHelpers . getValue ( 'ttsFormat' ) || 'opus' ) : 'opus' ,
7872 tts_bitrate : ttsEnabled ? ( DomHelpers . getValue ( 'ttsBitrate' ) || '64k' ) : '64k'
7973 } ;
8074
81- // Handle file input based on type
8275 if ( file . fileType === 'epub' || file . fileType === 'srt' ) {
8376 config . file_path = file . filePath ;
8477 } else {
85- // Text file
8678 if ( file . content ) {
8779 config . text = file . content ;
8880 } else {
@@ -123,10 +115,7 @@ export const BatchController = {
123115 * Start batch translation
124116 */
125117 async startBatchTranslation ( ) {
126- // Wait for TranslationTracker to be fully initialized
127118 if ( ! TranslationTracker . isInitialized || ! TranslationTracker . isInitialized ( ) ) {
128- console . warn ( 'TranslationTracker not yet initialized, waiting...' ) ;
129- // Wait a bit and try again
130119 await new Promise ( resolve => setTimeout ( resolve , 100 ) ) ;
131120 if ( ! TranslationTracker . isInitialized || ! TranslationTracker . isInitialized ( ) ) {
132121 MessageLogger . showMessage ( '⚠️ System still initializing, please wait...' , 'warning' ) ;
@@ -169,7 +158,6 @@ export const BatchController = {
169158 }
170159 }
171160
172- // Update any queued files that have empty languages with current form values
173161 let filesUpdated = false ;
174162 for ( const file of filesToProcess ) {
175163 if ( file . status !== 'Queued' ) continue ;
@@ -184,15 +172,12 @@ export const BatchController = {
184172 }
185173 }
186174
187- // Save updated file queue if any changes
188175 if ( filesUpdated ) {
189176 StateManager . setState ( 'files.toProcess' , filesToProcess ) ;
190177 }
191178
192- // Mark batch as active
193179 StateManager . setState ( 'translation.isBatchActive' , true ) ;
194180
195- // Count queued files
196181 const queuedFilesCount = filesToProcess . filter ( f => f . status === 'Queued' ) . length ;
197182
198183 // Update UI
@@ -220,13 +205,12 @@ export const BatchController = {
220205 */
221206 async processNextFileInQueue ( ) {
222207 const currentJob = StateManager . getState ( 'translation.currentJob' ) ;
223- if ( currentJob ) return ; // Already processing
208+ if ( currentJob ) return ;
224209
225210 const filesToProcess = StateManager . getState ( 'files.toProcess' ) || [ ] ;
226211 const fileToTranslate = filesToProcess . find ( f => f . status === 'Queued' ) ;
227212
228213 if ( ! fileToTranslate ) {
229- // Batch completed
230214 StateManager . setState ( 'translation.isBatchActive' , false ) ;
231215 StateManager . setState ( 'translation.currentJob' , null ) ;
232216
@@ -244,29 +228,24 @@ export const BatchController = {
244228 return ;
245229 }
246230
247- // Reset progress for new file
248231 ProgressManager . reset ( ) ;
249232
250- // Reset translation preview
251233 const lastTranslationPreview = DomHelpers . getElement ( 'lastTranslationPreview' ) ;
252234 if ( lastTranslationPreview ) {
253235 lastTranslationPreview . innerHTML = '<div style="color: #6b7280; font-style: italic; padding: 10px;">No translation yet...</div>' ;
254236 }
255237
256- // Show/hide stats based on file type
257238 if ( fileToTranslate . fileType === 'epub' ) {
258239 DomHelpers . hide ( 'statsGrid' ) ;
259240 } else {
260241 DomHelpers . show ( 'statsGrid' ) ;
261242 }
262243
263- // Update UI
264244 this . updateTranslationTitle ( fileToTranslate ) ;
265245 ProgressManager . show ( ) ;
266246 MessageLogger . addLog ( `▶️ Starting translation for: ${ fileToTranslate . name } (${ fileToTranslate . fileType . toUpperCase ( ) } )` ) ;
267247 updateFileStatusInList ( fileToTranslate . name , 'Preparing...' ) ;
268248
269- // Validate API keys for cloud providers using shared utility
270249 const provider = DomHelpers . getValue ( 'llmProvider' ) ;
271250 const endpoint = provider === 'openai' ? DomHelpers . getValue ( 'openaiEndpoint' ) : '' ;
272251 const apiKeyValidation = ApiKeyUtils . validateForProvider ( provider , endpoint ) ;
@@ -290,14 +269,11 @@ export const BatchController = {
290269 return ;
291270 }
292271
293- // Get translation config
294272 const config = getTranslationConfig ( fileToTranslate ) ;
295273
296274 try {
297- // Start translation
298275 const data = await ApiClient . startTranslation ( config ) ;
299276
300- // Update state
301277 StateManager . setState ( 'translation.currentJob' , {
302278 fileRef : fileToTranslate ,
303279 translationId : data . translation_id
@@ -306,29 +282,20 @@ export const BatchController = {
306282 fileToTranslate . translationId = data . translation_id ;
307283 updateFileStatusInList ( fileToTranslate . name , 'Submitted' , data . translation_id ) ;
308284
309- // Show progress section immediately (don't wait for WebSocket)
310- // Use requestAnimationFrame to ensure immediate DOM update
311285 DomHelpers . show ( 'progressSection' ) ;
312286 DomHelpers . show ( 'interruptBtn' ) ;
313287
314- // Force immediate DOM render
315288 requestAnimationFrame ( ( ) => {
316289 const progressSection = DomHelpers . getElement ( 'progressSection' ) ;
317290 if ( progressSection ) {
318291 progressSection . style . display = 'block' ;
319292 }
320293 } ) ;
321294
322- // Update title immediately
323295 this . updateTranslationTitle ( fileToTranslate ) ;
324-
325- // Show initial message
326296 MessageLogger . addLog ( `⏳ Translation submitted for ${ fileToTranslate . name } ...` ) ;
327-
328- // Remove file from processing list immediately when translation starts
329297 this . removeFileFromProcessingList ( fileToTranslate . name ) ;
330298
331- // Emit event
332299 const event = new CustomEvent ( 'translationStarted' , { detail : { file : fileToTranslate , translationId : data . translation_id } } ) ;
333300 window . dispatchEvent ( event ) ;
334301
0 commit comments