Skip to content

Conversation

Copy link

Copilot AI commented Oct 23, 2025

Problem

The driver waiting passengers list (driverWaitingList) was not being populated when drivers entered bus mode. While the passenger mode correctly displayed waiting passengers, the driver UI remained empty even when passengers were waiting at various stops.

Solution

This PR fixes the issue by making two targeted changes to static/script.js:

1. Load waiting stats on bus mode initialization

Added loadWaitingStats() call in the setupBusMode() function (line 600) to automatically fetch and display waiting passenger statistics when a driver enters bus mode:

function setupBusMode() {
    // ... existing setup code ...
    
    loadWaitingStats();  // ← Added this line
    
    console.log('✓ Bus mode setup complete');
}

2. Route updates to correct UI element based on mode

Modified updateWaitingDisplay() function (lines 1205-1212) to detect the current mode and update the appropriate DOM element:

function updateWaitingDisplay(stats) {
    // Determine which element to update based on current mode
    const waitingListId = currentMode === 'bus' ? 'driverWaitingList' : 'waitingList';
    const waitingList = document.getElementById(waitingListId);
    
    // Safety check to prevent errors
    if (!waitingList) {
        console.warn(`Waiting list element not found: ${waitingListId}`);
        return;
    }
    
    // ... rest of function continues ...
}

Impact

  • Driver Experience: Drivers now immediately see which stops have waiting passengers upon entering bus mode
  • Mode Isolation: Each mode (bus/passenger) independently updates its own waiting list element
  • Code Quality: Added defensive null check to prevent potential runtime errors
  • Minimal Changes: Only 9 lines added, 1 line removed - no breaking changes

Testing

✅ Verified bus mode successfully populates driverWaitingList element
✅ Verified passenger mode continues to work correctly with waitingList element
✅ Confirmed empty stats display appropriate "No one waiting" message
✅ JavaScript syntax validated with Node.js

Screenshot

Test Results showing both driver and passenger modes correctly displaying waiting passengers

The screenshot demonstrates successful population of waiting passengers in both modes, with the driver list (top) and passenger list (bottom) each showing stop names and passenger counts.

Original prompt

Update static/script.js to populate the driver waiting passengers list by adding loadWaitingStats() in setupBusMode and modifying updateWaitingDisplay to use the correct element based on mode.

This pull request was created as a result of the following prompt from Copilot chat.

Update static/script.js to populate the driver waiting passengers list by adding loadWaitingStats() in setupBusMode and modifying updateWaitingDisplay to use the correct element based on mode.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Oct 23, 2025
- Add loadWaitingStats() call in setupBusMode() to load waiting passengers when driver mode is initialized
- Modify updateWaitingDisplay() to use correct element based on mode:
  - Use 'driverWaitingList' for bus/driver mode
  - Use 'waitingList' for passenger mode
- Add safety check for missing element in updateWaitingDisplay()

Co-authored-by: Terrificdatabytes <66877413+Terrificdatabytes@users.noreply.github.com>
Copilot AI changed the title [WIP] Update script to populate driver waiting passengers list Populate driver waiting passengers list on bus mode initialization Oct 23, 2025
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.

2 participants