Repository navigation
[SCAL-343782] Type ContextObject.type as 'page' | 'dialog' - #717
Open
yinstardev wants to merge 6 commits into
Open
yinstardev wants to merge 6 commits into
yinstardev wants to merge 6 commits into
Conversation
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`.
Contributor
There was a problem hiding this comment.
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 on lines
+10308
to
+10309
| * Layer type of the context object: `page` or `dialog`. The context | ||
| * itself (liveboard, search-answer, spotter, …) is in `name`. |
Contributor
There was a problem hiding this comment.
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
- All written work must be in American English (en-US) format. (link)
commit: |
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getCurrentContext()returns each context entry as{ name, type, objectIds }, wheretypeis the page/dialog layer kind andnameis the context (liveboard,search-answer,spotter, …). This is what the context-aware-event-routing developer docs and the runtime both describe.The
ContextObjectTypeScript annotation incorrectly typedtypeasContextType. That misled consumers into routing ontypefor the context (which never matched, sincetypeholdspage/dialog), and it prompted a runtime change on the app side that contradicted the published docs.Change
ContextObject.stack[].typeandContextObject.currentContext.type:ContextType→'page' | 'dialog'.getCurrentContext()JSDoc example to match (type: 'page',name: 'liveboard').name.🤖 Generated with Claude Code