Add answer-first self-serve search UX

This commit is contained in:
master
2026-03-07 01:21:14 +02:00
parent 107d38a3be
commit 803940bd36
15 changed files with 1536 additions and 6 deletions

View File

@@ -172,6 +172,8 @@ Global search now consumes AKS and supports:
- Doctor: `Run` (navigate to doctor and copy run command).
- `More` action for "show more like this" local query expansion.
- A shared mode switch (`Find`, `Explain`, `Act`) across search and AdvisoryAI with mode-aware chip ranking and handoff prompts.
- An answer-first FE shell: every non-empty search renders a visible answer state (`grounded`, `clarify`, `insufficient`) before raw cards, using existing synthesis/cards plus page context until a backend `contextAnswer` payload is introduced.
- Page-owned self-serve questions and clarifiers, defined in `docs/modules/ui/search-self-serve-contract.md`, so search can offer "Common questions" and recovery prompts without per-page conditionals in the component.
- Zero-result rescue actions that keep the current query visible while broadening scope, trying a related pivot, retrying with page context, or opening AdvisoryAI reformulation.
- AdvisoryAI evidence-first next-step cards that can return search pivots (`chat_next_step_search`, `chat_next_step_policy`) back into global search or open cited evidence/context directly.
- Search-quality metrics taxonomy is standardized on `query`, `click`, and `zero_result` event types (no legacy `search` event dependency in quality SQL).

View File

@@ -4,6 +4,8 @@
- `docs/implplan/SPRINT_20260221_041_FE_prealpha_ia_ops_setup_rewire.md`
- `docs/implplan/SPRINT_20260306_001_Web_contextual_search_suggestions.md`
- `docs/implplan/SPRINT_20260306_002_FE_search_advisory_quality_ux.md`
- `docs/implplan/SPRINT_20260307_004_FE_self_serve_search_answer_first.md`
- `docs/implplan/SPRINT_20260307_006_FE_self_serve_rollout_and_gap_closure.md`
## Delivery Tasks
- [DONE] 041-T1 Root IA/nav rewrite (Mission Control + Ops + Setup)
@@ -28,6 +30,16 @@
- [DONE] FE-UX-003 Zero-result rescue and reformulation UX
- [DONE] FE-UX-004 AdvisoryAI evidence-first next-step cards
- [DONE] FE-UX-005 Docs sync and rollout notes for search/advisory quality UX
- [DONE] FE-SELF-001 Page-owned self-serve search contract
- [DONE] FE-SELF-002 Answer-first search panel
- [DONE] FE-SELF-003 Common questions and follow-up questions
- [DONE] FE-SELF-004 Self-serve verification and behavior hardening
- [DONE] FE-SELF-005 Docs sync and rollout guidance for self-serve search
- [TODO] FE-ROLL-001 Priority page self-serve rollout
- [TODO] FE-ROLL-002 Guided action handoffs
- [TODO] FE-ROLL-003 Telemetry-driven self-serve gap review UX
- [TODO] FE-ROLL-004 Full operator-journey Playwright coverage
- [TODO] FE-ROLL-005 Docs and rollout readiness
- [DONE] WEB-CTX-E2E Playwright coverage for contextual suggestions + ambient last-action payload
- [DONE] FE-UX-E2E Playwright coverage for mode switching, rescue flows, and AdvisoryAI next-step cards
- [DONE] WEB-CTX-NONOBVIOUS Strategic non-obvious suggestion recipes (cross-domain + action-aware)

View File

@@ -199,11 +199,13 @@ Each feature folder builds as a **standalone route** (lazy loaded). All HTTP sha
* **Strategic non-obvious suggestions**: each page scope injects at least one cross-domain guidance query (for example, findings -> policy/VEX impact, policy -> impacted findings, doctor -> release blockers) and switches to action-aware variants after meaningful user actions.
* **Explainable chips**: suggestion queries remain short and executable, while a separate rationale line explains whether a chip comes from page defaults, recent actions, or strategic cross-domain guidance.
* **Shared operator modes**: global search and AdvisoryAI share one persisted mode state (`Find`, `Explain`, `Act`) via `SearchExperienceModeService`; the mode changes chip ordering, Ask-AI prompts, empty-state starters, and structured next-step behavior.
* **Answer-first search**: every non-empty search renders a visible answer panel before raw cards; the panel must resolve to `grounded`, `clarify`, or `insufficient` and never leave the operator with an unexplained blank result area.
* **Page-owned self-serve questions**: priority pages define common questions and clarifying prompts in the shared search context registry; empty-state search uses those as "Common questions" and answer states reuse them as follow-up or clarification buttons.
* **Zero-result rescue loop**: no-result states must expose recovery actions for broadening scope, trying a related pivot, retrying with page context, and opening AdvisoryAI reformulation with the active mode and query context preserved.
* **Search-surface focus rule**: focus movement into controls inside the global-search surface (mode buttons, scope toggle, rescue buttons, filters) must not collapse the panel; the surface behaves like one command workspace rather than a disposable tooltip.
* **AdvisoryAI next-step cards**: assistant responses with citations render structured cards for evidence inspection, context navigation, deeper search, and policy pivots; search-return actions must emit deterministic `chat_next_step_*` metadata back into global search.
* **Ambient payload activation**: each global search request sends ambient context (`currentRoute`, `visibleEntityKeys`, `recentSearches`, `sessionId`, optional `lastAction`) so AdvisoryAI can apply contextual ranking/refinement.
* **Chip contract governance**: page-owned chip arrays and route mappings are defined by `docs/modules/ui/search-chip-context-contract.md` and implemented in `search-context.registry.ts`.
* **Contract governance**: page-owned chip arrays follow `docs/modules/ui/search-chip-context-contract.md`, while answer-first self-serve questions and fallback states follow `docs/modules/ui/search-self-serve-contract.md`; both are implemented in `search-context.registry.ts`.
* **Fallback transparency**: when unified search drops to legacy fallback, global search displays an explicit degraded banner and emits enter/exit telemetry markers for operator visibility.
---

View File

@@ -8,7 +8,8 @@ Provide a living plan for UI deliverables, dependencies, and evidence.
- Update this file when new scoped work is approved.
## Near-term deliverables
- TBD (add when sprint is staffed).
- `SPRINT_20260307_004_FE_self_serve_search_answer_first.md` - answer-first search shell, page-owned self-serve questions, and explicit fallback states.
- `SPRINT_20260307_006_FE_self_serve_rollout_and_gap_closure.md` - page rollout, guided handoffs, and telemetry-driven gap closure.
## Dependencies
- `docs/modules/ui/architecture.md`

View File

@@ -4,6 +4,7 @@
- Define one deterministic contract for page-aware search chips.
- Let feature teams add page suggestions without editing `AmbientContextService` logic.
- Blend route context, last few page actions, and bounded suggestion randomization.
- Answer-first self-serve questions and fallback states are governed separately in `docs/modules/ui/search-self-serve-contract.md`.
## Rule (mandatory for page teams)
- Every page that needs custom search chips must declare a context entry in `SEARCH_CONTEXT_DEFINITIONS`.

View File

@@ -0,0 +1,65 @@
# Search Self-Serve Contract
## Purpose
- Define the page-owned contract for answer-first search.
- Ensure every high-value page can expose common operator questions and clarifying prompts without editing `GlobalSearchComponent`.
- Keep the self-serve experience deterministic, evidence-first, and testable.
## Rule (mandatory for page teams)
- Every page that wants answer-first self-serve behavior must declare `selfServe` metadata in `SEARCH_CONTEXT_DEFINITIONS`.
- Page components should continue to implement `SearchContextComponent` so ownership remains explicit.
- `selfServe` definitions must provide one or both of:
- `commonQuestions[]`
- `clarifyingQuestions[]`
- Question entries must provide:
- `key` / `fallback` for the executable question text
- optional `kind` (`page`, `clarify`, `recent`)
- optional `preferredModes` (`find`, `explain`, `act`)
- Question arrays must stay deterministic and bounded:
- at most 3 base common questions per page
- at most 2 base clarifying questions per page
- concise, operator-facing wording
- no tenant secrets or volatile IDs in fallback copy
## Answer-first UX contract
- Every non-empty search must render one visible answer state before raw results:
- `grounded`
- `clarify`
- `insufficient`
- `grounded` states must expose visible evidence summary plus citations or top-result references.
- `clarify` states must offer narrowing questions instead of a blank panel.
- `insufficient` states must explain the lack of grounding and still provide credible next questions or next searches.
## Runtime behavior
- Empty-state search uses `commonQuestions[]` for page-owned "Common questions".
- The active mode (`Find`, `Explain`, `Act`) reorders questions via `preferredModes`.
- A recent-action question may be prepended from the latest meaningful page action:
- `Find` -> related discovery question
- `Explain` -> why-it-matters question
- `Act` -> what-to-do-next question
- Result-state answer panels use:
- `commonQuestions[]` as follow-up questions when grounded evidence exists
- `clarifyingQuestions[]` when no grounded answer exists
- "Search next" remains driven by contextual chip logic so pages do not need to define a second parallel action system.
## Source of truth
- Page registry and interfaces:
- `src/Web/StellaOps.Web/src/app/core/services/search-context.registry.ts`
- Runtime composition:
- `src/Web/StellaOps.Web/src/app/core/services/ambient-context.service.ts`
- Search surface:
- `src/Web/StellaOps.Web/src/app/layout/global-search/global-search.component.ts`
## Testing requirements
1. Add unit coverage for route-specific questions in `ambient-context.service.spec.ts`.
2. Add unit coverage for answer-state rendering in `global-search.component.spec.ts`.
3. Add Playwright coverage for:
- grounded answer
- clarify recovery
- answer-to-AdvisoryAI handoff
4. Keep route and API behavior mocked/deterministic; no live network dependencies.
## Relationship to chip contract
- `search-chip-context-contract.md` still governs contextual chips and route-suggestion behavior.
- This document governs answer-first questions and fallback states.
- Page teams adding self-serve behavior usually need to update both contracts together.