-
Notifications
You must be signed in to change notification settings - Fork 435
Fix/switch projects bug #501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe changes introduce a new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant PlaygroundSettings
participant AgentStore
User->>PlaygroundSettings: Loads component
PlaygroundSettings->>AgentStore: initializeFromProject(activeProject)
PlaygroundSettings->>AgentStore: initializeAgent(activeProject)
AgentStore->>AgentStore: Set currentProjectId, reset fields, set selected agent if needed
Possibly related PRs
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
frontend/src/lib/store/agent.ts (1)
72-85
: Handle “no‐agents” edge-case explicitlyIf
activeProject.agents
is empty the lastreturn
will callgetApiKey(activeProject, "")
, passing an invalid id and likely throwing downstream.
Guard for this case (e.g. return""
or throw a descriptive error) before the finalreturn
.
🧹 Nitpick comments (2)
frontend/src/lib/store/agent.ts (1)
206-220
: Avoid duplicating agent-selection logic
initializeAgent
largely repeats whatinitializeFromProject
already does when the selected agent is missing. Consolidating this in a single helper prevents future drift and keeps state initialisation predictable.frontend/src/app/playground/playground-settings.tsx (1)
44-47
: Potential double initialisation
initializeFromProject
already ensures a valid agent; immediately callinginitializeAgent
can trigger an extra state update and unnecessary re-render. Consider relying on a single initialiser.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
frontend/src/app/playground/playground-settings.tsx
(3 hunks)frontend/src/lib/store/agent.ts
(7 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Compose Tests
- GitHub Check: Format & Lint
- GitHub Check: Format, Lint, and Test
// Clear state if project ID doesn't match | ||
if ( | ||
state && | ||
state.currentProjectId !== window.location.pathname.split("/")[2] | ||
) { | ||
state.selectedApps = []; | ||
state.selectedFunctions = []; | ||
state.selectedLinkedAccountOwnerId = ""; | ||
state.selectedAgent = ""; | ||
state.apps = []; | ||
state.appFunctions = []; | ||
state.linkedAccounts = []; | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
window
access inside rehydrate may break SSR
onRehydrateStorage
references window.location
directly. While sessionStorage
limits this to the client, the file is imported by server-side code in Next.js and will throw during SSR builds.
Wrap the access in a runtime check (typeof window !== "undefined"
).
🤖 Prompt for AI Agents
In frontend/src/lib/store/agent.ts around lines 235 to 248, the code accesses
window.location.pathname directly inside onRehydrateStorage, which causes errors
during server-side rendering in Next.js. To fix this, wrap the window access in
a runtime check by verifying typeof window !== "undefined" before accessing
window.location.pathname. This ensures the code only runs on the client and
prevents SSR build failures.
✨ No issues found! Your code is sparkling clean! ✨ Need help? Join our Discord for support! |
🏷️ Ticket
notion
Summary by CodeRabbit
New Features
Bug Fixes
Chores