The container-side idle detection (--destroy-after-idle-ms) was ineffective because the daemon maintains a persistent CDP connection with keepalives. The cdp-activity-monitor.sh watched all CDP packets via tcpdump, but the constant keepalive traffic prevented idle detection from ever triggering.
Move idle detection to the host side by:
- Having the wrapper script touch activity files on every invocation
- A new monitor command checks activity file mtime to detect idle sessions
- When idle, the monitor closes sessions via the wrapper's close command
New command implementation that:
- Lists
*.activityfiles in~/.local/share/agent-browser/ - Checks each activity file's mtime to determine idle time
- Closes sessions that exceed the idle threshold
- Supports
--idle-timeout,--check-interval,--dry-run, and--onceoptions
The wrapper script now:
- Creates
STATE_DIR=~/.local/share/agent-browseron startup - Touches
${session_name}.activityon every invocation - Writes
${session_name}.containerwhen starting a new browser (maps session to container name) - Handles
closecommand specially: closes daemon, stops container, cleans up state files - No longer passes
--destroy-after-idle-msto browserctl
Added monitor-browser-sessions command with options:
--idle-timeout SECONDS(default: 90)--check-interval SECONDS(default: 15)--dry-run- show what would happen--once- run once and exit (for testing)
Removed --destroy-after-idle-ms option from start-browser command.
- Removed
DESTROY_AFTER_IDLE_MSenvironment variable handling - Removed
destroy_after_idle_msfrom saved state
- Removed
destroy_after_idle_msdisplay logic from verbose mode - Simplified idle info display
- Removed
destroy_after_idle_msdisplay logic from verbose mode - Simplified idle info display
- Removed
tcpdumpfrom installed packages (was only used for CDP monitoring) - Removed COPY commands for
cdp-activity-monitor.shandidle-reporter.sh - Removed chmod for deleted scripts
- Removed
--destroy-after-idle-ms 30000from browserctl start command - Existing
close_browser()function handles cleanup
- Removed
DESTROY_AFTER_IDLE_MSconstant - Removed
--destroy-after-idle-msfrom browserctl start command - Added new
close_browser()function for explicit cleanup
clis/browserctl/container/scripts/cdp-activity-monitor.sh- Watched CDP traffic via tcpdumpclis/browserctl/container/scripts/idle-reporter.sh- Checked activity file mtime and killed supervisord when idleclis/browserctl/container/services/cdp-activity.conf- Supervisor config for cdp-activity-monitorclis/browserctl/container/services/idle-reporter.conf- Supervisor config for idle-reporter
internalctl monitor-browser-sessionsinternalctl monitor-browser-sessions --idle-timeout 60 --check-interval 10internalctl monitor-browser-sessions --once --dry-run1. Agent calls: arthack-agent-browser --session myname goto https://example.com
2. Wrapper touches ~/.local/share/agent-browser/myname.activity
3. Wrapper writes container name to ~/.local/share/agent-browser/myname.container (on first start)
4. Monitor loop checks mtime of *.activity files
5. If (now - mtime) >= idle_timeout:
- Runs: arthack-agent-browser close --session myname
- Wrapper closes daemon, stops container, removes state files
-
refactor(browserctl): remove container-side idle detection- Removes
--destroy-after-idle-msoption - Deletes container scripts and supervisor configs
- Updates all callers
- Removes
-
feat(internalctl): add host-side browser session monitor- Adds
monitor-browser-sessionscommand - Updates wrapper with activity tracking and close handling
- Adds