feat(ai-session): add Phase 2 PSA integration, escalation handoff, and session management
Phase 2 of the FlowPilot-First Pivot connecting AI sessions to ConnectWise PSA: Slice 1 — PSA Ticket Intake: - FlowPilotEngine accepts psa_ticket intake with graceful CW API fallback - Ticket picker on intake screen (refactored TicketPickerModal for dual-mode) - Ticket context card in session sidebar Slice 2 — Auto Documentation Push: - PSA documentation service with resolution/escalation note formatting - Time entry creation via new ConnectWise provider method - Automatic retry scheduler (APScheduler, 5min interval, 3 retries) - PSA push status indicators in frontend with manual retry button - Member mapping warning when CW member not mapped Slice 3 — Session Pause/Resume & Escalation Handoff: - Pause/resume endpoints for same-engineer session bookmarking - Escalation flow: requesting_escalation status, self-escalation blocked - Enhanced escalation package with LLM-generated hypotheses/suggestions - Pickup endpoint with continue/fresh resume modes and briefing step - Escalation queue (sidebar nav + dedicated page) - SessionBriefing component with continue/fresh choice UI - EscalateModal with PSA-aware button text Slice 4 — Mid-Session Ticket Linking: - Link ticket retroactively with context injection into system prompt - Link Ticket button in session sidebar Slice 5 — FlowPilot PSA Settings: - Settings tab on IntegrationsPage with 7 configurable options - Stored as flowpilot_settings JSONB on PsaConnection Database: 2 migrations (flowpilot_settings, psa_post_log changes, status constraint) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -279,6 +279,69 @@ async def test_connection(
|
||||
return result
|
||||
|
||||
|
||||
# ── FlowPilot PSA Settings ──────────────────────────────────────
|
||||
|
||||
|
||||
@router.get("/connections/{connection_id}/flowpilot-settings")
|
||||
async def get_flowpilot_settings(
|
||||
connection_id: UUID,
|
||||
current_user: Annotated[User, Depends(require_account_owner)],
|
||||
db: Annotated[AsyncSession, Depends(get_db)],
|
||||
):
|
||||
"""Get FlowPilot-specific settings for a PSA connection."""
|
||||
conn = await _get_connection_or_404(connection_id, current_user, db)
|
||||
# Return settings with defaults filled in
|
||||
defaults = {
|
||||
"auto_push": True,
|
||||
"auto_time_entry": True,
|
||||
"time_rounding": "15min",
|
||||
"note_visibility": "internal",
|
||||
"include_diagnostic_steps": True,
|
||||
"prompt_status_on_resolution": False,
|
||||
"prompt_status_on_escalation": False,
|
||||
}
|
||||
settings_data = {**defaults, **(conn.flowpilot_settings or {})}
|
||||
return settings_data
|
||||
|
||||
|
||||
@router.put("/connections/{connection_id}/flowpilot-settings")
|
||||
async def update_flowpilot_settings(
|
||||
connection_id: UUID,
|
||||
data: dict,
|
||||
current_user: Annotated[User, Depends(require_account_owner)],
|
||||
db: Annotated[AsyncSession, Depends(get_db)],
|
||||
):
|
||||
"""Update FlowPilot-specific settings for a PSA connection."""
|
||||
conn = await _get_connection_or_404(connection_id, current_user, db)
|
||||
|
||||
# Validate allowed keys
|
||||
allowed_keys = {
|
||||
"auto_push", "auto_time_entry", "time_rounding",
|
||||
"note_visibility", "include_diagnostic_steps",
|
||||
"prompt_status_on_resolution", "prompt_status_on_escalation",
|
||||
}
|
||||
filtered = {k: v for k, v in data.items() if k in allowed_keys}
|
||||
|
||||
# Merge with existing
|
||||
current = conn.flowpilot_settings or {}
|
||||
current.update(filtered)
|
||||
conn.flowpilot_settings = current
|
||||
|
||||
await db.commit()
|
||||
await db.refresh(conn)
|
||||
|
||||
defaults = {
|
||||
"auto_push": True,
|
||||
"auto_time_entry": True,
|
||||
"time_rounding": "15min",
|
||||
"note_visibility": "internal",
|
||||
"include_diagnostic_steps": True,
|
||||
"prompt_status_on_resolution": False,
|
||||
"prompt_status_on_escalation": False,
|
||||
}
|
||||
return {**defaults, **(conn.flowpilot_settings or {})}
|
||||
|
||||
|
||||
# ── ticket / status / company endpoints ──────────────────────────
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user