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:
claude@clouddev1
2026-05-21 19:18:27 +00:00
parent c87363168f
commit ed40445828
6 changed files with 253 additions and 28 deletions
+18 -1
View File
@@ -97,10 +97,25 @@ pub struct HintResolution {
pub fn hint_resolution_at_input(
source: &str,
schema: Option<&crate::completion::SchemaCache>,
) -> Option<HintResolution> {
hint_resolution_at_input_in_mode(source, schema, crate::mode::Mode::Simple)
}
/// Mode-aware hint resolver (ADR-0022 Amendment 1).
///
/// Walks `source` in `mode` so advanced-mode SQL resolves slot
/// hints instead of being gated by the simple-mode "this is SQL"
/// path. The no-mode [`hint_resolution_at_input`] defaults to
/// `Mode::Simple`.
#[must_use]
pub fn hint_resolution_at_input_in_mode(
source: &str,
schema: Option<&crate::completion::SchemaCache>,
mode: crate::mode::Mode,
) -> Option<HintResolution> {
use crate::dsl::grammar::HintMode;
let snap = expected_for_hint_snapshot(source, schema);
let snap = expected_for_hint_snapshot(source, schema, mode);
// Empty expected set means the command is already complete
// (`WalkOutcome::Match`) — no slot to hint at.
if snap.expected.is_empty() {
@@ -1608,6 +1623,7 @@ struct HintWalkSnapshot {
fn expected_for_hint_snapshot(
source: &str,
schema: Option<&crate::completion::SchemaCache>,
mode: crate::mode::Mode,
) -> HintWalkSnapshot {
use crate::dsl::grammar::REGISTRY;
@@ -1633,6 +1649,7 @@ fn expected_for_hint_snapshot(
let mut ctx = schema.map_or_else(context::WalkContext::new, |s| {
context::WalkContext::with_schema(s)
});
ctx.mode = mode;
let (result, _cmd) = walk(source, outcome::WalkBound::EndOfInput, &mut ctx);
let Some(result) = result else {
return empty_snapshot();