Skip to content

Conversation

@number1pete
Copy link

@number1pete number1pete commented Jan 13, 2026

Description

This PR adds a new Sessions page to the Sunshine web UI that allows administrators to view and manage active streaming sessions.

Features:

  • View active streaming sessions - See all currently connected Moonlight clients with their name, IP address, and session duration
  • Disconnect sessions - Terminate streaming sessions directly from the web interface with a confirmation dialog
  • Auto-refresh - Sessions list automatically updates every 5 seconds (with toggle to disable)
  • Manual refresh - Button to manually refresh the session list

Implementation Details:

Backend (C++):

  • Added session::get_all_sessions() function in stream.cpp to enumerate active sessions thread-safely
  • Added session::disconnect() function to terminate sessions by ID
  • Added GET /api/sessions endpoint to retrieve session list as JSON
  • Added POST /api/sessions/disconnect endpoint to terminate a session
  • Fixed client name lookup by storing client's uniqueID during pairing (previously generated random UUID which couldn't be matched)

Frontend (Vue.js):

  • New sessions.html page following existing UI patterns
  • Bootstrap 5 modal for disconnect confirmation
  • Auto-refresh toggle with 5-second interval
  • Proper error handling and user feedback

Files Changed:

  • src/stream.h - Added session_info_t struct and function declarations
  • src/stream.cpp - Implemented session enumeration and disconnect functions
  • src/confighttp.cpp - Added API endpoints and page route
  • src/nvhttp.cpp - Fixed to store client's uniqueID during pairing
  • src_assets/common/assets/web/sessions.html - New sessions page
  • src_assets/common/assets/web/Navbar.vue - Added Sessions link to navigation
  • src_assets/common/assets/web/public/assets/locale/en.json - Added translations
  • vite.config.js - Added sessions.html to build inputs

Screenshot

sessions_empty
Empty state (no active sessions):
[Screenshot: Sessions page showing "No active streaming sessions" message]

With active session:
sessions_one_pc
[Screenshot: Sessions page showing client "yoga" connected from 10.0.0.2 with Disconnect button]

Issues Fixed or Closed

Roadmap Issues

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Unit tests have been added or updated for any new or modified functionality

AI Usage

  • None: No AI tools were used in creating this PR
  • Light: AI provided minor assistance (formatting, simple suggestions)
  • Moderate: AI helped with code generation or debugging specific parts
  • Heavy: AI generated most or all of the code changes

Notes:

  • Existing paired clients will display their UUID until re-paired (due to the uniqueID storage fix)
  • Thread-safe access to session list using existing sync_util::sync_t patterns
  • Tested on Windows with NVIDIA GPU

casey broome and others added 5 commits January 12, 2026 20:20
- Add /sessions page with table showing client name, IP address, and duration
- Add /api/sessions endpoint to list active streaming sessions
- Add /api/sessions/disconnect endpoint to terminate sessions
- Include auto-refresh (5s) and manual refresh options
- Add confirmation dialog before disconnecting
- Add Sessions link to navigation bar

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The disconnect confirmation modal was failing with "bootstrap is not
defined" because the Modal class wasn't being imported. Now imports
Modal from bootstrap/dist/js/bootstrap, matching the pattern used
in apps.html.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…lookup

Previously, add_authorized_client() generated a random UUID for each
paired client, while the Moonlight client sends its own uniqueid during
launch. This caused the session management UI to show random UUIDs
instead of friendly device names, since the lookup would never match.

Now stores the client's actual uniqueID when pairing completes, so
session lookups can properly match and display the friendly name
from the paired clients database.

Note: Existing paired clients will need to re-pair to get correct
name mapping.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adjust inline comment spacing to conform to project's clang-format
configuration.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add comprehensive documentation comments to get_all_sessions() and
disconnect() functions explaining their purpose, parameters, and
return values.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ReenigneArcher ReenigneArcher added the ai PR has signs of heavy ai usage (either indicated by user or assumed) label Jan 13, 2026
@number1pete
Copy link
Author

the branch is working great on my windows machine with nvidia card. Able to see the active sessions by name/ipaddress and terminate them successfully.

@ReenigneArcher
Copy link
Member

Thank you, we will review it.

Would you mind updating the PR to use our template though? https://github.com/LizardByte/.github/blob/master/.github/pull_request_template.md?plain=1

@number1pete
Copy link
Author

I updated the readme to match your PR template

Previously, if a temporary error occurred during session fetch (e.g.,
during the brief transition after disconnecting a client), the error
message would persist even after subsequent successful fetches because
the success path never cleared the errorMessage state.

Now clears errorMessage when fetch succeeds, so transient errors don't
persist on the UI.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
8 New issues
1 New Bugs (required ≤ 0)
7 New Code Smells (required ≤ 0)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai PR has signs of heavy ai usage (either indicated by user or assumed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants