Skip to content

Commit 24ffcaf

Browse files
committed
Fix automation timeline cause detail omission and detailKind/detailLength mismatch
- Add toTimelineMessage() to PreviewAutomationEvaluationError and PreviewAutomationInvalidSelectorError to extract cause details for timeline entries, matching the existing PreviewOperationError pattern. - Update finalizeControlAction to use these methods instead of falling through to the generic error.message for these error types. - Fix evaluateWithDebugger to use truthiness checks for description/text instead of !== undefined, preventing null and empty string from being misclassified as exception-description while detailLength resolves to a different field's length.
1 parent 09f6a22 commit 24ffcaf

1 file changed

Lines changed: 25 additions & 10 deletions

File tree

apps/desktop/src/preview/Manager.ts

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -876,9 +876,13 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
876876
const interrupted = isPreviewAutomationControlInterruptedError(error);
877877
const errorMessage = isPreviewOperationError(error)
878878
? PreviewOperationError.toTimelineMessage(error)
879-
: error instanceof Error
880-
? error.message
881-
: String(error);
879+
: isPreviewAutomationEvaluationError(error)
880+
? PreviewAutomationEvaluationError.toTimelineMessage(error)
881+
: isPreviewAutomationInvalidSelectorError(error)
882+
? PreviewAutomationInvalidSelectorError.toTimelineMessage(error)
883+
: error instanceof Error
884+
? error.message
885+
: String(error);
882886
yield* replaceAction(tabId, {
883887
...actionEvent,
884888
status: interrupted ? "interrupted" : "failed",
@@ -915,13 +919,8 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
915919
return Effect.fail(
916920
new PreviewAutomationEvaluationError({
917921
tabId,
918-
detailKind:
919-
description !== undefined
920-
? "exception-description"
921-
: text !== undefined
922-
? "exception-text"
923-
: "unknown",
924-
detailLength: description?.length ?? text?.length ?? 0,
922+
detailKind: description ? "exception-description" : text ? "exception-text" : "unknown",
923+
detailLength: description?.length || text?.length || 0,
925924
cause: response.exceptionDetails,
926925
}),
927926
);
@@ -2467,6 +2466,13 @@ export class PreviewAutomationEvaluationError extends Schema.TaggedErrorClass<Pr
24672466
cause: Schema.Defect(),
24682467
},
24692468
) {
2469+
static toTimelineMessage(error: PreviewAutomationEvaluationError): string {
2470+
const cause = error.cause as
2471+
| { text?: string; exception?: { description?: string } }
2472+
| undefined;
2473+
return cause?.exception?.description || cause?.text || error.message;
2474+
}
2475+
24702476
override get message(): string {
24712477
return `Preview JavaScript evaluation failed in tab ${this.tabId}`;
24722478
}
@@ -2513,6 +2519,11 @@ export class PreviewAutomationInvalidSelectorError extends Schema.TaggedErrorCla
25132519
cause: Schema.Defect(),
25142520
},
25152521
) {
2522+
static toTimelineMessage(error: PreviewAutomationInvalidSelectorError): string {
2523+
const cause = error.cause as { message?: string } | undefined;
2524+
return cause?.message || error.message;
2525+
}
2526+
25162527
get detail(): {
25172528
readonly selectorKind: PreviewAutomationSelectorKind;
25182529
readonly selectorLength?: number;
@@ -2595,6 +2606,10 @@ export const isPreviewManagerError = Schema.is(PreviewManagerError);
25952606
export const isPreviewAutomationControlInterruptedError = Schema.is(
25962607
PreviewAutomationControlInterruptedError,
25972608
);
2609+
export const isPreviewAutomationEvaluationError = Schema.is(PreviewAutomationEvaluationError);
2610+
export const isPreviewAutomationInvalidSelectorError = Schema.is(
2611+
PreviewAutomationInvalidSelectorError,
2612+
);
25982613

25992614
export class PreviewManager extends Context.Service<
26002615
PreviewManager,

0 commit comments

Comments
 (0)