Daryl Lim Claude Opus 4.6 (1M context) commited on
Commit
badac0a
·
1 Parent(s): be7cb6a

feat: enforce 2000 character limit on input

Browse files

Add max_length=2000 to the input textbox so the displayed limit
is enforced client-side, not just shown as a soft indicator.

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

Files changed (2) hide show
  1. app.py +1 -0
  2. tests/test_app.py +7 -0
app.py CHANGED
@@ -117,6 +117,7 @@ def _build_demo() -> gr.Blocks:
117
  )
118
  input_text = gr.Textbox(
119
  lines=6,
 
120
  show_label=False,
121
  buttons=["clear"],
122
  info=_format_info(0),
 
117
  )
118
  input_text = gr.Textbox(
119
  lines=6,
120
+ max_length=2000,
121
  show_label=False,
122
  buttons=["clear"],
123
  info=_format_info(0),
tests/test_app.py CHANGED
@@ -137,6 +137,13 @@ def test_input_textbox_height(demo):
137
  assert interactive[0].lines == 6, f"Expected lines=6, got {interactive[0].lines}"
138
 
139
 
 
 
 
 
 
 
 
140
  def test_input_textbox_has_no_placeholder(demo):
141
  """Input textbox should have no placeholder text."""
142
  textboxes = [b for b in demo.blocks.values() if type(b).__name__ == "Textbox"]
 
137
  assert interactive[0].lines == 6, f"Expected lines=6, got {interactive[0].lines}"
138
 
139
 
140
+ def test_input_textbox_max_length(demo):
141
+ """Input textbox should enforce 2000 character limit."""
142
+ textboxes = [b for b in demo.blocks.values() if type(b).__name__ == "Textbox"]
143
+ interactive = [t for t in textboxes if t.interactive is not False]
144
+ assert interactive[0].max_length == 2000, f"Expected max_length=2000, got {interactive[0].max_length}"
145
+
146
+
147
  def test_input_textbox_has_no_placeholder(demo):
148
  """Input textbox should have no placeholder text."""
149
  textboxes = [b for b in demo.blocks.values() if type(b).__name__ == "Textbox"]