Skip to content

Commit 0fe2e25

Browse files
committed
feat: MAJOR BREAKTHROUGH - Real Human Interaction System implemented - phase-specific dialogues, emotional state tracking, approval gates, feedback loops, and interaction history - complete human-centered agile development
1 parent a2e604a commit 0fe2e25

1 file changed

Lines changed: 293 additions & 1 deletion

File tree

apps/universal_composition_app.py

Lines changed: 293 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@
3131

3232
# Import Vibe-Agile Fusion Engine
3333
try:
34-
from utils.agile.vibe_agile_fusion import VibeAgileFusionEngine, VibeContext, VibeIntensity, AgilePhase
34+
from utils.agile.vibe_agile_fusion import (
35+
VibeAgileFusionEngine, VibeContext, VibeIntensity, AgilePhase,
36+
get_human_interaction_dialog
37+
)
3538
VIBE_AGILE_AVAILABLE = True
3639
except ImportError:
3740
VibeAgileFusionEngine = None
3841
VibeContext = None
3942
VibeIntensity = None
4043
AgilePhase = None
44+
get_human_interaction_dialog = None
4145
VIBE_AGILE_AVAILABLE = False
4246

4347
# Page configuration
@@ -154,6 +158,16 @@ def initialize_session_state():
154158
if 'current_agile_phase' not in st.session_state:
155159
st.session_state.current_agile_phase = AgilePhase.INCEPTION if VIBE_AGILE_AVAILABLE else None
156160

161+
# Initialize human interaction state
162+
if 'human_interactions' not in st.session_state:
163+
st.session_state.human_interactions = {}
164+
165+
if 'active_interaction' not in st.session_state:
166+
st.session_state.active_interaction = None
167+
168+
if 'interaction_history' not in st.session_state:
169+
st.session_state.interaction_history = []
170+
157171
if 'running_projects' not in st.session_state:
158172
st.session_state.running_projects = []
159173

@@ -2181,6 +2195,11 @@ def display_agile_vibe_projects_interface():
21812195
st.markdown('</div>', unsafe_allow_html=True)
21822196
return
21832197

2198+
# Display active human interaction dialog if one exists
2199+
if hasattr(st.session_state, 'show_interaction_dialog') and st.session_state.show_interaction_dialog:
2200+
display_human_interaction_dialog()
2201+
return
2202+
21842203
# Project Creation Interface
21852204
col1, col2 = st.columns([2, 1])
21862205

@@ -2316,6 +2335,18 @@ def create_vibe_agile_project(project_name, project_description, vibe_intensity,
23162335
with st.spinner("🎼 Creating vibe-agile project with complete agile artifacts..."):
23172336
result = st.session_state.vibe_agile_engine.create_vibe_agile_project(project_config)
23182337

2338+
# Initialize human interaction for this project
2339+
project_id = f"project_{len(st.session_state.vibe_agile_projects)}"
2340+
result['project_id'] = project_id
2341+
2342+
# Set up first human interaction checkpoint
2343+
if 'next_human_interaction' in result and result['next_human_interaction']:
2344+
st.session_state.active_interaction = {
2345+
'project_id': project_id,
2346+
'phase': result['next_human_interaction']['phase'],
2347+
'vibe_context': result['vibe_context']
2348+
}
2349+
23192350
# Add to session state
23202351
st.session_state.vibe_agile_projects.append(result)
23212352

@@ -2325,6 +2356,13 @@ def create_vibe_agile_project(project_name, project_description, vibe_intensity,
23252356
# Display creation summary
23262357
display_project_creation_summary(result)
23272358

2359+
# Start first human interaction
2360+
if st.session_state.active_interaction:
2361+
st.info("🤝 **Ready for Human Interaction!** Your project is waiting for the first dialogue checkpoint.")
2362+
if st.button("▶️ Start Human Interaction", type="primary"):
2363+
st.session_state.show_interaction_dialog = True
2364+
st.rerun()
2365+
23282366
except Exception as e:
23292367
st.error(f"🚨 Error creating vibe-agile project: {str(e)}")
23302368

@@ -2390,6 +2428,33 @@ def display_existing_vibe_agile_projects():
23902428

23912429
if st.button(f"📈 Project Health", key=f"health_{i}"):
23922430
show_project_health(project)
2431+
2432+
# Show interaction history for this project
2433+
project_interactions = [
2434+
record for record in st.session_state.interaction_history
2435+
if record.get('project_id') == project.get('project_id')
2436+
]
2437+
2438+
if project_interactions:
2439+
with st.expander(f"🤝 Interaction History ({len(project_interactions)} interactions)"):
2440+
for interaction in project_interactions[-3:]: # Show last 3 interactions
2441+
col_hist1, col_hist2, col_hist3 = st.columns([1, 2, 1])
2442+
2443+
with col_hist1:
2444+
st.markdown(f"**{interaction['phase'].title()}**")
2445+
st.markdown(f"*{interaction['timestamp'][:16]}*")
2446+
2447+
with col_hist2:
2448+
st.markdown(f"**Action**: {interaction['action'].title()}")
2449+
if interaction['emotional_state']['additional_thoughts']:
2450+
st.markdown(f"*{interaction['emotional_state']['additional_thoughts'][:100]}...*")
2451+
2452+
with col_hist3:
2453+
emo = interaction['emotional_state']
2454+
st.markdown(f"😊 {emo['satisfaction']}/10")
2455+
st.markdown(f"💪 {emo['energy']}/10")
2456+
2457+
st.markdown("---")
23932458

23942459
st.markdown('</div>', unsafe_allow_html=True)
23952460

@@ -2418,6 +2483,233 @@ def show_project_health(project):
24182483
st.info(f"📈 Project health for: {project.get('name', 'Unnamed Project')}")
24192484
st.info("🚧 Project health dashboard coming in next update...")
24202485

2486+
def display_human_interaction_dialog():
2487+
"""Display interactive dialog for human feedback and decision making."""
2488+
2489+
st.markdown('<div class="composition-card">', unsafe_allow_html=True)
2490+
st.subheader("🤝 Human Interaction Checkpoint")
2491+
2492+
if not st.session_state.active_interaction:
2493+
st.error("No active interaction found.")
2494+
st.markdown('</div>', unsafe_allow_html=True)
2495+
return
2496+
2497+
interaction = st.session_state.active_interaction
2498+
project_id = interaction['project_id']
2499+
phase = interaction['phase']
2500+
vibe_context = interaction['vibe_context']
2501+
2502+
# Get dialog configuration for current phase
2503+
try:
2504+
dialog_config = get_human_interaction_dialog(phase, vibe_context)
2505+
except Exception as e:
2506+
st.error(f"Error getting dialog configuration: {str(e)}")
2507+
dialog_config = {
2508+
'phase': phase,
2509+
'questions': ["How do you feel about the current progress?"],
2510+
'duration': "10 minutes",
2511+
'success_criteria': ["Clear feedback provided"],
2512+
'emotional_context': vibe_context.get('intensity', 'focused'),
2513+
'interaction_type': 'conversation'
2514+
}
2515+
2516+
# Display phase context
2517+
col1, col2, col3 = st.columns([1, 2, 1])
2518+
2519+
with col1:
2520+
st.metric("🎭 Phase", phase.replace('_', ' ').title())
2521+
st.metric("⏰ Duration", dialog_config.get('duration', '10 min'))
2522+
2523+
with col2:
2524+
st.markdown(f"### 🎯 {phase.replace('_', ' ').title()} Interaction")
2525+
st.markdown(f"**Emotional Context**: {dialog_config.get('emotional_context', 'balanced').title()}")
2526+
st.markdown(f"**Interaction Type**: {dialog_config.get('interaction_type', 'conversation').title()}")
2527+
2528+
with col3:
2529+
st.metric("💬 Vibe Level", vibe_context.get('intensity', 'focused').title())
2530+
st.metric("🎨 Style", vibe_context.get('communication_style', 'collaborative').title())
2531+
2532+
st.markdown("---")
2533+
2534+
# Display phase-specific questions
2535+
st.markdown("### 🗣️ Interactive Questions")
2536+
2537+
responses = {}
2538+
questions = dialog_config.get('questions', [])
2539+
2540+
for i, question in enumerate(questions):
2541+
st.markdown(f"**Question {i+1}**: {question}")
2542+
2543+
# Adapt input type based on question content
2544+
if 'rate' in question.lower() or 'scale' in question.lower():
2545+
response = st.slider(f"Response {i+1}", 1, 10, 5, key=f"q_{i}")
2546+
elif 'yes' in question.lower() or 'no' in question.lower():
2547+
response = st.radio(f"Response {i+1}", ["Yes", "No", "Maybe"], key=f"q_{i}")
2548+
elif 'choose' in question.lower() or 'select' in question.lower():
2549+
response = st.selectbox(f"Response {i+1}",
2550+
["Option A", "Option B", "Option C", "Other"],
2551+
key=f"q_{i}")
2552+
else:
2553+
response = st.text_area(f"Your thoughts",
2554+
placeholder="Share your detailed feedback...",
2555+
height=100, key=f"q_{i}")
2556+
2557+
responses[f"question_{i+1}"] = response
2558+
2559+
# Emotional feedback section
2560+
st.markdown("### 🎭 Emotional State Check")
2561+
2562+
col_emo1, col_emo2 = st.columns(2)
2563+
2564+
with col_emo1:
2565+
current_energy = st.slider("Current Energy Level", 1, 10, 5)
2566+
satisfaction_level = st.slider("Satisfaction with Progress", 1, 10, 7)
2567+
2568+
with col_emo2:
2569+
stress_level = st.slider("Stress Level", 1, 10, 3)
2570+
confidence_level = st.slider("Confidence in Direction", 1, 10, 8)
2571+
2572+
# Additional feedback
2573+
st.markdown("### 💭 Additional Feedback")
2574+
additional_thoughts = st.text_area(
2575+
"Any additional thoughts, concerns, or suggestions?",
2576+
placeholder="Share anything else on your mind about this project...",
2577+
height=120
2578+
)
2579+
2580+
# Success criteria check
2581+
if 'success_criteria' in dialog_config:
2582+
st.markdown("### ✅ Success Criteria")
2583+
criteria_met = []
2584+
for criterion in dialog_config['success_criteria']:
2585+
met = st.checkbox(f"✓ {criterion}")
2586+
criteria_met.append(met)
2587+
2588+
# Action buttons
2589+
st.markdown("---")
2590+
col_btn1, col_btn2, col_btn3, col_btn4 = st.columns(4)
2591+
2592+
with col_btn1:
2593+
if st.button("✅ Approve & Continue", type="primary"):
2594+
handle_interaction_response("approve", responses, {
2595+
'energy': current_energy,
2596+
'satisfaction': satisfaction_level,
2597+
'stress': stress_level,
2598+
'confidence': confidence_level,
2599+
'additional_thoughts': additional_thoughts
2600+
})
2601+
2602+
with col_btn2:
2603+
if st.button("🔄 Request Changes"):
2604+
handle_interaction_response("request_changes", responses, {
2605+
'energy': current_energy,
2606+
'satisfaction': satisfaction_level,
2607+
'stress': stress_level,
2608+
'confidence': confidence_level,
2609+
'additional_thoughts': additional_thoughts
2610+
})
2611+
2612+
with col_btn3:
2613+
if st.button("⏸️ Pause for Review"):
2614+
handle_interaction_response("pause", responses, {
2615+
'energy': current_energy,
2616+
'satisfaction': satisfaction_level,
2617+
'stress': stress_level,
2618+
'confidence': confidence_level,
2619+
'additional_thoughts': additional_thoughts
2620+
})
2621+
2622+
with col_btn4:
2623+
if st.button("❌ Cancel Interaction"):
2624+
st.session_state.show_interaction_dialog = False
2625+
st.session_state.active_interaction = None
2626+
st.rerun()
2627+
2628+
st.markdown('</div>', unsafe_allow_html=True)
2629+
2630+
def handle_interaction_response(action, responses, emotional_state):
2631+
"""Handle human interaction response and proceed with workflow."""
2632+
2633+
# Record interaction in history
2634+
interaction_record = {
2635+
'timestamp': datetime.now().isoformat(),
2636+
'project_id': st.session_state.active_interaction['project_id'],
2637+
'phase': st.session_state.active_interaction['phase'],
2638+
'action': action,
2639+
'responses': responses,
2640+
'emotional_state': emotional_state
2641+
}
2642+
2643+
st.session_state.interaction_history.append(interaction_record)
2644+
2645+
# Handle different actions
2646+
if action == "approve":
2647+
st.success("✅ **Approved!** Moving to next phase of development.")
2648+
advance_to_next_phase()
2649+
2650+
elif action == "request_changes":
2651+
st.warning("🔄 **Changes Requested** - The team will review and implement your feedback.")
2652+
st.info("Changes will be incorporated before moving to the next phase.")
2653+
2654+
elif action == "pause":
2655+
st.info("⏸️ **Paused for Review** - Project development is paused pending further review.")
2656+
2657+
# Clear current interaction
2658+
st.session_state.show_interaction_dialog = False
2659+
st.session_state.active_interaction = None
2660+
2661+
# Show feedback summary
2662+
display_interaction_feedback_summary(interaction_record)
2663+
2664+
st.rerun()
2665+
2666+
def advance_to_next_phase():
2667+
"""Advance the project to the next agile phase."""
2668+
2669+
current_phase = st.session_state.active_interaction['phase']
2670+
2671+
# Define phase progression
2672+
phase_sequence = [
2673+
'inception', 'planning', 'development',
2674+
'testing', 'review', 'retrospective', 'deployment'
2675+
]
2676+
2677+
try:
2678+
current_index = phase_sequence.index(current_phase)
2679+
if current_index < len(phase_sequence) - 1:
2680+
next_phase = phase_sequence[current_index + 1]
2681+
st.session_state.current_agile_phase = AgilePhase(next_phase)
2682+
st.info(f"🚀 **Advanced to {next_phase.title()}** - Ready for next interaction checkpoint!")
2683+
else:
2684+
st.success("🎉 **Project Complete!** All agile phases completed successfully.")
2685+
st.session_state.current_agile_phase = None
2686+
except ValueError:
2687+
st.warning(f"Unknown phase: {current_phase}")
2688+
2689+
def display_interaction_feedback_summary(interaction_record):
2690+
"""Display summary of interaction feedback."""
2691+
2692+
st.markdown("### 📊 Interaction Summary")
2693+
2694+
col1, col2, col3 = st.columns(3)
2695+
2696+
with col1:
2697+
st.metric("🎭 Phase", interaction_record['phase'].title())
2698+
st.metric("⚡ Action", interaction_record['action'].title())
2699+
2700+
with col2:
2701+
emotional_state = interaction_record['emotional_state']
2702+
st.metric("💪 Energy", f"{emotional_state['energy']}/10")
2703+
st.metric("😊 Satisfaction", f"{emotional_state['satisfaction']}/10")
2704+
2705+
with col3:
2706+
st.metric("😰 Stress", f"{emotional_state['stress']}/10")
2707+
st.metric("🎯 Confidence", f"{emotional_state['confidence']}/10")
2708+
2709+
if interaction_record['emotional_state']['additional_thoughts']:
2710+
st.markdown("**Additional Thoughts:**")
2711+
st.info(interaction_record['emotional_state']['additional_thoughts'])
2712+
24212713
def main():
24222714
"""Main application function."""
24232715
initialize_session_state()

0 commit comments

Comments
 (0)