Skip to content

feat: New useTimer hook - #25335

Merged
ramonlsouza merged 4 commits into
bigbluebutton:v3.0.x-developfrom
GuiLeme:plugin-sdk-use-timer
Jul 29, 2026
Merged

ramonlsouza merged 4 commits into
bigbluebutton:v3.0.x-developfrom
GuiLeme:plugin-sdk-use-timer

Conversation

@GuiLeme

@GuiLeme GuiLeme commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

It creates a new hook useTimer that mirrors the same hook from the core html5 client functions.

Motivation

This will resolve this comment and therefore we'll be able to make the suggestion in the issue as a Plugin.

More

This PR is closely related with the PR in the SDK: bigbluebutton/bigbluebutton-html-plugin-sdk#272

@coderabbitai

coderabbitai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 72f90b75-795f-4aa8-a884-465edb7ca317

📥 Commits

Reviewing files that changed from the base of the PR and between 388960c and 09e2f6a.

⛔ Files ignored due to path filters (1)
  • bigbluebutton-html5/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • bigbluebutton-html5/package.json
  • bigbluebutton-web/grails-app/conf/bigbluebutton.properties
🚧 Files skipped from review as they are similar to previous changes (1)
  • bigbluebutton-html5/package.json

Walkthrough

Adds timer data normalization for plugin consumption. useTimer now preserves loading when timer data is absent. A new formatter maps timer responses into the plugin SDK wrapper shape, and TimerHookContainer dispatches timer events when timer state changes or the version advances. PluginDataConsumptionManager registers the timer hook, and the HTML5 dependency and server configuration are updated to plugin SDK version 0.0.104.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PluginDataConsumptionManager
  participant TimerHookContainer
  participant useTimer
  participant formatTimerResponseFromGraphql
  participant window

  PluginDataConsumptionManager->>TimerHookContainer: render for DataConsumptionHooks.TIMER
  TimerHookContainer->>useTimer: read timer data and loading state
  TimerHookContainer->>TimerHookContainer: compare version with previous value
  alt version increases or timerData changes
    TimerHookContainer->>formatTimerResponseFromGraphql: format timer response
    formatTimerResponseFromGraphql-->>TimerHookContainer: GraphqlResponseWrapper<TimerData>
    TimerHookContainer->>window: dispatchEvent(CustomEvent<TimerData>)
  end
Loading

Suggested reviewers: arthurk12, germanocaumo

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and clearly reflects the main change: adding a new useTimer hook.
Description check ✅ Passed The description matches the changeset by explaining the new useTimer hook and its plugin-related motivation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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
`@bigbluebutton-html5/imports/ui/components/plugins-engine/data-consumption/domain/timer/hook-manager.tsx`:
- Around line 30-39: The timer update logic in hook-manager currently dispatches
the same TIMER payload twice on mount and can also retrigger on unrelated
rerenders because the separate useEffect blocks watch both version and the
unstable timerData object. Refactor the logic around updateTimerForPlugin so
there is a single effect that runs only when version changes and when the actual
timer fields used for the payload change, or memoize the payload before using it
as a dependency, to avoid duplicate dispatches.

In `@bigbluebutton-html5/imports/ui/core/hooks/useTimer.ts`:
- Line 40: The empty-state branch in useTimer is dropping the first query error,
so when no timer row exists the caller cannot see a failed response. Update the
early return in useTimer to preserve response.errors?.[0] alongside the existing
loading state, matching the shape used by the rest of the hook’s return object
so the plugin formatter can surface the failure correctly.

In `@bigbluebutton-html5/package.json`:
- Line 82: The dependency for bigbluebutton-html-plugin-sdk is pinned to a
GitHub tarball commit instead of a published semver release, so confirm whether
this is intentional; if not, update the entry in package.json to a tagged
published version rather than the codeload URL. After changing the resolution,
regenerate and commit the matching package-lock.json so npm ci and CI installs
stay in sync, and verify no stale 0.0.100 references remain in the lockfile or
other manifests.
🪄 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: CHILL

Plan: Pro

Run ID: 6980a2d5-45df-42b2-93fd-bf7f9e15d034

📥 Commits

Reviewing files that changed from the base of the PR and between 3392861 and 172d67d.

⛔ Files ignored due to path filters (1)
  • bigbluebutton-html5/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • bigbluebutton-html5/imports/ui/components/plugins-engine/data-consumption/domain/timer/hook-manager.tsx
  • bigbluebutton-html5/imports/ui/components/plugins-engine/data-consumption/domain/timer/utils.ts
  • bigbluebutton-html5/imports/ui/components/plugins-engine/data-consumption/manager.tsx
  • bigbluebutton-html5/imports/ui/core/hooks/useTimer.ts
  • bigbluebutton-html5/package.json

Comment on lines +30 to +39
useEffect(() => {
const previousVersionValue = previousVersion ?? 0;
if (version > previousVersionValue) {
updateTimerForPlugin();
}
}, [version]);

useEffect(() => {
updateTimerForPlugin();
}, [timerData]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Avoid double-dispatching TIMER updates.

Lines 30-39 can emit the same payload twice on mount: once because previousVersion is initially undefined, and again because the timerData effect always runs after mount. Since useTimer() returns a new object each render, Line 37 can also retrigger on unrelated rerenders.

Collapse this into one effect keyed on version plus stable timer fields, or memoize the payload before using it as a dependency.

🤖 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
`@bigbluebutton-html5/imports/ui/components/plugins-engine/data-consumption/domain/timer/hook-manager.tsx`
around lines 30 - 39, The timer update logic in hook-manager currently
dispatches the same TIMER payload twice on mount and can also retrigger on
unrelated rerenders because the separate useEffect blocks watch both version and
the unstable timerData object. Refactor the logic around updateTimerForPlugin so
there is a single effect that runs only when version changes and when the actual
timer fields used for the payload change, or memoize the payload before using it
as a dependency, to avoid duplicate dispatches.

}, []);

if (!response.data?.[0]) return { data: undefined };
if (!response.data?.[0]) return { data: undefined, loading: response.loading };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Preserve error in the empty-state return.

Line 40 still drops response.errors?.[0]. When the query fails before any timer row exists, the plugin formatter can only emit an empty timer instead of a failed response.

Suggested fix
-  if (!response.data?.[0]) return { data: undefined, loading: response.loading };
+  if (!response.data?.[0]) {
+    return {
+      data: undefined,
+      loading: response.loading,
+      error: response.errors?.[0],
+    };
+  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!response.data?.[0]) return { data: undefined, loading: response.loading };
if (!response.data?.[0]) {
return {
data: undefined,
loading: response.loading,
error: response.errors?.[0],
};
}
🤖 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 `@bigbluebutton-html5/imports/ui/core/hooks/useTimer.ts` at line 40, The
empty-state branch in useTimer is dropping the first query error, so when no
timer row exists the caller cannot see a failed response. Update the early
return in useTimer to preserve response.errors?.[0] alongside the existing
loading state, matching the shape used by the rest of the hook’s return object
so the plugin formatter can surface the failure correctly.

Comment thread bigbluebutton-html5/package.json Resolved
@github-actions

Copy link
Copy Markdown

This pull request has conflicts ☹
Please resolve those so we can review the pull request.
Thanks.

@ramonlsouza ramonlsouza added this to the Release 3.0 milestone Jun 29, 2026
@github-actions

Copy link
Copy Markdown

✅ Automated tests have passed!

@ramonlsouza
ramonlsouza merged commit e61a956 into bigbluebutton:v3.0.x-develop Jul 29, 2026
59 of 60 checks passed
antobinary added a commit that referenced this pull request Aug 12, 2026
3.0's plugin-sdk-use-timer work (#25335, commits bc4e822 / 172d67d /
388960c) adds a TIMER data-consumption hook and pairs it with plugin SDK
0.0.104. It merges cleanly on file level but does not compile on 4.0, because
it depends on SDK APIs that exist only on the 0.0.x line:

  - `TimerData` is not exported (TS2694)
  - `DataConsumptionHooks.TIMER` does not exist (TS2339)
  - `useTimer(...)` takes a boolean, not `{ enableNotifications, isIndicator }`
    (TS2345)

4.0 tracks the 0.1.x SDK line (html5PluginSdkVersion=0.1.24). I checked the
published SDK: neither 0.1.24 nor 0.1.25, the latest on that line, declares
TIMER in DataConsumptionHooks — the enum ends at CUSTOM_QUERY. So there is no
0.1.x version to bump to that would make this compile, and bumping to 0.0.104
would drag 4.0's plugin API back to the 3.0 line.

Removing the client half here rather than leaving 4.0 unbuildable. The feature
needs a real port once the 0.1.x SDK exposes the timer types, which is an SDK
change, not a merge conflict resolution. Nothing else references the hook: the
two files were added whole by the merge and the only other reference was the
registration in data-consumption/manager.tsx, removed here too.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.7] conference bell mode for the timer function

3 participants