Make the request preview show the request

The panel's preview calls buildPayload itself, and the scope arrived as a
parameter that the preview had no way to supply -- so it defaulted to empty
and printed a payload with no scope for a write that had one. A preview that
disagrees with what is sent is worse than no preview: it is the one place
someone looks to check before committing a change.

buildPayload reads the scope from the ref instead, so there is one payload
and both callers get it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Paul Trowbridge 2026-09-18 09:10:09 -04:00
parent d983e2b1df
commit cdb40e7368

View File

@ -1307,7 +1307,7 @@ export default function Forecast({ sources = [], sourceId, versions = [], versio
// changes a larger set. It travels as [col, op, value] rather than folded
// into the slices, because a slice is {col: value} and can only mean
// equality: a view filtered to sseas_e <= 2027 has no slice form at all.
const body = buildPayload(op, viewFilterRef.current)
const body = buildPayload(op)
if (!body) return
if (body.slices.some(sl => !Object.keys(sl).length)) {
flash('No dimension or date columns in slice — check col_meta', 'error'); return
@ -1436,7 +1436,11 @@ export default function Forecast({ sources = [], sourceId, versions = [], versio
return out
}
function buildPayload(op, viewFilter = []) {
// The scope is read from the ref rather than passed in: the request preview in
// the panel calls this too, and when it was a parameter the preview defaulted
// it away -- showing a payload with no scope for a write that had one.
function buildPayload(op) {
const viewFilter = viewFilterRef.current || []
if (!slices.length) return null
// Two clicked cells can differ only by a column the operation cannot filter on
// (pf_iter, say, which is not in col_meta and so is dropped here). Those become