Skip to content

feat: add selectable status indicator to toolbar v2#848

Merged
thomaswhyyou merged 20 commits into
mainfrom
thomas-kno-11142-sdk-guide-toolbar-v2-poc-8
Feb 19, 2026
Merged

feat: add selectable status indicator to toolbar v2#848
thomaswhyyou merged 20 commits into
mainfrom
thomas-kno-11142-sdk-guide-toolbar-v2-poc-8

Conversation

@thomaswhyyou
Copy link
Copy Markdown
Contributor

@thomaswhyyou thomaswhyyou commented Feb 2, 2026

Description

Another follow up to #846 and #847, this PR adds a "selectable" status to guide's annotation, and surfaced in GuideRow. This should be the final status indicator, which combined with other statuses should allow the toolbar to answer the question "why am i seeing or not seeing guide X"?

The "selectable" status is a bit more involved than other statuses because:

  1. It's based on multiple factors: what components are present on the current page and calling useGuide(s), what type of select queries they are issuing, whether throttling is happening at a given point in time etc.
  2. Multiple possible state values based on those factors, as explained here.

@linear
Copy link
Copy Markdown

linear Bot commented Feb 2, 2026

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 2, 2026

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

Project Deployment Actions Updated (UTC)
javascript-ms-teams-connect-example Ready Ready Preview, Comment Feb 19, 2026 9:04pm
javascript-nextjs-example Ready Ready Preview, Comment Feb 19, 2026 9:04pm
javascript-slack-connect-example Ready Ready Preview, Comment Feb 19, 2026 9:04pm
javascript-slack-kit-example Ready Ready Preview, Comment Feb 19, 2026 9:04pm

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 2, 2026

⚠️ No Changeset found

Latest commit: d8ddfe2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@thomaswhyyou thomaswhyyou force-pushed the thomas-kno-11142-sdk-guide-toolbar-v2-poc-7 branch from 67f3bd1 to bedf313 Compare February 2, 2026 20:10
@thomaswhyyou thomaswhyyou force-pushed the thomas-kno-11142-sdk-guide-toolbar-v2-poc-8 branch from 6f798fa to 5885839 Compare February 2, 2026 20:10
@thomaswhyyou thomaswhyyou force-pushed the thomas-kno-11142-sdk-guide-toolbar-v2-poc-7 branch from bedf313 to 07cd540 Compare February 2, 2026 21:34
@thomaswhyyou thomaswhyyou force-pushed the thomas-kno-11142-sdk-guide-toolbar-v2-poc-8 branch from 5885839 to 005eede Compare February 2, 2026 21:35
@thomaswhyyou thomaswhyyou force-pushed the thomas-kno-11142-sdk-guide-toolbar-v2-poc-7 branch from 07cd540 to e2af205 Compare February 3, 2026 19:09
@thomaswhyyou thomaswhyyou force-pushed the thomas-kno-11142-sdk-guide-toolbar-v2-poc-8 branch from 005eede to 6875fe2 Compare February 3, 2026 19:09
@thomaswhyyou
Copy link
Copy Markdown
Contributor Author

@cursor review

Comment thread packages/react/src/modules/guide/components/Toolbar/V2/GuideRow.tsx
Comment thread packages/client/src/clients/guide/types.ts
}

result.metadata = { guideGroup: defaultGroup };
result.metadata = { guideGroup: defaultGroup, filters, ...metadata };
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I knew this metadata field was going to come in handy at some point..! :)

);

const selectedGuide = this.selectGuide(state, filters, opts);
// 1. First, call selectGuide() using the same filters to ensure we have a
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No functional changes here, except for adding code paths to record select query results with additional metadata.

By "recording", we accumulate all select query results inside this.stage data. As a reminder, this "group stage" state data is something we manage outside of the tanstack store, which powers guides the priority resolution mechanism in the guide client each time a new page renders).

We are recording select query results w/ metadata, in order for the toolbar to use it as a basis to infer which guides could or could not render. It's a proxy to guessing if/what guide components are present on the current page.

By default we only record query results while in debug mode.

return undefined;
}

const result = select(state, filters);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No changes to the core logic here, but it's been moved down because we moved up the part where we open the group stage (i.e. this.openGroupStage()). Previously we could delay opening the group stage until later, but in order record all the select queries being issued in a given page, we need the group stage to be open.

Comment on lines +725 to +733
// Must come AFTER we ensure a group stage exists above, so we can record
// select queries. By default, we only record the result while in debugging.
const { recordSelectQuery = !!state.debug?.debugging } = opts;
const metadata: SelectQueryMetadata = {
limit: "one",
opts: { ...opts, recordSelectQuery },
};
const result = select(state, filters, metadata);
this.maybeRecordSelectResult(result);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the new bit, to record query results.


// Check if inside the throttle window (i.e. throttled) and if so stop and
// return undefined unless explicitly given the option to include throttled.
const throttled = !opts.includeThrottled && checkStateIfThrottled(state);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved the early return to later inside the switch statement below. Previously we didn't need to resolve the group stage while in the throttle window. But now we want the toolbar to still know which guide is being resolved to display but being throttled. Should functionally be the same.

StoreState,
} from "./types";

// Extends the map class to allow having metadata on it, which is used to record
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved to types.ts to make the imports a bit more streamlined.

Copy link
Copy Markdown
Contributor

@connorlindsey connorlindsey left a comment

Choose a reason for hiding this comment

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

🎉

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.


const byKey = <T extends { key: string }>(items: T[]) => {
return items.reduce((acc, item) => ({ ...acc, [item.key]: item }), {});
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Duplicated byKey utility already exists in helpers

Low Severity

The byKey helper duplicates the identical function already exported from packages/client/src/clients/guide/helpers.ts. It isn't currently re-exported from the package index, but adding it to the index.ts exports (alongside the newly added checkStateIfThrottled) would avoid the duplication.

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is fine

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 19, 2026

Codecov Report

❌ Patch coverage is 89.83051% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.90%. Comparing base (04a8f16) to head (d8ddfe2).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...c/modules/guide/components/Toolbar/V2/GuideRow.tsx 0.00% 24 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #848      +/-   ##
==========================================
+ Coverage   67.41%   67.90%   +0.49%     
==========================================
  Files         204      204              
  Lines        8561     8767     +206     
  Branches     1118     1183      +65     
==========================================
+ Hits         5771     5953     +182     
- Misses       2766     2790      +24     
  Partials       24       24              
Files with missing lines Coverage Δ
packages/client/src/clients/guide/client.ts 89.58% <100.00%> (+0.65%) ⬆️
packages/client/src/clients/guide/helpers.ts 93.52% <ø> (-0.27%) ⬇️
packages/client/src/clients/guide/index.ts 100.00% <100.00%> (ø)
packages/client/src/clients/guide/types.ts 100.00% <100.00%> (ø)
...omponents/Toolbar/V2/useInspectGuideClientStore.ts 100.00% <100.00%> (ø)
...c/modules/guide/components/Toolbar/V2/GuideRow.tsx 8.59% <0.00%> (-1.99%) ⬇️

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