Skip to content

Commit 259b3d8

Browse files
committed
feat: navigate tabs to chrome://newtab after loading Claude extension
The Claude extension opens claude.ai by default, which shows a login prompt. After loading the extension and restarting Chrome, navigate all tabs to chrome://newtab for a cleaner initial state.
1 parent abae93f commit 259b3d8

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

internal/claude/loader.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,25 @@ func LoadIntoBrowser(ctx context.Context, opts LoadIntoBrowserOptions) error {
130130
}
131131

132132
// Restart Chromium to pick up the new pinned extension preference
133-
// Use Spawn (fire and forget) because supervisorctl start can take time
134-
_, _ = proc.Spawn(ctx, opts.BrowserID, kernel.BrowserProcessSpawnParams{
135-
Command: "supervisorctl",
136-
Args: []string{"start", "chromium"},
137-
AsRoot: kernel.Opt(true),
133+
// Use Exec to wait for it to start before navigating
134+
_, _ = proc.Exec(ctx, opts.BrowserID, kernel.BrowserProcessExecParams{
135+
Command: "supervisorctl",
136+
Args: []string{"start", "chromium"},
137+
AsRoot: kernel.Opt(true),
138+
TimeoutSec: kernel.Opt(int64(30)),
139+
})
140+
141+
// Step 4: Navigate all tabs to chrome://newtab to avoid the Claude login page
142+
// The extension opens claude.ai by default which shows a login prompt
143+
navigateScript := `
144+
const pages = context.pages();
145+
for (const p of pages) {
146+
await p.goto('chrome://newtab');
147+
}
148+
`
149+
_, _ = opts.Client.Browsers.Playwright.Execute(ctx, opts.BrowserID, kernel.BrowserPlaywrightExecuteParams{
150+
Code: navigateScript,
151+
TimeoutSec: kernel.Opt(int64(30)),
138152
})
139153

140154
return nil

0 commit comments

Comments
 (0)