Presenter mode

From 5throck/ai-workspace-standards · View interactive version

Presenter mode is an AI agent skill from the GitHub repository 5throck/ai-workspace-standards. Dual-window presenter state synchronization using browser BroadcastChannel API, syncing slide index, speaker notes, timer, current/next slide preview.

How to use this skill

Skill file

Skill: presenter-mode

Context

In high-impact presentations and lecture delivery (co-deck), presenting slides across multiple screens requires real-time synchronization between what the audience sees (Main Presentation Window) and what the speaker controls (Presenter Dashboard Window).

presenter-mode defines the browser-native dual-window state synchronization standard using the BroadcastChannel API. It provides sub-50ms synchronization latency without requiring external WebSocket servers or network infrastructure, keeping presentation decks zero-dependency and fully self-contained.

When to Use

Execution Steps

  1. Initialize Channel: Establish a named BroadcastChannel instance (co-deck-presenter-channel).
  2. State Registration: Set up state listeners for STATE_UPDATE, NAVIGATE, TIMER_TOGGLE, TIMER_RESET, and SYNC_REQUEST events.
  3. Dispatch Navigation: On slide transition, parse speaker notes and broadcast STATE_UPDATE to connected windows.
  4. Dashboard Synchronization: Open Presenter Dashboard window, send SYNC_REQUEST, and hydrate UI controls with synced state.

Output Format

State updates are dispatched as JSON messages matching the PresenterStateMessage contract over BroadcastChannel:

{
  "type": "STATE_UPDATE",
  "deckId": "co-deck-presentation",
  "currentSlide": 3,
  "totalSlides": 12,
  "speakerNotes": "Highlight key architectural design decisions for Phase 1.",
  "timer": { "elapsedSeconds": 145, "isRunning": true, "startTime": 1722943200000 },
  "timestamp": 1722943345000
}

Related Skills

Core Architecture & State Model

The presenter synchronization engine operates over a named BroadcastChannel (e.g., co-deck-presenter-channel). Both windows connect to the same channel context and exchange structured JSON event messages.

+-----------------------------------+         BroadcastChannel API        +-----------------------------------+
|         Audience Window           |   ("co-deck-presenter-channel")     |         Presenter Window          |
|      (Main Slide Viewport)        | <=================================> |       (Speaker Dashboard)         |
|  - Renders active slide           |   - STATE_UPDATE                    |  - Speaker notes view             |
|  - Listens to nav events          |   - NAVIGATE                        |  - Current & Next slide preview   |
|  - Emits slide index change       |   - TIMER_TOGGLE / RESET            |  - Presentation timer             |
+-----------------------------------+   - SYNC_REQUEST                    +-----------------------------------+

Message Schema (`PresenterStateMessage`)

All messages sent across the BroadcastChannel MUST adhere to the following contract:

export type PresenterMessageType =
  | 'STATE_UPDATE'   // Broadcast full current state
  | 'NAVIGATE'       // Request navigation to specific slide index
  | 'TIMER_TOGGLE'   // Pause / resume presentation timer
  | 'TIMER_RESET'    // Reset presentation timer to zero
  | 'SYNC_REQUEST';  // Request state broadcast from active window

export interface PresenterStateMessage {
  type: PresenterMessageType;
  deckId: string;
  currentSlide: number;
  totalSlides: number;
  speakerNotes: string;
  currentSlideTitle?: string;
  nextSlidePreview?: {
    index: number;
    title: string;
    snippet?: string;
  } | null;
  timer: {
    elapsedSeconds: number;
    isRunning: boolean;
    startTime: number | null;
  };
  timestamp: number;
}

Dual-Window Workflow

1. Audience Window (Main Display)

2. Presenter Window (Speaker Dashboard)

1. Current Slide View: High-fidelity view or thumbnail of active slide.

2. Next Slide Preview: Preview of upcoming slide to allow seamless verbal transitions.

3. Speaker Notes: Formatted markdown/HTML notes parsed from the current slide markup.

4. Presentation Timer: Elapsed time clock, start/pause toggle, and reset controls.

5. Navigation Controls: Next, Previous, Direct Jump grid for rapid access.

Canonical Implementation Patterns

Pattern 1: Initializing BroadcastChannel & State Dispatcher

// presenter-sync.js
const CHANNEL_NAME = 'co-deck-presenter-channel';
const channel = new BroadcastChannel(CHANNEL_NAME);

// Broadcast state from Audience window to Presenter window
function broadcastState(currentSlideIndex, totalSlides, notes, nextSlideInfo, timerState) {
  const message = {
    type: 'STATE_UPDATE',
    deckId: document.title || 'co-deck-presentation',
    currentSlide: currentSlideIndex,
    totalSlides: totalSlides,
    speakerNotes: notes || '',
    nextSlidePreview: nextSlideInfo ? {
      index: nextSlideInfo.index,
      title: nextSlideInfo.title,
    } : null,
    timer: timerState,
    timestamp: Date.now(),
  };
  channel.postMessage(message);
}

Pattern 2: Incoming Event Handling & Navigation Request

// Listen for messages across windows
channel.onmessage = (event) => {
  const data = event.data;
  if (!data || !data.type) return;

  switch (data.type) {
    case 'NAVIGATE':
      if (typeof data.currentSlide === 'number') {
        goToSlide(data.currentSlide);
      }
      break;

    case 'STATE_UPDATE':
      updatePresenterDashboard(data);
      break;

    case 'SYNC_REQUEST':
      // Respond with active state if this is the Audience window
      if (!isPresenterWindow) {
        broadcastState(currentIndex, totalSlides, currentNotes, nextSlide, currentTimerState);
      }
      break;

    case 'TIMER_TOGGLE':
      toggleTimerState();
      break;

    case 'TIMER_RESET':
      resetTimerState();
      break;
  }
};

Pattern 3: Auto-Resync & Mid-Presentation Window Launch

// Execute on Presenter Window initialization
function initPresenterDashboard() {
  // Request immediate state sync from Audience window
  channel.postMessage({
    type: 'SYNC_REQUEST',
    timestamp: Date.now(),
  });

  // Local Storage Fallback if BroadcastChannel message missed
  const cachedState = localStorage.getItem('co_deck_last_presenter_state');
  if (cachedState) {
    try {
      updatePresenterDashboard(JSON.parse(cachedState));
    } catch (e) {
      // Ignore parse errors
    }
  }
}

Quality Gate Checklist

Before finalizing presenter mode implementation in presentation decks:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.