Skip to content

Commit af2e99f

Browse files
ottomaoclaude
andauthored
remove unnecessary guarding code (#2160)
* refactor(report): require data-group-id on dump elements, remove backward compat Drop `buildPlaywrightTaskFromElement` and the ungrouped fallback path. All `<script type="midscene_web_dump">` elements must now have a `data-group-id` attribute; missing it throws an error at parse time. https://claude.ai/code/session_017ir8y83LbmEhoMgshK3zzH * refactor(report): remove unreachable fallback and try-catch in grouped dump parsing The `elements` array from groupMap is guaranteed non-empty, so `baseDump` is always assigned after the loop — remove the dead else branch. Also remove the try-catch that silently swallowed parse errors with an empty GroupedActionDump; errors should propagate to the caller. https://claude.ai/code/session_017ir8y83LbmEhoMgshK3zzH --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9cbac80 commit af2e99f

File tree

1 file changed

+21
-44
lines changed

1 file changed

+21
-44
lines changed

apps/report/src/App.tsx

Lines changed: 21 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -371,53 +371,30 @@ export function App() {
371371
result.push({
372372
get: () => {
373373
if (!isParsed) {
374-
try {
375-
console.time('parse_grouped_dump');
376-
const allExecutions: any[] = [];
377-
let baseDump: GroupedActionDump | null = null;
378-
379-
for (const el of elements) {
380-
const content = antiEscapeScriptTag(el.textContent || '');
381-
const parsed = JSON.parse(content);
382-
const restored = restoreImageReferences(
383-
parsed,
384-
resolveImageFromDom,
385-
);
386-
const dump = GroupedActionDump.fromJSON(restored);
387-
if (!baseDump) {
388-
baseDump = dump;
389-
}
390-
allExecutions.push(...dump.executions);
374+
console.time('parse_grouped_dump');
375+
const allExecutions: any[] = [];
376+
let baseDump: GroupedActionDump | null = null;
377+
378+
for (const el of elements) {
379+
const content = antiEscapeScriptTag(el.textContent || '');
380+
const parsed = JSON.parse(content);
381+
const restored = restoreImageReferences(
382+
parsed,
383+
resolveImageFromDom,
384+
);
385+
const dump = GroupedActionDump.fromJSON(restored);
386+
if (!baseDump) {
387+
baseDump = dump;
391388
}
389+
allExecutions.push(...dump.executions);
390+
}
392391

393-
if (baseDump) {
394-
baseDump.executions = allExecutions;
395-
cachedJsonContent = baseDump;
396-
} else {
397-
cachedJsonContent = new GroupedActionDump({
398-
sdkVersion: '',
399-
groupName: '',
400-
modelBriefs: [],
401-
executions: [],
402-
});
403-
}
392+
baseDump!.executions = allExecutions;
393+
cachedJsonContent = baseDump!;
404394

405-
console.timeEnd('parse_grouped_dump');
406-
(cachedJsonContent as any).attributes = attributes;
407-
isParsed = true;
408-
} catch (e) {
409-
console.error('failed to parse grouped dump content', e);
410-
cachedJsonContent = new GroupedActionDump({
411-
sdkVersion: '',
412-
groupName: '',
413-
modelBriefs: [],
414-
executions: [],
415-
});
416-
(cachedJsonContent as any).attributes = attributes;
417-
(cachedJsonContent as any).error =
418-
'Failed to parse grouped JSON content';
419-
isParsed = true;
420-
}
395+
console.timeEnd('parse_grouped_dump');
396+
(cachedJsonContent as any).attributes = attributes;
397+
isParsed = true;
421398
}
422399
return cachedJsonContent!;
423400
},

0 commit comments

Comments
 (0)