fix: include the tab id in get_tab_id's text response (#2381)

As discussed in #2366: `get_tab_id` gates on
`--experimentalInteropTools`, but its result only went into
`structuredContent`, which is dropped unless
`--experimentalStructuredContent` is also set – so with interop alone
the tool always returned an empty text response.

This appends a `Tab ID: <id>` line to the text response and keeps
`structuredContent.tabId` as-is – `key: value` so it stays trivially
parseable.

## Testing

The existing `returns the tab id` test asserted empty `responseLines`,
which pinned the old behavior – now it asserts the `Tab ID:` line.
Verified end-to-end over stdio with `--experimentalInteropTools` alone:
the text response is `Tab ID: <id>` where it was `""` before.
This commit is contained in:
Thomas Bachem
2026-07-20 17:00:49 +02:00
committed by GitHub
parent 71e5c59bc9
commit dcbaf49518
2 changed files with 2 additions and 1 deletions
+1
View File
@@ -409,5 +409,6 @@ export const getTabId = definePageTool({
const page = context.getPageById(request.params.pageId);
const tabId = (page.pptrPage as unknown as CdpPage)._tabId;
response.setTabId(tabId);
response.appendResponseLine(`Tab ID: ${tabId}`);
},
});
+1 -1
View File
@@ -1293,7 +1293,7 @@ describe('pages', () => {
const result = await response.handle('get_tab_id', context);
// @ts-expect-error _tabId is internal.
assert.strictEqual(result.structuredContent.tabId, 'test-tab-id');
assert.deepStrictEqual(response.responseLines, []);
assert.deepStrictEqual(response.responseLines, ['Tab ID: test-tab-id']);
});
});
});