Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface CaptureGenerationPreviewCommandOptions {
attemptNumber?: string | number;
url?: string;
waitFor?: string;
storageStatePath?: string;
}
export interface ReviewGenerationAttemptCommandOptions {
sessionDir?: string;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1207,13 +1207,20 @@ export async function runCaptureGenerationPreviewCommand(options) {
throw new SessionInputError(`Preview URL must use http or https: ${options.url}.`);
}
const viewport = { width: 1440, height: 1024 };
const storageStatePath = asString(options.storageStatePath);
if (storageStatePath && !fs.existsSync(storageStatePath)) {
throw new SessionInputError(`Storage state file not found: ${storageStatePath}.`);
}
const browser = await chromium.launch({
headless: process.env.INTERFACECTL_PLAYWRIGHT_HEADLESS !== "0" &&
process.env.INTERFACECTL_PLAYWRIGHT_HEADLESS !== "false",
}).catch((error) => {
throw toBrowserLaunchError(error);
});
const context = await browser.newContext({ viewport });
const context = await browser.newContext({
viewport,
...(storageStatePath ? { storageState: storageStatePath } : {}),
});
const page = await context.newPage();
try {
await page.goto(parsedUrl.toString(), { waitUntil: "load", timeout: 15_000 });
Expand Down
2 changes: 2 additions & 0 deletions packages/interfacectl-cli/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,14 @@ program
.requiredOption("--attempt <number>", "Attempt number to capture")
.requiredOption("--url <url>", "Absolute preview URL to capture")
.option("--wait-for <value>", "Optional text or selector to wait for before capturing")
.option("--storage-state <path>", "Optional Playwright storage state JSON file for authenticated previews")
.action(async (options) => {
process.exitCode = await runCaptureGenerationPreviewCommand({
sessionDir: options.sessionDir,
attemptNumber: options.attempt,
url: options.url,
waitFor: options.waitFor,
storageStatePath: options.storageState,
});
});
program
Expand Down
10 changes: 9 additions & 1 deletion packages/interfacectl-cli/src/commands/generation-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface CaptureGenerationPreviewCommandOptions {
attemptNumber?: string | number;
url?: string;
waitFor?: string;
storageStatePath?: string;
}

export interface ReviewGenerationAttemptCommandOptions {
Expand Down Expand Up @@ -1824,14 +1825,21 @@ export async function runCaptureGenerationPreviewCommand(
}

const viewport = { width: 1440, height: 1024 };
const storageStatePath = asString(options.storageStatePath);
if (storageStatePath && !fs.existsSync(storageStatePath)) {
throw new SessionInputError(`Storage state file not found: ${storageStatePath}.`);
}
const browser = await chromium.launch({
headless:
process.env.INTERFACECTL_PLAYWRIGHT_HEADLESS !== "0" &&
process.env.INTERFACECTL_PLAYWRIGHT_HEADLESS !== "false",
}).catch((error) => {
throw toBrowserLaunchError(error);
});
const context = await browser.newContext({ viewport });
const context = await browser.newContext({
viewport,
...(storageStatePath ? { storageState: storageStatePath } : {}),
});
Comment on lines +1839 to +1842

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Treat invalid storage-state files as input errors

If --storage-state points to a file that exists but contains malformed or incompatible Playwright state, browser.newContext throws at this call site before execution reaches the inner try/catch that converts failures into SessionInputError. The outer handler then reports generation-session.internal and returns exit code 1, which misclassifies a user-fixable argument problem and breaks callers that rely on exit code 10 for invalid inputs.

Useful? React with 👍 / 👎.

const page = await context.newPage();

try {
Expand Down
2 changes: 2 additions & 0 deletions packages/interfacectl-cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,14 @@ program
.requiredOption("--attempt <number>", "Attempt number to capture")
.requiredOption("--url <url>", "Absolute preview URL to capture")
.option("--wait-for <value>", "Optional text or selector to wait for before capturing")
.option("--storage-state <path>", "Optional Playwright storage state JSON file for authenticated previews")
.action(async (options) => {
process.exitCode = await runCaptureGenerationPreviewCommand({
sessionDir: options.sessionDir,
attemptNumber: options.attempt,
url: options.url,
waitFor: options.waitFor,
storageStatePath: options.storageState,
});
});

Expand Down
Loading