fix(app): sync cloud providers when the app window regains focus#2307
Open
benjaminshafii wants to merge 1 commit into
Open
fix(app): sync cloud providers when the app window regains focus#2307benjaminshafii wants to merge 1 commit into
benjaminshafii wants to merge 1 commit into
Conversation
Cloud-managed provider/model changes made in the Den web admin only reached the desktop app on sign-in, app launch, a 5-minute interval, or by opening Settings -> Cloud providers. Returning to the app window after editing a model in the web admin left the new model invisible for up to five minutes. Add window focus / visibilitychange triggers to useCloudProviderAutoSync so reconciliation runs when the user comes back to the app. The tick is throttled (15s) and deduped by the existing in-flight guard and the provider-auth store's sync queue.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
@benjaminshafii is attempting to deploy a commit to the Different AI Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Cloud-managed provider/model changes made in the Den web admin (port 3005) only reached the desktop app on sign-in, app launch, a 5-minute interval, or by manually opening Settings → Cloud providers. Returning to the app window after editing a model in the web admin left the new model invisible for up to five minutes — there was no window-focus / visibility trigger.
Fix
Add
focusandvisibilitychangetriggers touseCloudProviderAutoSyncso reconciliation runs when the user comes back to the app. The tick is:runCloudProviderSync).Files:
apps/app/src/app/cloud/sync/constants.ts— newCLOUD_FOCUS_SYNC_MIN_INTERVAL_MS.apps/app/src/react-app/domains/cloud/use-cloud-provider-auto-sync.ts—window_focusreason + listeners.apps/app/src/react-app/domains/connections/provider-auth/store.ts— extendCloudProviderSyncReasonunion.The reconciliation path itself (
performCloudProviderSyncinstore.ts) is unchanged and already correct — it force-refreshes Den providers, detects out-of-sync imports viaupdatedAt+modelIds, and removes + re-imports. The only gap was the missing trigger.Verification
Typecheck
```
pnpm --filter @openwork/app typecheck # PASS (tsc --noEmit, no errors)
```
Daytona e2e (BEFORE / dev branch — bug reproduced)
Two-sandbox flow: Den server sandbox (
openwork-server-...) + Electron sandbox (openwork-test-...) pointed at Den via--den-base-url/--den-api-base-urlwith--require-signin.lpr_01kv9rrbbbfzvsegx77t9jt274) with one modelgpt-4o-mini+ credential viaPOST /v1/llm-providers.alex@acme.test; selected Acme Robotics; onboarding showed "AI Providers — 1 MODEL"./workspace/hello. Cloud sync on sign-in imported the provider:```
opencode.jsonc -> provider.lpr_01kv9rrbbbfzvsegx77t9jt274.models = ["gpt-4o-mini"] ✅
```
gpt-4.1-miniviaPATCH /v1/llm-providers/:id(same payload the Den Web editor sends). Den list now returned 2 models;updatedAtbumped.blur+focus+visibilitychange(visible) on the window.opencode.jsoncstill showed only["gpt-4o-mini"]after focus. The new model did NOT sync. ConfirmeduseCloudProviderAutoSynchad no focus/visibility listener ondev.Daytona e2e (AFTER / fix branch)
Switched the same Electron sandbox to
fix/cloud-provider-window-focus-sync; Vite HMR picked up the change. The sandbox auto-stopped (60min--auto-stop) before the full AFTER flow could be re-run end-to-end, so the AFTER assertion is not yet captured as a recording.What is verified: the fix compiles clean, and the missing trigger is the only gap —
performCloudProviderSyncis the exact same reconciliation path the Settings → Cloud providers tab uses (settings_cloud_openedreason), which was verified working in the BEFORE run (it correctly detected the provider as out-of-sync and offered Import).Commands to reproduce
```bash
Server sandbox
bash .devcontainer/test-server-on-daytona.sh dev
Seed
daytona exec -- 'cd /workspace && pnpm --filter @openwork/email build && cd ee/apps/den-api && OPENWORK_DEV_MODE=1 ... pnpm exec tsx scripts/seed-demo-org.ts --reset'
Electron sandbox
bash .devcontainer/test-on-daytona.sh --den-base-url <DEN_WEB_URL> --den-api-base-url <DEN_API_URL> --require-signin --artifacts-volume
```
Notes / honesty