fix: return fresh Session per call in _get_kba_session(), remove global session cache#21
Closed
fix: return fresh Session per call in _get_kba_session(), remove global session cache#21
Conversation
- struktur aufgeräumt - README.md angepasst - learning_mechanism.md plan erstellt - desing fixes
Database & Backend:
- Add search_questions column migration in operations.py (ALTER TABLE for existing databases)
- Add /api/kba/drafts/{id}/replace endpoint in app.py
- Fix backward compatibility in kba_service.py (_table_to_draft, _draft_to_table)
- Add search questions generation to replace_draft workflow
- Fix NULL constraint errors by ensuring empty strings for required fields
- Update related_tickets validation: accept INC + 9-12 digits (was fixed at 12)
Frontend:
- Add Text component import to KBADrafterPage.jsx (fix TypeError)
- Add full-screen blur overlay with centered spinner during KBA generation
- Show overlay for both new draft creation and replacement operations
- Update styles: loadingOverlay with backdrop-filter blur effect
Documentation:
- Update kba_prompts.py: clarify related_tickets format with examples
- Update GENERAL.md: correct related_tickets format specification
Fixes #1 - KBA drafts not loading (missing DB column)
Fixes #2 - Replace endpoint not found (405 error)
Fixes #3 - Ticket ID validation too strict
- Add "Zurück zu Entwurf" button for reviewed status KBAs - Add handleUnreview() handler to update status from "reviewed" to "draft" - Import ArrowUndo24Regular icon for the unreview action - Allow users to continue editing KBAs after review without deletion This enables editing of reviewed KBAs that need changes before publishing.
… improvements - Add ticket viewer dialog to display original incident details * New "Ticket" button in KBA header with DocumentSearch icon * Modal dialog showing incident data (ID, summary, status, priority, assignee, notes, resolution) * Backend endpoint /api/csv-tickets/by-incident/<incident_id> for incident ID lookup * Frontend API function getCSVTicketByIncident() - Add unreview functionality for reviewed KBAs * "Zurück zu Entwurf" button with ArrowUndo icon * Allows resetting reviewed KBAs back to draft status for further editing - Redesign KBA overview list * Replace corner delete button with professional overflow menu (⋮) * Horizontal layout: content left, status badge right-aligned, menu button * Menu component with delete option - Add status filter dropdown to KBA overview * Filter options: All, draft, reviewed, published * Dropdown in card header for easy filtering - Align EditableList "Add" button width with input fields * Use invisible placeholder buttons for exact width matching * Ensures consistent layout regardless of allowReorder setting Files modified: - frontend/src/features/kba-drafter/KBADrafterPage.jsx - frontend/src/features/kba-drafter/components/EditableList.jsx - frontend/src/services/api.js - backend/app.py
- Fix delete draft error: use response.items instead of response.drafts - Make AutoGenSettings card collapsible with chevron icon - Starts collapsed to reduce visual dominance - Smooth slide-down animation when expanded - Status badge visible in collapsed header - Clickable header with keyboard support (Enter key)
When clicking on a draft from the list after scrolling down, the page now automatically scrolls to the top with a smooth animation. This ensures users always start at the beginning of the draft content.
…changes Replace native window.confirm() with ConfirmDialog component for better UX consistency and modern appearance. Adds centered warning modal when user attempts to discard unsaved changes (close draft, switch to preview, or load different draft). Changes: - Add unsavedChangesDialogOpen and pendingAction states - Update toggleEditMode, loadDraft, and handleClose to trigger modal - Add handleDiscardChanges and handleCancelDiscard handlers - Add ConfirmDialog with warning intent at end of component
Fixes: - Fix CSV folder case mismatch (CSV -> csv) in app.py and operations.py - Remove duplicate get_ticket_by_incident_id method in csv_data.py - Replace inefficient len(session.exec().all()) with SQL COUNT(*) in kba_service.py - Replace hardcoded placeholder credentials with env var lookups in kba_service.py - Fix scheduler swallowing exceptions (remove bare raise, return None) - Add settings reload at start of each scheduler run to fix race condition - Add generation_warnings field to surface search questions failures to users - Add schema migration for generation_warnings column Tests: - Add 19 Playwright e2e tests for KBA Drafter feature covering: page load, navigation, LLM health status, draft generation, draft display, draft list, editing, review workflow, duplicate handling, and backend API integration Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…dependency - LiteLLM is now the default LLM backend (no .env or API key needed) - Multistage model fallback chain: claude-sonnet-4 → gpt-4o → gpt-4o-mini - OpenAI SDK still used when OPENAI_API_KEY is explicitly set - agents.py and workbench service use ChatLiteLLM when no OpenAI key - Added csv_ticket_stats and csv_sla_breach_tickets to agent tools - Added KBA Drafter to Playwright nav tests and menu screenshots - Added e2e tests: publish, delete, status filter, ticket viewer - 32 unit tests + 5 live integration tests for LLM service - Updated .env.example with LiteLLM-first documentation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Merged
… session cache Co-authored-by: abossard <86611+abossard@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] WIP address feedback from review on Kba draft
fix: return fresh Session per call in _get_kba_session(), remove global session cache
Mar 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_get_kba_session()cached a single globalSessioninstance. Any caller using it as a context manager (with _get_kba_session() as session:) closes the session on exit, leaving the global pointing to a dead session for all subsequent requests — and leaking state across requests.Changes
operations.py— drop_kba_sessionglobal;_get_kba_session()now returnsSession(_kba_db_engine)on every call (only the engine is cached). All 8 KBA operation handlers updated to use the context-manager protocol:auto_gen_service.py— remove_get_kba_service()helper (returned aKBAServicewrapping an unmanaged, never-closed session).run_auto_generation()now opens an explicit context-managed session inline.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.