5 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
2a233080f7 Update listTabsMarkdown to use 0-based indexing consistently
Co-authored-by: dgozman <9881434+dgozman@users.noreply.github.com>
2025-06-20 11:55:50 +00:00
copilot-swe-agent[bot]
f4bc6447eb Revert description changes to remove explicit 0-based indexing mentions
Co-authored-by: Skn0tt <14912729+Skn0tt@users.noreply.github.com>
2025-06-19 09:50:55 +00:00
copilot-swe-agent[bot]
708aa6d6a5 Change tab selection to use 0-based indexing instead of 1-based
Co-authored-by: Skn0tt <14912729+Skn0tt@users.noreply.github.com>
2025-06-19 09:38:10 +00:00
copilot-swe-agent[bot]
c82a17ddfd Clarify 1-based indexing in browser_tab_select and browser_tab_close tools
Co-authored-by: Skn0tt <14912729+Skn0tt@users.noreply.github.com>
2025-06-19 09:25:48 +00:00
copilot-swe-agent[bot]
8e0ccf770b Initial plan for issue 2025-06-19 08:34:03 +00:00
4 changed files with 21 additions and 27 deletions

View File

@@ -101,7 +101,7 @@ export class Context {
}
async selectTab(index: number) {
this._currentTab = this._tabs[index - 1];
this._currentTab = this._tabs[index];
await this._currentTab.page.bringToFront();
}
@@ -121,13 +121,13 @@ export class Context {
const title = await tab.title();
const url = tab.page.url();
const current = tab === this._currentTab ? ' (current)' : '';
lines.push(`- ${i + 1}:${current} [${title}] (${url})`);
lines.push(`- ${i}:${current} [${title}] (${url})`);
}
return lines.join('\n');
}
async closeTab(index: number | undefined) {
const tab = index === undefined ? this._currentTab : this._tabs[index - 1];
const tab = index === undefined ? this._currentTab : this._tabs[index];
await tab?.page.close();
return await this.listTabsMarkdown();
}

View File

@@ -34,12 +34,6 @@ const close = defineTool({
code: [`await page.close()`],
captureSnapshot: false,
waitForNetwork: false,
resultOverride: {
content: [{
type: 'text',
text: 'Browser closed successfully.',
}],
},
};
},
});

View File

@@ -29,7 +29,7 @@ test('test reopen browser', async ({ startClient, server, mcpMode }) => {
expect(await client.callTool({
name: 'browser_close',
})).toContainTextContent('Browser closed successfully.');
})).toContainTextContent('No open pages available');
expect(await client.callTool({
name: 'browser_navigate',

View File

@@ -33,7 +33,7 @@ test('list initial tabs', async ({ client }) => {
expect(await client.callTool({
name: 'browser_tab_list',
})).toHaveTextContent(`### Open tabs
- 1: (current) [] (about:blank)`);
- 0: (current) [] (about:blank)`);
});
test('list first tab', async ({ client }) => {
@@ -41,8 +41,8 @@ test('list first tab', async ({ client }) => {
expect(await client.callTool({
name: 'browser_tab_list',
})).toHaveTextContent(`### Open tabs
- 1: [] (about:blank)
- 2: (current) [Tab one] (data:text/html,<title>Tab one</title><body>Body one</body>)`);
- 0: [] (about:blank)
- 1: (current) [Tab one] (data:text/html,<title>Tab one</title><body>Body one</body>)`);
});
test('create new tab', async ({ client }) => {
@@ -53,8 +53,8 @@ test('create new tab', async ({ client }) => {
\`\`\`
### Open tabs
- 1: [] (about:blank)
- 2: (current) [Tab one] (data:text/html,<title>Tab one</title><body>Body one</body>)
- 0: [] (about:blank)
- 1: (current) [Tab one] (data:text/html,<title>Tab one</title><body>Body one</body>)
### Current tab
- Page URL: data:text/html,<title>Tab one</title><body>Body one</body>
@@ -71,9 +71,9 @@ test('create new tab', async ({ client }) => {
\`\`\`
### Open tabs
- 1: [] (about:blank)
- 2: [Tab one] (data:text/html,<title>Tab one</title><body>Body one</body>)
- 3: (current) [Tab two] (data:text/html,<title>Tab two</title><body>Body two</body>)
- 0: [] (about:blank)
- 1: [Tab one] (data:text/html,<title>Tab one</title><body>Body one</body>)
- 2: (current) [Tab two] (data:text/html,<title>Tab two</title><body>Body two</body>)
### Current tab
- Page URL: data:text/html,<title>Tab two</title><body>Body two</body>
@@ -90,18 +90,18 @@ test('select tab', async ({ client }) => {
expect(await client.callTool({
name: 'browser_tab_select',
arguments: {
index: 2,
index: 1,
},
})).toHaveTextContent(`
- Ran Playwright code:
\`\`\`js
// <internal code to select tab 2>
// <internal code to select tab 1>
\`\`\`
### Open tabs
- 1: [] (about:blank)
- 2: (current) [Tab one] (data:text/html,<title>Tab one</title><body>Body one</body>)
- 3: [Tab two] (data:text/html,<title>Tab two</title><body>Body two</body>)
- 0: [] (about:blank)
- 1: (current) [Tab one] (data:text/html,<title>Tab one</title><body>Body one</body>)
- 2: [Tab two] (data:text/html,<title>Tab two</title><body>Body two</body>)
### Current tab
- Page URL: data:text/html,<title>Tab one</title><body>Body one</body>
@@ -118,17 +118,17 @@ test('close tab', async ({ client }) => {
expect(await client.callTool({
name: 'browser_tab_close',
arguments: {
index: 3,
index: 2,
},
})).toHaveTextContent(`
- Ran Playwright code:
\`\`\`js
// <internal code to close tab 3>
// <internal code to close tab 2>
\`\`\`
### Open tabs
- 1: [] (about:blank)
- 2: (current) [Tab one] (data:text/html,<title>Tab one</title><body>Body one</body>)
- 0: [] (about:blank)
- 1: (current) [Tab one] (data:text/html,<title>Tab one</title><body>Body one</body>)
### Current tab
- Page URL: data:text/html,<title>Tab one</title><body>Body one</body>