Skip to content

Commit 36e09e3

Browse files
committed
refactor(browsers): unify browser delete messages
1 parent bb36721 commit 36e09e3

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ Create an API key from the [Kernel dashboard](https://dashboard.onkernel.com).
149149

150150
- `kernel browsers list` - List running browsers
151151
- `kernel browsers create` - Create a new browser session
152-
- `-p, --persistence-id <id>` - Unique identifier for browser session persistence
153152
- `-s, --stealth` - Launch browser in stealth mode to avoid detection
154153
- `-H, --headless` - Launch browser without GUI access
155154
- `--kiosk` - Launch browser in kiosk mode

cmd/browsers.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,7 @@ func (b BrowsersCmd) Delete(ctx context.Context, in BrowsersDeleteInput) error {
400400
return nil
401401
}
402402

403-
var confirmMsg string
404-
if found.Persistence.ID == in.Identifier {
405-
confirmMsg = fmt.Sprintf("Are you sure you want to delete browser with persistent ID \"%s\"?", in.Identifier)
406-
} else {
407-
confirmMsg = fmt.Sprintf("Are you sure you want to delete browser with ID \"%s\"?", in.Identifier)
408-
}
403+
confirmMsg := fmt.Sprintf("Are you sure you want to delete browser \"%s\"?", in.Identifier)
409404
pterm.DefaultInteractiveConfirm.DefaultText = confirmMsg
410405
result, _ := pterm.DefaultInteractiveConfirm.Show()
411406
if !result {
@@ -414,21 +409,20 @@ func (b BrowsersCmd) Delete(ctx context.Context, in BrowsersDeleteInput) error {
414409
}
415410

416411
if found.Persistence.ID == in.Identifier {
417-
pterm.Info.Printf("Deleting browser with persistent ID: %s\n", in.Identifier)
418412
err = b.browsers.Delete(ctx, kernel.BrowserDeleteParams{PersistentID: in.Identifier})
419413
if err != nil && !util.IsNotFound(err) {
420414
return util.CleanedUpSdkError{Err: err}
421415
}
422-
pterm.Success.Printf("Successfully deleted browser with persistent ID: %s\n", in.Identifier)
416+
pterm.Success.Printf("Successfully deleted browser: %s\n", in.Identifier)
423417
return nil
424418
}
425419

426-
pterm.Info.Printf("Deleting browser with ID: %s\n", in.Identifier)
420+
pterm.Info.Printf("Deleting browser: %s\n", in.Identifier)
427421
err = b.browsers.DeleteByID(ctx, in.Identifier)
428422
if err != nil && !util.IsNotFound(err) {
429423
return util.CleanedUpSdkError{Err: err}
430424
}
431-
pterm.Success.Printf("Successfully deleted browser with ID: %s\n", in.Identifier)
425+
pterm.Success.Printf("Successfully deleted browser: %s\n", in.Identifier)
432426
return nil
433427
}
434428

@@ -443,7 +437,7 @@ func (b BrowsersCmd) Delete(ctx context.Context, in BrowsersDeleteInput) error {
443437
}
444438
}
445439

446-
// Attempt by persistent ID
440+
// Attempt by persistent ID (backward compatibility)
447441
if err := b.browsers.Delete(ctx, kernel.BrowserDeleteParams{PersistentID: in.Identifier}); err != nil {
448442
if !util.IsNotFound(err) {
449443
nonNotFoundErrors = append(nonNotFoundErrors, err)
@@ -2571,7 +2565,7 @@ func truncateURL(url string, maxLen int) string {
25712565
return url[:maxLen-3] + "..."
25722566
}
25732567

2574-
// resolveBrowserByIdentifier finds a browser by session ID or persistent ID.
2568+
// resolveBrowserByIdentifier finds a browser by session ID or persistent ID (backward compatibility).
25752569
func (b BrowsersCmd) resolveBrowserByIdentifier(ctx context.Context, identifier string) (*kernel.BrowserListResponse, error) {
25762570
page, err := b.browsers.List(ctx, kernel.BrowserListParams{})
25772571
if err != nil {

0 commit comments

Comments
 (0)