Skip to content

✨(frontend) Improve presenter core behavior#2482

Draft
PanchoutNathan wants to merge 12 commits into
mainfrom
feature/present-mode-core
Draft

✨(frontend) Improve presenter core behavior#2482
PanchoutNathan wants to merge 12 commits into
mainfrom
feature/present-mode-core

Conversation

@PanchoutNathan

Copy link
Copy Markdown
Contributor

Purpose

  • Mount the presenter from a shared root and store.
  • Add a generated title slide before content slides.
  • Keep divider children in rendered slides and trim divider spacing.
  • Hide selected-node editor chrome in read-only presenter slides.

Refs #2466
Closes #2398
Closes #2393

@PanchoutNathan PanchoutNathan self-assigned this Jul 1, 2026
@PanchoutNathan PanchoutNathan marked this pull request as draft July 1, 2026 11:32
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Size Change: +917 B (+0.02%)

Total Size: 4.37 MB

📦 View Changed
Filename Size Change
apps/impress/out/_next/static/0fe5c2d9/_buildManifest.js 0 B -695 B (removed) 🏆
apps/impress/out/_next/static/9669f61a/_buildManifest.js 696 B +696 B (new file) 🆕
apps/impress/out/_next/static/chunks/1440.js 3.98 kB +3.98 kB (new file) 🆕
apps/impress/out/_next/static/chunks/1859.js 0 B -3.2 kB (removed) 🏆
apps/impress/out/_next/static/chunks/5815.js 0 B -3.95 kB (removed) 🏆
apps/impress/out/_next/static/chunks/8979.js 4.08 kB +4.08 kB (new file) 🆕

compressed-size-action

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR restructures the document presenter feature: a global Zustand store (usePresenterStore) now controls presenter open state and starting slide index, replacing local component state in DocToolBox. PresenterRoot is introduced as a page-level mount that lazily loads PresenterOverlay with a boot cover. Slide data is now typed (PresenterBlock, PresenterSlideData) and includes an explicit generated title slide, rendered via new PresenterTitleSlide and PresenterSlideContent (non-editable BlockNote) components. useSlides's splitBlocksIntoSlides and getSlideTitle were rewritten to preserve structural divider children and trim only boundary empty paragraphs. E2E and unit tests were updated to reflect the new 4-slide deck and divider/image behaviors.

Estimated code review effort: 4 (Complex) | ~60 minutes

Suggested reviewers: AntoLC, Ovgodd

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description matches the presenter-mode refactor, title slide, divider handling, and chrome-hiding changes.
Linked Issues check ✅ Passed The PR preserves divider children in slide separation and hides unintended image/node focus in presenter slides, matching #2398 and #2393.
Out of Scope Changes check ✅ Passed The changes stay focused on presenter-mode core, related components, tests, and supporting exports with no clear unrelated additions.
Title check ✅ Passed The title accurately summarizes the main theme of the PR: core presenter-mode behavior improvements.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/present-mode-core

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/frontend/apps/impress/src/features/docs/doc-presenter/components/PresenterOverlay.tsx (1)

42-65: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Thread the store’s starting slide index into this overlay.

The new presenter contract is supposed to carry a starting slide index, but this component now only accepts { doc, onClose } and prepends a title slide at index 0. Since Line 66 still hard-codes useState(0), every open lands on the title slide and callers can no longer start the deck at the requested content slide.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/frontend/apps/impress/src/features/docs/doc-presenter/components/PresenterOverlay.tsx`
around lines 42 - 65, The PresenterOverlay component is ignoring the starting
slide index from the presenter contract, so it always opens at the title slide.
Update PresenterOverlayProps and the PresenterOverlay signature to accept and
use the incoming start index, then thread that value into the local slide state
instead of hard-coding the initial index. Make sure the slides array built from
title and contentSlides still aligns with the passed index when opening.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/frontend/apps/impress/src/features/docs/doc-presenter/components/PresenterRoot.tsx`:
- Around line 51-86: The PresenterRoot component only stops rendering when
active becomes false, but it never resets the presenter Zustand state, so isOpen
can remain true across mobile resize or unmount/remount. Update PresenterRoot to
close the presenter in a useEffect when active turns false, using the existing
close action from usePresenterStore alongside handleClose, so the global
presenter state is cleared whenever the root deactivates.

In
`@src/frontend/apps/impress/src/features/docs/doc-presenter/stores/usePresenterStore.tsx`:
- Around line 14-15: The open handler in usePresenterStore still allows
non-integer or non-finite values to be stored in initialIndex, which can break
slide selection. Update the open function to sanitize index before calling set
by coercing it to a finite integer and falling back to 0 for NaN, Infinity, and
fractional or invalid inputs. Keep the fix localized to the open method and
ensure initialIndex always represents a valid 0-based slide position.

In `@src/frontend/apps/impress/src/features/docs/doc-presenter/types.ts`:
- Around line 15-18: `PresenterContentSlide.blocks` is still typed as
`unknown[]`, which forces unsafe casts in the presenter pipeline. Update the
`PresenterContentSlide` type in `types.ts` to use `PresenterBlock[]` instead,
and ensure the shared slide contract matches the shape already produced by
`useSlides` and consumed by `PresenterOverlay`/`getSlideTitle` so downstream
code can rely on type safety without casts.

---

Outside diff comments:
In
`@src/frontend/apps/impress/src/features/docs/doc-presenter/components/PresenterOverlay.tsx`:
- Around line 42-65: The PresenterOverlay component is ignoring the starting
slide index from the presenter contract, so it always opens at the title slide.
Update PresenterOverlayProps and the PresenterOverlay signature to accept and
use the incoming start index, then thread that value into the local slide state
instead of hard-coding the initial index. Make sure the slides array built from
title and contentSlides still aligns with the passed index when opening.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 757c0d8c-a494-411d-949d-ec8e78e7f2d4

📥 Commits

Reviewing files that changed from the base of the PR and between 6ec541f and 577544d.

📒 Files selected for processing (15)
  • src/frontend/apps/e2e/__tests__/app-impress/presenter-mode.spec.ts
  • src/frontend/apps/e2e/__tests__/app-impress/utils-common.ts
  • src/frontend/apps/impress/src/features/docs/doc-header/components/DocToolBox.tsx
  • src/frontend/apps/impress/src/features/docs/doc-presenter/__tests__/useSlides.spec.ts
  • src/frontend/apps/impress/src/features/docs/doc-presenter/components/PresenterOverlay.tsx
  • src/frontend/apps/impress/src/features/docs/doc-presenter/components/PresenterRoot.tsx
  • src/frontend/apps/impress/src/features/docs/doc-presenter/components/PresenterSlide.tsx
  • src/frontend/apps/impress/src/features/docs/doc-presenter/components/PresenterSlideContent.tsx
  • src/frontend/apps/impress/src/features/docs/doc-presenter/components/PresenterTitleSlide.tsx
  • src/frontend/apps/impress/src/features/docs/doc-presenter/hooks/useSlides.ts
  • src/frontend/apps/impress/src/features/docs/doc-presenter/index.ts
  • src/frontend/apps/impress/src/features/docs/doc-presenter/stores/index.ts
  • src/frontend/apps/impress/src/features/docs/doc-presenter/stores/usePresenterStore.tsx
  • src/frontend/apps/impress/src/features/docs/doc-presenter/types.ts
  • src/frontend/apps/impress/src/pages/docs/[id]/index.tsx

Comment thread src/frontend/apps/impress/src/features/docs/doc-presenter/types.ts
@PanchoutNathan PanchoutNathan changed the title Feature/present mode core ✨(frontend) Improve presenter core behavior Jul 1, 2026
@PanchoutNathan PanchoutNathan requested a review from AntoLC July 6, 2026 11:31
@AntoLC AntoLC added enhancement improve an existing feature frontend labels Jul 7, 2026
Comment thread src/frontend/apps/e2e/__tests__/app-impress/utils-common.ts Outdated
Comment thread src/frontend/apps/impress/src/features/docs/doc-presenter/index.ts Outdated
Comment thread src/frontend/apps/impress/src/features/docs/doc-presenter/types.ts Outdated
Comment thread src/frontend/apps/e2e/__tests__/app-impress/presenter-mode.spec.ts Outdated
Comment thread src/frontend/apps/e2e/__tests__/app-impress/presenter-mode.spec.ts Outdated
@AntoLC AntoLC requested a review from Ovgodd July 7, 2026 13:04
createDoc returned before the ProseMirror editor was visible, so tests
that immediately typed or opened the presenter raced the load. Wait for
the editor container before handing control back.
Move presenter ownership out of DocToolBox into a top-level
PresenterRoot driven by a zustand store, lazy-load the overlay and paint
a boot cover while the editor boots. Groundwork for the deep-link and
present-from-here features (#2466).
Pull the BlockNote rendering out of PresenterSlide into
PresenterSlideContent so it can be reused by the title slide and the PDF
export. Add a PresenterSlideData union (title | content) and a shared
PresenterBlock type.
Prepend a slide with the document title (emoji stripped) so every
presentation opens on a cover, announced to screen readers like any
other slide (#2466).
Dividers with children are kept as structural parents so their slide
keeps its indentation; the divider's own rule is hidden. Empty
paragraphs around a divider are dropped so habitual spacing no longer
offsets slides.

Closes #2398
A selected image (or any selected node) leaked its editing outline into
the read-only slide. Suppress the selected-node outline so nothing looks
focused unless the user tabs or clicks.

Closes #2393
@PanchoutNathan PanchoutNathan force-pushed the feature/present-mode-core branch from 577544d to 86a56f4 Compare July 8, 2026 09:06
@PanchoutNathan PanchoutNathan requested a review from AntoLC July 8, 2026 09:12

@AntoLC AntoLC left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except the e2e commit, LGTM !
Can you squash your fixup commit ?

Comment on lines +158 to +161
await page.waitForURL(`**/docs/${docId}**`, {
timeout: 10000,
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have this part quite stable, I am reluctant to add any change here, and if so, it should be in a dedicated PR.

@Ovgodd Ovgodd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a suggestion for long slides accessibility

if (pm) {
pm.removeAttribute('role');
pm.removeAttribute('contenteditable');
pm.setAttribute('tabindex', '-1');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider setting tabindex="0" on the slide content. With tabindex="-1", keyboard users cannot reach long slides via Tab and cannot scroll their content.

Suggested change
pm.setAttribute('tabindex', '-1');
pm.setAttribute('tabindex', '0');

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

Labels

enhancement improve an existing feature frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Presenter mode drops children of the divider Focus on image in presenter mode

3 participants