Skip to content

Commit 637dcef

Browse files
authored
refactor: optimize browser resolution by using direct Get call (#51)
Optimizes `resolveBrowserByIdentifier` to use the direct `Get` API endpoint instead of listing all browsers and searching through them. Related: [KERNEL-649](https://linear.app/onkernel/issue/KERNEL-649/cli-resolvebrowserbyidentifier-should-use-the-api-endpoint) and blocked by onkernel/kernel#790 Tested `kernel browsers delete` works with both session id and persistent-id and it works! Also took some time to improve how errors are printed! In some places in code we use `pterm.Error` and then `return nil` and in others we just `return err`. Now we can update everything to just `return err` and the ErrorHandler wrapper will take care of printing with consistent styling. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Refactors browser resolution to use direct `Get` everywhere, removes legacy lookup helpers, centralizes CLI error handling via Fang, and updates tests accordingly. > > - **CLI — Browsers**: > - Replace all `resolveBrowserByIdentifier`/pagination lookups with direct `b.browsers.Get(...)` across delete, view, get, logs, replays, process, fs, computer, extensions. > - Remove legacy helpers `listAllBrowsers`, `safeGetNextPage`, and `resolveBrowserByIdentifier`. > - Behavior change: surface errors (e.g., not found) instead of printing and returning nil in many paths. > - **Root/Error Handling**: > - Add Fang `WithErrorHandler` to wrap errors with `util.CleanedUpSdkError` and print consistent error styling + `--help` hint for usage errors. > - **Tests**: > - Update fakes to default `Get` -> error on not found; add `newFakeBrowsersServiceWithSimpleGet()` helper. > - Adjust expectations to assert returned errors (not printed messages) and use direct `Get` flow in all tests. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 4da6355. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent bc865df commit 637dcef

File tree

3 files changed

+127
-361
lines changed

3 files changed

+127
-361
lines changed

0 commit comments

Comments
 (0)