Skip to content

Commit 9e32002

Browse files
ch-basnroscino
andauthored
fix: return error message when screencast_stop is called with no active recording (#2209)
## Summary `screencast_stop` returns an empty response when no recording is active, making it impossible for the calling agent to distinguish "stopped successfully" from "nothing was recording." `screencast_start` already handles its inverse case with an explicit error (`"a screencast recording is already in progress"`), so this makes `stop` consistent. ## Change Added an error message when `screencast_stop` is called without an active recording: ```ts if (!data) { response.appendResponseLine( 'Error: no active screencast recording to stop.', ); return; } ``` ## Before Empty tool response — agent cannot tell what happened. ## After `Error: no active screencast recording to stop.` --------- Co-authored-by: Nicholas Roscino <nroscino@google.com>
1 parent e77101e commit 9e32002

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/tools/screencast.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ export const stopScreencast = definePageTool({
107107
handler: async (_request, response, context) => {
108108
const data = context.getScreenRecorder();
109109
if (!data) {
110+
response.appendResponseLine(
111+
'Error: no active screencast recording to stop.',
112+
);
110113
return;
111114
}
112115
try {

tests/tools/screencast.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,19 @@ describe('screencast', () => {
151151
});
152152

153153
describe('screencast_stop', () => {
154-
it('does nothing if no recording is active', async () => {
154+
it('returns an error message if no recording is active', async () => {
155155
await withMcpContext(async (response, context) => {
156156
assert.strictEqual(context.getScreenRecorder(), null);
157157
await stopScreencast.handler(
158158
{params: {}, page: context.getSelectedMcpPage()},
159159
response,
160160
context,
161161
);
162-
assert.strictEqual(response.responseLines.length, 0);
162+
assert.ok(
163+
response.responseLines
164+
.join('\n')
165+
.includes('no active screencast recording to stop'),
166+
);
163167
});
164168
});
165169

0 commit comments

Comments
 (0)