-
Notifications
You must be signed in to change notification settings - Fork 2
Fix code generation #5
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
Changes from 5 commits
70589a2
9a9fd6b
4518c34
c2fe37a
0ce48d7
f04ea61
761c6db
b7b815c
a013668
130faf3
c8ab382
fba1a10
738b452
ba1ca5a
2ec04fe
b6a1903
6b3d52a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -100,11 +100,14 @@ export const DecoderSelector = memo(function DecoderSelector() { | |||||
|
|
||||||
| // Group decoders by type and source | ||||||
| const builtinDecoders = availableDecoders.filter(d => | ||||||
| d.type === 'tfjs' && (!d.source || d.source.type === 'builtin') | ||||||
| d.type === 'tfjs' && (!d.source || d.source.type === 'builtin') && !d.code | ||||||
| ); | ||||||
| const customDecoders = availableDecoders.filter(d => | ||||||
| d.source?.type === 'url' || d.source?.type === 'local' | ||||||
| ); | ||||||
| const codeDecoders = availableDecoders.filter(d => | ||||||
| d.type === 'tfjs' && d.code | ||||||
|
||||||
| d.type === 'tfjs' && d.code | |
| d.type === 'javascript' && d.code |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /** | ||
| * UI State Slice | ||
| * | ||
| * Manages global UI state like modals, preventing auto-navigation | ||
| * when critical modals are open. | ||
| */ | ||
|
|
||
| import type { StateCreator } from 'zustand'; | ||
|
|
||
| export interface UISlice { | ||
| // Modal state - blocks auto-navigation when a critical modal is open | ||
| activeModal: string | null; | ||
|
|
||
| // Actions | ||
| openModal: (modalId: string) => void; | ||
| closeModal: () => void; | ||
|
|
||
| // Computed - check if navigation should be blocked | ||
| isModalBlocking: () => boolean; | ||
| } | ||
|
|
||
| export const createUISlice: StateCreator< | ||
| UISlice, | ||
| [], | ||
| [], | ||
| UISlice | ||
| > = (set, get) => ({ | ||
| activeModal: null, | ||
|
|
||
| openModal: (modalId: string) => { | ||
| set({ activeModal: modalId }); | ||
| console.log(`[UI] Modal opened: ${modalId}`); | ||
| }, | ||
|
|
||
| closeModal: () => { | ||
| const current = get().activeModal; | ||
| set({ activeModal: null }); | ||
| if (current) { | ||
| console.log(`[UI] Modal closed: ${current}`); | ||
| } | ||
| }, | ||
|
|
||
| isModalBlocking: () => { | ||
| return get().activeModal !== null; | ||
| }, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cleanup function unconditionally calls
closeModal()on unmount, but this could interfere with modal state if the component unmounts for reasons other than closing the modal. If the parent component re-renders and causes AddDecoderModal to unmount/remount while isOpen is still true, this would clear the modal state unexpectedly. Consider only calling closeModal in the cleanup if the modal was actually open, or rely on the else branch (line 44) to handle the close case.