Add nebula-genui: streaming generative UI from an LLM - #1
Open
AndroidPoet wants to merge 1 commit into
Open
Conversation
Render a component tree that a model streams token by token. Adds a tolerant partial-JSON repair pass, a Flow<String> -> Flow<NebulaComponent> streaming parser, a NebulaStream composable that fills the UI in as tokens arrive, an auto-generated system prompt from the component catalog, and a pluggable NebulaUiSource (bring your own model).
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 freeto 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.
What
A new
nebula-genuimodule that renders a Nebula component tree an LLM streams back token by token — the screen assembles itself as JSON arrives instead of waiting for the full response. This is the generative-UI counterpart to the existing JSON SDUI path, reusing the wholeNebulaComponentmodel and renderer.Why
The JSON path today needs the complete document before it can render (
decodeFromString). A model dribbles JSON out over seconds. This module closes that gap so you can point Nebula at any LLM and watch native Compose UI build progressively.How it works
repairToValidJson— a single-pass, string/scalar-aware repair that turns any prefix of a JSON document into the largest valid JSON so far (balancing open containers, dropping a dangling,, a half-typed key, or an in-progress number). This is the core trick that makes partial output renderable.Flow<String>.asNebulaTree()— buffers tokens, repairs, decodes toNebulaComponent, and emits a new tree only when it changes.NebulaStream— a@Composablethat observes the flow and renders the partial tree via the existingNebula(component = …), refilling on each update.NebulaPrompt.system()— auto-generates the system prompt from the component + action catalog, so the model only emits components the renderer understands (prompt and renderer can't drift).NebulaUiSource— pluggable, bring-your-own-model interface (core only consumes aFlow<String>).MockNebulaUiSourcedrives previews/tests with no network.No changes to
nebula-core— this builds entirely on top.Tests
:nebula-genui:desktopTest— 12 tests, all green. Highlights:type.Notes / follow-ups
nebula-coreonly, so this module is verified locally via the desktop target.