Skip to content

Commit abae93f

Browse files
committed
fix: stop Chrome before updating Preferences for extension pinning
Chrome overwrites the Preferences file on exit, so we need to: 1. Stop Chromium via supervisorctl stop 2. Update the Preferences file with pinned_extensions 3. Start Chromium via supervisorctl start This ensures Chrome reads our updated Preferences on startup.
1 parent 066a1ed commit abae93f

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

internal/claude/loader.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,38 @@ func LoadIntoBrowser(ctx context.Context, opts LoadIntoBrowserOptions) error {
102102
}
103103

104104
// Step 3: Pin the extension to the toolbar
105+
// We need to:
106+
// 1. Stop Chromium so it doesn't overwrite our Preferences changes
107+
// 2. Update the Preferences file
108+
// 3. Restart Chromium to pick up the changes
109+
proc := opts.Client.Browsers.Process
110+
111+
// Stop Chromium first (use Exec to wait for it to complete)
112+
_, _ = proc.Exec(ctx, opts.BrowserID, kernel.BrowserProcessExecParams{
113+
Command: "supervisorctl",
114+
Args: []string{"stop", "chromium"},
115+
AsRoot: kernel.Opt(true),
116+
TimeoutSec: kernel.Opt(int64(30)),
117+
})
118+
119+
// Now update the Preferences file while Chrome is stopped
105120
if err := pinExtension(ctx, opts.Client, opts.BrowserID, ExtensionID); err != nil {
106121
// Don't fail the whole operation if pinning fails - it's a nice-to-have
107122
// The extension is still loaded and functional
123+
// But still restart Chromium
124+
_, _ = proc.Spawn(ctx, opts.BrowserID, kernel.BrowserProcessSpawnParams{
125+
Command: "supervisorctl",
126+
Args: []string{"start", "chromium"},
127+
AsRoot: kernel.Opt(true),
128+
})
108129
return nil
109130
}
110131

111-
// Step 4: Restart Chromium to pick up the new pinned extension preference
112-
// Use Spawn (fire and forget) because supervisorctl restart waits a long time
113-
proc := opts.Client.Browsers.Process
132+
// Restart Chromium to pick up the new pinned extension preference
133+
// Use Spawn (fire and forget) because supervisorctl start can take time
114134
_, _ = proc.Spawn(ctx, opts.BrowserID, kernel.BrowserProcessSpawnParams{
115135
Command: "supervisorctl",
116-
Args: []string{"restart", "chromium"},
136+
Args: []string{"start", "chromium"},
117137
AsRoot: kernel.Opt(true),
118138
})
119139

0 commit comments

Comments
 (0)