Rebrands the product from MobilityOps to Fleet Ops across the UI, backend defaults and knowledge base, and makes nl-BE/en-GB/fr-BE full first-class languages: i18next with eager-bundled per-namespace resources, a persisted accessible language switcher (topbar and mobile drawer), locale-aware date/number formatting, and a coverage test that fails the build on any missing or empty translation key. Backend dynamic content (demo scenarios, blocked-reason text, integration status) moves from fixed English/Dutch prose to stable message codes + params so the frontend can localize it; the demo knowledge base gains a fully translated NL/EN/FR procedure corpus (11 documents each) with per-language retrieval and localized evidence-state messages. The Demo Guide becomes breakpoint-adaptive: a docked rail on extra-wide desktop, a floating panel that auto-collapses to a persistent, closable progress chip on standard desktop/tablet, and a collapsed/half/full bottom sheet on mobile -- with scroll+focus+ highlight on "go to this step", Escape handling, and reduced-motion support. The Data Quality Workbench gets accessible choice-card decisions with a clear primary/ secondary/tertiary action hierarchy; the Automation ledger groups repeated successes and uses meaningful short refs; the Audit trail groups events by correlation id with human action labels and readable before/after diffs. Attention Queue, Today's movements, Vehicles, Bookings and Data Quality rows are fully clickable (stretched-link pattern) with independent secondary links, keyboard support and mobile touch targets. Fixes a topbar overflow on mobile caused by the new language switcher (moved into the mobile drawer at <=960px) and two dangling aria-labelledby references introduced this session. Updates all affected Playwright specs for the new nl-BE default and the new Audit/DemoGuide DOM structure, and adds new i18n-coverage, demo-guide-adaptive and clickable-rows specs. 131 backend tests, Ruff and mypy, and 71 Playwright tests pass. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
60 lines
1.8 KiB
Python
60 lines
1.8 KiB
Python
from __future__ import annotations
|
|
|
|
import uuid
|
|
from typing import Literal
|
|
|
|
from fastapi import APIRouter, Depends
|
|
from pydantic import BaseModel, Field
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.api.deps import get_current_user, get_db
|
|
from app.schemas import CurrentUser
|
|
from app.services.audit import record_audit_event
|
|
from app.services.knowledge import GroundedAnswer, KnowledgeHealth, get_knowledge_provider
|
|
|
|
router = APIRouter(prefix="/api/v1/knowledge", tags=["knowledge"])
|
|
|
|
SupportedLanguage = Literal["nl-BE", "en-GB", "fr-BE"]
|
|
|
|
|
|
class AskQuestionRequest(BaseModel):
|
|
question: str = Field(min_length=3, max_length=1000)
|
|
language: SupportedLanguage = "en-GB"
|
|
|
|
|
|
@router.post("/questions", response_model=GroundedAnswer)
|
|
def ask_question(
|
|
body: AskQuestionRequest,
|
|
db: Session = Depends(get_db),
|
|
user: CurrentUser = Depends(get_current_user),
|
|
) -> GroundedAnswer:
|
|
correlation_id = str(uuid.uuid4())
|
|
provider = get_knowledge_provider()
|
|
answer = provider.ask(body.question, correlation_id, body.language)
|
|
|
|
record_audit_event(
|
|
db,
|
|
actor_type="user",
|
|
actor_label=user.display_name,
|
|
action="knowledge_question_asked",
|
|
entity_type="knowledge",
|
|
correlation_id=uuid.UUID(correlation_id),
|
|
metadata={
|
|
"evidence_state": answer.evidence_state,
|
|
"provider": answer.provider,
|
|
"source_ids": [s.document_id for s in answer.sources],
|
|
"question_length": len(body.question),
|
|
"language": body.language,
|
|
},
|
|
)
|
|
db.commit()
|
|
return answer
|
|
|
|
|
|
@router.get("/status", response_model=KnowledgeHealth)
|
|
def knowledge_status(
|
|
language: SupportedLanguage = "en-GB",
|
|
_user: CurrentUser = Depends(get_current_user),
|
|
) -> KnowledgeHealth:
|
|
return get_knowledge_provider().health(language)
|