fix: browse env inconsistently updates internal state

Merged
SH
8mo ago
+8-2

Summary

  • browse env showed stale "local" mode after browse env remote
  • Root cause: .mode file was only written during lazy browser init (ensureBrowserInitialized), not at daemon startup. Between daemon start and first command, readCurrentMode() returned null and fell back to hardcoded "local"
  • Write .mode eagerly in runDaemon() at startup so it's immediately available
  • Fall back to desiredMode instead of "local" in the env display handler as a safety net

Test plan

  • Reproduced bug: browse env remote → browse env showed "mode":"local"
  • Verified fix: browse env remote → browse env now shows "mode":"remote"
  • mode.test.ts passes (3/3)

Summary by cubic

Fixes browse env showing stale "local" after browse env remote (STG-1547). The daemon now writes .mode at startup, the display falls back to desiredMode until mode is written, and a patch changeset is added for @browserbasehq/browse-cli.