btcp-browser-agent 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/package.json +8 -9
  2. package/packages/core/dist/actions.d.ts +97 -0
  3. package/packages/core/dist/actions.js +940 -0
  4. package/packages/core/dist/errors.d.ts +138 -0
  5. package/packages/core/dist/errors.js +157 -0
  6. package/packages/core/dist/index.d.ts +120 -0
  7. package/packages/core/dist/index.js +134 -0
  8. package/packages/core/dist/ref-map.d.ts +16 -0
  9. package/packages/core/dist/ref-map.js +91 -0
  10. package/packages/core/dist/snapshot.d.ts +37 -0
  11. package/packages/core/dist/snapshot.js +751 -0
  12. package/packages/core/dist/types.d.ts +396 -0
  13. package/packages/core/dist/types.js +7 -0
  14. package/packages/extension/dist/background.d.ts +227 -0
  15. package/packages/extension/dist/background.js +737 -0
  16. package/packages/extension/dist/content.d.ts +18 -0
  17. package/packages/extension/dist/content.js +149 -0
  18. package/packages/extension/dist/index.d.ts +228 -0
  19. package/packages/extension/dist/index.js +350 -0
  20. package/packages/extension/dist/session-manager.d.ts +87 -0
  21. package/packages/extension/dist/session-manager.js +322 -0
  22. package/packages/extension/{src/session-types.ts → dist/session-types.d.ts} +113 -144
  23. package/packages/extension/dist/session-types.js +5 -0
  24. package/packages/extension/dist/types.d.ts +88 -0
  25. package/packages/extension/dist/types.js +7 -0
  26. package/CLAUDE.md +0 -230
  27. package/SKILL.md +0 -143
  28. package/SNAPSHOT_IMPROVEMENTS.md +0 -302
  29. package/USAGE.md +0 -146
  30. package/dist/index.d.ts.map +0 -1
  31. package/dist/index.js.map +0 -1
  32. package/docs/browser-cli-design.md +0 -500
  33. package/examples/chrome-extension/CHANGELOG.md +0 -210
  34. package/examples/chrome-extension/DEBUG.md +0 -231
  35. package/examples/chrome-extension/ERROR_FIXED.md +0 -147
  36. package/examples/chrome-extension/QUICK_TEST.md +0 -189
  37. package/examples/chrome-extension/README.md +0 -149
  38. package/examples/chrome-extension/SESSION_ONLY_MODE.md +0 -305
  39. package/examples/chrome-extension/TEST_WITH_YOUR_TABS.md +0 -97
  40. package/examples/chrome-extension/build.js +0 -43
  41. package/examples/chrome-extension/manifest.json +0 -37
  42. package/examples/chrome-extension/package-lock.json +0 -1063
  43. package/examples/chrome-extension/package.json +0 -21
  44. package/examples/chrome-extension/popup.html +0 -195
  45. package/examples/chrome-extension/src/background.ts +0 -12
  46. package/examples/chrome-extension/src/content.ts +0 -7
  47. package/examples/chrome-extension/src/popup.ts +0 -303
  48. package/examples/chrome-extension/src/scenario-google-github.ts +0 -389
  49. package/examples/chrome-extension/test-page.html +0 -127
  50. package/examples/chrome-extension/tests/README.md +0 -206
  51. package/examples/chrome-extension/tests/scenario-google-to-github-star.ts +0 -380
  52. package/examples/chrome-extension/tsconfig.json +0 -14
  53. package/examples/snapshots/README.md +0 -207
  54. package/examples/snapshots/amazon-com-detail.html +0 -9528
  55. package/examples/snapshots/amazon-com-detail.snapshot.txt +0 -997
  56. package/examples/snapshots/convert-snapshots.ts +0 -97
  57. package/examples/snapshots/edition-cnn-com.html +0 -13292
  58. package/examples/snapshots/edition-cnn-com.snapshot.txt +0 -562
  59. package/examples/snapshots/github-com-microsoft-vscode.html +0 -2916
  60. package/examples/snapshots/github-com-microsoft-vscode.snapshot.txt +0 -455
  61. package/examples/snapshots/google-search.html +0 -20012
  62. package/examples/snapshots/google-search.snapshot.txt +0 -195
  63. package/examples/snapshots/metadata.json +0 -86
  64. package/examples/snapshots/npr-org-templates.html +0 -2031
  65. package/examples/snapshots/npr-org-templates.snapshot.txt +0 -224
  66. package/examples/snapshots/stackoverflow-com.html +0 -5216
  67. package/examples/snapshots/stackoverflow-com.snapshot.txt +0 -2404
  68. package/examples/snapshots/test-all-mode.html +0 -46
  69. package/examples/snapshots/test-all-mode.snapshot.txt +0 -5
  70. package/examples/snapshots/validate.test.ts +0 -296
  71. package/packages/cli/package.json +0 -42
  72. package/packages/cli/src/__tests__/cli.test.ts +0 -434
  73. package/packages/cli/src/__tests__/errors.test.ts +0 -226
  74. package/packages/cli/src/__tests__/executor.test.ts +0 -275
  75. package/packages/cli/src/__tests__/formatter.test.ts +0 -260
  76. package/packages/cli/src/__tests__/parser.test.ts +0 -288
  77. package/packages/cli/src/__tests__/suggestions.test.ts +0 -255
  78. package/packages/cli/src/commands/back.ts +0 -22
  79. package/packages/cli/src/commands/check.ts +0 -33
  80. package/packages/cli/src/commands/clear.ts +0 -33
  81. package/packages/cli/src/commands/click.ts +0 -32
  82. package/packages/cli/src/commands/closetab.ts +0 -31
  83. package/packages/cli/src/commands/eval.ts +0 -41
  84. package/packages/cli/src/commands/fill.ts +0 -30
  85. package/packages/cli/src/commands/focus.ts +0 -33
  86. package/packages/cli/src/commands/forward.ts +0 -22
  87. package/packages/cli/src/commands/goto.ts +0 -34
  88. package/packages/cli/src/commands/help.ts +0 -162
  89. package/packages/cli/src/commands/hover.ts +0 -34
  90. package/packages/cli/src/commands/index.ts +0 -129
  91. package/packages/cli/src/commands/newtab.ts +0 -35
  92. package/packages/cli/src/commands/press.ts +0 -40
  93. package/packages/cli/src/commands/reload.ts +0 -25
  94. package/packages/cli/src/commands/screenshot.ts +0 -27
  95. package/packages/cli/src/commands/scroll.ts +0 -64
  96. package/packages/cli/src/commands/select.ts +0 -35
  97. package/packages/cli/src/commands/snapshot.ts +0 -21
  98. package/packages/cli/src/commands/tab.ts +0 -32
  99. package/packages/cli/src/commands/tabs.ts +0 -26
  100. package/packages/cli/src/commands/text.ts +0 -27
  101. package/packages/cli/src/commands/title.ts +0 -17
  102. package/packages/cli/src/commands/type.ts +0 -38
  103. package/packages/cli/src/commands/uncheck.ts +0 -33
  104. package/packages/cli/src/commands/url.ts +0 -17
  105. package/packages/cli/src/commands/wait.ts +0 -54
  106. package/packages/cli/src/errors.ts +0 -164
  107. package/packages/cli/src/executor.ts +0 -68
  108. package/packages/cli/src/formatter.ts +0 -215
  109. package/packages/cli/src/index.ts +0 -257
  110. package/packages/cli/src/parser.ts +0 -195
  111. package/packages/cli/src/suggestions.ts +0 -207
  112. package/packages/cli/src/terminal/Terminal.ts +0 -365
  113. package/packages/cli/src/terminal/index.ts +0 -5
  114. package/packages/cli/src/types.ts +0 -155
  115. package/packages/cli/tsconfig.json +0 -20
  116. package/packages/core/package.json +0 -35
  117. package/packages/core/src/actions.ts +0 -1210
  118. package/packages/core/src/errors.ts +0 -296
  119. package/packages/core/src/index.test.ts +0 -638
  120. package/packages/core/src/index.ts +0 -220
  121. package/packages/core/src/ref-map.ts +0 -107
  122. package/packages/core/src/snapshot.ts +0 -873
  123. package/packages/core/src/types.ts +0 -536
  124. package/packages/core/tsconfig.json +0 -23
  125. package/packages/extension/README.md +0 -129
  126. package/packages/extension/package.json +0 -43
  127. package/packages/extension/src/background.ts +0 -888
  128. package/packages/extension/src/content.ts +0 -172
  129. package/packages/extension/src/index.ts +0 -579
  130. package/packages/extension/src/session-manager.ts +0 -385
  131. package/packages/extension/src/types.ts +0 -162
  132. package/packages/extension/tsconfig.json +0 -28
  133. package/src/index.ts +0 -64
  134. package/tsconfig.build.json +0 -12
  135. package/tsconfig.json +0 -26
  136. package/vitest.config.ts +0 -13
@@ -1,210 +0,0 @@
1
- # Changelog
2
-
3
- ## Latest Changes
4
-
5
- ### Session Management with Auto-Created Blank Tab
6
-
7
- **What Changed:**
8
- - When you click "Start New Session", it now **creates a new blank tab** and adds it to the session
9
- - Previously used the current active tab, which could interrupt your workflow
10
- - The new blank tab is ready for automation without affecting existing tabs
11
-
12
- **Why:**
13
- - Clean slate for each session
14
- - Doesn't interfere with tabs you already have open
15
- - Clear starting point for automation
16
-
17
- **How It Works:**
18
- ```javascript
19
- // User clicks "Start New Session"
20
- await client.groupCreate({ title: "BTCP Session 1" });
21
-
22
- // This now:
23
- // 1. Creates a new blank tab (about:blank)
24
- // 2. Adds it to a blue tab group labeled "BTCP Session 1"
25
- // 3. Makes it the active tab
26
- // 4. Ready for navigation/automation
27
- ```
28
-
29
- **User Experience:**
30
- 1. Click "Start New Session"
31
- 2. New blank tab opens in a blue group
32
- 3. All subsequent operations work in this session
33
- 4. Your existing tabs remain untouched
34
-
35
- ### Session-Only Mode
36
-
37
- **What Changed:**
38
- - Extension **only manages tabs within its session/tab group**
39
- - All operations require an active session
40
- - No operations allowed outside the session
41
-
42
- **Operations Affected:**
43
- - `listTabs()` - Only shows session tabs
44
- - `tabNew()` - Only creates in session
45
- - `closeTab()` - Only closes session tabs
46
- - `switchTab()` - Only switches to session tabs
47
- - `navigate()` - Only navigates session tabs
48
- - All DOM operations - Only in session tabs
49
-
50
- **Error Messages:**
51
- Without a session:
52
- ```
53
- Error: "No active session. Create a session first to manage tabs."
54
- ```
55
-
56
- Trying to access outside tabs:
57
- ```
58
- Error: "Cannot switch to tab: tab is not in the active session"
59
- ```
60
-
61
- **Benefits:**
62
- - ✅ Better security and isolation
63
- - ✅ Clear visual boundaries (tab groups)
64
- - ✅ Explicit user consent required
65
- - ✅ Protects personal tabs from automation
66
- - ✅ Clean separation of contexts
67
-
68
- ## Testing the Changes
69
-
70
- ### Test 1: New Blank Tab on Session Start
71
- ```
72
- 1. Open extension popup
73
- 2. Click "Start New Session"
74
- 3. Expected: New blank tab opens in blue group
75
- 4. Verify: Tab shows "about:blank" URL
76
- 5. Verify: Tab group labeled "BTCP Session 1"
77
- ```
78
-
79
- ### Test 2: Session Isolation
80
- ```
81
- 1. Have 3 regular tabs open (A, B, C)
82
- 2. Start new session → new blank tab D in group
83
- 3. Click "List Tabs" → should only show tab D
84
- 4. Create new tab → should join session with D
85
- 5. Tabs A, B, C remain untouched
86
- ```
87
-
88
- ### Test 3: Operations Require Session
89
- ```
90
- 1. Open popup without starting session
91
- 2. Click "List Tabs" → Error shown
92
- 3. Click "New Tab" → Error shown
93
- 4. Start session → Operations now work
94
- ```
95
-
96
- ## Migration Guide
97
-
98
- ### Before
99
- ```javascript
100
- // Extension used current active tab
101
- await client.groupCreate();
102
- // Your current tab got grouped
103
-
104
- // Could access any tab
105
- const tabs = await client.listTabs(); // All tabs
106
- ```
107
-
108
- ### After
109
- ```javascript
110
- // Extension creates new blank tab
111
- await client.groupCreate();
112
- // New blank tab created in group
113
- // Your existing tabs untouched
114
-
115
- // Only session tabs accessible
116
- const tabs = await client.listTabs(); // Only session tabs
117
- ```
118
-
119
- ### If You Want to Group Existing Tab
120
- ```javascript
121
- // Get tab you want to add
122
- const targetTab = await chrome.tabs.get(tabId);
123
-
124
- // Create session with that tab
125
- await client.groupCreate({ tabIds: [targetTab.id] });
126
-
127
- // Or add to existing session
128
- const session = await client.sessionGetCurrent();
129
- await client.groupAddTabs(session.groupId, [targetTab.id]);
130
- ```
131
-
132
- ## Visual Guide
133
-
134
- ### Session Start Flow
135
-
136
- **Before:**
137
- ```
138
- Browser tabs: [Gmail] [GitHub] [YouTube*]
139
- ↑ active
140
- User clicks "Start New Session"
141
- Result: [Gmail] [GitHub] [(YouTube* in blue group)]
142
- ↑ YouTube grouped, disrupts workflow
143
- ```
144
-
145
- **After:**
146
- ```
147
- Browser tabs: [Gmail] [GitHub] [YouTube]
148
- User clicks "Start New Session"
149
- Result: [Gmail] [GitHub] [YouTube] [(blank* in blue group)]
150
- ↑ New tab, clean slate
151
- ```
152
-
153
- ### Session Isolation
154
-
155
- ```
156
- Before session:
157
- [Tab A] [Tab B] [Tab C] [Tab D] [Tab E]
158
- ↑ Extension could access all tabs
159
-
160
- After session:
161
- [Tab A] [Tab B] [Tab C] | [Session: Tab D] [Tab E*]
162
- ↑ Blue group boundary
163
- Extension only accesses D and E
164
- ```
165
-
166
- ## Breaking Changes
167
-
168
- ### 1. Session Required
169
- **Before:** Could use extension without session
170
- **After:** Must create session first
171
-
172
- **Fix:** Always call `groupCreate()` before other operations
173
-
174
- ### 2. No Universal Tab Access
175
- **Before:** Could access any tab in window
176
- **After:** Can only access tabs in session
177
-
178
- **Fix:** Add tabs to session explicitly or create new tabs via extension
179
-
180
- ### 3. Active Tab Behavior
181
- **Before:** Session used current active tab
182
- **After:** Session creates new blank tab
183
-
184
- **Fix:** If you need to add existing tab, use `groupCreate({ tabIds: [existingTabId] })`
185
-
186
- ## Rollback
187
-
188
- If you need the old behavior, you can modify the source:
189
-
190
- **Remove session requirement:**
191
- In `background.ts`, change validation:
192
- ```typescript
193
- if (sessionGroupId === null) {
194
- return true; // Allow without session
195
- }
196
- ```
197
-
198
- **Use current tab instead of new:**
199
- In `session-manager.ts`, revert to:
200
- ```typescript
201
- const [activeTab] = await chrome.tabs.query({ active: true });
202
- targetTabIds = [activeTab.id];
203
- ```
204
-
205
- ## Version Info
206
-
207
- - **Build Date:** 2026-01-16
208
- - **Session Manager:** Creates blank tab by default
209
- - **Access Mode:** Session-only (no universal access)
210
- - **Backward Compatible:** No (requires session for all operations)
@@ -1,231 +0,0 @@
1
- # Debugging Guide: Start Session Not Working
2
-
3
- ## Step 1: Load the Extension
4
-
5
- 1. Open Chrome and go to `chrome://extensions`
6
- 2. Enable **Developer mode** (toggle in top right)
7
- 3. Click **Load unpacked**
8
- 4. Navigate to: `/Users/minh/Documents/btcp/btcp-browser-agent/examples/chrome-extension/dist/`
9
- 5. Select the `dist` folder and click **Select**
10
-
11
- ## Step 2: Check Extension Loaded
12
-
13
- You should see:
14
- - **BTCP Browser Agent** card in the extensions list
15
- - No errors shown in the extension card
16
- - Extension icon appears in the Chrome toolbar
17
-
18
- If you see errors, note them and check Step 3.
19
-
20
- ## Step 3: Check for Permission Errors
21
-
22
- ### View Background Service Worker Logs:
23
- 1. On the extension card, click **service worker** link (under "Inspect views")
24
- 2. This opens DevTools for the background script
25
- 3. Check Console tab for errors
26
-
27
- **Common errors:**
28
- - `chrome.tabGroups is not defined` → Permission missing
29
- - `SessionManager is not a constructor` → Build issue
30
- - `Failed to execute 'group'` → Invalid tab IDs
31
-
32
- ### Check Console Output:
33
- Look for these messages when extension loads:
34
- - No errors = Good ✅
35
- - Red errors = Problem ❌
36
-
37
- ## Step 4: Test the Popup
38
-
39
- 1. Click the extension icon in Chrome toolbar
40
- 2. Popup should open showing:
41
- - **Session** section at top
42
- - "No active session" (gray)
43
- - "Start New Session" button (blue)
44
- - Quick Actions section below
45
-
46
- 3. **Open popup DevTools:**
47
- - Right-click anywhere in the popup
48
- - Select **Inspect**
49
- - Go to **Console** tab
50
-
51
- ## Step 5: Test Start Session Button
52
-
53
- ### Click "Start New Session" button and watch for:
54
-
55
- **In Popup Console (DevTools):**
56
- ```
57
- [timestamp]
58
- Starting new session...
59
- ```
60
-
61
- Then either:
62
- ```javascript
63
- // Success:
64
- {
65
- "created": "BTCP Session 1",
66
- "groupId": 123
67
- }
68
-
69
- // Or Error:
70
- Error: [error message here]
71
- ```
72
-
73
- **In Background Service Worker Console:**
74
- Look for command execution logs or errors.
75
-
76
- ## Step 6: Common Issues & Solutions
77
-
78
- ### Issue 1: "chrome.tabGroups is undefined"
79
- **Cause:** Permission not granted
80
- **Fix:**
81
- 1. Open `manifest.json`
82
- 2. Verify `"tabGroups"` is in `"permissions"` array
83
- 3. Rebuild: `npm run build`
84
- 4. Reload extension in `chrome://extensions`
85
-
86
- ### Issue 2: "No active tab for DOM command"
87
- **Cause:** Extension needs an active tab to create group
88
- **Fix:**
89
- 1. Make sure you have at least one tab open
90
- 2. Click on a regular webpage tab (not chrome:// pages)
91
- 3. Then click extension icon and try again
92
-
93
- ### Issue 3: "Failed to execute 'group' on 'tabs'"
94
- **Cause:** Invalid tab ID or tab already closed
95
- **Fix:**
96
- 1. Open a new tab first
97
- 2. Navigate to a regular website (e.g., example.com)
98
- 3. Then try creating session
99
-
100
- ### Issue 4: Button click does nothing
101
- **Cause:** JavaScript error in popup
102
- **Fix:**
103
- 1. Check popup console for errors (see Step 4)
104
- 2. Common errors:
105
- - `client.groupCreate is not a function` → Rebuild needed
106
- - `btnStartSession is null` → HTML/JS mismatch
107
- - `Cannot read property 'group'` → API response issue
108
-
109
- ### Issue 5: "SessionManager is not a constructor"
110
- **Cause:** session-manager.js not properly built/imported
111
- **Fix:**
112
- ```bash
113
- # Rebuild the packages
114
- cd /Users/minh/Documents/btcp/btcp-browser-agent
115
- npm run build
116
- cd examples/chrome-extension
117
- npm run build
118
- ```
119
- Then reload extension.
120
-
121
- ## Step 7: Manual Console Testing
122
-
123
- ### Test in Background Service Worker Console:
124
- ```javascript
125
- // Get background agent
126
- const agent = globalThis.__backgroundAgent;
127
-
128
- // Test session manager
129
- agent.sessionManager.createGroup({ title: "Test Session" })
130
- .then(group => console.log("Created:", group))
131
- .catch(err => console.error("Error:", err));
132
- ```
133
-
134
- ### Test in Popup Console:
135
- ```javascript
136
- // Get client
137
- const client = createClient();
138
-
139
- // Test group creation
140
- client.groupCreate({ title: "Test Session" })
141
- .then(result => console.log("Result:", result))
142
- .catch(err => console.error("Error:", err));
143
- ```
144
-
145
- ## Step 8: Check Tab Groups API
146
-
147
- Test if Chrome supports tab groups:
148
- ```javascript
149
- // In any console:
150
- console.log(chrome.tabGroups);
151
- // Should show: Object with methods like 'group', 'update', 'query'
152
- // If undefined: Chrome version too old or API not available
153
- ```
154
-
155
- **Minimum Chrome version:** 89+ (tab groups API)
156
-
157
- ## Step 9: Verify Session Creation Manually
158
-
159
- After clicking "Start New Session":
160
-
161
- 1. **Check tabs in browser:**
162
- - Do you see a blue colored tab group?
163
- - Is there a label like "BTCP Session 1"?
164
-
165
- 2. **If no group visible:**
166
- - SessionManager may have created group but no tabs in it
167
- - Try clicking "New Tab" button
168
- - New tab should appear in a blue group
169
-
170
- ## Step 10: Full Debug Flow
171
-
172
- Run this complete test in **Background Service Worker Console**:
173
-
174
- ```javascript
175
- // 1. Check SessionManager exists
176
- console.log("SessionManager:", globalThis.SessionManager);
177
-
178
- // 2. Check background agent has session manager
179
- const agent = globalThis.__backgroundAgent || getBackgroundAgent();
180
- console.log("Agent has sessionManager:", !!agent.sessionManager);
181
-
182
- // 3. Try creating a group directly
183
- agent.sessionManager.createGroup({ title: "Debug Test" })
184
- .then(group => {
185
- console.log("✅ Group created:", group);
186
- return chrome.tabs.query({ groupId: group.id });
187
- })
188
- .then(tabs => {
189
- console.log("✅ Tabs in group:", tabs.length);
190
- })
191
- .catch(err => {
192
- console.error("❌ Error:", err);
193
- console.error("Stack:", err.stack);
194
- });
195
- ```
196
-
197
- ## Step 11: Collect Debug Info
198
-
199
- If still not working, collect this info:
200
-
201
- ```javascript
202
- // Run in Background Service Worker Console:
203
- {
204
- chromeVersion: navigator.userAgent.match(/Chrome\/(\d+)/)?.[1],
205
- tabGroupsAPI: typeof chrome.tabGroups,
206
- sessionManagerLoaded: typeof SessionManager !== 'undefined',
207
- backgroundAgent: typeof getBackgroundAgent !== 'undefined',
208
- activeTabs: await chrome.tabs.query({ active: true }),
209
- allGroups: await chrome.tabGroups.query({})
210
- }
211
- ```
212
-
213
- ## Quick Fix Checklist
214
-
215
- - [ ] Extension loaded without errors
216
- - [ ] Developer mode enabled
217
- - [ ] `tabGroups` permission in manifest
218
- - [ ] At least one regular tab open (not chrome://)
219
- - [ ] Background service worker console has no errors
220
- - [ ] Popup console has no errors
221
- - [ ] Chrome version 89 or higher
222
- - [ ] Extension reloaded after rebuild
223
-
224
- ## Getting More Help
225
-
226
- If still stuck, provide:
227
- 1. Chrome version
228
- 2. Console errors from both background and popup
229
- 3. Result of Step 10 debug flow
230
- 4. Screenshot of extension popup
231
- 5. Output of Step 11 debug info
@@ -1,147 +0,0 @@
1
- # ✅ Error Fixed: "Tabs can only be moved to and from normal windows"
2
-
3
- ## What Was the Problem?
4
-
5
- The error occurred because:
6
- 1. The extension was trying to get the "current window" using `chrome.windows.getCurrent()`
7
- 2. When called from a popup, this returns the **popup window**, not the main browser window
8
- 3. Chrome only allows tab grouping in **normal windows**, not popup/devtools/app windows
9
-
10
- ## The Fix
11
-
12
- Changed `session-manager.ts` to:
13
- 1. Find which window the target tab belongs to
14
- 2. Verify it's a "normal" window type
15
- 3. Use that window's ID for group creation
16
- 4. Provide clear error messages if window type is wrong
17
-
18
- ## How to Test Now
19
-
20
- ### Step 1: Reload Extension
21
- ```bash
22
- # Go to: chrome://extensions
23
- # Find: BTCP Browser Agent
24
- # Click the refresh icon (or remove and re-add)
25
- ```
26
-
27
- ### Step 2: Proper Test Setup
28
- 1. **Open a regular browser window** (if you don't have one)
29
- 2. **Open a regular website** in a tab (e.g., https://example.com)
30
- - NOT chrome:// pages
31
- - NOT extension pages
32
- - NOT devtools
33
- 3. **Make sure that tab is active** (click on it to focus)
34
- 4. **Then click the extension icon** in the toolbar
35
- 5. **Click "Start New Session"**
36
-
37
- ### Step 3: Expected Result
38
-
39
- ✅ **Success looks like:**
40
- ```
41
- [SessionManager] createGroup called with options: {}
42
- [SessionManager] No tabIds provided, getting active tab...
43
- [SessionManager] Active tab: {id: 123, url: "https://example.com", ...}
44
- [SessionManager] Creating group with tabs: [123]
45
- [SessionManager] Group created with ID: 456
46
- [SessionManager] Group updated with title: BTCP Session 1
47
- ```
48
-
49
- ✅ **Visual confirmation:**
50
- - Your active tab gets a **blue border/group indicator**
51
- - The tab shows group label: **"BTCP Session 1"**
52
- - Popup updates to show session info
53
-
54
- ## Common Mistakes to Avoid
55
-
56
- ### ❌ Wrong: Opening popup in a popup window
57
- **Don't:** Open extension in its own window
58
-
59
- **Do:** Use the extension icon in the main browser toolbar
60
-
61
- ### ❌ Wrong: Testing on chrome:// pages
62
- **Don't:** Have chrome://extensions as active tab
63
-
64
- **Do:** Have a real website (https://...) as active tab
65
-
66
- ### ❌ Wrong: Using DevTools window
67
- **Don't:** Have DevTools undocked as separate window
68
-
69
- **Do:** Keep DevTools docked or use regular browser window
70
-
71
- ## Verification Test
72
-
73
- Run this in the **Background Service Worker Console**:
74
-
75
- ```javascript
76
- // Check window types
77
- chrome.windows.getAll({ populate: true }, (windows) => {
78
- windows.forEach(w => {
79
- console.log(`Window ${w.id}:`, {
80
- type: w.type,
81
- focused: w.focused,
82
- tabs: w.tabs?.length || 0,
83
- tabTitles: w.tabs?.map(t => t.title)
84
- });
85
- });
86
- });
87
-
88
- // This should show at least one window with type: "normal"
89
- ```
90
-
91
- ## Still Not Working?
92
-
93
- If you still get errors, provide:
94
-
95
- 1. **Error message** (exact text from console)
96
- 2. **Window type** (from verification test above)
97
- 3. **Active tab URL** (what page are you on?)
98
- 4. **How you opened the extension** (toolbar icon? right-click?)
99
-
100
- ## Next Steps After Fix Works
101
-
102
- Once "Start New Session" works:
103
-
104
- 1. ✅ **Test "New Tab" button** - should auto-join the session
105
- 2. ✅ **Test "Close Session" button** - should close all tabs in group
106
- 3. ✅ **Test multiple tabs** - create several tabs, verify they all join
107
- 4. ✅ **Test session persistence** - session should exist until you close it
108
-
109
- ## Technical Details
110
-
111
- The key change in `session-manager.ts`:
112
-
113
- ```typescript
114
- // OLD (broken):
115
- const groupId = await chrome.tabs.group({
116
- tabIds: targetTabIds,
117
- createProperties: {
118
- windowId: (await chrome.windows.getCurrent()).id, // ❌ Returns popup window!
119
- },
120
- });
121
-
122
- // NEW (fixed):
123
- const tabs = await chrome.tabs.query({ windowId: chrome.windows.WINDOW_ID_CURRENT });
124
- const targetTab = tabs.find(t => targetTabIds.includes(t.id!));
125
- const window = await chrome.windows.get(targetTab.windowId);
126
-
127
- if (window.type !== 'normal') {
128
- throw new Error(`Tabs can only be grouped in normal windows`);
129
- }
130
-
131
- const groupId = await chrome.tabs.group({
132
- tabIds: targetTabIds,
133
- createProperties: {
134
- windowId: targetTab.windowId, // ✅ Uses tab's actual window!
135
- },
136
- });
137
- ```
138
-
139
- ## Build Version
140
-
141
- This fix is included in the build dated: **2026-01-16**
142
-
143
- Make sure you rebuild and reload:
144
- ```bash
145
- npm run build
146
- # Then reload extension in chrome://extensions
147
- ```