-
Notifications
You must be signed in to change notification settings - Fork 87
Fix #8683: Refresh target template list when new template is created #8696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
m4cd4r4
wants to merge
439
commits into
huridocs:production
Choose a base branch
from
m4cd4r4:fix/paragraph-extraction-template-refresh
base: production
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix #8683: Refresh target template list when new template is created #8696
m4cd4r4
wants to merge
439
commits into
huridocs:production
from
m4cd4r4:fix/paragraph-extraction-template-refresh
Conversation
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
…created
## Problem
When creating a paragraph extractor, if the target template doesn't exist
and the user creates it, the newly created template doesn't appear in the
available templates list until the browser is refreshed.
This is a HIGH PRIORITY bug affecting human rights investigators who need
to quickly set up document extraction workflows.
## Root Cause
The TargetTemplate Body component (line 15) initializes the `options` state
with `targetTemplateOptions` on mount but never updates it when new templates
are created:
```typescript
const [options, setOptions] = useState<MultiselectListOption[]>(targetTemplateOptions);
```
While the `templatesAtom` (Jotai global state) updates when a template is
created, the local `options` state doesn't react to this change, causing
the UI to become stale.
## Solution
Added a `useEffect` hook that updates the `options` state whenever
`targetTemplateOptions` changes:
```typescript
useEffect(() => {
setOptions(targetTemplateOptions);
}, [targetTemplateOptions]);
```
This ensures that when:
1. User creates a new template
2. `templatesAtom` updates via atomStore
3. Component re-renders with new template data
4. `useEffect` synchronizes local state with latest templates
5. New template appears immediately in the dropdown
## Impact for Human Rights Documentation
- Eliminates workflow interruption for investigators setting up extractors
- No longer need to reload browser mid-configuration
- Faster setup of document analysis pipelines for evidence gathering
Tested: Template appears immediately after creation without refresh.
🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Member
|
@m4cd4r4 This is amazing, thanks! Could you point the PR to huridocs:production as we have changed the main branch. |
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.
Fixes #8683
The target template dropdown wasn't updating when you created a new template. Had to refresh the browser to see it.
Added a useEffect hook to sync the local state with the templates atom when it changes. Now it updates immediately.
Tested by creating a new template during extractor setup and it showed up right away.