Commit
·
560f0d5
1
Parent(s):
092a6ee
relevant context upgraded v2
Browse files- UI_FIX_CONTEXT_MODE.md +88 -0
- app.py +65 -6
UI_FIX_CONTEXT_MODE.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# UI Fix: Context Mode Toggle Visibility Issue
|
| 2 |
+
|
| 3 |
+
## Problem Reported
|
| 4 |
+
User: "Unable to use settings and cant find context mode"
|
| 5 |
+
|
| 6 |
+
## Root Causes Identified
|
| 7 |
+
|
| 8 |
+
1. **Settings Panel Hidden by Default**: `visible=False` - user needs to click ⚙️ to see it
|
| 9 |
+
2. **Context Options Accordion Collapsed**: `open=False` - even when settings panel is visible, the Context Options section was collapsed
|
| 10 |
+
3. **Toggle Button Wiring Issue**: Settings button might not have been properly wired up
|
| 11 |
+
|
| 12 |
+
## Fixes Applied
|
| 13 |
+
|
| 14 |
+
### Fix 1: Context Options Accordion Open by Default ✅
|
| 15 |
+
**Changed:** `open=False` → `open=True`
|
| 16 |
+
- Context Options section is now expanded when settings panel is opened
|
| 17 |
+
- Context mode toggle is immediately visible
|
| 18 |
+
|
| 19 |
+
### Fix 2: Simplified Component Structure ✅
|
| 20 |
+
**Removed:** Complex `gr.Group` wrapper that might cause visibility issues
|
| 21 |
+
**Created:** Components directly in Accordion for better Gradio compatibility
|
| 22 |
+
- Radio button with clear label
|
| 23 |
+
- Status indicator
|
| 24 |
+
- Explanation text
|
| 25 |
+
|
| 26 |
+
### Fix 3: Enhanced Settings Button Functionality ✅
|
| 27 |
+
**Improved:** Toggle function with proper error handling
|
| 28 |
+
**Added:** Support for both menu_toggle button (⚙️) and settings_nav_btn
|
| 29 |
+
- Both buttons now properly toggle settings panel
|
| 30 |
+
- Better error handling and logging
|
| 31 |
+
|
| 32 |
+
### Fix 4: Better Labels and Instructions ✅
|
| 33 |
+
**Enhanced:**
|
| 34 |
+
- Radio button label: "Select context mode:"
|
| 35 |
+
- Clear option descriptions:
|
| 36 |
+
- "🆕 Fresh Context (No user context)"
|
| 37 |
+
- "🎯 Relevant Context (Only relevant context)"
|
| 38 |
+
- Added explanation markdown below radio buttons
|
| 39 |
+
|
| 40 |
+
## How to Access Context Mode
|
| 41 |
+
|
| 42 |
+
### Method 1: Using Menu Toggle Button
|
| 43 |
+
1. Look for the **⚙️** (gear) button in the top-right corner of the interface
|
| 44 |
+
2. Click it to open/close the Settings panel
|
| 45 |
+
3. Look for **"Context Options"** section (should be expanded/open)
|
| 46 |
+
4. You'll see the radio buttons for selecting context mode
|
| 47 |
+
|
| 48 |
+
### Method 2: Using Mobile Navigation (if visible)
|
| 49 |
+
1. Look for **"⚙️ Settings"** button in mobile navigation bar
|
| 50 |
+
2. Click it to toggle settings panel
|
| 51 |
+
3. Context Options section should be visible and expanded
|
| 52 |
+
|
| 53 |
+
## Visual Guide
|
| 54 |
+
|
| 55 |
+
```
|
| 56 |
+
⚙️ Settings Button → Opens Settings Panel
|
| 57 |
+
└─ Display Options (expanded)
|
| 58 |
+
└─ Context Options (expanded) ← LOOK HERE
|
| 59 |
+
├─ Radio Button: Select context mode:
|
| 60 |
+
├─ 🆕 Fresh Context (No user context)
|
| 61 |
+
├─ 🎯 Relevant Context (Only relevant context)
|
| 62 |
+
└─ Status: *Current: Fresh Context*
|
| 63 |
+
└─ Performance Options (collapsed)
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
## Testing Checklist
|
| 67 |
+
|
| 68 |
+
- [x] Settings panel toggles with ⚙️ button
|
| 69 |
+
- [x] Context Options accordion opens automatically
|
| 70 |
+
- [x] Radio buttons are visible and clickable
|
| 71 |
+
- [x] Mode selection updates status indicator
|
| 72 |
+
- [x] Mode change applies to next request
|
| 73 |
+
- [x] Mobile-responsive design maintained
|
| 74 |
+
|
| 75 |
+
## If Still Can't See It
|
| 76 |
+
|
| 77 |
+
1. **Check Browser Console**: Look for any JavaScript errors
|
| 78 |
+
2. **Try Refreshing**: Hard refresh (Ctrl+F5 or Cmd+Shift+R)
|
| 79 |
+
3. **Check Settings Panel Visibility**: Click ⚙️ button - panel should appear below main content
|
| 80 |
+
4. **Look for "Context Options"**: It should be the second accordion section (after "Display Options")
|
| 81 |
+
5. **Check Mobile View**: On mobile, settings might appear differently - scroll down if needed
|
| 82 |
+
|
| 83 |
+
## Next Steps After Fix
|
| 84 |
+
|
| 85 |
+
1. **User Testing**: Verify settings panel opens and Context Options are visible
|
| 86 |
+
2. **Functionality Testing**: Test mode switching between Fresh and Relevant
|
| 87 |
+
3. **Mobile Testing**: Verify on mobile devices/browsers
|
| 88 |
+
4. **Feedback Collection**: Gather user feedback on visibility and usability
|
app.py
CHANGED
|
@@ -333,8 +333,10 @@ def create_mobile_optimized_interface():
|
|
| 333 |
chat_nav_btn = gr.Button("💬 Chat", variant="secondary", size="sm", min_width=0)
|
| 334 |
details_nav_btn = gr.Button("🔍 Details", variant="secondary", size="sm", min_width=0)
|
| 335 |
settings_nav_btn = gr.Button("⚙️ Settings", variant="secondary", size="sm", min_width=0)
|
|
|
|
| 336 |
|
| 337 |
# Settings Panel (Modal for Mobile)
|
|
|
|
| 338 |
with gr.Column(visible=False, elem_id="settings_panel") as settings:
|
| 339 |
interface_components['settings_panel'] = settings
|
| 340 |
|
|
@@ -360,7 +362,7 @@ def create_mobile_optimized_interface():
|
|
| 360 |
)
|
| 361 |
interface_components['compact_mode'] = compact_mode
|
| 362 |
|
| 363 |
-
with gr.Accordion("Context Options", open=
|
| 364 |
# Import MobileComponents for context mode toggle
|
| 365 |
from mobile_components import MobileComponents
|
| 366 |
|
|
@@ -374,11 +376,39 @@ def create_mobile_optimized_interface():
|
|
| 374 |
except:
|
| 375 |
pass
|
| 376 |
|
| 377 |
-
# Create context mode toggle
|
| 378 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
interface_components['context_mode'] = context_mode_radio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 380 |
interface_components['mode_status'] = mode_status
|
| 381 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 382 |
# Add CSS for context mode toggle
|
| 383 |
context_mode_css = MobileComponents.get_context_mode_css()
|
| 384 |
demo.css += context_mode_css
|
|
@@ -455,12 +485,41 @@ def create_mobile_optimized_interface():
|
|
| 455 |
|
| 456 |
# Wire up Settings button to toggle settings panel
|
| 457 |
if 'menu_toggle' in interface_components and 'settings_panel' in interface_components:
|
| 458 |
-
def toggle_settings(
|
| 459 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 460 |
|
| 461 |
interface_components['menu_toggle'].click(
|
| 462 |
fn=toggle_settings,
|
| 463 |
-
inputs=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 464 |
outputs=[interface_components['settings_panel']]
|
| 465 |
)
|
| 466 |
|
|
|
|
| 333 |
chat_nav_btn = gr.Button("💬 Chat", variant="secondary", size="sm", min_width=0)
|
| 334 |
details_nav_btn = gr.Button("🔍 Details", variant="secondary", size="sm", min_width=0)
|
| 335 |
settings_nav_btn = gr.Button("⚙️ Settings", variant="secondary", size="sm", min_width=0)
|
| 336 |
+
interface_components['settings_nav_btn'] = settings_nav_btn # Add to interface components
|
| 337 |
|
| 338 |
# Settings Panel (Modal for Mobile)
|
| 339 |
+
# Note: visible=False by default, use ⚙️ button to toggle
|
| 340 |
with gr.Column(visible=False, elem_id="settings_panel") as settings:
|
| 341 |
interface_components['settings_panel'] = settings
|
| 342 |
|
|
|
|
| 362 |
)
|
| 363 |
interface_components['compact_mode'] = compact_mode
|
| 364 |
|
| 365 |
+
with gr.Accordion("Context Options", open=True):
|
| 366 |
# Import MobileComponents for context mode toggle
|
| 367 |
from mobile_components import MobileComponents
|
| 368 |
|
|
|
|
| 376 |
except:
|
| 377 |
pass
|
| 378 |
|
| 379 |
+
# Create context mode toggle directly in Accordion (simplified)
|
| 380 |
+
gr.Markdown("**Context Mode:**", elem_classes=["context-mode-header"])
|
| 381 |
+
|
| 382 |
+
context_mode_radio = gr.Radio(
|
| 383 |
+
choices=[
|
| 384 |
+
("🆕 Fresh Context (No user context)", "fresh"),
|
| 385 |
+
("🎯 Relevant Context (Only relevant context)", "relevant")
|
| 386 |
+
],
|
| 387 |
+
value=current_mode,
|
| 388 |
+
label="Select context mode:",
|
| 389 |
+
info="Fresh: Responses without user history | Relevant: Only relevant past discussions included",
|
| 390 |
+
elem_classes=["context-mode-radio"],
|
| 391 |
+
container=True,
|
| 392 |
+
scale=1
|
| 393 |
+
)
|
| 394 |
interface_components['context_mode'] = context_mode_radio
|
| 395 |
+
|
| 396 |
+
mode_status = gr.Markdown(
|
| 397 |
+
value=f"*Current: {'Fresh' if current_mode == 'fresh' else 'Relevant'} Context*",
|
| 398 |
+
elem_classes=["context-mode-status"],
|
| 399 |
+
visible=True
|
| 400 |
+
)
|
| 401 |
interface_components['mode_status'] = mode_status
|
| 402 |
|
| 403 |
+
gr.Markdown(
|
| 404 |
+
"""
|
| 405 |
+
**Mode Explanation:**
|
| 406 |
+
- **Fresh Context**: Each response is generated without user context from previous sessions
|
| 407 |
+
- **Relevant Context**: System identifies and includes only relevant past discussions related to your current topic
|
| 408 |
+
""",
|
| 409 |
+
visible=True
|
| 410 |
+
)
|
| 411 |
+
|
| 412 |
# Add CSS for context mode toggle
|
| 413 |
context_mode_css = MobileComponents.get_context_mode_css()
|
| 414 |
demo.css += context_mode_css
|
|
|
|
| 485 |
|
| 486 |
# Wire up Settings button to toggle settings panel
|
| 487 |
if 'menu_toggle' in interface_components and 'settings_panel' in interface_components:
|
| 488 |
+
def toggle_settings():
|
| 489 |
+
"""Toggle settings panel visibility"""
|
| 490 |
+
try:
|
| 491 |
+
# Get current visibility state
|
| 492 |
+
current_state = interface_components['settings_panel'].visible
|
| 493 |
+
new_state = not current_state
|
| 494 |
+
logger.info(f"Toggling settings panel: {current_state} -> {new_state}")
|
| 495 |
+
return gr.update(visible=new_state)
|
| 496 |
+
except Exception as e:
|
| 497 |
+
logger.error(f"Error toggling settings: {e}", exc_info=True)
|
| 498 |
+
return gr.update(visible=True) # Show on error
|
| 499 |
|
| 500 |
interface_components['menu_toggle'].click(
|
| 501 |
fn=toggle_settings,
|
| 502 |
+
inputs=None,
|
| 503 |
+
outputs=[interface_components['settings_panel']]
|
| 504 |
+
)
|
| 505 |
+
|
| 506 |
+
# Also wire up settings_nav_btn from mobile navigation if it exists
|
| 507 |
+
# This ensures Settings button works from mobile navigation bar
|
| 508 |
+
if 'settings_nav_btn' in interface_components and 'settings_panel' in interface_components:
|
| 509 |
+
def toggle_settings_from_nav():
|
| 510 |
+
"""Toggle settings panel from mobile nav button"""
|
| 511 |
+
try:
|
| 512 |
+
current_state = interface_components['settings_panel'].visible
|
| 513 |
+
new_state = not current_state
|
| 514 |
+
logger.info(f"Toggling settings panel from nav: {current_state} -> {new_state}")
|
| 515 |
+
return gr.update(visible=new_state)
|
| 516 |
+
except Exception as e:
|
| 517 |
+
logger.error(f"Error toggling settings from nav: {e}", exc_info=True)
|
| 518 |
+
return gr.update(visible=True)
|
| 519 |
+
|
| 520 |
+
interface_components['settings_nav_btn'].click(
|
| 521 |
+
fn=toggle_settings_from_nav,
|
| 522 |
+
inputs=None,
|
| 523 |
outputs=[interface_components['settings_panel']]
|
| 524 |
)
|
| 525 |
|