feat: fix playground tab duplication#2291
Conversation
WalkthroughReverses gating logic in the workspace provider's initial data loading effect to execute namespace processing only when data is present, response code is OK, and namespaces exist. Tightens useEffect dependencies to Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
studio/src/components/dashboard/workspace-provider.tsx(2 hunks)studio/src/pages/[organizationSlug]/[namespace]/graph/[slug]/playground.tsx(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
studio/src/pages/[organizationSlug]/[namespace]/graph/[slug]/playground.tsx (1)
studio/src/lib/constants.ts (1)
PLAYGROUND_DEFAULT_HEADERS_TEMPLATE(211-213)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: build_test
- GitHub Check: build_push_image
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (2)
studio/src/pages/[organizationSlug]/[namespace]/graph/[slug]/playground.tsx (1)
1292-1292: Good fix: prevents unnecessary GraphiQL re-renders.Switching from the controlled
headersprop todefaultHeadersprevents GraphiQL from re-rendering when theheadersstate changes during initialization. SinceshouldPersistHeadersis enabled (Line 1286), GraphiQL manages its own internal headers state and will callonEditHeaderswhen changes occur. This change directly addresses the tab duplication issue by stabilizing the initial render.studio/src/components/dashboard/workspace-provider.tsx (1)
36-38: Critical fix: corrects reversed logic bug.The old condition would return early when
data?.response?.code === EnumStatusCode.OK, which is backwards—it should only proceed when the response is OK. The corrected logicdata?.response?.code !== EnumStatusCode.OKproperly gates the effect to run only when the response is successful and namespaces exist. This bug likely caused improper namespace initialization and unexpected route parameter updates, contributing to the tab duplication issue.
…ithin-the-playground
Summary by CodeRabbit
Bug Fixes
Changes
Checklist