Skip to content

Chrome DevTools for coding agents

fix: return error message when screencast_stop is called with no active recording (#2209)

bassem chagra9e32002a6947
diff --git a/src/tools/screencast.ts b/src/tools/screencast.ts
index 96334c0e..cc26e6cd 100644
--- a/src/tools/screencast.ts
+++ b/src/tools/screencast.ts
@@ -107,6 +107,9 @@ export const stopScreencast = definePageTool({
handler: async (_request, response, context) => {
const data = context.getScreenRecorder();
if (!data) {
+ response.appendResponseLine(
+ 'Error: no active screencast recording to stop.',
+ );
return;
}
try {
diff --git a/tests/tools/screencast.test.ts b/tests/tools/screencast.test.ts
index d60ec7db..4708f12c 100644
--- a/tests/tools/screencast.test.ts
+++ b/tests/tools/screencast.test.ts
@@ -151,7 +151,7 @@ describe('screencast', () => {
});
describe('screencast_stop', () => {
- it('does nothing if no recording is active', async () => {
+ it('returns an error message if no recording is active', async () => {
await withMcpContext(async (response, context) => {
assert.strictEqual(context.getScreenRecorder(), null);
await stopScreencast.handler(
@@ -159,7 +159,11 @@ describe('screencast', () => {
response,
context,
);
- assert.strictEqual(response.responseLines.length, 0);
+ assert.ok(
+ response.responseLines
+ .join('\n')
+ .includes('no active screencast recording to stop'),
+ );
});
});