feat(kernel): add preview/demo runtime mode with auto-login and simulated identity#676
feat(kernel): add preview/demo runtime mode with auto-login and simulated identity#676
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Add PreviewRequest/PreviewResponse schemas to app-store protocol and preview configuration to MarketplaceListingSchema, allowing customers to browse package content without login/registration. Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
你理解错了,我说的是objectstack 运行的时候,是通过一个插件或者开关让前端知道我现在是预览模式就不显示登录和注册的页面,甚至自动模拟一个管理员的身份进入系统。 @copilot |
…identity Revert marketplace changes (misunderstanding). Instead, add 'preview' to RuntimeMode enum and PreviewModeConfigSchema to KernelContextSchema. This allows the kernel to signal preview mode to the frontend, bypassing auth screens and simulating an admin identity for demos. Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
已重新理解需求并修正实现。在
使用方式: const ctx = KernelContextSchema.parse({
mode: 'preview',
previewMode: {
autoLogin: true,
simulatedRole: 'admin',
},
// ...
});前端通过检查 |
|
@copilot 更新现有example,增加 preview 运行模式,更新文档。 |
- Add PreviewHostExample to app-host/objectstack.config.ts with full preview mode KernelContext usage documentation - Update app-host README with preview mode section, config table, and OS_MODE=preview quick start - Update content/docs/references/kernel/context.mdx with preview mode enum value and PreviewModeConfig schema reference - Update examples/README.md with preview mode in protocol coverage Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
已在
|
There was a problem hiding this comment.
Pull request overview
Adds a preview runtime mode to the kernel context protocol in @objectstack/spec, introducing a dedicated previewMode configuration for demo/marketplace scenarios and documenting it with tests and examples.
Changes:
- Extended
RuntimeModewithpreviewand addedPreviewModeConfigSchemaplus optionalpreviewModeonKernelContextSchema. - Added unit tests for preview mode parsing/defaults and validation edge cases.
- Updated example configs and docs/READMEs to describe how to run and configure preview mode.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/spec/src/kernel/context.zod.ts | Adds preview runtime mode and defines PreviewModeConfigSchema; extends KernelContextSchema with optional previewMode. |
| packages/spec/src/kernel/context.test.ts | Adds tests for preview mode acceptance, config defaults, and validation errors. |
| examples/app-host/objectstack.config.ts | Adds a PreviewHostExample stack configuration demonstrating preview mode usage. |
| examples/app-host/README.md | Documents how to run app-host in preview mode and lists PreviewModeConfig properties. |
| examples/README.md | Mentions preview mode support and adds quick-start command for OS_MODE=preview. |
| content/docs/references/kernel/context.mdx | Updates reference docs to include preview and previewMode, plus a PreviewModeConfig section. |
| /** | ||
| * Preview Mode Configuration Schema | ||
| * | ||
| * Configures the kernel's preview/demo mode behaviour. |
There was a problem hiding this comment.
Spelling: the codebase consistently uses American English “behavior”. Consider changing “behaviour” to “behavior” here for consistency (also aligns with other schema docs/descriptions).
| * Configures the kernel's preview/demo mode behaviour. | |
| * Configures the kernel's preview/demo mode behavior. |
| import { KernelContext, RuntimeMode, PreviewModeConfig } from '@objectstack/spec/kernel'; | ||
| import type { KernelContext, RuntimeMode, PreviewModeConfig } from '@objectstack/spec/kernel'; | ||
|
|
||
| // Validate data | ||
| const result = KernelContext.parse(data); |
There was a problem hiding this comment.
The TypeScript usage snippet is incorrect: KernelContext is a type (not a Zod schema), so KernelContext.parse(...) and the value import will fail. Also importing the same identifiers as both value and type in separate import statements is invalid/redundant. Update the snippet to import and use KernelContextSchema.parse(...), and only import KernelContext/RuntimeMode/PreviewModeConfig as types if needed.
| import { KernelContext, RuntimeMode, PreviewModeConfig } from '@objectstack/spec/kernel'; | |
| import type { KernelContext, RuntimeMode, PreviewModeConfig } from '@objectstack/spec/kernel'; | |
| // Validate data | |
| const result = KernelContext.parse(data); | |
| import { KernelContextSchema } from '@objectstack/spec/kernel'; | |
| import type { KernelContext, RuntimeMode, PreviewModeConfig } from '@objectstack/spec/kernel'; | |
| // Validate data | |
| const result = KernelContextSchema.parse(data); |
|
|
||
| ## PreviewModeConfig | ||
|
|
||
| Configures the kernel's preview/demo mode behaviour. When `mode` is set to `'preview'`, the platform |
There was a problem hiding this comment.
Spelling: the repo overwhelmingly uses “behavior” (American English). Consider changing “behaviour” to “behavior” in this new PreviewModeConfig section for consistency.
| Configures the kernel's preview/demo mode behaviour. When `mode` is set to `'preview'`, the platform | |
| Configures the kernel's preview/demo mode behavior. When `mode` is set to `'preview'`, the platform |
Adds a
'preview'runtime mode to the ObjectStack kernel, allowing the platform to bypass authentication screens and automatically simulate an admin identity. This is useful for marketplace demos, app showcases, or onboarding tours where visitors should explore the system without registering or logging in.Changes
Schema (
packages/spec/src/kernel/context.zod.ts)'preview'toRuntimeModeenum alongsidedevelopment,production,test, andprovisioningPreviewModeConfigSchemawith the following properties:autoLogin(defaulttrue) — skip login/registration pagessimulatedRole('admin' | 'user' | 'viewer', default'admin') — permission role for the simulated usersimulatedUserName(default'Preview User') — display name in the UIreadOnly(defaultfalse) — restrict to read-only operationsexpiresInSeconds(default0) — session duration (0 = no expiration)bannerMessage(optional) — banner displayed in the UI during preview modepreviewModefield toKernelContextSchemaTests (
packages/spec/src/kernel/context.test.ts)Example (
examples/app-host/)PreviewHostExampletoobjectstack.config.tswith fullKernelContextpreview mode usageREADME.mdwith preview mode section,OS_MODE=previewquick start,PreviewModeConfigproperties table, and security warningDocumentation
content/docs/references/kernel/context.mdxwithpreviewenum value,previewModeproperty onKernelContext, and fullPreviewModeConfigschema referenceexamples/README.mdwith preview mode in System Protocol coverage table and app-host descriptionUsage
The frontend detects
mode === 'preview'to skip login/registration and enter the system with the simulated admin identity.Testing
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.