Skip to content

Conversation

@connorlindsey
Copy link
Contributor

@connorlindsey connorlindsey commented Aug 27, 2025

Description

Handles live preview update events and uses preview content if available for the given guide.

Checklist

  • Tests have been added for new features or major refactors to existing features.

@linear
Copy link

linear bot commented Aug 27, 2025

@changeset-bot
Copy link

changeset-bot bot commented Aug 27, 2025

🦋 Changeset detected

Latest commit: d397b4d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@knocklabs/client Minor
@knocklabs/react Minor
client-example Patch
guide-example Patch
@knocklabs/expo Patch
@knocklabs/react-core Patch
@knocklabs/react-native Patch
ms-teams-connect-example Patch
nextjs-app-dir-example Patch
nextjs-example Patch
slack-connect-example Patch
slack-kit-example Patch
@knocklabs/expo-example Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor Author

connorlindsey commented Aug 27, 2025

@vercel
Copy link

vercel bot commented Aug 27, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
javascript-ms-teams-connect-example Ready Ready Preview Comment Sep 5, 2025 7:24pm
javascript-nextjs-example Ready Ready Preview Comment Sep 5, 2025 7:24pm
javascript-slack-connect-example Ready Ready Preview Comment Sep 5, 2025 7:24pm
javascript-slack-kit-example Ready Ready Preview Comment Sep 5, 2025 7:24pm

@connorlindsey connorlindsey force-pushed the connor-kno-9373-js-client-handle-return_all_guides-override-for-guides branch from ac3d799 to e6effa0 Compare August 27, 2025 16:03
@connorlindsey connorlindsey force-pushed the connor-kno-9377-js-client-connect-to-preview-guides-ws-channel-when-token branch from c8dd940 to f854611 Compare August 27, 2025 16:03
@connorlindsey connorlindsey force-pushed the connor-kno-9373-js-client-handle-return_all_guides-override-for-guides branch from e6effa0 to 5e8972a Compare August 27, 2025 21:39
@connorlindsey connorlindsey force-pushed the connor-kno-9377-js-client-connect-to-preview-guides-ws-channel-when-token branch from f854611 to 626a881 Compare August 27, 2025 21:39
@connorlindsey connorlindsey marked this pull request as ready for review August 27, 2025 21:40
Copy link
Contributor

@thomaswhyyou thomaswhyyou left a comment

Choose a reason for hiding this comment

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

A few comments/questions.

Comment on lines 1024 to 1025
const debugStateChanged =
JSON.stringify(currentDebugParams) !== JSON.stringify(newDebugParams);
Copy link
Contributor

@thomaswhyyou thomaswhyyou Sep 5, 2025

Choose a reason for hiding this comment

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

Hm I feel like JSON.stringify() can be brittle, for example:

JSON.stringify({a:1, b:2}) === JSON.stringify({b:2, a:1}) // false

For this I wonder if we can just check the key vals individually with a helper like checkDebugStageChanged(), or use something like fast-deep-equal we use in react-core? Given only two params, maybe just do this manually for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I'll just do a manual check especially since we actually only care whether or not guide key is present or not (since either way, we're just sending 'force all guides' to SB)

Copy link
Contributor

Choose a reason for hiding this comment

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

since we actually only care whether or not guide key is present or not (since either way, we're just sending 'force all guides' to SB)

Double checking, don't you send preview_session_id for subscribe() also in Line 366 though?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I meant that specifically when comparing the guide key we just care about presence, but yeah, we still want to compare the rest of the debug state, here's what I added:

  private checkDebugStateChanged(a: DebugState, b: DebugState): boolean {
    return (
      Boolean(a.forcedGuideKey) !== Boolean(b.forcedGuideKey) ||
      a.previewSessionId !== b.previewSessionId
    );
  }

@connorlindsey connorlindsey force-pushed the connor-kno-9377-js-client-connect-to-preview-guides-ws-channel-when-token branch from 721de22 to f0cf0d4 Compare September 5, 2025 16:18
cursor[bot]

This comment was marked as outdated.

@connorlindsey connorlindsey force-pushed the connor-kno-9377-js-client-connect-to-preview-guides-ws-channel-when-token branch from df729b7 to d397b4d Compare September 5, 2025 19:00
@connorlindsey connorlindsey merged commit c761e7c into main Sep 5, 2025
8 of 11 checks passed
@connorlindsey connorlindsey deleted the connor-kno-9377-js-client-connect-to-preview-guides-ws-channel-when-token branch September 5, 2025 19:04
@codecov
Copy link

codecov bot commented Sep 5, 2025

Codecov Report

❌ Patch coverage is 84.90566% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.99%. Comparing base (3558784) to head (d397b4d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/client/src/clients/guide/client.ts 83.67% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #730      +/-   ##
==========================================
+ Coverage   63.92%   63.99%   +0.06%     
==========================================
  Files         185      185              
  Lines        7513     7549      +36     
  Branches      900      907       +7     
==========================================
+ Hits         4803     4831      +28     
- Misses       2684     2692       +8     
  Partials       26       26              
Files with missing lines Coverage Δ
packages/client/src/clients/guide/index.ts 100.00% <100.00%> (ø)
packages/client/src/clients/guide/types.ts 100.00% <ø> (ø)
...les/guide/components/GuideToolbar/GuideToolbar.tsx 66.37% <100.00%> (+0.58%) ⬆️
packages/client/src/clients/guide/client.ts 89.84% <83.67%> (-0.67%) ⬇️

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.

3 participants