ai-powered-conversational-intelligence

Frontend features — invariants and limitations

The React dashboard: the UI redesign, role-based navigation, the chat workspace’s panels, charting, and the analysis artifact workspace.

Moved verbatim out of the root CLAUDE.md. The recurring rule across all of it: no UI-level restriction is a security boundary — every one is UX only, and the server re-checks every request.

Contents


Frontend UI redesign (2026 UI pass)

A ground-up-in-appearance, additive-in-substance redesign of frontend/ into a left-sidebar/main-workspace layout. Invariant that must not regress: no backend logic, API contract, auth flow, SQL validation, or chat-persistence behavior changed as part of this pass or its two follow-up bug-fix passes (duplicated Settings/Sign-out controls; a dark-mode-only modal-transparency bug from an inherited “glass” CSS token) — every change is presentation/interaction layer only.

Read, per topic:

Responsive layout and the conversation reading column

A later, presentation-only pass over the same shell: the conversation now has one reading measure — --chat-column (48rem), surfaced as the max-w-chat utility — shared by the turns, the composer and the shared read-only view, with the avatar-width pl-10 insets removed so a question, its answer and the composer line up on one pair of edges. The shell adapts at sm/lg/xl: the composer’s controls drop below the textarea on a phone, the sidebar appears at lg, and QuestionNavigator’s flyout widens by breakpoint (its right-edge rail is present at every size, clamping the panel to the viewport on a phone). That flyout expands on hover and collapses when the pointer leaves, after a short grace period that keeps it from flickering shut mid-travel; touch users tap the rail icon to open it and tap outside to dismiss.

Invariant: the same one as the redesign above — no backend logic, API contract, auth flow, SQL validation or chat-persistence behavior changed; /ask → “Confirm and Run” → governed execution is untouched.

Authoritative: docs/ui-responsive-layout.md — the measure, what shares it, the per-breakpoint table, how it was measured across ten viewport widths, and what that verification does not cover (no real devices, no touch or on-screen-keyboard behaviour).

Analytics & Insights panels in the answered turn (Prompt 30)

No new page: the analysis renders under each answered question’s insight in TurnCard.tsx (frontend/src/components/analytics/AnalyticsSummary.tsx), gated like the insight itself (after “Confirm and Run”, and only while the SQL box still holds the SQL that produced the answer). It is lazy-loaded like ChartSection, so Chart.js stays out of the main bundle – do not statically import any analytics panel from TurnCard.tsx.

It renders only from already-computed backend state and never recomputes a statistic. AskResponse gained four additive pass-through fields (analytical_intent, analytical_plan, governing_metrics, restricted_field_notice); ExecuteResponse.cache_status mirrors the X-Cache header into the JSON body. The restricted notice is a presentation translation of an existing failure category; the restricted-column gate and its retry behavior are unchanged.

Every database-originated label goes through lib/analyticsCharts.ts’s sanitizeLabel before it is shown or fed into a drill-down question (master rule 8). Every claim shows its truth level (TruthLevelBadge). Charts reuse ResultChart/PreparedChart; no second chart engine.

Known gaps (see the contract for detail): reloaded past turns show no analysis (analytics fields are not in persisted message metadata); cache_status is session-only; visualization_spec is still not consumed; root-cause attribution is not wired into the live graph; query scope is read-only.

Read 30_ANALYTICS_INSIGHTS_DASHBOARD_CONTRACT.md for the full prompt text and outcome summary.

Recommendation & action dashboard (Prompt 31)

frontend/src/pages/Recommendations.tsx (route /recommended-actions, not /recommendations, which is the API list path; nav tab shown by the server’s navigation policy) is the reviewer-facing surface over the governed recommendation APIs from Prompts 18/31. Read 31_RECOMMENDATION_ACTION_DASHBOARD_CONTRACT.md before changing it.

Invariants that must not regress:

Known gaps: local accounts only (require_local_user); the list is capped at 200 with no pagination; owner changes are last-writer-wins; the rate limit is per IP.

Role-based navigation, server-driven access & the onboarding→SME bridge (Prompt 32)

32_ROLE_BASED_NAVIGATION_CONTRACT.md is the full record. The short version a future session needs:

Known gaps: a “Confirm and run” button is shown to any user who can ask a question, including a viewer who lacks execute_sql; the server refuses it, but the button is not gated on the capability yet. The “viewer” role has no screen of its own: “read-only viewer” maps to auditor. Browser-level end-to-end tests are not part of the project (no Playwright); the journey test is at the HTTP API layer.


Conversational Intelligence UI (chat workspace, 2026-10)

Ten UI capabilities were requested for the chat workspace. The audit found four already complete (QuestionNavigator, the analytics workspace, the evidence panel, and the conversation list/search half of context management) and three more existing in parts. This pass added what was missing and consolidated what was scattered – nothing that already worked was rebuilt.

The one genuinely missing piece of data: agent.nodes._timed_node has always recorded a per-node StageTiming into AgentState["stage_timings"], and observability/metrics.py aggregates it – but it was never exposed, so the UI could show retry outcomes (RetryTimeline) and never where the time went. AskResponse .stage_timings now carries it (new StageTimingOut, additive and optional, defaulting to []), feeding chat/AgentExecutionTimeline.tsx. No new instrumentation: the data was being discarded.

New components: chat/AgentExecutionTimeline.tsx (per-stage durations, aggregated across retried calls, in pipeline order – later given per-stage status and made the single stage-level surface, see “Agent execution timeline” below), sql/ExecutionStatusBar.tsx (one scannable badge row for validation / retries / cost / rows / truncation / duration / cache / governance), sql/SqlIntelligencePanel.tsx (one expander replacing four siblings), chat/FollowUpSuggestions.tsx, chat/ConversationContextPanel.tsx, chat/ArtifactWorkspace.tsx + PinTurnButton.

Invariants that must not regress:

A pre-existing flake fixed in passing: TurnCard.analytics.test.tsx races the lazily-loaded analysis section because CodeMirror throws while measuring in jsdom (textRange(...).getClientRects is not a function). It failed intermittently before this pass too – verified by stashing the changes and reproducing – and a heavier TurnCard made it trip more often. The editor is now stubbed in that one file, which tests the analysis section, not the editor. A second flake remains open and is not mine: src/pages/TenantAdmin.test.tsx fails intermittently under full-suite parallel load while passing 3/3 standalone; that file and its page were untouched.

Known limitations: pinned artifacts and the context panel are session-scoped like queryHistory itself (persisting artifacts would need a server-side artifact store); the lineage link opens the explorer without pre-seeding a database, because that page resolves its own selection.

SQL Intelligence Panel refinement (same pass). The panel now owns everything about a turn’s SQL behind one progressive disclosure: collapsed it reads SQL • Validated • 42 rows; expanded it holds the SQL itself, Confirm and Run, a metadata grid (statement type, tables referenced, database, model, attempts, rows, duration), the plan, governed metrics, retrieved schema and the lineage link. It replaced five sibling expanders.

Already present, so deliberately not rebuilt: CodeMirror with @codemirror/lang-sql gives SqlEditor syntax highlighting; ui/CopyButton inside it already provides Copy SQL (navigator.clipboard.writeText only); and EditorView.lineWrapping already keeps long SQL usable. No highlighter, clipboard helper or second code-presentation mechanism was added.

New: AskResponse.sql_summary (optional, null when absent) from a new pure agent.sql_validator.summarize_sql, carrying statement_type and referenced_tables. Those are the two facts the UI had no accurate source for: the statement type is read from the parsed AST (a leading comment or a WITH prefix cannot mislabel it), and the referenced tables are not schema_tables – those are the top-k candidates retrieval offered, commonly a superset of what the query uses, so labelling them “tables referenced” would be wrong. It reuses the same parse and the same CTE-aware filtering find_unexpected_table_references already performs, and gates nothing.

Invariants that must not regress:

A real bug mypy caught that the tests did not: _sql_summary_out passed the whole DatabaseConnectionConfig to get_sqlglot_dialect, which takes db_type: str. At runtime that returns None – sqlglot’s generic dialect – and T-SQL does not parse under the generic dialect, so every SQL Server query (all four configured databases here) would have returned sql_summary: null. The existing tests passed because an ordinary ANSI SELECT parses either way. Fixed, and pinned by a mutation-tested regression (SELECT TOP 10 name FROM [dbo].[Employee]). Worth remembering when resolving a dialect anywhere: pass config.db_type, not the config.

A caveat recorded here earlier has since resolved: at the time of the SQL-panel commit, npm run build (tsc -b && vite build) failed on src/components/chat/QuestionNavigator.test.tsx, which carried an unused variable from a parallel session’s in-progress edit in the same working tree (left untouched rather than fixed mid-edit; npx vite build was used instead). That edit has since been completed and the full npm run build now passes.

Query lifecycle rail (same pass). sql/QueryLifecycle.tsx is one compact row saying how far a question got and where it stopped: ✓ Understanding ✓ Schema ✓ SQL ✓ Validation ✓ Cost check ● Ready to run ○ Execution. Three run-related surfaces already existed and none answered that question – RetryTimeline answered “what happened on each attempt” (since replaced, see “Agent execution timeline” below), AgentExecutionTimeline “which stage was slow”, ExecutionStatusBar “can the result be trusted”.

Invariants that must not regress:

There is no streaming, so this is final-state rendering. POST /ask is a single request returning once the graph has finished; there is no SSE/WebSocket endpoint anywhere in api/, so no “currently on stage N” signal exists mid-run. running is used only where genuinely observable: the user’s own Confirm and Run. deriveLifecycle takes exactly one required argument – the completed response – which is the structural form of that statement. The in-flight /ask phase keeps PendingTurn’s “Thinking Ns…” badge; a rail with a guessed active stage was considered and rejected. Zero backend changes were needed – stage_timings and attempt_history already carried everything.

Evidence status on every claim (same pass). Three of the five labels the brief named already existed in TruthLevelBadge (Computed from data/Approved definition/AI estimate) and ~12 analytics panels already rendered one. Two did not exist at all (Source-backed, Not available), and two prominent claims carried no label whatsoever: the insight narrative (a sparkle box) and a document/policy/web answer. EvidencePanel was also, despite its name, a recommendations panel.

Invariants that must not regress:

One additive backend field, AskResponse.insight_numbers_checked. The UI could have asserted “numbers verified” from the server’s drop-if-ungrounded behaviour alone, but that makes the claim an assumption about server control flow that a future change would falsify silently. null/0/n are three different statements and the UI says three different things: nothing about verification / “states no figures of its own” / “n figures were checked against the 42 returned rows”. The count is len(extract_numbers(text)) taken after grounding passed, so it is exactly the count verified – confirmed against the real functions (2, 1, 0 for three realistic insights).

Analysis artifact workspace (same pass). The one part of this series that needed persistence. A session-only pinned worklist already existed (pinnedEntryIds on chatStore); it could not carry a source id, a timestamp, lineage, a result reference, tenant ownership, or anything to refresh, so a real analysis_artifacts table now sits behind the same control. New artifacts/ (pure: models.py, staleness.py, policy.py), identity/repositories/artifacts.py, api/artifacts.py (5 routes), migration p8t1u4v7w0x3.

Invariants that must not regress:

Known limitations: local accounts only (require_local_user) – the same limitation chat history itself has; without one the control falls back to the pre-existing session pin and the panel says so. Soft delete only, capped by ARTIFACT_MAX_PER_USER (a further save is refused, never a silent eviction). Schema-change detection reads the schema index’s own manifest, so a change nothing has discovered yet is invisible. The refreshed result renders as a table in the panel; the original capture does not (it already renders in the turn the artifact points at).

Follow-up recommendation chips (“Ask next”)

RecommendationKind.NEXT_QUESTION and the chip component (chat/FollowUpSuggestions.tsx) both already existed. What did not was a producer: the only two anywhere in this codebase were analytics.forecasting.recommendations_for_forecast and analytics.scenario.recommendations_for_scenario, and both are disclosed above as not wired into any live path, while recommendation.engine itself produced zero. The chips were real UI over a permanently empty list – in the live /ask pipeline they never rendered at all. recommendation/followups.py is that missing producer.

It produces candidates, not Recommendations: recommendation.engine._finalize_candidate stays the single construction point, so the evidence floor, the confidence floor (RECOMMENDATION_MIN_CONFIDENCE) and the restricted-column authorization gate all apply to a chip exactly as to any other rule. The engine runs it last, so every real finding stays ahead of every chip.

Everything a chip is grounded in is a fact the request already computed – no new query, no vector lookup, no LLM call. Result shape and findings from analytics.engine (a RANKING finding’s own DATABASE_FACT claim is reused verbatim as the evidence for “Top 5”, a GROWTH finding’s for a period comparison); the introspected DDL of the tables retrieval already selected; and governing_metrics/ governing_dimensions, which are CONFIRMED_BUSINESS_TRUTH published catalog entries. extract_governing_dimensions (Prompt 37, until now with no live caller) finally has one. The question and the conversation are used only to suppress a repeat – user input is never evidence.

Invariants that must not regress:

Reuse rather than a second parser: db.schema_introspection .extract_ddl_column_types is new, sharing extract_ddl_column_names’ own line-skipping rules, and agent.plan_validator._column_type_family was refactored onto it – one DDL type lookup in this codebase, not two.

Four real bugs its own tests and the type checker caught: the cap was checked after appending, so MAX_FOLLOW_UP_SUGGESTIONS=0 still leaked one chip; the same column was offered twice under two names; an exhaustive-equality test pinned the category enum to nine (working as designed); and Record<RecommendationCategory, string> in lib/recommendationDisplay.ts stopped compiling until the new category had a label.

Known limitations: chips need the analytics engine on (ENABLE_ANALYTICS_ENGINE) – result shape is a required grounding input. A dimension candidate is any non-key text-family column, since DDL carries no cardinality, so a high-cardinality text column can be offered. Questions are templated, not LLM-phrased – deliberate (no new LLM call, and determinism), at the cost of some naturalness. A reloaded past turn shows no chips, since recommendations are not in the persisted message metadata (the same disclosed limitation the analytics panels carry).

Read docs/conversational-intelligence-ui.md for the feature-by-feature audit table, the API change, the accessibility/performance/security review and the full test counts.

Agent execution timeline (stage-level status)

chat/AgentExecutionTimeline.tsx is the one stage-level record of a run: collapsed it reads Agent completed • 2.75s in 7 stages • 1 retry; expanded it lists each stage that did something, with ✓ / ↻ / ✗, its duration, its call count, and – for the stage that stopped the run – a user-safe sentence. It began as a duration-only bar chart with mechanical labels (“Generate sql”); this pass gave it status, retries, failure reasons and readable operational labels.

Per-stage status is recorded by the server, not re-derived by the client. agent.state.StageTiming gained outcome (ok/error/no_op) and error_category, set by agent.nodes._stage_outcome from the dict that node itself returned. Reading the merged state instead would blame the wrong node: last_error_category persists across a retry, so generate_sql’s second attempt would inherit validate_sql’s first-attempt violation. No new instrumentation – _timed_node already computed both values for its [trace] line and discarded them. A node that raises appends no timing at all, so a record’s presence already means “this call completed”.

Invariants that must not regress:

A real bug this found and fixed. The graph registers add_node("estimate_cost", ...) but the node was decorated @_timed_node("estimate_query_cost") – the only one of eighteen where the two identifier spaces disagreed. docs/ARCHITECTURE.md had disclosed that as harmless, correctly so when written; it stopped being harmless once QueryLifecycle began deciding which stage a run reached by matching stage_timings[].stage against node keys, which silently meant its always-visible “Cost check” chip could never read as reached on any run, however long cost estimation actually took. Its own tests passed because their fixtures used the node name, not the label the server actually records – the test encoded the same assumption as the code. Renamed to the single canonical node key, and tests/test_agent_nodes.py::TestStageTimingLabels now pins every _timed_node label to a real graph node name, comparing the two spaces against each other rather than against a hand-written list.

Known limitations: the 18 stage labels are English-only, as the mechanical labels they replaced were (the panel’s own chrome is translated), with a derived fallback so a newly added node still gets a readable label rather than a raw identifier; and a turn reconstructed from saved chat history shows no timeline, since stage_timings is not persisted – the same disclosed gap the lifecycle rail already has.


SQL structural description in the query-metadata grid (2026-10-17)

SqlIntelligencePanel.tsx showed what SQL was generated and whether it validated; nothing said how the tables were joined, what was filtered, what was aggregated, or at what grain. Six rows now join the existing metadata grid — Joins, Filtered on, Aggregates, Grouped by, Ordered by, and Duplicate rows (rendered only when DISTINCT is applied) — alongside the Statement type and Tables referenced rows that were already there. No new component, and each row is omitted when the statement has nothing to say for it, so a simple query does not render six empty rows.

The server returns structured facts; the frontend owns the prose. The fields on SqlSummaryOut are lists of identifiers and a boolean, and the labels come from i18n keys added to all five locales (sqlPanel.joins, filterColumns, aggregates, groupBy, orderBy, distinct, distinctRemoved). English prose from the server would have made the feature untranslatable in a five-locale app — the same reason the stage labels in the execution timeline are the exception that gets called out rather than the rule.

What the panel deliberately cannot show, because the server does not send it: no row limit (the TOP n in the SQL is this platform’s governance cap, not the query’s intent), no business interpretation of the grain, and no filter values — column names only, since a predicate can carry data and this grid is rendered and may be logged. Full rationale: ../API.md under POST /ask.

It gates nothing. The description is read from the same AST validate_sql already parsed, so it cannot invent a join, but it is also not a verdict: agent/sql_validator.py remains the only thing that decides whether SQL may run, and a backend test asserts validate_sql still rejects DELETE while describe_sql happily describes it.


Accessibility: static lint plus runtime axe checks (2026-10-17)

The UI had aria labels, focus management and responsive layout throughout, and 53 of 88 test files already queried by role or label — but nothing asserted any of it stayed true. Two layers now do, and they catch genuinely different things.

Static. oxlint 1.82 already shipped a jsx-a11y plugin that was simply not enabled — frontend/.oxlintrc.json listed only react, typescript and oxc. Enabling it cost zero dependencies and surfaced 28 findings.

Runtime. frontend/src/test/axe.ts wraps axe-core — Deque’s own engine, a dev dependency only and unreachable from the app entry, so Vite cannot bundle it. It was chosen over the vitest-axe matcher deliberately: that package is 0.1.0, last modified January 2025, and is a thin wrapper around this same engine, so for a repository that digest-pins base images and justifies every CVE ignore individually, depending on the maintained first-party engine and writing the fifteen-line matcher ourselves is the cheaper long-term position. frontend/src/components/ui/accessibility.test.tsx runs it against shared primitives, an open dialog and a chat message.

The runtime layer is what proved three static rules were false positives, which is why they are off with evidence rather than for noise. jsx-a11y/label-has-associated-control, jsx-a11y/heading-has-content and jsx-a11y/prefer-tag-over-role cannot see text nested two levels deep, nor know that children exist: ShareModal’s access-mode radios (a <label> wrapping an input plus nested spans) and card.tsx’s CardTitle (<h3 {...props} />, taking content via children) both render with no violation — while a genuinely empty <h3 /> is still caught, so the engine is not merely permissive.

Non-vacuity is proven, not assumed. One test renders an icon-only button with no accessible name and asserts axe reports button-name, so if axe ever stopped running, that test fails instead of silently passing.

Known limitations, stated because they bound the claim: