[codex] Fix PowerPoint slide sync detection#21
Conversation
✅ Deploy Preview for handoutmarc ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughEnhances PowerPoint add-in slide synchronization with explicit Convex type casting, introduces polling-based state updates with hybrid mode fallback support, adds Vite client type definitions to tsconfig, and corrects slide number calculation from zero-based to one-based indexing. Changes
Sequence DiagramsequenceDiagram
participant Timer as Polling Timer
participant OfficeBridge as Office Bridge
participant Office as Office App
participant Server as Convex Server
participant UI as UI Callbacks
rect rgba(100, 150, 200, 0.5)
Note over OfficeBridge,UI: Initialization
OfficeBridge->>Office: Initialize Office Bridge
OfficeBridge->>OfficeBridge: Start polling (1s interval)
OfficeBridge->>OfficeBridge: syncCurrentSlide()
OfficeBridge->>Office: getCurrentSlideInfo()
Office-->>OfficeBridge: Slide info
OfficeBridge->>Server: Update current slide
OfficeBridge->>UI: onModeChange("auto")
end
rect rgba(150, 200, 100, 0.5)
Note over Timer,Server: Polling Loop
loop Every 1000ms
Timer->>OfficeBridge: Poll tick
OfficeBridge->>OfficeBridge: syncCurrentSlide()
OfficeBridge->>Office: getCurrentSlideInfo()
Office-->>OfficeBridge: Slide info
OfficeBridge->>Server: Update if changed
end
end
rect rgba(200, 150, 100, 0.5)
Note over OfficeBridge,UI: Fallback on Error
OfficeBridge->>Office: Register event handler
Office--XOfficeBridge: Handler registration fails
OfficeBridge->>UI: onModeChange("hybrid")
Note over OfficeBridge: Continue polling, disable auto-sync
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Greptile SummaryThis PR fixes PowerPoint add-in slide synchronization by correcting the 0-based-to-1-based slide index conversion ( The changes are well-motivated and the core fix is correct. A few issues warrant attention:
Confidence Score: 3/5Core index fix is correct but a stale-callback bug in the addin bridge teardown path should be resolved before merge. The P1 in apps/powerpoint-addin/src/lib/officeBridge.ts — stale _callbacks surviving the early-return in destroyOfficeBridge — can cause Convex mutations to fire against a session already switched away from, which is the primary user path this PR is meant to fix. One targeted fix in the addin file and an error guard in the web bridge are needed before this is reliably safe to merge. Primary: apps/powerpoint-addin/src/lib/officeBridge.ts (destroyOfficeBridge early-return). Secondary: apps/web/src/lib/powerpoint/officeBridge.ts (getSlideCountAsync exception guard). Important Files Changed
Sequence DiagramsequenceDiagram
participant App as App.tsx / PowerPointAddinClient
participant Bridge as officeBridge.ts
participant Office as Office.js
participant Convex as Convex (setCurrentSlide)
App->>Bridge: initOfficeBridge(callbacks)
Bridge->>Office: Office.onReady()
Office-->>Bridge: onReady callback fires
Bridge->>Bridge: isOfficeInitialized = true
Bridge->>Bridge: syncCurrentSlide() [startup sync]
Bridge->>Bridge: startPolling() [1s interval fallback]
Bridge->>Office: addHandlerAsync(DocumentSelectionChanged)
Bridge->>Office: addHandlerAsync(ActiveViewChanged)
Office-->>Bridge: handler registered
Bridge-->>App: Promise resolves with auto/hybrid
loop Every 1 second (polling fallback)
Bridge->>Office: getSelectedDataAsync(SlideRange)
Office-->>Bridge: slides[0].index (0-based)
Bridge->>Bridge: slideNumber = slides[0].index + 1
Bridge->>Office: getSlideCountAsync()
Office-->>Bridge: totalSlides
Bridge->>Bridge: compare with _lastReportedSlide
alt slide changed
Bridge-->>App: onSlideChange(info)
App->>Convex: setCurrentSlide(slideNumber)
end
end
Note over Bridge,Office: Also fires on DocumentSelectionChanged and ActiveViewChanged (debounced 250ms)
App->>Bridge: destroyOfficeBridge() [on unmount]
Bridge->>Bridge: clearInterval / clearTimeout
Bridge->>Office: removeHandlerAsync(DocumentSelectionChanged)
Bridge->>Office: removeHandlerAsync(ActiveViewChanged)
|
What changed
Why
The automatic slide detection was not reliably recognizing the current slide. One bridge returned the wrong slide index, and the add-in relied too heavily on a single Office event that does not always fire when expected.
Impact
Presenters should now see the current slide update more reliably in the PowerPoint integration, especially when opening the add-in or switching views.
Validation
pnpm --filter web type-checkpnpm --filter powerpoint-addin type-checkSummary by CodeRabbit
Release Notes