Skip to content

feat(extension): make WINDOW_IDLE_TIMEOUT configurable via OPENCLI_WINDOW_IDLE_TIMEOUT env var#1015

Open
xzygis wants to merge 1 commit intojackwener:mainfrom
xzygis:feat/configurable-window-idle-timeout
Open

feat(extension): make WINDOW_IDLE_TIMEOUT configurable via OPENCLI_WINDOW_IDLE_TIMEOUT env var#1015
xzygis wants to merge 1 commit intojackwener:mainfrom
xzygis:feat/configurable-window-idle-timeout

Conversation

@xzygis
Copy link
Copy Markdown

@xzygis xzygis commented Apr 14, 2026

Summary

Make the extension's automation window idle timeout configurable via the OPENCLI_WINDOW_IDLE_TIMEOUT environment variable, following the same per-command relay pattern used by OPENCLI_WINDOW_FOCUSED (#915).

Closes #1014

Problem

The extension's WINDOW_IDLE_TIMEOUT is hardcoded to 30 seconds. When opencli browser subcommands are used by AI agents, the automation window closes between commands because agents typically need 30-60+ seconds to analyze state and plan the next action.

Unlike adapter commands (which explicitly call closeWindow() per #915), opencli browser subcommands rely entirely on the idle timer for window lifecycle — making the 30s default too aggressive.

Changes

3 files, +15/-6 lines — minimal and focused:

extension/src/protocol.ts

  • Add windowIdleTimeout?: number to Command interface

src/browser/daemon-client.ts

  • Add windowIdleTimeout?: number to DaemonCommand interface
  • Read OPENCLI_WINDOW_IDLE_TIMEOUT env var (seconds, min 5), convert to ms, attach per-command

extension/src/background.ts

  • Replace hardcoded WINDOW_IDLE_TIMEOUT = 30000 with DEFAULT_WINDOW_IDLE_TIMEOUT = 600_000 (10 min)
  • Use mutable windowIdleTimeout variable updated from per-command payload
  • All idle timer code uses the variable instead of the constant

Design Decisions

  1. Per-command relay (not stored in chrome.storage): Follows the windowFocused pattern from feat: auto-close adapter windows, add OPENCLI_WINDOW_FOCUSED, document config #915. Each command carries the timeout value, keeping the extension stateless.

  2. Default raised to 10 minutes: Adapter commands already close windows immediately (feat: auto-close adapter windows, add OPENCLI_WINDOW_FOCUSED, document config #915), so the idle timer only matters for opencli browser sessions. 10 minutes gives AI agents ample time between steps.

  3. Minimum 5 seconds: Prevents misconfiguration from making windows uncloseable.

  4. Fully backward-compatible: If windowIdleTimeout is absent from the command payload, the extension uses the new 10-minute default. Old CLI versions work unchanged.

Usage

# Set idle timeout to 5 minutes (300 seconds)
export OPENCLI_WINDOW_IDLE_TIMEOUT=300
opencli browser open "https://example.com"
# Window stays alive for 5 min between commands

# Default (no env var): 10 minutes
opencli browser open "https://example.com"

Testing

Tested locally on macOS with Chrome + Browser Bridge Extension v1.0.0:

  • ✅ Without env var: window survives 60s+ idle (was closing at 30s)
  • ✅ With OPENCLI_WINDOW_IDLE_TIMEOUT=10: window closes after ~10s idle
  • opencli browser close still works for explicit cleanup
  • ✅ Adapter commands still auto-close immediately (unchanged behavior)

…NDOW_IDLE_TIMEOUT env var

- Add windowIdleTimeout field to Command protocol and DaemonCommand
- CLI reads OPENCLI_WINDOW_IDLE_TIMEOUT (seconds, min 5) and passes it per-command
- Extension uses received timeout, default raised from 30s to 10min
- Follows existing OPENCLI_WINDOW_FOCUSED pattern (per-command relay)

Closes jackwener#1014

Change-Id: I27135b861dd471d55bd15c0afa9cd92d91f7f8e1
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.

[Feature]: Make extension WINDOW_IDLE_TIMEOUT configurable via daemon

1 participant