Teach the OpenUI skill to integrate and migrate to Cloud#754
Open
vishxrad wants to merge 3 commits into
Open
Conversation
430bea2 to
5d9760d
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
This PR teaches the OpenUI skill how to integrate OpenUI Cloud into an existing project and how to migrate an existing open-source/self-hosted OpenUI application to Cloud without discarding working behavior or inventing unsupported APIs.
It also reconciles the generated Cloud template and canonical documentation with that guidance. The rebased implementation preserves main's newer model-switcher, billing, and CLI setup architecture while adding a production fail-closed boundary, bounded request validation, safer error handling, and explicit migration methodology.
Feedback addressed
The OpenUI skill already handled open-source framework integration well, but it did not understand the managed Cloud architecture. In particular, it could not reliably:
Methodology
1. Audited the actual Cloud contract
We started from repository sources instead of writing an isolated example from memory:
@openuidev/react-ui,@openuidev/react-headless,@openuidev/thesys, and@openuidev/thesys-server;response.artifact_call.deltaevent was intentionally retired when live artifacts moved into standard Responses function-call arguments, so stale claims were removed rather than reintroducing a private protocol extension.2. Used independent design reviews
The design phase incorporated independent recommendations from Grok and Claude. Those reviews converged on the same approach:
3. Added progressive-disclosure skill routing
skills/openui/SKILL.mdnow retains main's comprehensive package, framework, renderer, theming, and OpenUI Lang guidance while routing Cloud-specific work by starting state and desired outcome:Detailed workflows live in:
skills/openui/references/cloud-integration.mdfor existing-project integration;skills/openui/references/cloud-migration.mdfor replace, dual-mode, code-migration, data-migration, and unsupported-capability decisions.4. Defined and preserved the Cloud invariants
The integration runbook encodes two independent Cloud planes:
ChatLLMposts to the application's server-side generation proxy, which usesTHESYS_API_KEY.useOpenuiCloudStorage()accesses Cloud storage using a short-lived frontend token scoped to the authenticated user.It also requires:
conversation: threadId;openAIResponsesAdapter()withopenAIConversationMessageFormat;dynamic(..., { ssr: false })boundary;defineArtifactCategories(...);5. Made conversation authorization implementable
No stock
canAccessConversation()helper exists, so the runbook documents two concrete production strategies:{ conversationId, ownerUserId }mapping, preferably created transactionally through a trusted server path;The generation route should return
403only for a confirmed ownership miss and a service error when verification itself fails. If neither verified path is supported by the installed version, the skill keeps production generation disabled and reports the boundary.6. Hardened the generated Cloud template
The scaffold remains convenient locally but is not accidentally deployable as a shared unauthenticated proxy:
503withCache-Control: no-storein production until host authentication and authorization replace the demo guard;MODEL_OPTIONScatalog;429UX from main is preserved, while non-billing request and stream failures are logged server-side and returned as generic client errors;app/page.tsxdynamically loads main's feature-richcomponents/cloud-chat.tsxwithssr: false, preserving the current model switcher and billing dialog without retaining a duplicate Cloud UI.The request parser is intentionally text-only. Applications adding images or files must extend the allowlist and limits deliberately.
7. Rebased onto main without regressing newer work
The branch originally forked from a stale local
main. During the rebase, the conflicts were resolved semantically rather than by choosing one side wholesale:CloudChat, curated model switcher, billing dialog, selected-model transport, and billing-credit429handling are retained;EnvResultflow are retained, withOPENUI_MODELadded to the centrally written Cloud environment;app/cloud-agent.tsximplementation was removed.8. Reconciled canonical sources
The implementation also removes drift found during the audit:
@openuidev/react-headless,AgentInterfacefrom@openuidev/react-ui, Cloud client APIs from@openuidev/thesys, and server helpers from@openuidev/thesys-server;openaiin production dependencies because the route imports it at runtime;OPENUI_MODELbeside the Cloud key and demo identity;9. Ran scenario and adversarial reviews
The skill was exercised against independent scenarios:
Post-implementation reviews covered security and conversation ownership, skill routing and OSS preservation, and code/template/documentation regressions. Findings were incorporated into the final runbooks and scaffold.
Validation on the rebased branch
pnpm --filter @openuidev/cli run ci— passedpnpm --filter @openuidev/cli run build— passed, including CLI TypeScript and template packagingpnpm --filter @openuidev/docs run types:check— passedpnpm --filter @openuidev/react-ui run typecheck— passedpnpm --filter @openuidev/react-ui run test— 6 tests passedcloud-request.test.tsandenv.test.ts— 10 tests passedgit diff --check origin/main...HEAD— passedThe previous fresh-scaffold build results were not carried forward as a post-rebase claim; the list above contains only validation run against the combined rebased implementation.
Deliberate boundaries
Checklist