fix(desktop): decouple machineId from host-service connection#3876
fix(desktop): decouple machineId from host-service connection#3876saddlepaddle merged 1 commit intomainfrom
Conversation
Previously, machineId was sourced from `hostServiceCoordinator.getConnection`, which returns null whenever no host-service instance is running. After macOS sleep killed the detached host-service child, every v2 workspace failed the `workspace.hostId === machineId` check and got routed through the relay as if it were remote, causing data not to load until app restart. machineId is a deterministic per-device value (`getHostId()`), so expose it via a dedicated `device.getMachineId` tRPC query and gate provider render on it so the context value is non-nullable. Note: this only fixes the misclassification. Reviving the host-service on wake (e.g. via `powerMonitor`) is a separate change.
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughA new TRPC device router endpoint ( Changes
Sequence DiagramsequenceDiagram
participant Client as LocalHostServiceProvider
participant TRPC as Device Router<br/>(TRPC Endpoint)
participant HostInfo as Host Info Service<br/>(getHostId)
Client->>TRPC: electronTrpc.device.getMachineId()
activate TRPC
TRPC->>HostInfo: getHostId()
activate HostInfo
HostInfo-->>TRPC: hostId (string)
deactivate HostInfo
TRPC-->>Client: { machineId: string }
deactivate TRPC
Client->>Client: Cache result with infinite freshness
Client->>Client: Render context with non-null machineId
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Summary
machineIdwas sourced fromhostServiceCoordinator.getConnection, which returnsnullwhenever no host-service instance is running. After macOS sleep killed the detached host-service child, the renderer receivedmachineId: null, every v2 workspace failed theworkspace.hostId === machineIdcheck, and all workspaces fell through to the relay branch — so data didn't load until the app was restarted.machineIdis a deterministic per-device value (getHostId()), so it shouldn't be coupled to host-service liveness in the first place. Added a dedicateddevice.getMachineIdtRPC query and gateLocalHostServiceProviderrender on it, makingmachineIdnon-nullable everywhere downstream.powerMonitor.on('resume', ...)) is being handled in a separate change.Test plan
isLocal === true); behavior should match the pre-sleep state for any host-service that survived. If the host-service died, the workspace should showWorkspaceNotFoundStaterather than silently routing through the relay.device.getMachineIdbefore rendering children — verify no perceptible delay.bun run typecheckandbun run lintpass.Summary by cubic
Fixes local workspace misclassification after macOS sleep by decoupling the machine ID from host-service liveness and sourcing it directly from the device. Host-service auto-revive on wake will be handled separately.
devicetRPC router withdevice.getMachineIdusinggetHostId()from@superset/shared/host-info.LocalHostServiceProviderto fetch the machine ID once, make it non-nullable, and stop reading it fromhostServiceCoordinator.getConnection.machineIddirectly.Written for commit 3a74bc3. Summary will update on new commits. Review in cubic
Summary by CodeRabbit