Skip to content

Forward teaser.dismissible through FloatBubble/useFloatBubble#74

Merged
LEVI-RIVKIN merged 1 commit into
mainfrom
claude/sdk-react-teaser-dismissible
Jul 13, 2026
Merged

Forward teaser.dismissible through FloatBubble/useFloatBubble#74
LEVI-RIVKIN merged 1 commit into
mainfrom
claude/sdk-react-teaser-dismissible

Conversation

@LEVI-RIVKIN

@LEVI-RIVKIN LEVI-RIVKIN commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Problem

1.15.0 added the teaser.dismissible option (the × button that lets a visitor dismiss the float teaser without opening the chat). The core @perspective-ai/sdk renders and honors it, but the React wrapper never forwards it, so teaser={{ dismissible: false }} has no effect when using @perspective-ai/sdk-react — the × button always renders.

The cause is in useFloatBubble, which stabilizes the teaser prop on its primitive fields (to avoid remounting the bubble on every parent render) and only carried three of them:

// before — dismissible silently dropped
{ enabled: teaserEnabled, delay: teaserDelay, sound: teaserSound }

dismissible was never destructured, so it never reached createFloatBubble.

This surfaced downstream in the demos site, where &teaser.dismissible=false on the float/chat page had no effect despite the param being parsed and passed correctly.

Fix

  • packages/sdk-react/src/hooks/useFloatBubble.ts — destructure teaser?.dismissible, add it to the stabilized teaser object, and include it in the useMemo dependency array.
  • packages/sdk-react/src/hooks/useFloatBubble.test.ts — new test asserting all four teaser fields (enabled, delay, sound, dismissible) are forwarded to createFloatBubble.

Audit of the other teaser surfaces

Confirmed the React hook was the only surface dropping the field. Every other path already forwards dismissible and is test-covered:

Surface Status Coverage
Vanilla config — createFloatBubble({ teaser }) ✅ correct (core resolveTeaserConfig spreads all fields) float.test.ts
CDN data-attribute — data-perspective-teaser-dismissible ✅ correct (parser reads all four attrs) browser.test.ts
React — <FloatBubble> / useFloatBubble ⚠️ was broken → fixed here new test
  • packages/sdk/src/types.ts — the only remaining inaccuracy was the EmbedConfig.teaser JSDoc, which listed enabled/delay/sound but not dismissible; corrected so the documented API matches.

Changeset

  • .changeset/float-teaser-dismissible-react.mdpatch bump for both @perspective-ai/sdk-react and @perspective-ai/sdk (the packages are fixed-linked).

Verification

  • Core @perspective-ai/sdkpnpm typecheck clean, 455 tests pass.
  • @perspective-ai/sdk-reactpnpm typecheck clean, 91 tests pass (including the new one).
  • pnpm build succeeds and dismissible now appears in the compiled dist/index.js.
  • Pre-commit/pre-push hooks (lint, format, test, typecheck across all packages) pass.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

📦 Snapshot Release

Published snapshot packages for this PR:

pnpm add @perspective-ai/sdk@1.15.1-pr-74-20260713201345
pnpm add @perspective-ai/sdk-react@1.15.1-pr-74-20260713201345

Or use the npm tag (always points to the latest snapshot from this PR):

pnpm add @perspective-ai/sdk@pr-74
pnpm add @perspective-ai/sdk-react@pr-74

Copilot AI 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.

Pull request overview

This PR fixes the React wrapper (@perspective-ai/sdk-react) not forwarding the core SDK’s teaser.dismissible option, ensuring teaser={{ dismissible: false }} correctly hides the float teaser × dismiss button when using useFloatBubble / FloatBubble.

Changes:

  • Forward teaser.dismissible through useFloatBubble by stabilizing it alongside the other teaser primitive fields and adding it to the memo dependencies.
  • Add a hook test verifying all teaser fields (enabled, delay, sound, dismissible) are passed to createFloatBubble.
  • Add a changeset to publish a patch release of @perspective-ai/sdk-react.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/sdk-react/src/hooks/useFloatBubble.ts Adds teaser.dismissible to the stabilized teaser config passed into createFloatBubble.
packages/sdk-react/src/hooks/useFloatBubble.test.ts Adds a regression test asserting dismissible is forwarded to the core SDK.
.changeset/float-teaser-dismissible-react.md Declares a patch bump and documents the forwarding fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The 1.15.0 teaser `dismissible` option was added to the core SDK but the
React wrapper never forwarded it. useFloatBubble stabilizes the teaser prop
on its primitive fields and only carried `enabled`, `delay`, and `sound`,
so `dismissible` was silently dropped — `teaser={{ dismissible: false }}`
had no effect and the × dismiss button always rendered.

Add `dismissible` to the stabilized teaser object (and its useMemo deps) so
it reaches createFloatBubble, plus a test asserting all teaser fields are
forwarded.

Also audited the other teaser surfaces to confirm none share the bug: the
vanilla createFloatBubble config and the CDN data-perspective-teaser*
attributes both forward dismissible already (core resolveTeaserConfig
spreads all fields; the data-attribute parser reads all four), each covered
by existing tests. Corrected the EmbedConfig.teaser JSDoc, which listed only
enabled/delay/sound, to include dismissible. Adds a changeset patching both
packages.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172vANJgSbNmv6nnQUErgU2
@LEVI-RIVKIN LEVI-RIVKIN force-pushed the claude/sdk-react-teaser-dismissible branch from 17ea7b6 to 86d1ddb Compare July 13, 2026 20:13
@LEVI-RIVKIN LEVI-RIVKIN merged commit b8ef5dc into main Jul 13, 2026
5 checks passed
@LEVI-RIVKIN LEVI-RIVKIN deleted the claude/sdk-react-teaser-dismissible branch July 13, 2026 20:15
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