Skip to content

fix(web): prevent stale workspace requests during peer surface hydration - #3528

Merged
kev1n77 merged 1 commit into
GCWing:mainfrom
kev1n77:fix/peer-workspace
Oct 23, 2026
Merged

kev1n77 merged 1 commit into
GCWing:mainfrom
kev1n77:fix/peer-workspace

Conversation

@kev1n77

@kev1n77 kev1n77 commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Delay peer-mode:changed and surface snapshot publication until the target workspace catalog has finished hydrating.
  • Keep the transport-side peer mode flag safe during hydration and restore it when returning to the local surface.
  • Contain rejected automatic Git refreshes so stale workspace requests cannot become unhandled Promise rejections.

Type and Areas

Type: Regression fix

Areas: Web UI, Peer Device Mode, Git state refresh

Motivation / Impact

During a Peer Device Mode switch, the adapter changed before workspace hydration completed. UI consumers could still issue requests with the previous local workspace ID against the peer host, producing Workspace ID is unavailable on this host errors and an uncaught page error. This change keeps React consumers on the previous published surface until the new workspace catalog is authoritative and adds a defensive boundary for automatic refresh failures.

Verification

  • pnpm --dir src/web-ui run test:run src/infrastructure/peer-device/PeerDeviceSurfaceController.test.ts src/tools/git/hooks/useGitState.test.tsx — passed (12 tests).
  • pnpm run type-check:web — passed.
  • git diff --check and git diff --cached --check — passed.
  • pnpm run check:web — failed at the existing generated artifact check: Stale MiniApp chat style projection: chat-styles.css in theme:color-audit:all; no MiniApp generated files are included in this PR.

Reviewer Notes

  • The new controller regression test blocks workspace hydration and verifies that no peer-mode event or snapshot is published before hydration completes.
  • Live remote-host switching was not exercised in this local validation; the failure ordering is covered by the deferred hydration test and the existing Peer Device Mode controller suite.
  • The unrelated untracked src/apps/peripheral-device/ directory was preserved and not staged.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, including the existing generated-artifact check blocker.
  • User-facing strings, docs, and locales are not applicable.

Generated with OpenBitFun

Delay peer surface notifications until the target workspace catalog is ready and contain automatic Git refresh failures during the transition.

Co-authored-by: OpenBitFun <318544290+bitfun-ai@users.noreply.github.com>
@kev1n77
kev1n77 marked this pull request as ready for review October 23, 2026 01:22
@kev1n77
kev1n77 merged commit 3e6d2e6 into GCWing:main Oct 23, 2026
9 checks passed
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.

1 participant