Commit graph

210 commits

Author SHA1 Message Date
michael
de62fa1f87 Show partial parse status in UI when some pages fail
- LlamaParse service now returns a ParseResult dataclass with markdown,
  total page count, and a list of failed pages (page number + error)
- Knowledge base service sets status to "partial" (instead of "parsed")
  when some pages failed, with a descriptive error listing which pages
  failed and why
- Frontend StatusBadge shows "partial parse" in orange for partial status
- Error details are shown inline below the document row for both partial
  and error statuses

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 17:51:52 -06:00
michael
49facbe713 Log full details of failed LlamaParse pages for troubleshooting
Handle MarkdownPageFailedMarkdownPage objects gracefully by checking for
the markdown attribute with hasattr instead of assuming all pages have
it. Failed pages now log their type and all attributes so the actual
LlamaParse error is visible in logs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 17:45:58 -06:00
michael
8a9a24ebe6 Parallelize LlamaParse document processing with asyncio.gather
Parse documents concurrently (up to 10 at a time via semaphore) instead
of serially. Each coroutine uses its own DB session for per-document
status updates, while a shared lock serializes job progress increments
on the main session to avoid session-sharing issues.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 17:39:01 -06:00
michael
919e8185fa Add confirmation dialog before deleting source documents
Prevents accidental deletion of knowledge base source documents by
prompting the user to confirm before proceeding.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 16:28:25 -06:00
michael
ba9c0ebde3 Reduce auth logging verbosity: INFO → DEBUG
All routine MSAL token verification logs now use DEBUG level so they
don't flood the console on every polling request.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 16:13:25 -06:00
michael
7835f557aa Fix processing job not visible to background task (FK violation)
The background task runs in its own DB session but the job row hadn't been
committed yet by the request session. The background task couldn't find
the job, causing FK violations when trying to create spec_versions.

Fix: explicitly commit the request session after creating the job and
before adding the background task, ensuring the job row is visible.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 16:09:50 -06:00
michael
3aa99144d4 Stop job polling on error (404) to prevent infinite poll loop
When the poll request fails (e.g. job not found 404), clear the activeJob
state and stop the interval instead of endlessly retrying. Also refresh
the KB detail to get the current state.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 16:08:21 -06:00
michael
42bf5ad003 Fix stuck processing state: auto-fail stale jobs, improve active job detection
- Frontend: only treat parsing_documents/distilling as actively running;
  pending jobs older than 2 minutes are ignored as stale
- Backend: add fail_stale_jobs() that marks pending/active jobs older than
  5 minutes as failed before checking for active jobs in trigger_processing
- Prevents UI from getting stuck on old jobs that never completed

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 16:03:25 -06:00
michael
0b7213af01 Fix doc ID mismatch in KB document upload
Create DB record first to get the auto-generated UUID, then use that ID
for the storage key. Previously a separate UUID was generated for storage
but the DB record got a different one, causing file retrieval to fail
during processing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 15:50:35 -06:00
michael
1601622e07 Fix SpecVersion/ProcessingJob circular relationship direction error
Remove bidirectional back_populates between SpecVersion and ProcessingJob
since both sides have FKs to each other (circular), causing SQLAlchemy to
see both as MANYTOONE. ProcessingJob.spec_version is now a standalone
relationship with explicit foreign_keys. SpecVersion no longer has a
reverse relationship to ProcessingJob (not needed for any queries).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 15:42:35 -06:00
michael
4833fa127d Fix SQLAlchemy ambiguous FK error between SpecVersion and ProcessingJob
Add explicit foreign_keys argument to both sides of the bidirectional
relationship to resolve the multiple FK paths (SpecVersion.processing_job_id
and ProcessingJob.spec_version_id).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 15:40:36 -06:00
michael
2c6f3d0686 Switch LlamaParse to llama-cloud SDK with agentic_plus tier
Replace deprecated llama-cloud-services package with llama-cloud>=1.0 (API v2).
Use AsyncLlamaCloud client with tier="agentic_plus" for maximum parsing accuracy
on complex layouts, tables, and visual structure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 15:29:23 -06:00
michael
9e2473c3e9 Add Knowledge Base management system for AI agent specs
Full-stack implementation enabling UI-driven management of the 5 AI agent knowledge bases
(Legal, Brand Barclays, Brand Barclaycard, Channel Best Practices, Channel Tech Specs).

Backend:
- 4 new DB models: KnowledgeBase, SourceDocument, SpecVersion, ProcessingJob
- Migration 006: creates tables, seeds 5 KB rows, imports existing prompts/*.md as v1 specs
- KnowledgeBaseRepository with full CRUD for all 4 tables
- LlamaParseService for document parsing, KnowledgeBaseService for pipeline orchestration
- ReferenceDocsService updated with DB-backed spec loading + cache invalidation
- 11 REST endpoints under /api/knowledge-base (list, detail, upload, delete, process, job status, versions, diff, activate)
- StorageService extended with KB document storage

Frontend:
- TypeScript types for all KB entities (KnowledgeBaseListItem, SourceDocument, ProcessingJob, SpecVersion, DiffResult)
- ApiService methods for all KB endpoints including multipart file upload
- KnowledgeBase component with 3-level UI: agent grid, detail view (documents + versions tabs), diff viewer
- Drag-and-drop file upload, processing progress bar with 3s polling, version comparison
- KnowledgeBaseIcon + Sidebar nav item with adminOnly filtering

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-12 15:00:36 -06:00
michael
2b2d82ecec Fix Resolutions tab Proof Name to use blue link styling
Change from plain black text (font-medium text-black-title) to blue
link styling (font-semibold text-active-blue), matching the Flags and
Errors tabs for visual consistency.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 14:09:19 -06:00
michael
220a97ab57 Wire up Errors tab in Auditing: auto-create ErrorItem on Analysis Error
- Create ErrorItem record when proof analysis results in "Analysis Error" status
- Add submitter_name/submitter_agency fields to ErrorItemResponse schema
- Eager-load proof creator and agency in error items query to avoid N+1
- Populate submitter fields from proof creator in the API route
- Update frontend ErrorItemResponse type and conversion to map submitter fields
- Fix ErrorsTable proof name styling to blue link (text-active-blue) matching Flags tab

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 13:55:16 -06:00
michael
9ec892b46b Fix flagging feature: blue link in Auditing, remove alert popup, show solid red flag icon
- Style Proof Name column in Auditing Flags tab as blue clickable link
- Replace browser alert() with in-app success message in flag modal that auto-closes after 2s
- Add filled prop to FlagIcon for solid red variant when flagged
- Thread flaggedItems from App → Campaigns → ProofDetailView → FeedbackReport
- Show solid red flag icon on SubReviewCard and LeadAgentSummary when agent has been flagged

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 13:46:15 -06:00
michael
33c2ce5cf4 Remove unused [Beta] tab from Settings page
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 12:07:12 -06:00
michael
cf29d70908 Hide Users tab in Settings since it's not connected to the app
The Settings > Users tab is a disconnected prototype that stores data
only in localStorage and is not used by any other part of the application.
Backend user management is handled separately via Azure AD auto-provisioning.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 11:40:41 -06:00
michael
a67236af73 Remove 'View Documentation' button from Hero section
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 11:33:15 -06:00
michael
a957cf0276 Pass proof metadata (channel, sub-channel, proof type) to AI agents during analysis
Previously, proof metadata collected during upload was only used for database
persistence. Now it flows through the entire analysis pipeline so agents can
tailor their feedback to the specific channel and format being reviewed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 11:30:38 -06:00
michael
adc7a2cc71 Update CampaignDetailView table text color from black to primary blue
Change all proof table body cells in the CampaignDetailView (analyzing,
error, and completed states) from text-black-title to text-primary-blue
to match the campaign list table styling.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 16:59:22 -06:00
michael
325221610f UI overhaul: white backgrounds, flat design, teal hero, sidebar flush-left nav
- Add teal-brand (#01A1A2) color to Tailwind config
- Hero: white bg, teal text, remove gradient circles/noise overlay, font-semibold
- Sidebar: stacked logo, lime COMPLIANCE AI, flush-left active items, remove blue dots
- ChecksOverview: remove gradient background and decorative blurs
- Campaigns: white bg, primary-blue table text, font-semibold headings
- Analytics: white bg, borderless shadow cards, sentence case headings
- Auditing: white bg, font-semibold heading
- Settings: white bg, remove tab container styling, flat cards, sentence case Proof types
- Profile: white bg, flat layout, active-blue question button, design system colors
- All page titles changed from font-bold to font-semibold

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 16:53:03 -06:00
michael
ebf92a91c7 Replace 'asset' with 'proof' in user-facing UI text
Update all user-visible strings across the frontend to use "proof/proofs"
terminology instead of "asset/assets". This includes button labels, headers,
tooltips, confirmation messages, and mock feedback text. Internal code
(variable names, types, HTML IDs) remains unchanged.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 15:45:48 -06:00
michael
35918dd310 Replace low-quality icons on Analytics page with Heroicons
- TrendingUpIcon: Changed to chart-bar icon for Pass Rate
- BugIcon: Changed to x-circle icon for Failed Reviews
- LightbulbIcon: Changed to proper light-bulb icon for Key Insight

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 15:30:18 -06:00
michael
b83a2a219f Adjust status pill padding: 0 top, 13px bottom
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 15:21:24 -06:00
michael
98633534ef Remove debug border and set bottom padding to 20px
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 15:18:47 -06:00
michael
24150ab221 Adjust padding to 2px top / 6px bottom to raise text
More bottom padding pushes text upward in the badge.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 15:16:49 -06:00
michael
ed040efac0 Add blue border to status badge to verify deployment
Testing if changes are being picked up correctly.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 15:15:25 -06:00
michael
8ba0f01e20 Use table/table-cell display for reliable vertical centering
Wrap text in nested spans using display: inline-table on outer
and display: table-cell with vertical-align: middle on inner.
This is a classic centering technique that html2canvas should handle.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 15:09:14 -06:00
michael
bfee60399c Try fixed height with matching line-height for vertical centering
Use height: 24px with line-height: 24px and no vertical padding.
This forces text to center vertically within the fixed height container.
Added box-sizing: border-box and vertical-align: middle for reliability.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 15:07:25 -06:00
michael
e071576765 Adjust padding to raise text in status pills (3px top / 5px bottom)
Text was sitting too low, reducing top padding and increasing bottom
to push text upward for visual centering.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 15:05:27 -06:00
michael
e68aab0d03 Correct padding direction - more top padding to push text down
Text was sitting too high, so need 5px top / 4px bottom to push
the text downward for visual centering.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 15:03:31 -06:00
michael
8dc3ef34b0 Fix PDF status pill vertical centering with asymmetric padding
Use 4px top / 5px bottom padding to compensate for Arial font metrics
where the visual center differs from mathematical center. The extra
bottom padding pushes the text up to appear visually centered.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 15:03:15 -06:00
michael
1799902448 Fix PDF status pill text centering for html2canvas
Replace flexbox-based centering (inline-flex, alignItems, justifyContent)
with explicit height + line-height matching (22px) for reliable rendering
in html2canvas. Flexbox properties don't render consistently when
converting HTML to canvas.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 14:54:48 -06:00
michael
5629d18df4 Fix email service crash when Mailgun not configured
Add validation to check MAILGUN_API_URL has a valid protocol prefix
and MAILGUN_API_KEY is set before attempting to make HTTP request.
Returns False gracefully with warning log instead of crashing with
httpx.UnsupportedProtocol error.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 14:40:42 -06:00
michael
c7228c95a2 Apply UI audit fixes for Barclays design guidelines compliance
- Update font config to prioritize Barclays Effra with Inter fallback
- Add "powered by OLIVER" text to sidebar branding
- Fix sidebar user profile button border radius to consistent 10px
- Update Hero "View Documentation" button to Active Blue outline style
- Remove legacy color definitions from Tailwind config

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 14:27:51 -06:00
michael
7698bbbd5a Apply Barclays brand colors to Projects.tsx and fix Sidebar corner radius
Updates Projects.tsx to use Barclays design system colors throughout:
- StatusBadge: bg-warning/bg-success/bg-warning-light/bg-grey-100
- OverallStatusBadge: bg-success/bg-error/bg-grey-300
- Tables: bg-lime headers, bg-grey-300 borders, even:bg-grey-100 rows
- Buttons: rounded-full pill shape, border-2 outlines
- Forms: rounded-[10px], text-black-title labels
- Hover states: hover:bg-info-light for row selection
- Delete modal: rounded-[10px], bg-error delete button

Updates Sidebar.tsx nav buttons from rounded-xl to rounded-[10px] per spec.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 14:19:15 -06:00
michael
0fdaedc7ff Complete UI design system migration to Barclays brand colors
Updates all remaining frontend components to use the new Barclays
design system color tokens:
- brand-dark-blue → primary-blue (#1A2142)
- brand-accent → active-blue (#006DE3)
- brand-light-blue → cyan-brand (#00AEEF)
- brand-gray → grey-100 (#F6F6F6)

Components updated:
- CampaignDetail and ProofDetailView in Campaigns.tsx
- Projects.tsx (full component migration)
- StatusDashboard.tsx (status tiles and colors)
- CreateProjectModal.tsx (modal styling)
- FeedbackReport.tsx (remaining brand colors)
- Login.tsx and Profile.tsx
- WIPReviewer.tsx and CopyGenAI.tsx
- Header, LoadingVisual, ToggleSwitch
- AssetPreview, ProofPreview, AssetUpload
- ProofTypeManager

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 14:00:13 -06:00
michael
75b2c6e699 Update modals and remaining UI components in Campaigns
- Update UploadProofModal with new design system colors
- Update LoadingCell progress bar to active-blue
- Update DeleteConfirmationModal with pill buttons and rounded corners
- Update CampaignDeleteConfirmationModal styling
- Apply consistent border radius (10px) to all modals
- Update drag & drop zone colors to use success theme

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 13:52:57 -06:00
michael
532d7541d6 Implement Barclays design system UI update
- Update Tailwind config with new color tokens (primary-blue, active-blue,
  electric-violet, lime, grey-100/300/700/900, success, warning, error)
- Add Inter font from Google Fonts as Barclays Effra alternative
- Update Sidebar with primary-blue background and white active state
- Update Hero with electric-violet accent and pill-shaped buttons
- Update all tables with lime (#C3FB5A) header backgrounds
- Implement alternating row colors (white/grey-100) on tables
- Update status badges: In Progress (amber), Completed (green)
- Update tabs with active-blue underline styling
- Apply 10px border radius to cards and containers
- Update button styling to pill-shaped with active-blue
- Update input/dropdown borders to grey-700 with 2px
- Update selected state highlighting to info-light (#E7F0FB)
- Update FeedbackReport RAG status colors to new design system

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 13:50:46 -06:00
michael
e5a841716e Add categorized issue display for revision analysis
When analyzing proof revisions (version > 1), SubReviewCard now displays
issues in three distinct categories: Resolved Issues (green, collapsed by
default), Outstanding Issues (amber), and New Issues (red). Each section
is collapsible with count badges. Original mode (version 1) maintains
backward compatibility with the single "Actionable Issues" list.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 10:39:42 -06:00
michael
bf1d689f42 Fix migration down_revision to correct revision ID
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 10:18:11 -06:00
michael
2f547dc494 Detect identical file uploads via MD5 hashing
- Add file_hash and is_identical_file columns to proof_versions table
- Compute MD5 hash on file upload and compare with previous version
- Display warning banner when uploading identical file as revision
- Return is_identical_file in WebSocket response and API endpoints

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 10:15:48 -06:00
michael
3a5c3bcde3 Implement revision-aware proof analysis pipeline
When a subsequent revision of a proof is uploaded, the analysis now takes
place in context of the previous version's results. The system identifies:
- Resolved issues: fixed in the new revision
- Outstanding issues: still present from previous version
- New issues: introduced in the new revision

Key changes:
- Add resolvedIssues, outstandingIssues, newIssues fields to SubReview
- Add PreviousReviewContext model for passing previous review data
- Update all specialist agents to accept previous_review context
- Extend GeminiService with include_revision_fields parameter
- Add get_latest_version_review() repository method
- Update LeadAgent to synthesize cross-version context in summary
- Fetch previous analysis in WebSocket handler for revisions

First version analysis continues to work exactly as before with revision
fields set to null.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 10:04:16 -06:00
michael
f13fa2f7e8 Parallelize specialist agent analysis with asyncio.gather
Run all 4 specialist agents (Legal, Brand, Channel Best Practices,
Channel Tech Specs) concurrently instead of sequentially. This reduces
total analysis time to roughly the duration of the slowest agent rather
than the sum of all agent times.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 09:13:15 -06:00
michael
8eac1f8492 Update Gemini model to gemini-3-pro-preview
Changed the AI model used for proof analysis from gemini-2.5-flash
to gemini-3-pro-preview for improved analysis capabilities.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 09:09:04 -06:00
michael
53351c86f3 Fix PDF pages route ordering for correct path matching
Move /files/{storage_key}/pages endpoint before the base /files/{storage_key}
endpoint so FastAPI matches the more specific route first.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 09:04:58 -06:00
michael
d97be02b0b Add PDF preview support with on-demand rasterization
- Backend: Generate PDF thumbnail from first rasterized page on upload
- Backend: Add /files/{storage_key}/pages endpoint for PDF rasterization
- Frontend: Add getPdfPages() method to apiService
- Frontend: Create usePdfPages hook for on-demand PDF page loading
- Frontend: Pass pdfPages prop to ProofPreview in Campaigns view

This fixes the issue where PDF uploads showed no visual preview in results.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 08:56:23 -06:00
michael
0bfe28af59 Add bullet style to actionable issues list in PDF export
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 08:31:24 -06:00
michael
bf22248025 Fix PDF export formatting by parsing HTML and bullet text
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 08:26:31 -06:00