fix(ui): distinguish local Pi initialization - #4047
Conversation
|
😎 Merged successfully - details. |
|
React Doctor found 1 issue in 1 file · 1 warning. 1 warning
Reviewed by React Doctor for commit |
Prompt To Fix All With AI### Issue 1
packages/ui/src/features/pi-sessions/PiSessionView.tsx:307
**Cloud sessions start as local**
When a cloud Pi session first enters the connecting state, `cloudStatus` remains undefined until the asynchronous session subscription resolves, so this expression selects the local target and shows “Connecting to Pi on this device” for a cloud run.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "fix(ui): distinguish local Pi initializa..." | Re-trigger Greptile |
| ); | ||
| const sessionAvailable = | ||
| session.connectionState === "connected" || hasTranscript; | ||
| const executionTarget = session.cloudStatus === undefined ? "local" : "cloud"; |
There was a problem hiding this comment.
When a cloud Pi session first enters the connecting state, cloudStatus remains undefined until the asynchronous session subscription resolves, so this expression selects the local target and shows “Connecting to Pi on this device” for a cloud run.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/ui/src/features/pi-sessions/PiSessionView.tsx
Line: 307
Comment:
**Cloud sessions start as local**
When a cloud Pi session first enters the connecting state, `cloudStatus` remains undefined until the asynchronous session subscription resolves, so this expression selects the local target and shows “Connecting to Pi on this device” for a cloud run.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.|
Note 🤖 stamphog reviewed Greptile's inline comment identifies a real, unfixed bug:
Gate mechanics and policy version
|
|
Fixed in 395c243. |
|
The original concern is confirmed. In void this.getPiSession(taskId)
.then((session) => {
// ...
this.updateSession(taskId, { cloudStatus: session.cloudStatus });
})The store starts from const executionTarget = session.cloudStatus === undefined ? "local" : "cloud";will incorrectly render local-device copy for a cloud session during that async gap. The reliable discriminator is already available as a prop: This is determined synchronously at render time with no async dependency, so there's no flash of incorrect copy for cloud sessions. |
There was a problem hiding this comment.
Contained UI-only fix (component rename plus a synchronous isCloud prop) with no risky-territory surface touched; the async cloudStatus race Greptile flagged was fixed by deriving executionTarget from a synchronously-known isCloud value passed from TaskDetail, and a new test covers exactly that race scenario.
- Author wrote 44% of the modified lines and has 10 merged PRs in these paths (familiarity MODERATE).
- 👍 on the PR from greptile-apps[bot].
Gate mechanics and policy version
| Gate | Result | |
|---|---|---|
| prerequisites | ✓ | all clear |
| deny-list | ✓ | no deny categories matched |
| size | ✓ | 55L, 4F substantive, 105L/5F incl. docs/generated/snapshots — within ceiling |
| tier | ✓ | T1-agent / T1c-medium (105L, 5F, single-area, fix) |
| stamphog 2.0.0b3 | .stamphog/policy.yml @ 1fac094 · reviewed head 395c243 |
Problem
Local Pi sessions reuse cloud initialization copy, so the UI can claim it is connecting to a cloud runner.
Changes
How did you test this?
pnpm --filter @posthog/ui exec vitest run src/features/sessions/components/SessionInitializingView.test.tsxpnpm --filter @posthog/ui typecheckpnpm exec biome check --write packages/ui/src/features/sessions/components/SessionInitializingView.tsx packages/ui/src/features/sessions/components/SessionInitializingView.test.tsx packages/ui/src/features/sessions/components/SessionView.tsx packages/ui/src/features/pi-sessions/PiSessionView.tsxAutomatic notifications