Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(cli): add --live and --focus flags for automation window lifecycle#1122

Merged
jackwener merged 1 commit into
mainfrom
feat/live-focus-flags
Apr 21, 2026
Merged

feat(cli): add --live and --focus flags for automation window lifecycle#1122
jackwener merged 1 commit into
mainfrom
feat/live-focus-flags

Conversation

@jackwener
Copy link
Copy Markdown
Owner

Summary

  • --live / OPENCLI_LIVE=1 keeps the automation window open after an adapter command finishes (default: close immediately as before)
  • --focus / OPENCLI_WINDOW_FOCUSED=1 already existed as env var; now also a CLI flag so users don't have to shell-export
  • Both parsed early and stripped from argv → work on any subcommand (adapter or browser), in any position

Why

@WAWQAQ asked for a way to stop commands from auto-closing, so the page stays visible for inspection or follow-up commands. --focus was also brought up and turned out to already exist as an env var — exposing it as a flag makes it actually discoverable.

Test plan

  • New execution.test.ts cases: OPENCLI_LIVE=1 skips closeWindow() on both success and failure paths
  • Existing calls closeWindow on browser command failure case still passes (default behavior unchanged)
  • npx vitest run src/execution.test.ts src/commanderAdapter.test.ts src/cli.test.ts — 99 passed
  • npm run build green
  • Smoke: opencli --live list and opencli list --focus both parse correctly

Not in scope

  • No auto-teardown timer for the lingering window — the extension's existing 30s idle timeout still applies if the user doesn't explicitly close. Can revisit if agents end up leaking windows across long sessions.

--live (OPENCLI_LIVE=1) keeps the automation window open after an adapter
command finishes, so agents or humans can inspect the page state. Default
behavior (immediate closeWindow) is unchanged.

--focus (OPENCLI_WINDOW_FOCUSED=1) surfaces the existing env-var toggle as a
CLI flag so users don't need to shell-export to see the window in foreground.

Both flags are parsed early in main.ts and stripped from argv, so they can be
placed anywhere on the command line and work on any subcommand (adapter or
browser).
@jackwener jackwener merged commit d36bee0 into main Apr 21, 2026
13 checks passed
@jackwener jackwener deleted the feat/live-focus-flags branch April 21, 2026 13:14
luxiaolei pushed a commit to luxiaolei/OpenCLI that referenced this pull request Apr 22, 2026
…le (jackwener#1122)

--live (OPENCLI_LIVE=1) keeps the automation window open after an adapter
command finishes, so agents or humans can inspect the page state. Default
behavior (immediate closeWindow) is unchanged.

--focus (OPENCLI_WINDOW_FOCUSED=1) surfaces the existing env-var toggle as a
CLI flag so users don't need to shell-export to see the window in foreground.

Both flags are parsed early in main.ts and stripped from argv, so they can be
placed anywhere on the command line and work on any subcommand (adapter or
browser).

(cherry picked from commit d36bee0)
@Henry-G-H-Huang
Copy link
Copy Markdown

I checked PR #1122 more closely, and I think the keep-alive fix may only apply to adapter execution, not to opencli browser ... built-in subcommands.
From the diff in PR #1122:

  • src/main.ts only parses --live / --focus and converts them into env vars
  • src/execution.ts is the only place that actually consumes OPENCLI_LIVE
  • the change there only skips page.closeWindow() after command execution
    However, PR feat(cli): add --live and --focus flags for automation window lifecycle #1122 does not seem to modify the built-in browser command path at all:
  • src/cli.ts
  • src/browser/page.ts
  • src/browser/bridge.ts
  • src/browser/daemon-client.ts
    So unless I’m missing something, --live appears to affect adapter cleanup, but not opencli browser open/state/click/tab list/....
    That seems consistent with what I’m observing in practice:
  • opencli browser --live ... is accepted
  • but multi-step browser flows can still drift back to about:blank / lose the active target
  • so the browser command group itself still does not seem to have true keep-alive semantics
    Could you clarify whether PR feat(cli): add --live and --focus flags for automation window lifecycle #1122 was intended to cover opencli browser ... subcommands too?
    If yes, could you point to the code path where OPENCLI_LIVE is consumed for browser subcommands?
    If not, then I think 自动关闭问题 #924 may only be partially resolved: adapter commands are covered, but the browser command group is not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants