feat(cli): add tab profile controls and automation primitives (#1396)

* feat(cli): add browser tab profile controls

* feat(cli): add tab profile automation primitives

* refactor(cli): narrow tab profile automation scope

* chore: retrigger PR checks

* review: harden tab profile automation CLI

- Wait for tab re-registration after browser.tabSetProfile so a follow-up tab list --show-profile reads the new sessionProfileId from BrowserManager instead of the stale one from the previous webview
- Wait for tab registration after browser.tabProfileClone, matching browser.tabCreate, so the cloned browserPageId is operable when the CLI returns
- Short-circuit browser.tabSetProfile when the tab is already on the requested profile so we do not tear down and remount the webview for a no-op switch
- Switch TabShow.worktree from OptionalPlainString to OptionalString to match every other tab schema; empty --worktree should fall back to the active worktree, not pass through as the empty string
- Add max-lines disable to browser.test.ts (file grew past 300 lines after adding the new tab-profile and tab-show tests)

* review: fix useIpcEvents test setup for tab profile API

CI failure: useIpcEvents.test.ts threw at module load with TypeError: window.addEventListener is not a function. The chain: the rebased useIpcEvents.ts imports destroyPersistentWebview from webview-registry, which calls window.addEventListener at module load. The test stubs window via vi.stubGlobal as a plain object without addEventListener, so the typeof window check passes but the call throws.

- webview-registry.ts: tighten the module-load guard to also check that window.addEventListener is callable, so importing this module from a non-DOM-ish test env (vitest node env with stubbed window) does not throw at module load
- useIpcEvents.test.ts: add the new onRequestTabSetProfile and replyTabSetProfile stubs to all 8 window.api.ui mocks so the new IPC subscription registered by useIpcEvents resolves

* review: restore profile CRUD lost during rebase onto 1397-merged main

The rebase brought commit 3242aa27 (refactor: narrow tab profile automation scope) onto a main that already had the lifecycle CRUD from 1397. The refactor commit removes BrowserProfileList/Create/Delete types, runtime methods, RPC registrations and schemas, plus the help/specs entries, because those were the precursor versions in commit 1 of this branch. Post-rebase those removals land on the hardened versions inherited from main, breaking 1397.

Restore:
- runtime-types.ts: BrowserSessionProfile import; ProfileList/Create/Delete result types
- orca-runtime.ts: ProfileList/Create/Delete result type imports; browserProfileList/Create/Delete methods
- browser-core.ts: ProfileCreate, ProfileDelete schema imports; browser.profileList/profileCreate/profileDelete RPC registrations
- browser-schemas.ts: ProfileCreate, ProfileDelete zod schemas
- help.ts: list/create/delete subcommand lines under Browser Automation
- specs/browser-basic.ts: list/create/delete spec entries

---------

Co-authored-by: Nikolatesla-lj <Nikolatesla-lj@users.noreply.github.com>
Co-authored-by: Jinwoo-H <jinwoo0825@gmail.com>
This commit is contained in:
Nikolatesla-lj
2026-05-04 23:46:23 -07:00
committed by GitHub
co-authored by Nikolatesla-lj Jinwoo-H
parent 70ffa0a73d
commit e623372cdb
20 changed files with 855 additions and 86 deletions
+39 -3
View File
@@ -154,7 +154,19 @@ export const BROWSER_BASIC_COMMAND_SPECS: CommandSpec[] = [
{
path: ['tab', 'list'],
summary: 'List open browser tabs',
usage: 'orca tab list [--worktree <selector|all>] [--json]',
usage: 'orca tab list [--worktree <selector|all>] [--show-profile] [--json]',
allowedFlags: [...GLOBAL_FLAGS, 'worktree', 'show-profile']
},
{
path: ['tab', 'show'],
summary: 'Show one browser tab by page id',
usage: 'orca tab show --page <id> [--worktree <selector>] [--json]',
allowedFlags: [...GLOBAL_FLAGS, 'worktree']
},
{
path: ['tab', 'current'],
summary: 'Show the current browser tab',
usage: 'orca tab current [--worktree <selector|all>] [--json]',
allowedFlags: [...GLOBAL_FLAGS, 'worktree']
},
{
@@ -166,8 +178,8 @@ export const BROWSER_BASIC_COMMAND_SPECS: CommandSpec[] = [
{
path: ['tab', 'create'],
summary: 'Create a new browser tab in the current worktree',
usage: 'orca tab create [--url <url>] [--worktree <selector>] [--json]',
allowedFlags: [...GLOBAL_FLAGS, 'url', 'worktree']
usage: 'orca tab create [--url <url>] [--worktree <selector>] [--profile <id>] [--json]',
allowedFlags: [...GLOBAL_FLAGS, 'url', 'worktree', 'profile']
},
{
path: ['tab', 'profile', 'list'],
@@ -187,6 +199,30 @@ export const BROWSER_BASIC_COMMAND_SPECS: CommandSpec[] = [
usage: 'orca tab profile delete --profile <id> [--json]',
allowedFlags: [...GLOBAL_FLAGS, 'profile']
},
{
path: ['tab', 'profile', 'set'],
summary: 'Switch a browser tab to a different browser profile',
usage: 'orca tab profile set (--page <id> | --worktree <selector>) --profile <id> [--json]',
allowedFlags: [...GLOBAL_FLAGS, 'profile', 'worktree']
},
{
path: ['tab', 'profile', 'show'],
summary: 'Show the browser profile bound to a tab',
usage: 'orca tab profile show --page <id> [--worktree <selector>] [--json]',
allowedFlags: [...GLOBAL_FLAGS, 'worktree']
},
{
path: ['tab', 'profile', 'use-default'],
summary: 'Switch a browser tab back to the default browser profile',
usage: 'orca tab profile use-default --page <id> [--worktree <selector>] [--json]',
allowedFlags: [...GLOBAL_FLAGS, 'worktree']
},
{
path: ['tab', 'profile', 'clone'],
summary: 'Clone a browser tab into a different browser profile',
usage: 'orca tab profile clone --profile <id> [--page <id>] [--worktree <selector>] [--json]',
allowedFlags: [...GLOBAL_FLAGS, 'profile', 'worktree']
},
{
path: ['tab', 'close'],
summary: 'Close a browser tab',