ADR-0022 stage 5/8: hint panel ambient typing assistance
ParseError::Invalid gains an `expected: Vec<String>` field —
the human-rendered names of the patterns chumsky was looking
for at the failure point (`\`create\``, `identifier`, etc.).
Empty for custom errors, which have no expected-set framing.
Populated by a new `describe_expected()` helper in parser.rs
that humanise() also delegates to (eliminates duplication).
`input_render::ambient_hint(input) -> Option<String>` returns
the hint-panel content per ADR-0022 §6:
- empty input → None (caller falls back to panel.hint_empty);
- Valid → t!("hint.ambient_complete") ("submit with Enter");
- IncompleteAtEof → t!("hint.ambient_expected", expected = …)
listing the parser's expected next tokens, oxford-joined;
- DefiniteErrorAt → t!("hint.ambient_error_with_usage", …)
composing the parse-error message with the matching
parse.usage.* template if a known entry keyword was
consumed, else the bare message.
Catalog gains the three hint.ambient_* keys + validator
declarations.
ui::render_hint_panel resolution order:
1. explicit app.hint (modal contexts) wins;
2. simple-mode + non-empty input → ambient_hint;
3. fallback to panel.hint_empty.
Advanced mode (persistent + one-shot `:`) bypasses ambient
hinting per ADR-0022 §12.
Snapshot: highlighted_input_all_token_classes rebaselined
because the hint panel now displays an ambient hint instead
of the empty placeholder when input is non-empty.
Tests: 698 passing, 0 failing, 1 ignored (693 baseline →
+5 ambient_hint cases). Clippy clean.
Stage 6 introduces the IdentSlot taxonomy + parser audit so
identifier-typed slots can yield schema-aware completion
candidates in stage 8.
This commit is contained in:
@@ -683,10 +683,26 @@ fn render_hint_panel(app: &App, theme: &Theme, frame: &mut Frame<'_>, area: Rect
|
||||
))
|
||||
.style(Style::default().bg(theme.bg).fg(theme.fg));
|
||||
|
||||
// Resolution order for the hint panel body:
|
||||
// 1. An explicit app-set hint (e.g. modal contexts) wins.
|
||||
// 2. Otherwise, in simple mode with non-empty input,
|
||||
// the ambient typing-assistance hint (ADR-0022 §6).
|
||||
// 3. Otherwise, the existing empty-state placeholder.
|
||||
// Advanced mode skips ambient hinting (ADR-0022 §12) —
|
||||
// the DSL lexer/parser don't speak SQL.
|
||||
let empty_hint = crate::t!("panel.hint_empty");
|
||||
let body = app.hint.as_deref().unwrap_or(empty_hint.as_str());
|
||||
let ambient = match app.effective_mode() {
|
||||
EffectiveMode::Simple => crate::input_render::ambient_hint(&app.input),
|
||||
EffectiveMode::AdvancedPersistent | EffectiveMode::AdvancedOneShot => None,
|
||||
};
|
||||
let body: String = app
|
||||
.hint
|
||||
.as_deref()
|
||||
.map(ToString::to_string)
|
||||
.or(ambient)
|
||||
.unwrap_or(empty_hint);
|
||||
let paragraph = Paragraph::new(Line::from(Span::styled(
|
||||
body.to_string(),
|
||||
body,
|
||||
Style::default().fg(theme.muted),
|
||||
)))
|
||||
.block(block)
|
||||
|
||||
Reference in New Issue
Block a user