feat(viewer): preserve last successful result on null/error#121
feat(viewer): preserve last successful result on null/error#121laurigates wants to merge 2 commits into
Conversation
When a query returns only null or fails to parse/run, the viewer now keeps showing the most recent successful result instead of resetting to the whole input document — so the pane stays stable and you keep your context while fixing the filter (ynqa#103). Before any successful query it still falls back to the original input. The guide pane keeps reporting the null/error as before. Closes ynqa#103 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
An empty (or whitespace-only) query is rejected by jaq as an invalid program, so it fell through to the `show_last_good()` fallback — which silently re-displayed the stale last result, or on a fresh view dumped the entire input document with no explanation. Clearing the filter (e.g. Ctrl+U) therefore looked like the view "wouldn't clear". Special-case the empty query as "no filter": reset `last_good` and point the view at the full input fresh, with a neutral `no filter — showing full input` status hint. Non-empty incomplete filters (`.fo`, `.a |`) still preserve the last good result to avoid flicker while typing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Pushed a follow-up that handles the empty-filter case for the preserved view. Previously, clearing the editor to empty was indistinguishable from a half-typed filter: jaq rejects an empty program as invalid, so it fell through to Now an empty (or whitespace-only) query is treated explicitly as "no filter": |
|
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 ( |
Summary
When a query returns only
nullor fails (parse/run error), the viewer now keeps showing the most recent successful result instead of resetting the pane to the whole input document. This keeps the view stable so you retain context while fixing the filter (#103).Before any query has succeeded, it still falls back to the original input. The guide pane keeps reporting the null/error exactly as before.
Behavior
.foo(valid).foo.foo(remembered as last-good).foo.bad(null).foo.foo |(error).foo.foo.bar.foo.bar.foo.bar(new last-good)Implementation
JsonViewergains alast_good: Vec<Value>holding the most recent non-null successful result (empty until the first success).last_goodand renders it; null/error renderlast_good, or the original input if nothing has succeeded yet (show_last_good).all(null)check is vacuously true for empty), so a filter that produces nothing also preserves the view.The issue lists a few methodologies; this implements "result of the most recent successful query", which best matches keeping context. Easy to switch to always-original-input if you'd prefer.
Closes #103