VibecoderMcSwaggins commited on
Commit
a46131e
·
1 Parent(s): 3bfd42c

docs: update P1 bug report with actual Gradio accordion root cause

Browse files
docs/bugs/P1_GRADIO_SETTINGS_CLEANUP.md CHANGED
@@ -1,140 +1,133 @@
1
- # P1: Gradio Settings Panel - Keep or Remove?
2
 
3
- **Priority**: P1 (UX improvement)
4
- **Status**: NEEDS DECISION
5
  **Date**: 2025-11-27
6
 
7
  ---
8
 
9
- ## Current State
10
 
11
- The Gradio UI has a "Settings" accordion containing:
12
 
13
- 1. **Orchestrator Mode**: simple | magentic
14
- 2. **API Key (BYOK)**: User can enter their own key
15
- 3. **API Provider**: openai | anthropic
16
 
17
- Screenshot shows it takes up vertical space even when collapsed.
18
 
19
- ---
 
 
 
20
 
21
- ## The Question
 
 
 
 
 
 
 
 
22
 
23
- Should we **keep**, **simplify**, or **remove** this settings panel?
24
 
25
  ---
26
 
27
- ## Analysis
28
 
29
- ### Option A: Remove Entirely
 
 
30
 
31
- **Pros:**
32
- - Cleaner, simpler UI
33
- - Magentic mode is broken anyway (P0 bug)
34
- - 95% of users will use defaults
35
- - Less cognitive load for hackathon judges
36
 
37
- **Cons:**
38
- - No BYOK option (users stuck with server's API key or free tier)
39
- - No way to test Magentic mode when fixed
40
 
41
- **Code Change:**
42
  ```python
43
- # Remove additional_inputs entirely
44
- gr.ChatInterface(
45
  fn=research_agent,
46
- examples=[...],
47
- # No additional_inputs_accordion
48
- # No additional_inputs
 
49
  )
50
  ```
51
 
52
- ### Option B: Simplify to Just BYOK
 
53
 
54
- **Pros:**
55
- - Keep useful feature (bring your own key)
56
- - Remove broken Magentic option
57
- - Simpler UI
58
 
59
- **Cons:**
60
- - Still has settings panel
61
 
62
- **Code Change:**
63
  ```python
64
- additional_inputs=[
65
- gr.Textbox(
66
- label="🔑 API Key (Optional)",
67
- placeholder="sk-... or sk-ant-...",
68
- type="password",
69
- ),
70
- ]
 
 
 
 
 
71
  ```
72
 
73
- ### Option C: Keep But Fix Accordion
 
74
 
75
- **Pros:**
76
- - All options available
77
- - Power users can access
78
 
79
- **Cons:**
80
- - Magentic is broken
81
- - Adds complexity
82
 
83
- **Code Change:**
84
- - Ensure `open=False` works correctly
85
- - Maybe move to footer or separate tab
 
 
 
 
 
 
86
 
87
  ---
88
 
89
  ## Recommendation
90
 
91
- **For Hackathon**: **Option A (Remove)** or **Option B (BYOK only)**
92
 
93
- Reasoning:
94
- 1. Magentic mode has a P0 bug - offering it confuses users
95
- 2. Simple mode works perfectly
96
- 3. Clean UI impresses judges
97
- 4. BYOK is the only genuinely useful setting
98
 
99
  ---
100
 
101
- ## Decision Needed
102
 
103
- - [ ] **Remove all settings** (cleanest)
104
- - [ ] **Keep only BYOK** (useful subset)
105
- - [ ] **Keep all but hide better** (preserve functionality)
106
- - [ ] **Keep as-is** (no change)
107
 
108
  ---
109
 
110
- ## Implementation
111
 
112
- If removing settings:
 
 
 
 
113
 
114
- **File**: `src/app.py`
115
 
116
- ```python
117
- # Before (lines 229-249)
118
- additional_inputs_accordion=gr.Accordion(label="⚙️ Settings", open=False),
119
- additional_inputs=[
120
- gr.Radio(...), # mode
121
- gr.Textbox(...), # api_key
122
- gr.Radio(...), # provider
123
- ],
124
-
125
- # After
126
- # Delete additional_inputs_accordion and additional_inputs
127
- # Update research_agent signature to remove unused params
128
- ```
129
 
130
- Also update `research_agent()` function signature:
131
- ```python
132
- # Before
133
- async def research_agent(message, history, mode, api_key, api_provider):
134
-
135
- # After (if removing all settings)
136
- async def research_agent(message, history):
137
- mode = "simple" # Hardcode
138
- api_key = ""
139
- api_provider = "openai"
140
- ```
 
1
+ # P1 Bug: Gradio Settings Accordion Not Collapsing
2
 
3
+ **Priority**: P1 (UX Bug)
4
+ **Status**: OPEN
5
  **Date**: 2025-11-27
6
 
7
  ---
8
 
9
+ ## Bug Description
10
 
11
+ The "Settings" accordion in the Gradio UI does not collapse/hide its content. Even when the accordion arrow shows "collapsed" state, all settings (Orchestrator Mode, API Key, API Provider) remain visible.
12
 
13
+ ---
 
 
14
 
15
+ ## Root Cause
16
 
17
+ **Known Gradio Bug**: `additional_inputs_accordion` does not work correctly when `ChatInterface` is used inside `gr.Blocks()`.
18
+
19
+ **GitHub Issue**: [gradio-app/gradio#8861](https://github.com/gradio-app/gradio/issues/8861)
20
+ > "Is there any subsequent plan to support gr.ChatInterface inheritance under gr.Block()? Currently using accordion is not working well."
21
 
22
+ **Our Code** (`src/app.py` lines 196-250):
23
+ ```python
24
+ with gr.Blocks(...) as demo: # <-- Using gr.Blocks wrapper
25
+ gr.ChatInterface(
26
+ ...
27
+ additional_inputs_accordion=gr.Accordion(label="⚙️ Settings", open=False),
28
+ additional_inputs=[...],
29
+ )
30
+ ```
31
 
32
+ The `additional_inputs_accordion` parameter is designed for standalone `ChatInterface`, but breaks when wrapped in `gr.Blocks()`.
33
 
34
  ---
35
 
36
+ ## Evidence
37
 
38
+ - Accordion arrow toggles (visual feedback works)
39
+ - Content does NOT hide when collapsed
40
+ - Same behavior in local dev and HuggingFace Spaces
41
 
42
+ ---
43
+
44
+ ## Possible Fixes
45
+
46
+ ### Option 1: Remove gr.Blocks Wrapper (Recommended)
47
 
48
+ If we don't need the header/footer markdown, use standalone `ChatInterface`:
 
 
49
 
 
50
  ```python
51
+ # Instead of gr.Blocks wrapper
52
+ demo = gr.ChatInterface(
53
  fn=research_agent,
54
+ title="🧬 DeepCritical",
55
+ description="AI-Powered Drug Repurposing Agent",
56
+ additional_inputs_accordion=gr.Accordion(label="⚙️ Settings", open=False),
57
+ additional_inputs=[...],
58
  )
59
  ```
60
 
61
+ **Pros**: Accordion should work correctly
62
+ **Cons**: Less control over layout, no custom header/footer
63
 
64
+ ### Option 2: Manual Accordion Outside ChatInterface
 
 
 
65
 
66
+ Move settings outside `ChatInterface` into a proper `gr.Accordion`:
 
67
 
 
68
  ```python
69
+ with gr.Blocks() as demo:
70
+ gr.Markdown("# 🧬 DeepCritical")
71
+
72
+ with gr.Accordion("⚙️ Settings", open=False):
73
+ mode = gr.Radio(choices=["simple", "magentic"], value="simple", label="Mode")
74
+ api_key = gr.Textbox(label="API Key", type="password")
75
+ provider = gr.Radio(choices=["openai", "anthropic"], value="openai", label="Provider")
76
+
77
+ chatbot = gr.Chatbot()
78
+ msg = gr.Textbox(label="Ask a research question")
79
+
80
+ msg.submit(research_agent, [msg, chatbot, mode, api_key, provider], chatbot)
81
  ```
82
 
83
+ **Pros**: Full control, accordion works
84
+ **Cons**: More code, lose ChatInterface conveniences (examples, etc.)
85
 
86
+ ### Option 3: Wait for Gradio Fix
 
 
87
 
88
+ Gradio added `.expand()` and `.collapse()` events in recent versions. Upgrading might help.
 
 
89
 
90
+ **Check current version**:
91
+ ```bash
92
+ pip show gradio | grep Version
93
+ ```
94
+
95
+ **Upgrade**:
96
+ ```bash
97
+ pip install --upgrade gradio
98
+ ```
99
 
100
  ---
101
 
102
  ## Recommendation
103
 
104
+ **Option 1** (Remove gr.Blocks) is cleanest if we can live without custom header/footer.
105
 
106
+ If header/footer needed, **Option 2** gives working accordion at cost of more code.
 
 
 
 
107
 
108
  ---
109
 
110
+ ## Files to Modify
111
 
112
+ | File | Change |
113
+ |------|--------|
114
+ | `src/app.py` | Restructure UI per chosen option |
115
+ | `pyproject.toml` | Possibly upgrade Gradio version |
116
 
117
  ---
118
 
119
+ ## Test Plan
120
 
121
+ 1. Run locally: `uv run python -m src.app`
122
+ 2. Click Settings accordion to collapse
123
+ 3. Verify content hides when collapsed
124
+ 4. Verify content shows when expanded
125
+ 5. Test on HuggingFace Spaces after deploy
126
 
127
+ ---
128
 
129
+ ## Sources
 
 
 
 
 
 
 
 
 
 
 
 
130
 
131
+ - [Gradio Issue #8861 - Accordion not working in Blocks](https://github.com/gradio-app/gradio/issues/8861)
132
+ - [Gradio ChatInterface Docs](https://www.gradio.app/docs/gradio/chatinterface)
133
+ - [Gradio Accordion Docs](https://www.gradio.app/docs/gradio/accordion)