Skip to content

[SCAL-343782] Type ContextObject.type as 'page' | 'dialog' - #717

Open
yinstardev wants to merge 6 commits into
mainfrom
scal-343782-context-object-type-annotation
Open

yinstardev wants to merge 6 commits into
mainfrom
scal-343782-context-object-type-annotation

Conversation

@yinstardev

Copy link
Copy Markdown
Contributor

Summary

getCurrentContext() returns each context entry as { name, type, objectIds }, where type is the page/dialog layer kind and name is the context (liveboard, search-answer, spotter, …). This is what the context-aware-event-routing developer docs and the runtime both describe.

The ContextObject TypeScript annotation incorrectly typed type as ContextType. That misled consumers into routing on type for the context (which never matched, since type holds page/dialog), and it prompted a runtime change on the app side that contradicted the published docs.

Change

  • ContextObject.stack[].type and ContextObject.currentContext.type: ContextType → 'page' | 'dialog'.
  • Fixed the getCurrentContext() JSDoc example to match (type: 'page', name: 'liveboard').
  • No runtime change; the context value stays in name.

🤖 Generated with Claude Code

getCurrentContext() returns `type` = the page/dialog layer kind and `name`
= the context, as the developer docs (context-aware-event-routing) and the
runtime describe. The ContextObject annotation typed `type` as ContextType,
which misled consumers into routing on `type` for the context (it never
matched) and prompted a runtime change that contradicted the docs.

Annotate `type` as 'page' | 'dialog' and fix the getCurrentContext example
to match. No runtime change; the context value stays in `name`.
@yinstardev
yinstardev requested a review from a team as a code owner October 19, 2026 05:30

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request updates the ContextObject interface in src/types.ts by changing the type property from ContextType to a union of string literals 'page' | 'dialog'. JSDoc comments and examples in src/embed/ts-embed.ts are updated accordingly. Feedback is provided to replace a non-ASCII horizontal ellipsis character (…) in the JSDoc comments with standard ASCII dots (...) to ensure compatibility.

Comment thread src/types.ts Outdated
Comment on lines +10308 to +10309
* Layer type of the context object: `page` or `dialog`. The context
* itself (liveboard, search-answer, spotter, …) is in `name`.

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.

medium

The horizontal ellipsis character (…) is used in the comment. To ensure compatibility and adhere to standard ASCII formatting in code comments, please replace the non-ASCII ellipsis character … with standard three dots ....

Suggested change
* Layer type of the context object: `page` or `dialog`. The context
* itself (liveboard, search-answer, spotter, …) is in `name`.
* Layer type of the context object: `page` or `dialog`. The context
* itself (liveboard, search-answer, spotter, ...) is in `name`.
References
  1. All written work must be in American English (en-US) format. (link)

@pkg-pr-new

pkg-pr-new Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@thoughtspot/visual-embed-sdk@717

commit: 2d30ac2

Comment thread src/types.ts Outdated
yinstardev and others added 4 commits October 20, 2026 14:16
Replace the inline 'page' | 'dialog' union on ContextObject's stack and
currentContext `type` fields with an exported PageType enum
(Page = 'page', Dialog = 'dialog'), mirroring the runtime enum in blink
page-context that produces the value. Consumers get a named, documented,
autocomplete-friendly type to route on, kept in step with the runtime
contract instead of a bare string union.

- Add and export PageType from types.ts and index.ts
- Point ContextObject stack/currentContext `type` at PageType
- getCurrentContext spec: use PageType.Page, dropping the `as any` cast
src/index.ts now exports PageType, and the all-types-export parity test
requires every index export to be importable from the React entry point
too.

This branch has not been deployed

No deployments
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