Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 26, 2025

The dashboard session duration graphs previously only displayed terminal/SSH session metrics, providing an incomplete view of system activity. This PR extends the session tracking to include agent websocket sessions, ensuring that all session types are represented in the dashboard analytics.

Changes Made

Enhanced Agent Session Tracking

  • ActiveWebSocketSessionManager: Extended to track session start times and calculate durations when sessions end
  • SessionController: Added new endpoints to expose agent session duration data:
    • GET /api/v1/sessions/agent/durations - Returns completed agent sessions
    • GET /api/v1/sessions/agent/active-durations - Returns active agent sessions

Unified Dashboard Integration

  • SessionService: Enhanced getGraphData() to fetch and combine both terminal and agent session data
  • Error Handling: Graceful fallback when agent-proxy service is unavailable
  • Configuration: Uses agentproxy.externalUrl property to connect to agent services

Data Flow

  1. Agent websocket sessions register/unregister with duration tracking
  2. Dashboard API endpoint aggregates terminal + agent session data
  3. Existing Chart.js pie chart automatically displays unified session metrics
  4. Users now see complete system activity across all session types

Example Output

Before: Dashboard showed only terminal sessions (incomplete view)
After: Dashboard shows combined session duration distribution:

{
  "0-5 min": 5,    // 3 terminal + 2 agent sessions
  "5-15 min": 8,   // 4 terminal + 4 agent sessions  
  "15-30 min": 3,  // 2 terminal + 1 agent session
  "30+ min": 2     // 2 terminal sessions
}

Benefits

  • Complete Visibility: Dashboard graphs now include all session activity
  • Unified Analytics: Single view for both terminal and agent session metrics
  • Real-time Tracking: Active agent sessions included in duration calculations
  • Backward Compatible: Existing functionality preserved, no frontend changes required

Fixes #85.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • repository.jboss.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.11/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.11/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.11 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.11/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/Sentrius/Sentrius org.codehaus.plexus.classworlds.launcher.Launcher clean compile -DskipTests -q (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: phrocker <1781585+phrocker@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Session Duration for Websocket sessions into agents in graphs Add agent session duration tracking to dashboard graphs Jul 26, 2025
Copilot AI requested a review from phrocker July 26, 2025 11:51
@phrocker
Copy link
Contributor

@copilot build failures...

Co-authored-by: phrocker <1781585+phrocker@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jul 26, 2025

@copilot build failures...

Fixed the build failure in commit cd8c9bb. The issue was a type mismatch in the test mocks where findMinAndMaxLogTmBySessionLogId returns List&lt;Object[]&gt; but the test was using Arrays.asList(new Object[]{...}) which creates List&lt;Object&gt;. Changed to use Collections.singletonList(new Object[]{...}) to create the correct type. Also removed unnecessary WebSocket session mocks that weren't being used. Build now passes successfully.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • repository.jboss.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.11/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.11/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.11 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.11/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/Sentrius/Sentrius org.codehaus.plexus.classworlds.launcher.Launcher clean compile -DskipTests -q (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@phrocker phrocker marked this pull request as ready for review July 26, 2025 16:01
@phrocker phrocker merged commit 0314443 into main Jul 26, 2025
9 checks passed
@phrocker phrocker deleted the copilot/fix-85 branch July 31, 2025 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Session Duration for Websocket sessions into agents in graphs

2 participants