Own response filter state where the filter runs - #549
Merged
Conversation
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 SummaryThe PR moves response-filter state and debouncing into a dedicated hook owned by
Confidence Score: 5/5The 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.
|
| 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
Reviews (1): Last reviewed commit: "Own response filter state where the filt..." | Re-trigger Greptile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TextViewerevaluated the filter during its own render, by calling anonFiltercallback that set state inHTMLOrTextViewer. That logs a React warning:It also meant the result the viewer read could describe the previous expression for a render.
Filter state now lives in a
useResponseFilterhook, used by the component that runs the query, andTextViewertakes the state and result as props. No behavior change — filtering is still live and debounced.Groundwork for #338.