Daryl Lim Claude Opus 4.6 (1M context) commited on
Commit
9780ff0
·
1 Parent(s): 151fa6d

feat: redesign Batch tab with two-column layout matching Single tab

Browse files

Restructure the Batch tab from a vertical stack to a side-by-side
layout (file upload left, file download right) with a full-width
preview table below, matching the Single tab's structure for visual
consistency when switching tabs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Files changed (2) hide show
  1. app.py +6 -3
  2. tests/test_app.py +10 -1
app.py CHANGED
@@ -229,13 +229,16 @@ def _build_demo() -> gr.Blocks:
229
  )
230
 
231
  with gr.Tab("Batch"):
232
- gr.Markdown("Upload a `.txt` file (one sentence per line) or a `.csv` file with a `text` column.")
233
- batch_input = gr.File(label="Upload file", file_types=[".txt", ".csv"])
 
 
 
 
234
 
235
  batch_btn = gr.Button("Translate", variant="primary")
236
 
237
  batch_preview = gr.Dataframe(label="Preview", interactive=False)
238
- batch_output = gr.File(label="Download translations", interactive=False)
239
 
240
  batch_btn.click(
241
  fn=translate_batch,
 
229
  )
230
 
231
  with gr.Tab("Batch"):
232
+ with gr.Row():
233
+ batch_input = gr.File(
234
+ label="Upload file (.txt, one sentence per line, or .csv with 'text' column)",
235
+ file_types=[".txt", ".csv"],
236
+ )
237
+ batch_output = gr.File(label="Download translations", interactive=False)
238
 
239
  batch_btn = gr.Button("Translate", variant="primary")
240
 
241
  batch_preview = gr.Dataframe(label="Preview", interactive=False)
 
242
 
243
  batch_btn.click(
244
  fn=translate_batch,
tests/test_app.py CHANGED
@@ -329,6 +329,13 @@ def test_dataframe_is_non_interactive(demo):
329
  assert dataframes[0].interactive is False
330
 
331
 
 
 
 
 
 
 
 
332
  # --- UI component tests ---
333
 
334
 
@@ -404,11 +411,13 @@ def test_dropdown_default_is_french(demo):
404
 
405
 
406
  def test_file_upload_accepts_txt_and_csv(demo):
407
- """File upload component should accept .txt and .csv files."""
408
  file_components = [b for b in demo.blocks.values() if type(b).__name__ == "File"]
409
  upload_files = [f for f in file_components if f.file_types is not None]
410
  assert len(upload_files) >= 1
411
  assert set(upload_files[0].file_types) == {".txt", ".csv"}
 
 
412
 
413
 
414
  def test_batch_output_is_non_interactive(demo):
 
329
  assert dataframes[0].interactive is False
330
 
331
 
332
+ def test_batch_tab_has_row_layout(demo):
333
+ """Batch tab should use a Row for side-by-side upload/download layout."""
334
+ # Rows: outer layout + Single tab + Batch tab = 3
335
+ rows = [b for b in demo.blocks.values() if type(b).__name__ == "Row"]
336
+ assert len(rows) == 3, f"Expected 3 Rows (outer + Single + Batch), found {len(rows)}"
337
+
338
+
339
  # --- UI component tests ---
340
 
341
 
 
411
 
412
 
413
  def test_file_upload_accepts_txt_and_csv(demo):
414
+ """File upload component should accept .txt and .csv files with instructions in label."""
415
  file_components = [b for b in demo.blocks.values() if type(b).__name__ == "File"]
416
  upload_files = [f for f in file_components if f.file_types is not None]
417
  assert len(upload_files) >= 1
418
  assert set(upload_files[0].file_types) == {".txt", ".csv"}
419
+ assert ".txt" in upload_files[0].label
420
+ assert ".csv" in upload_files[0].label
421
 
422
 
423
  def test_batch_output_is_non_interactive(demo):