Fix plan display: filter out section headers like Title/Description
Browse files- chainlit_app.py +38 -11
chainlit_app.py
CHANGED
|
@@ -22,8 +22,8 @@ from concurrent.futures import ThreadPoolExecutor
|
|
| 22 |
# ============================================================
|
| 23 |
# STARTUP VERSION CHECK - Change this to detect if rebuild worked
|
| 24 |
# ============================================================
|
| 25 |
-
APP_VERSION = "3.6.
|
| 26 |
-
BUILD_ID = "2024-12-20-
|
| 27 |
print("=" * 60)
|
| 28 |
print(f"[STARTUP] CodePilot Chainlit App")
|
| 29 |
print(f"[STARTUP] APP_VERSION: {APP_VERSION}")
|
|
@@ -372,6 +372,27 @@ def format_plan_display(plan: str) -> str:
|
|
| 372 |
plan_lines = plan.split('\n')
|
| 373 |
steps = []
|
| 374 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 375 |
# Strategy 1: Look for existing numbered steps (1., 2., etc.)
|
| 376 |
for line in plan_lines:
|
| 377 |
stripped = line.strip()
|
|
@@ -381,8 +402,10 @@ def format_plan_display(plan: str) -> str:
|
|
| 381 |
match = re.match(r'^(\d+)[.)\]:]\s*(.+)', stripped)
|
| 382 |
if match:
|
| 383 |
step_text = match.group(2).strip()
|
| 384 |
-
# Skip
|
| 385 |
-
if len(step_text) > 10 and
|
|
|
|
|
|
|
| 386 |
steps.append(step_text)
|
| 387 |
|
| 388 |
# Strategy 2: Look for bullet points if no numbered steps found
|
|
@@ -393,11 +416,11 @@ def format_plan_display(plan: str) -> str:
|
|
| 393 |
# Match bullet points
|
| 394 |
if stripped.startswith(('-', '*', '•')) and len(stripped) > 5:
|
| 395 |
step_text = stripped.lstrip('-*• ').strip()
|
| 396 |
-
# Skip headers, file paths,
|
| 397 |
if (len(step_text) > 15 and
|
| 398 |
not step_text.startswith('#') and
|
| 399 |
not step_text.startswith('/') and
|
| 400 |
-
|
| 401 |
steps.append(step_text)
|
| 402 |
|
| 403 |
# Strategy 3: Extract key sentences with action verbs
|
|
@@ -406,12 +429,16 @@ def format_plan_display(plan: str) -> str:
|
|
| 406 |
action_verbs = ['create', 'add', 'implement', 'write', 'update', 'modify',
|
| 407 |
'define', 'set up', 'configure', 'import', 'export', 'build']
|
| 408 |
for line in plan_lines:
|
| 409 |
-
stripped = line.strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 410 |
for verb in action_verbs:
|
| 411 |
-
if verb in
|
| 412 |
# Clean up the line
|
| 413 |
-
clean =
|
| 414 |
-
if clean and clean not in steps:
|
| 415 |
steps.append(clean)
|
| 416 |
break
|
| 417 |
|
|
@@ -435,7 +462,7 @@ def format_plan_display(plan: str) -> str:
|
|
| 435 |
else:
|
| 436 |
# Fallback: show first meaningful line
|
| 437 |
for line in plan_lines:
|
| 438 |
-
if line.strip() and not line.startswith('#'):
|
| 439 |
lines.append(f"1. {line.strip()[:80]}")
|
| 440 |
break
|
| 441 |
if len(lines) == 1:
|
|
|
|
| 22 |
# ============================================================
|
| 23 |
# STARTUP VERSION CHECK - Change this to detect if rebuild worked
|
| 24 |
# ============================================================
|
| 25 |
+
APP_VERSION = "3.6.1-plan-fix"
|
| 26 |
+
BUILD_ID = "2024-12-20-v6"
|
| 27 |
print("=" * 60)
|
| 28 |
print(f"[STARTUP] CodePilot Chainlit App")
|
| 29 |
print(f"[STARTUP] APP_VERSION: {APP_VERSION}")
|
|
|
|
| 372 |
plan_lines = plan.split('\n')
|
| 373 |
steps = []
|
| 374 |
|
| 375 |
+
# Section headers to skip (template sections, not actual steps)
|
| 376 |
+
skip_patterns = [
|
| 377 |
+
'title:', 'description:', 'overview:', 'summary:', 'objective:',
|
| 378 |
+
'installation:', 'running', 'testing', 'use case:', 'example:',
|
| 379 |
+
'note:', 'warning:', 'important:', 'files:', 'dependencies:',
|
| 380 |
+
'prerequisites:', 'requirements:', 'setup:', 'configuration:',
|
| 381 |
+
'readme', 'docstring', 'documentation'
|
| 382 |
+
]
|
| 383 |
+
|
| 384 |
+
def is_section_header(text: str) -> bool:
|
| 385 |
+
"""Check if text is a section header, not an action step."""
|
| 386 |
+
text_lower = text.lower().strip()
|
| 387 |
+
# Skip if starts with common header patterns
|
| 388 |
+
for pattern in skip_patterns:
|
| 389 |
+
if text_lower.startswith(pattern):
|
| 390 |
+
return True
|
| 391 |
+
# Skip if it's just a label ending with colon and nothing else useful
|
| 392 |
+
if text_lower.endswith(':') and len(text_lower) < 30:
|
| 393 |
+
return True
|
| 394 |
+
return False
|
| 395 |
+
|
| 396 |
# Strategy 1: Look for existing numbered steps (1., 2., etc.)
|
| 397 |
for line in plan_lines:
|
| 398 |
stripped = line.strip()
|
|
|
|
| 402 |
match = re.match(r'^(\d+)[.)\]:]\s*(.+)', stripped)
|
| 403 |
if match:
|
| 404 |
step_text = match.group(2).strip()
|
| 405 |
+
# Skip section headers, file paths, and too short items
|
| 406 |
+
if (len(step_text) > 10 and
|
| 407 |
+
not step_text.startswith('/') and
|
| 408 |
+
not is_section_header(step_text)):
|
| 409 |
steps.append(step_text)
|
| 410 |
|
| 411 |
# Strategy 2: Look for bullet points if no numbered steps found
|
|
|
|
| 416 |
# Match bullet points
|
| 417 |
if stripped.startswith(('-', '*', '•')) and len(stripped) > 5:
|
| 418 |
step_text = stripped.lstrip('-*• ').strip()
|
| 419 |
+
# Skip headers, file paths, section headers
|
| 420 |
if (len(step_text) > 15 and
|
| 421 |
not step_text.startswith('#') and
|
| 422 |
not step_text.startswith('/') and
|
| 423 |
+
not is_section_header(step_text)):
|
| 424 |
steps.append(step_text)
|
| 425 |
|
| 426 |
# Strategy 3: Extract key sentences with action verbs
|
|
|
|
| 429 |
action_verbs = ['create', 'add', 'implement', 'write', 'update', 'modify',
|
| 430 |
'define', 'set up', 'configure', 'import', 'export', 'build']
|
| 431 |
for line in plan_lines:
|
| 432 |
+
stripped = line.strip()
|
| 433 |
+
stripped_lower = stripped.lower()
|
| 434 |
+
# Skip section headers
|
| 435 |
+
if is_section_header(stripped):
|
| 436 |
+
continue
|
| 437 |
for verb in action_verbs:
|
| 438 |
+
if verb in stripped_lower and len(stripped) > 20:
|
| 439 |
# Clean up the line
|
| 440 |
+
clean = stripped.lstrip('-*• 0123456789.):]').strip()
|
| 441 |
+
if clean and clean not in steps and not is_section_header(clean):
|
| 442 |
steps.append(clean)
|
| 443 |
break
|
| 444 |
|
|
|
|
| 462 |
else:
|
| 463 |
# Fallback: show first meaningful line
|
| 464 |
for line in plan_lines:
|
| 465 |
+
if line.strip() and not line.startswith('#') and not is_section_header(line):
|
| 466 |
lines.append(f"1. {line.strip()[:80]}")
|
| 467 |
break
|
| 468 |
if len(lines) == 1:
|