Skip to content

Commit badd948

Browse files
committed
feat(browsers): log browser details in list output
1 parent 7faef87 commit badd948

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

cmd/browsers.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ func (b BrowsersCmd) List(ctx context.Context, in BrowsersListInput) error {
250250
tableData := pterm.TableData{headers}
251251

252252
for _, browser := range browsers {
253+
// log the browser
254+
pterm.Info.Println(browser)
255+
253256
persistentID := "-"
254257
if browser.Persistence.ID != "" {
255258
persistentID = browser.Persistence.ID
@@ -264,8 +267,8 @@ func (b BrowsersCmd) List(ctx context.Context, in BrowsersListInput) error {
264267

265268
// Check for pool_id in ExtraFields (until SDK is updated with PoolID field)
266269
poolID := "-"
267-
if pf, ok := browser.JSON.ExtraFields["pool_id"]; ok && pf.Valid() {
268-
poolID = "Pooled"
270+
if browser.PoolID != "" {
271+
poolID = browser.PoolID
269272
}
270273

271274
row := []string{
@@ -370,17 +373,17 @@ func (b BrowsersCmd) Create(ctx context.Context, in BrowsersCreateInput) error {
370373
return util.CleanedUpSdkError{Err: err}
371374
}
372375

373-
printBrowserSessionResult(browser.SessionID, browser.CdpWsURL, browser.BrowserLiveViewURL, browser.Persistence, browser.Profile)
376+
printBrowserSessionResult(browser.SessionID, browser.CdpWsURL, browser.BrowserLiveViewURL, browser.PoolID, browser.Persistence, browser.Profile)
374377
return nil
375378
}
376379

377-
func printBrowserSessionResult(sessionID, cdpURL, liveViewURL string, persistence kernel.BrowserPersistence, profile kernel.Profile) {
378-
tableData := buildBrowserTableData(sessionID, cdpURL, liveViewURL, persistence, profile)
380+
func printBrowserSessionResult(sessionID, cdpURL, liveViewURL, poolID string, persistence kernel.BrowserPersistence, profile kernel.Profile) {
381+
tableData := buildBrowserTableData(sessionID, cdpURL, liveViewURL, poolID, persistence, profile)
379382
PrintTableNoPad(tableData, true)
380383
}
381384

382385
// buildBrowserTableData creates a base table with common browser session fields.
383-
func buildBrowserTableData(sessionID, cdpURL, liveViewURL string, persistence kernel.BrowserPersistence, profile kernel.Profile) pterm.TableData {
386+
func buildBrowserTableData(sessionID, cdpURL, liveViewURL, poolID string, persistence kernel.BrowserPersistence, profile kernel.Profile) pterm.TableData {
384387
tableData := pterm.TableData{
385388
{"Property", "Value"},
386389
{"Session ID", sessionID},
@@ -399,6 +402,9 @@ func buildBrowserTableData(sessionID, cdpURL, liveViewURL string, persistence ke
399402
}
400403
tableData = append(tableData, []string{"Profile", profVal})
401404
}
405+
if poolID != "" {
406+
tableData = append(tableData, []string{"Pool ID", poolID})
407+
}
402408
return tableData
403409
}
404410

@@ -504,6 +510,7 @@ func (b BrowsersCmd) Get(ctx context.Context, in BrowsersGetInput) error {
504510
browser.SessionID,
505511
browser.CdpWsURL,
506512
browser.BrowserLiveViewURL,
513+
browser.PoolID,
507514
browser.Persistence,
508515
browser.Profile,
509516
)
@@ -2082,7 +2089,7 @@ func runBrowsersCreate(cmd *cobra.Command, args []string) error {
20822089
pterm.Error.Println("Acquire request timed out (no browser available). Retry to continue waiting.")
20832090
return nil
20842091
}
2085-
printBrowserSessionResult(resp.SessionID, resp.CdpWsURL, resp.BrowserLiveViewURL, resp.Persistence, resp.Profile)
2092+
printBrowserSessionResult(resp.SessionID, resp.CdpWsURL, resp.BrowserLiveViewURL, resp.PoolID, resp.Persistence, resp.Profile)
20862093
return nil
20872094
}
20882095

0 commit comments

Comments
 (0)