feat: add serving type generator, Vite plugin, and UI hooks#240
Merged
feat: add serving type generator, Vite plugin, and UI hooks#240
Conversation
This was referenced Apr 3, 2026
83dab4c to
76a2618
Compare
735aa72 to
9b7bcc1
Compare
76a2618 to
41a0074
Compare
2657962 to
8687067
Compare
218f9b5 to
cab05df
Compare
a8ebf5e to
cccf049
Compare
2080612 to
1996ad6
Compare
ac0a669 to
10204a8
Compare
22df022 to
ac93525
Compare
10204a8 to
6c85231
Compare
ac93525 to
99bbfad
Compare
6c85231 to
e1068f6
Compare
Add Vite plugin that auto-generates TypeScript types from serving endpoint OpenAPI schemas. Includes AST-based server file extraction (@ast-grep/napi), schema-to-TypeScript conversion, and caching. Also adds useServingInvoke and useServingStream React hooks in appkit-ui with full type-safe registry support. Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com>
- Store requestKeys[] in serving cache instead of regex-parsing TypeScript type strings in schema-filter (fragile indentation dependency) - Add overrideBody parameter to useServingStream's stream() to allow callers to pass fresh body without waiting for useMemo recomputation - Lazy-init WorkspaceClient in type generator (skip when no endpoints resolve) Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com>
Chunks persisted after onComplete, causing the streaming bubble to remain visible alongside the committed message (duplicate response). Now chunks are cleared atomically with setStreaming(false) so React batches all state updates in one render. Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com>
Clearing chunks in the hook's .then() handler caused a race with React batching — chunks were empty before the component could commit them. Let consumers decide when to clear via reset() instead. Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com>
Without a .catch(), if connectSSE rejects the promise is unhandled and setStreaming(false) never fires, leaving the hook in a broken state. This matches the pattern used by the genie chat hook. Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com>
The invoke callback is recreated whenever body changes (via useCallback deps), which triggers the useEffect cleanup that aborts in-flight requests. Adding overrideBody allows callers to use a stable body while passing the real payload per-invocation, matching useServingStream. Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com>
…T_NAME in type generator Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com>
e1068f6 to
c428977
Compare
Collaborator
|
also almost forgot, this should be hooked into the |
- Add appKitServingTypesPlugin to vite-dev-server (auto-included) - Use SDK getOpenApi method instead of manual fetch in fetcher - Extract helpers from generateServingTypes for readability - Add clientConfig to ServingPlugin, use in hooks for URL construction - Export type-generator/serving entry point for CLI generate-types - Hook serving type generation into generate-types CLI command Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com>
MarioCadenas
approved these changes
Apr 10, 2026
- Replace manual getPluginClientConfig + useMemo with usePluginClientConfig hook - Move generateServingTypes to explicit import + export in type-generator index - Remove unnecessary typeof guard in generate-types CLI command - Update test mocks to mock use-plugin-config instead of @/js Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com>
MarioCadenas
approved these changes
Apr 10, 2026
Collaborator
MarioCadenas
left a comment
There was a problem hiding this comment.
once the artifact ci is fixed it LGTM, as a followup, I would add a system that allows us to write all the types in client/src/appKitTypes.d.ts or another cleaner approach, I would like to avoid populating with multiple d.ts files. Maybe to make it look cleaner and not having to have a full lock mechanism we could simply change the appKitTypes.d.ts to a file that simply references others in a folder, and the folder contains one file per plugin that needs it? something like this
appKitTypes.d.ts
|- appkit-types
|- analytics.d.ts
|- serving.d.ts
having appKitTypes.d.ts as something like this
/// <reference path="./appkit-types/analytics.d.ts" />
/// <reference path="./appkit-types/serving.d.ts" />but just an idea!
Rolldown tree-shaking only preserves "own exports" (locally defined) — not re-exports. Use a local binding instead of a re-export so the serving vite plugin's import keeps it in the dependency graph. Also remove gitignore comment for type generator caches. Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com>
2dbaf25 to
09ec8f3
Compare
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
@ast-grep/napi) for automatic endpoint discoveryuseServingInvokeanduseServingStreamReact hooks with type-safe registry supportDemo
model-serving-demo-compressed.mp4
PR Stack — Model Serving