Skip to content

Commit ab48f3e

Browse files
committed
fix: rm __name, limit to single text name
1 parent 56aeb5e commit ab48f3e

File tree

1 file changed

+43
-41
lines changed

1 file changed

+43
-41
lines changed

src/components/robot/pages/RobotEditPage.tsx

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -436,15 +436,6 @@ export const RobotEditPage = ({ handleStart }: RobotSettingsProps) => {
436436
// update the standard name field
437437
action.name = newName;
438438

439-
// also update legacy __name location if present (args[0].__name)
440-
if (action.args && action.args.length > 0 && typeof action.args[0] === 'object' && action.args[0] !== null && '__name' in action.args[0]) {
441-
try {
442-
action.args[0] = { ...action.args[0], __name: newName };
443-
} catch (e) {
444-
console.error('Failed to update legacy __name field:', e);
445-
}
446-
}
447-
448439
updatedWorkflow[pairIndex].what[actionIndex] = action;
449440
}
450441

@@ -515,7 +506,6 @@ export const RobotEditPage = ({ handleStart }: RobotSettingsProps) => {
515506
const scrapeListAction = robot?.recording?.workflow?.[limitInfo.pairIndex]?.what?.[limitInfo.actionIndex];
516507
const actionName =
517508
scrapeListAction?.name ||
518-
(scrapeListAction?.args?.[0]?.__name) ||
519509
`List Limit ${index + 1}`;
520510

521511
return (
@@ -564,7 +554,7 @@ export const RobotEditPage = ({ handleStart }: RobotSettingsProps) => {
564554

565555
let currentName =
566556
action.name ||
567-
(action.args && action.args[0] && typeof action.args[0] === 'object' && action.args[0].__name) ||
557+
(action.args && action.args[0] && typeof action.args[0] === 'object') ||
568558
'';
569559

570560
if (!currentName) {
@@ -608,9 +598,49 @@ export const RobotEditPage = ({ handleStart }: RobotSettingsProps) => {
608598
);
609599

610600
switch (action.action) {
611-
case 'scrapeSchema':
612-
textInputs.push(textField);
601+
case 'scrapeSchema': {
602+
const existingName =
603+
currentName ||
604+
(action.args && action.args[0] && typeof action.args[0] === "object") ||
605+
"Texts";
606+
607+
if (!textInputs.length) {
608+
textInputs.push(
609+
<TextField
610+
key={`schema-${pairIndex}-${actionIndex}`}
611+
type="text"
612+
value={existingName}
613+
onChange={(e) => {
614+
const newName = e.target.value;
615+
616+
setRobot((prev) => {
617+
if (!prev?.recording?.workflow) return prev;
618+
619+
const updated = { ...prev };
620+
updated.recording = { ...prev.recording };
621+
updated.recording.workflow = prev.recording.workflow.map((p) => ({
622+
...p,
623+
what: p.what?.map((a) => {
624+
if (a.action === "scrapeSchema") {
625+
const updatedAction = { ...a };
626+
updatedAction.name = newName;
627+
return updatedAction;
628+
}
629+
return a;
630+
}),
631+
}));
632+
633+
return updated;
634+
});
635+
}}
636+
style={{ marginBottom: "12px" }}
637+
fullWidth
638+
/>
639+
);
640+
}
641+
613642
break;
643+
}
614644
case 'screenshot':
615645
screenshotInputs.push(textField);
616646
break;
@@ -621,34 +651,6 @@ export const RobotEditPage = ({ handleStart }: RobotSettingsProps) => {
621651
});
622652
});
623653

624-
if (textInputs.length === 1 && textCount === 1) {
625-
robot.recording.workflow.forEach((pair, pairIndex) => {
626-
if (!pair.what) return;
627-
628-
pair.what.forEach((action, actionIndex) => {
629-
if (action.action === 'scrapeSchema') {
630-
const existingName =
631-
action.name ||
632-
(action.args && action.args[0] && typeof action.args[0] === 'object' && action.args[0].__name) ||
633-
'';
634-
635-
const currentName = !existingName ? 'Texts' : existingName;
636-
637-
textInputs[0] = (
638-
<TextField
639-
key={`action-name-${pairIndex}-${actionIndex}`}
640-
type="text"
641-
value={currentName}
642-
onChange={(e) => handleActionNameChange(pairIndex, actionIndex, e.target.value)}
643-
style={{ marginBottom: '12px' }}
644-
fullWidth
645-
/>
646-
);
647-
}
648-
});
649-
});
650-
}
651-
652654
const hasAnyInputs = textInputs.length > 0 || screenshotInputs.length > 0 || listInputs.length > 0;
653655
if (!hasAnyInputs) return null;
654656

0 commit comments

Comments
 (0)