fix: resolve 3 real bugs found in PR review
- ConfigEditorDialog: wrap api.config.get() in try/catch to prevent dialog from getting stuck in loading state on IPC failure - CreateTaskDialog: clear description and chips when dialog opens without defaults, preventing stale state from previous opens - useAttachments: handle persistenceKey→undefined transition by flushing pending saves and clearing stale attachment state
This commit is contained in:
parent
64f2d3f413
commit
4cc297690a
3 changed files with 64 additions and 47 deletions
|
|
@ -175,6 +175,7 @@ export const ConfigEditorDialog = ({
|
|||
setJsonError(null);
|
||||
|
||||
const init = async (): Promise<void> => {
|
||||
try {
|
||||
const config = await api.config.get();
|
||||
if (destroyed) return;
|
||||
|
||||
|
|
@ -226,6 +227,11 @@ export const ConfigEditorDialog = ({
|
|||
});
|
||||
viewRef.current = view;
|
||||
});
|
||||
} catch (e) {
|
||||
if (destroyed) return;
|
||||
setLoading(false);
|
||||
setJsonError(e instanceof Error ? e.message : 'Failed to load config');
|
||||
}
|
||||
};
|
||||
|
||||
void init();
|
||||
|
|
|
|||
|
|
@ -102,6 +102,10 @@ export const CreateTaskDialog = ({
|
|||
descChipDraft.setChips([defaultChip]);
|
||||
} else if (defaultDescription) {
|
||||
descriptionDraft.setValue(defaultDescription);
|
||||
descChipDraft.clearChipDraft();
|
||||
} else {
|
||||
descriptionDraft.clearDraft();
|
||||
descChipDraft.clearChipDraft();
|
||||
}
|
||||
setOwner(defaultOwner);
|
||||
setBlockedBy([]);
|
||||
|
|
|
|||
|
|
@ -106,7 +106,14 @@ export function useAttachments(options?: UseAttachmentsOptions): UseAttachmentsR
|
|||
|
||||
// Load persisted attachments on mount
|
||||
useEffect(() => {
|
||||
if (!persistenceKey) return;
|
||||
if (!persistenceKey) {
|
||||
// Transitioning to non-persistent context: flush pending save and clear stale state
|
||||
flushPending();
|
||||
attachmentsRef.current = [];
|
||||
// eslint-disable-next-line react-hooks/set-state-in-effect -- intentional sync reset on key transition
|
||||
setAttachments([]);
|
||||
return;
|
||||
}
|
||||
|
||||
let cancelled = false;
|
||||
// Flush any pending debounced save for the previous key before switching.
|
||||
|
|
|
|||
Loading…
Reference in a new issue