Skip to content

Commit f2a644f

Browse files
fix(preview): scope blank-tab hint in URL errors to preview_open
preview_navigate shares the URL error formatter but cannot omit url, so the hint now names preview_open explicitly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 4b02a6b commit f2a644f

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎packages/contracts/src/preview.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ export class PreviewInvalidUrlError extends Schema.TaggedError<PreviewInvalidUrl
367367
) {
368368
override get message() {
369369
const protocol = this.protocol === undefined ? "" : `: ${this.protocol}`;
370-
return `Invalid preview URL (${this.reason}${protocol}; input length ${this.inputLength}). Use an http(s) URL or a schemeless host such as localhost:5173, or omit url to open a blank tab.`;
370+
return `Invalid preview URL (${this.reason}${protocol}; input length ${this.inputLength}). Use an http(s) URL or a schemeless host such as localhost:5173. With preview_open, omit url to open a blank tab.`;
371371
}
372372
}
373373

‎packages/shared/src/preview.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ describe("resolveSearchUrlTemplate", () => {
150150

151151
describe("normalizePreviewUrl", () => {
152152
it("tells agents how to open a blank tab and which URLs are accepted", () => {
153-
expect(() => normalizePreviewUrl("about:blank")).toThrow(/omit (?:the )?url[^.]*blank tab/i);
153+
expect(() => normalizePreviewUrl("about:blank")).toThrow(
154+
/preview_open, omit url[^.]*blank tab/i,
155+
);
154156
expect(() => normalizePreviewUrl("about:blank")).toThrow(/http\(s\)/i);
155157
expect(() => normalizePreviewUrl("about:blank")).toThrow(/schemeless host/i);
156158
});

‎packages/shared/src/preview.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class PreviewUrlNormalizationError extends Schema.TaggedError<PreviewUrlN
6666
) {
6767
override get message(): string {
6868
const protocol = this.protocol === undefined ? "" : `: ${this.protocol}`;
69-
return `Invalid preview URL (${this.reason}${protocol}; input length ${this.inputLength}). Use an http(s) URL or a schemeless host such as localhost:5173, or omit url to open a blank tab.`;
69+
return `Invalid preview URL (${this.reason}${protocol}; input length ${this.inputLength}). Use an http(s) URL or a schemeless host such as localhost:5173. With preview_open, omit url to open a blank tab.`;
7070
}
7171
}
7272

0 commit comments

Comments
 (0)