Skip to content

Commit 0eb9580

Browse files
authored
[UI] Fix adding flags in an opt instance in a pipeline (#29)
handleRemovePass and handleUpdatePass should only update the pipeline array. Before this Edit Compilation Pass was resulting in Error: Cannot read properties of undefined (reading 'length')
1 parent 5bcdcc8 commit 0eb9580

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/app/ExplorerContent.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,17 +226,33 @@ export default function ExplorerContent() {
226226
const handleUpdatePass = () => {
227227
updateActiveSource((s) => ({
228228
...s,
229-
irWindows: s.irWindows.map((p, i) =>
230-
i === editPassIndex ? { tool: editTool, flags: editFlags } : p,
231-
),
229+
irWindows: s.irWindows.map((w) => {
230+
if (w.id !== editPassWindowId) return w;
231+
232+
// replace only the single pass in w.pipeline
233+
return {
234+
...w,
235+
pipeline: w.pipeline.map((pass, idx) =>
236+
idx === editPassIndex ? { tool: editTool, flags: editFlags } : pass,
237+
),
238+
};
239+
}),
232240
}));
233241
setEditModalVisible(false);
234242
};
235243

236244
const handleRemovePass = () => {
237245
updateActiveSource((s) => ({
238246
...s,
239-
irWindows: s.irWindows.filter((_, i) => i !== editPassIndex),
247+
irWindows: s.irWindows.map((w) => {
248+
if (w.id !== editPassWindowId) return w;
249+
250+
// drop just that one pass in w.pipeline
251+
return {
252+
...w,
253+
pipeline: w.pipeline.filter((_, idx) => idx !== editPassIndex),
254+
};
255+
}),
240256
}));
241257
setEditModalVisible(false);
242258
};

0 commit comments

Comments
 (0)