Skip to content

feat(viewer): stay quiet on incomplete/invalid filters while typing#122

Open
laurigates wants to merge 1 commit into
ynqa:mainfrom
laurigates:feat/quiet-invalid-filter
Open

feat(viewer): stay quiet on incomplete/invalid filters while typing#122
laurigates wants to merge 1 commit into
ynqa:mainfrom
laurigates:feat/quiet-invalid-filter

Conversation

@laurigates

Copy link
Copy Markdown

Problem

jaq runs on each (debounced) keystroke, so a half-typed filter — e.g. ending in | — fails to parse. The result was a raw Debug dump of jaq's internal parser structs flashing in the guide line on nearly every keypress:

jq failed: `jq filter parsing failed: [(File { code: ". | .user | ", path: () }, Parse([(Term, "")]))]`

Two issues: the message is an internal Debug representation, and erroring at all on an incomplete expression (the normal state while typing) is noise.

Fix

run_jaq now returns a typed JaqError:

  • Invalid — parse/compile failure (an incomplete or malformed expression, expected while typing).
  • Execution — the filter parsed and compiled but failed at runtime (a real problem worth reporting).

The viewer suppresses the guide message for Invalid and leaves the view in place, so typing a multi-stage filter is quiet. Execution errors are still reported, now with jaq's Display message instead of the Debug dump.

Notes

This is a lightweight take on #63 (don't choke on an incomplete expression): it stops the nagging without yet evaluating the longest valid prefix, which would be a larger change. Partially addresses #63.

Running jaq on each keystroke means a half-typed filter (e.g. a trailing
`|`) fails to parse, and the raw parser error — a `Debug` dump of jaq's
internal structs — was flashed in the guide line on every keypress.

`run_jaq` now returns a typed `JaqError` distinguishing parse/compile
failures (`Invalid`, expected while typing) from runtime failures
(`Execution`, a real problem on a well-formed filter). The viewer suppresses
the guide message for `Invalid` and keeps the current view, so typing is
quiet; genuine execution errors are still reported, now with a clean message
instead of the debug dump.

Partially addresses ynqa#63.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@laurigates

Copy link
Copy Markdown
Author

Related PRs (no strict merge order)#120, #121, and #122 are a small series of viewer / status-line improvements that independently edit the same code (refresh_view_with_query in src/json_viewer.rs; this one also touches src/json.rs). They're independent in intent but overlap textually, so whichever merges first, the others will need a quick rebase — no specific order is required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant