ui: re-enable advanced-mode ambient assistance (ADR-0022 Amendment 1)
Advanced-mode hinting + completion-preview were dead: render_hint_panel returned None for advanced mode (stale ADR-0022 §12 gate, predating the SQL grammar) and the hint resolver/ambient_hint never threaded Mode, so a SQL statement was gated as "this is SQL". The unified walker (ADR-0030/ 0031/0032) speaks SQL, so this lifts the gate. - ambient_hint_in_mode + hint_resolution_at_input_in_mode + expected_for_hint_snapshot(mode); candidate/diagnostic/parse sub-calls run in the active mode. - render_hint_panel calls ambient for all modes; one-shot `:` sigil stripped (strip_one_shot_prefix) so `: sel` hints `select`. - ADR-0022 Amendment 1 + README index. Found by manual advanced-mode testing; Phase 2 marked SQL hint/completion green at the engine layer but never exercised the UI. App-level render test (advanced_mode_hint_panel_surfaces_sql_candidates) + ambient-layer regression locks. 1466 baseline green.
This commit is contained in:
@@ -368,6 +368,87 @@ If profiling later shows render-loop pressure, options are
|
||||
(b) lex+parse only on input change, not every render. Both
|
||||
are local optimisations; not part of this ADR.
|
||||
|
||||
## Amendment 1 — Advanced-mode ambient assistance re-enabled (2026-05-21)
|
||||
|
||||
This amendment **supersedes §12's carve-out** that ambient
|
||||
typing assistance is a simple-mode-only feature.
|
||||
|
||||
### The obsolete premise
|
||||
|
||||
§12 disabled ambient assistance in advanced mode because, at the
|
||||
time, "the DSL lexer + parser don't speak SQL; using them for SQL
|
||||
input would mark almost everything as Identifier/Error and
|
||||
mislead." That premise no longer holds. ADR-0030 / ADR-0031 /
|
||||
ADR-0032 moved the SQL surface into the **same unified, mode-aware
|
||||
walker grammar** (ADR-0023 / ADR-0024). The walker now speaks SQL:
|
||||
in `Mode::Advanced` it parses `SELECT` (and, from ADR-0033, DML),
|
||||
highlights SQL keywords, resolves slot hints, and produces
|
||||
completion candidates — exactly the inputs ambient assistance
|
||||
needs.
|
||||
|
||||
### The bug this fixes
|
||||
|
||||
Despite the walker being mode-aware, the **UI never surfaced**
|
||||
advanced-mode ambient assistance:
|
||||
|
||||
- `render_hint_panel` hard-returned `None` for advanced mode (the
|
||||
stale §12 gate), so the hint panel showed only `panel.hint_empty`
|
||||
— no prose hints and no candidate preview for SQL.
|
||||
- The hint resolver (`hint_resolution_at_input` →
|
||||
`expected_for_hint_snapshot`) and `ambient_hint` never threaded
|
||||
the mode, so even the engine-level calls defaulted to
|
||||
`Mode::Simple` and gated a SQL statement as "this is SQL".
|
||||
|
||||
The result: in advanced mode, hinting and completion-preview for
|
||||
SQL were completely dead, even for a bare `SELECT`.
|
||||
|
||||
This gap survived Phase 2 because ADR-0032's cross-cut matrix rows
|
||||
for "Tab completion works for SQL keywords" / "Hint-panel prose
|
||||
appears at every SQL slot" were validated by **engine-level** tests
|
||||
(`completion_probe_in_mode(…, Advanced)`, `hint_mode_*` called
|
||||
directly) — which prove the walker *can* produce SQL
|
||||
hints/candidates but never exercise the UI that suppressed them.
|
||||
This is the "free-for-free claim shipping without a real-app test"
|
||||
failure mode the project's process pins call out.
|
||||
|
||||
### What changed
|
||||
|
||||
- **`ambient_hint_in_mode(input, cursor, memo, cache, mode)`** —
|
||||
the mode-aware ambient entry point. `ambient_hint` is now a thin
|
||||
wrapper that forwards `Mode::Simple`. Its sub-calls
|
||||
(`input_diagnostics_in_mode`, `hint_resolution_at_input_in_mode`,
|
||||
`candidates_at_cursor_in_mode`, the fallback `parse_command_in_mode`)
|
||||
all run in the supplied `mode`.
|
||||
- **`hint_resolution_at_input_in_mode` + `expected_for_hint_snapshot`**
|
||||
now set `ctx.mode`, so the hint walk respects the active mode.
|
||||
- **`render_hint_panel`** calls `ambient_hint_in_mode` with the
|
||||
effective mode for *all* modes (no more advanced-mode `None`).
|
||||
- **One-shot `:` handling.** In one-shot advanced mode the raw
|
||||
input carries the `:` sigil, which is not part of the grammar.
|
||||
The panel strips it (mirroring `App::submit`) before the ambient
|
||||
walk, so `: sel` hints `select` rather than the sigil.
|
||||
|
||||
### What still holds
|
||||
|
||||
- **Simple mode is unchanged.** The simple-mode entry point keeps
|
||||
gating SQL as "this is SQL"; advanced assistance is opt-in via
|
||||
mode, never leaked into simple mode (regression-locked).
|
||||
- **Syntax highlighting** already ran with `Mode::Advanced` and is
|
||||
unaffected.
|
||||
- **The validity indicator** was already mode-aware (ADR-0032
|
||||
§10.6); this amendment aligns the ambient hint panel with it.
|
||||
- **§13 performance posture** is unchanged — one walk per render,
|
||||
now in the active mode.
|
||||
|
||||
### Coverage
|
||||
|
||||
App-level regression at the layer Phase 2 missed:
|
||||
`src/ui.rs::advanced_mode_hint_panel_surfaces_sql_candidates`
|
||||
(renders the panel in advanced mode and asserts the FROM-slot
|
||||
table candidate appears). Ambient-layer locks:
|
||||
`src/input_render.rs::advanced_mode_ambient_offers_sql_from_slot_candidate`
|
||||
and `simple_mode_ambient_does_not_surface_sql_candidates`.
|
||||
|
||||
### 14. Catalog additions
|
||||
|
||||
```yaml
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ This directory contains the project's ADRs, recorded per
|
||||
- [ADR-0019 — Friendly error layer (H1) and i18n message catalog](0019-friendly-error-layer-and-i18n.md)
|
||||
- [ADR-0020 — Tokenization layer for the DSL parser](0020-tokenization-layer-for-the-dsl-parser.md)
|
||||
- [ADR-0021 — Parser-as-source-of-truth for H1a (per-command usage in parse errors)](0021-parser-as-source-of-truth-for-h1a.md)
|
||||
- [ADR-0022 — Ambient typing assistance: colour, hint panel, completion (I3 + I4)](0022-ambient-typing-assistance.md)
|
||||
- [ADR-0022 — Ambient typing assistance: colour, hint panel, completion (I3 + I4)](0022-ambient-typing-assistance.md) — **Amendment 1 supersedes §12's simple-mode-only carve-out**: the unified mode-aware walker (ADR-0030/0031/0032) now speaks SQL, so advanced-mode ambient assistance is re-enabled. `ambient_hint_in_mode` + `hint_resolution_at_input_in_mode` + `expected_for_hint_snapshot` thread `Mode`; `render_hint_panel` calls ambient for all modes (no more advanced-mode `None`); the one-shot `:` sigil is stripped before the ambient walk. Fixes a live bug where advanced-mode SQL hinting/completion-preview were dead despite Phase 2 marking them green (validated at the engine layer, not the UI). Simple-mode gating, highlighting, and the §13 performance posture are unchanged; covered by an app-level render test plus ambient-layer regression locks
|
||||
- [ADR-0023 — Unified declarative grammar tree](0023-unified-grammar-tree.md) — direction (superseded for execution detail by ADR-0024)
|
||||
- [ADR-0024 — Unified grammar tree: execution plan](0024-unified-grammar-tree-execution-plan.md) — **Accepted**, the executable spec — implemented (Phases A–F; Phase F shipped "minimal", `parser.rs` retained as the router — see the ADR's Phase F implementation note)
|
||||
- [ADR-0025 — Indexes](0025-indexes.md) — **Accepted**, `add index` / `drop index`, persistence, rebuild-table preservation, and items-list display (`C3` index portion + `S2`)
|
||||
|
||||
Reference in New Issue
Block a user