Skip to content

Own response filter state where the filter runs - #549

Merged
gschier merged 1 commit into
mainfrom
refactor/response-filter-state
Aug 15, 2026
Merged

Own response filter state where the filter runs#549
gschier merged 1 commit into
mainfrom
refactor/response-filter-state

Conversation

@gschier

@gschier gschier commented Aug 15, 2026

Copy link
Copy Markdown
Member

TextViewer evaluated the filter during its own render, by calling an onFilter callback that set state in HTMLOrTextViewer. That logs a React warning:

Cannot update a component (`HttpTextViewer`) while rendering a different component (`TextViewer`)

It also meant the result the viewer read could describe the previous expression for a render.

Filter state now lives in a useResponseFilter hook, used by the component that runs the query, and TextViewer takes the state and result as props. No behavior change — filtering is still live and debounced.

Groundwork for #338.

TextViewer evaluated the filter during render via an onFilter callback, which
updated HTMLOrTextViewer mid-render and produced a React warning. Filter state
now lives in a useResponseFilter hook next to the query that applies it, and the
viewer takes the state and result as props.
@greptile-apps

greptile-apps Bot commented Aug 15, 2026

Copy link
Copy Markdown

Greptile Summary

The PR moves response-filter state and debouncing into a dedicated hook owned by HttpTextViewer, avoiding parent state updates during TextViewer rendering.

  • Adds useResponseFilter with globally keyed filter state and a debounced expression.
  • Changes TextViewer to consume filter state and results as presentational props.
  • Runs filtered-body queries directly from HttpTextViewer.

Confidence Score: 5/5

The PR appears safe to merge with no concrete changed-code regression identified.

The refactor preserves existing filter persistence and debounce behavior while moving query ownership out of TextViewer’s render path, and all current callers provide compatible filter props.

Important Files Changed

Filename Overview
apps/yaak-client/components/responseViewers/HTMLOrTextViewer.tsx Owns filter state beside the filtered-body query and passes the resulting state and data to TextViewer.
apps/yaak-client/components/responseViewers/TextViewer.tsx Removes render-time filter callbacks and renders from the supplied filter API and result.
apps/yaak-client/hooks/useResponseFilter.ts Introduces globally keyed response-filter state, toggle behavior, and debounced query text.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Filter input] --> B[useResponseFilter]
  B -->|immediate state| C[TextViewer]
  B -->|debounced expression| D[useResponseBodyText]
  D -->|query result| C
Loading

Reviews (1): Last reviewed commit: "Own response filter state where the filt..." | Re-trigger Greptile

@gschier
gschier merged commit 7dfa7e0 into main Aug 15, 2026
6 checks passed
@gschier
gschier deleted the refactor/response-filter-state branch August 15, 2026 05:38
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