Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (codex): clear unsaved caption drafts after a bulk strip so a stale blur can't re-PATCH the removed fragments (#1320)

[._.]/ Adam Eivy46484b280409
diff --git a/client/src/components/loraTraining/DatasetImageGrid.jsx b/client/src/components/loraTraining/DatasetImageGrid.jsx
index 53bbcd6cca..1f9bf408a4 100644
--- a/client/src/components/loraTraining/DatasetImageGrid.jsx
+++ b/client/src/components/loraTraining/DatasetImageGrid.jsx
@@ -88,8 +88,14 @@ const SOURCE_BADGE = {
gallery: { label: 'gallery', cls: 'bg-sky-600/20 text-sky-300' },
};
-export default function DatasetImageGrid({ dataset, onImagesChange, onCaptionRunStarted, captionModel = null }) {
+export default function DatasetImageGrid({
+ dataset, onImagesChange, onCaptionRunStarted, captionModel = null, draftResetToken = 0,
+}) {
const [drafts, setDrafts] = useState({});
+ // A bulk caption rewrite in the parent (e.g. strip-shared-fragments) replaces
+ // dataset.images out from under any unsaved per-cell draft. Drop the drafts on
+ // that signal so the next blur doesn't PATCH the superseded text back.
+ useEffect(() => { setDrafts({}); }, [draftResetToken]);
const [savingId, setSavingId] = useState(null);
const [confirmingId, setConfirmingId] = useState(null);
const [deletingId, setDeletingId] = useState(null);
diff --git a/client/src/pages/LoraDatasetDetail.jsx b/client/src/pages/LoraDatasetDetail.jsx
index 6cc9b17141..fcfdd46fd3 100644
--- a/client/src/pages/LoraDatasetDetail.jsx
+++ b/client/src/pages/LoraDatasetDetail.jsx
@@ -266,6 +266,10 @@ export default function LoraDatasetDetail() {
// runs pass the explicit selection.
const [captionModel, setCaptionModel] = useState({ providerId: null, model: null });
const [strippingFragments, setStrippingFragments] = useState(false);
+ // Bumped after a bulk caption rewrite (strip) so the image grid drops any
+ // unsaved caption drafts the rewrite superseded — otherwise a stale draft
+ // blur-saves the old text back, undoing the strip.
+ const [captionDraftResetToken, setCaptionDraftResetToken] = useState(0);
const fileInputRef = useRef(null);
const refresh = useCallback(() => getLoraDataset(datasetId)
@@ -328,6 +332,7 @@ export default function LoraDatasetDetail() {
try {
const { dataset: next, removedFragments, updatedImages } = await stripLoraDatasetSharedCaptionFragments(datasetId);
setDataset(next);
+ setCaptionDraftResetToken((n) => n + 1);
if (removedFragments.length) {
toast.success(`Stripped ${removedFragments.length} shared identity fragment${removedFragments.length === 1 ? '' : 's'} from ${updatedImages} caption${updatedImages === 1 ? '' : 's'}`);
} else {
@@ -680,6 +685,7 @@ export default function LoraDatasetDetail() {
onImagesChange={onImagesChange}
onCaptionRunStarted={setCaptionRun}
captionModel={captionModel}
+ draftResetToken={captionDraftResetToken}
/>
<TrainingPanel
dataset={dataset}