From 2a233080f7737a5add9390cadeb029f662d1de9f Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Fri, 20 Jun 2025 11:55:50 +0000
Subject: [PATCH] Update listTabsMarkdown to use 0-based indexing consistently
Co-authored-by: dgozman <9881434+dgozman@users.noreply.github.com>
---
src/context.ts | 2 +-
tests/tabs.spec.ts | 26 +++++++++++++-------------
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/context.ts b/src/context.ts
index d2f4238..2b1e0d8 100644
--- a/src/context.ts
+++ b/src/context.ts
@@ -121,7 +121,7 @@ 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');
}
diff --git a/tests/tabs.spec.ts b/tests/tabs.spec.ts
index a0f7735..40f049b 100644
--- a/tests/tabs.spec.ts
+++ b/tests/tabs.spec.ts
@@ -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,
Tab oneBody one)`);
+- 0: [] (about:blank)
+- 1: (current) [Tab one] (data:text/html,Tab oneBody one)`);
});
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,Tab oneBody one)
+- 0: [] (about:blank)
+- 1: (current) [Tab one] (data:text/html,Tab oneBody one)
### Current tab
- Page URL: data:text/html,Tab oneBody one
@@ -71,9 +71,9 @@ test('create new tab', async ({ client }) => {
\`\`\`
### Open tabs
-- 1: [] (about:blank)
-- 2: [Tab one] (data:text/html,Tab oneBody one)
-- 3: (current) [Tab two] (data:text/html,Tab twoBody two)
+- 0: [] (about:blank)
+- 1: [Tab one] (data:text/html,Tab oneBody one)
+- 2: (current) [Tab two] (data:text/html,Tab twoBody two)
### Current tab
- Page URL: data:text/html,Tab twoBody two
@@ -99,9 +99,9 @@ test('select tab', async ({ client }) => {
\`\`\`
### Open tabs
-- 1: [] (about:blank)
-- 2: (current) [Tab one] (data:text/html,Tab oneBody one)
-- 3: [Tab two] (data:text/html,Tab twoBody two)
+- 0: [] (about:blank)
+- 1: (current) [Tab one] (data:text/html,Tab oneBody one)
+- 2: [Tab two] (data:text/html,Tab twoBody two)
### Current tab
- Page URL: data:text/html,Tab oneBody one
@@ -127,8 +127,8 @@ test('close tab', async ({ client }) => {
\`\`\`
### Open tabs
-- 1: [] (about:blank)
-- 2: (current) [Tab one] (data:text/html,Tab oneBody one)
+- 0: [] (about:blank)
+- 1: (current) [Tab one] (data:text/html,Tab oneBody one)
### Current tab
- Page URL: data:text/html,Tab oneBody one