Skip to content
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

[grid] Add feature to go directly to a VNC session #15179

Merged
merged 5 commits into from
Jan 31, 2025

Conversation

emilhem
Copy link
Contributor

@emilhem emilhem commented Jan 28, 2025

Motivation and Context

Makes it easy to link directly to a running session.

Users can now after retrieving the session id go to https://grid.example.com/ui/#/session/SESSION_ID to directly launch a VNC session.

Fixes: #15178

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Users can now go directly to a VNC session if they have the session ID.

This makes it easier to create direct links to a running session which
can make it easier to fault trace a running session.

Fixes SeleniumHQ#15178
@CLAassistant
Copy link

CLAassistant commented Jan 28, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Logic Error

The session validation condition in useEffect has incorrect logic. The condition (sessionId !== undefined || sessionId === '') will always evaluate to true, potentially causing unnecessary navigation to /sessions.

if ((sessionId !== undefined || sessionId === '') && data.sessionsInfo.sessions.length === 0) {
Missing Error Handling

The LiveView component lacks error handling for failed VNC connections. Consider adding error states and user feedback for connection failures.

<LiveView
  ref={liveViewRef}
  url={row.vnc as string}
  scaleViewport
  onClose={() => navigate("/sessions")}
/>

Copy link
Contributor

qodo-merge-pro bot commented Jan 28, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Score
Possible issue
✅ Fix incorrect session validation logic
Suggestion Impact:The commit directly implemented the suggested change to fix the session validation logic in the useEffect hook

code diff:

-    if ((sessionId !== undefined || sessionId === '') && data.sessionsInfo.sessions.length === 0) {
+    if (sessionId && data.sessionsInfo.sessions.length === 0) {

The session validation logic in useEffect has incorrect condition. The current
condition (sessionId !== undefined || sessionId === '') will always be true,
potentially causing unnecessary navigations.

javascript/grid-ui/src/screens/Sessions/Sessions.tsx [44-46]

-if ((sessionId !== undefined || sessionId === '') && data.sessionsInfo.sessions.length === 0) {
+if (sessionId && data.sessionsInfo.sessions.length === 0) {
   navigate("/sessions")
 }
  • Apply this suggestion
Suggestion importance[1-10]: 9

Why: The current condition has a logical error that would always evaluate to true, causing unnecessary navigations. This fix is critical for proper session validation and routing behavior.

9
General
Add missing useEffect dependency

The useEffect dependency array is missing the 'navigate' function, which could lead
to stale closures. Add 'navigate' to the dependency array.

javascript/grid-ui/src/components/RunningSessions/RunningSessions.tsx [282-293]

 useEffect(() => {
   let s = sessionId || ''
   let session_ids = sessions.map((session) => session.id)
   if (!session_ids.includes(s)) {
     setRowLiveViewOpen('')
     navigate('/sessions')
   } else {
     setRowLiveViewOpen(s)
   }
-}, [sessionId, sessions])
+}, [sessionId, sessions, navigate])
  • Apply this suggestion
Suggestion importance[1-10]: 7

Why: Missing 'navigate' in the dependency array could lead to stale closures and unexpected navigation behavior. This is an important React hooks rule that affects component reliability.

7

@VietND96 VietND96 requested a review from diemol January 28, 2025 17:11
@emilhem emilhem force-pushed the feature/direct_session_link branch from 46da259 to 69adc84 Compare January 30, 2025 11:19
Copy link
Member

@diemol diemol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @emilhem!

@diemol diemol merged commit 7e5b0a0 into SeleniumHQ:trunk Jan 31, 2025
32 of 33 checks passed
@emilhem emilhem deleted the feature/direct_session_link branch February 3, 2025 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[🚀 Feature]: Direct Link to Selenium Grid VNC Session
5 participants