Skip to content

feat(kernel): add preview/demo runtime mode with auto-login and simulated identity#676

Merged
hotlong merged 4 commits intomainfrom
copilot/add-demo-preview-mode
Feb 14, 2026
Merged

feat(kernel): add preview/demo runtime mode with auto-login and simulated identity#676
hotlong merged 4 commits intomainfrom
copilot/add-demo-preview-mode

Conversation

Copy link
Contributor

Copilot AI commented Feb 14, 2026

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)

  • Added 'preview' to RuntimeMode enum alongside development, production, test, and provisioning
  • Added PreviewModeConfigSchema with the following properties:
    • autoLogin (default true) — skip login/registration pages
    • simulatedRole ('admin' | 'user' | 'viewer', default 'admin') — permission role for the simulated user
    • simulatedUserName (default 'Preview User') — display name in the UI
    • readOnly (default false) — restrict to read-only operations
    • expiresInSeconds (default 0) — session duration (0 = no expiration)
    • bannerMessage (optional) — banner displayed in the UI during preview mode
  • Added optional previewMode field to KernelContextSchema

Tests (packages/spec/src/kernel/context.test.ts)

  • 8 new tests covering preview mode validation, defaults, role enum, read-only config, and edge cases

Example (examples/app-host/)

  • Added PreviewHostExample to objectstack.config.ts with full KernelContext preview mode usage
  • Updated README.md with preview mode section, OS_MODE=preview quick start, PreviewModeConfig properties table, and security warning

Documentation

  • Updated content/docs/references/kernel/context.mdx with preview enum value, previewMode property on KernelContext, and full PreviewModeConfig schema reference
  • Updated examples/README.md with preview mode in System Protocol coverage table and app-host description

Usage

import { KernelContextSchema } from '@objectstack/spec/kernel';

const ctx = KernelContextSchema.parse({
  instanceId: '550e8400-e29b-41d4-a716-446655440000',
  mode: 'preview',
  version: '1.0.0',
  cwd: '/app',
  startTime: Date.now(),
  previewMode: {
    autoLogin: true,
    simulatedRole: 'admin',
    simulatedUserName: 'Demo Admin',
    bannerMessage: 'You are exploring a demo — data will be reset periodically.',
  },
});

The frontend detects mode === 'preview' to skip login/registration and enter the system with the simulated admin identity.

Testing

  • All 195 test files / 5278 tests pass
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.

@vercel
Copy link

vercel bot commented Feb 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectstack-play Ready Ready Preview, Comment Feb 14, 2026 7:57am
spec Ready Ready Preview, Comment Feb 14, 2026 7:57am

Request Review

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>
Copilot AI changed the title [WIP] Add demo or preview mode for application market feat(cloud): add preview/demo mode protocol for marketplace listings Feb 14, 2026
Copilot AI requested a review from hotlong February 14, 2026 07:36
@hotlong
Copy link
Contributor

hotlong commented Feb 14, 2026

你理解错了,我说的是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>
Copy link
Contributor Author

Copilot AI commented Feb 14, 2026

你理解错了,我说的是objectstack 运行的时候,是通过一个插件或者开关让前端知道我现在是预览模式就不显示登录和注册的页面,甚至自动模拟一个管��...

已重新理解需求并修正实现。在 8e5aa99 中:

  1. 撤回了之前对 marketplace/app-store 的修改(理解有误)
  2. RuntimeMode 枚举中新增 'preview' 模式
  3. 新增 PreviewModeConfigSchema,包含:
    • autoLogin(默认 true)— 自动登录,跳过登录/注册界面
    • simulatedRole(默认 'admin')— 模拟用户角色
    • simulatedUserName — 模拟用户显示名
    • readOnly — 只读模式(可选)
    • expiresInSeconds — 会话过期时间
    • bannerMessage — 前端展示的预览模式提示条
  4. KernelContextSchema 上新增可选的 previewMode 字段

使用方式:

const ctx = KernelContextSchema.parse({
  mode: 'preview',
  previewMode: {
    autoLogin: true,
    simulatedRole: 'admin',
  },
  // ...
});

前端通过检查 mode === 'preview' 即可跳过登录/注册页面,直接以模拟管理员身份进入系统。

@hotlong
Copy link
Contributor

hotlong commented Feb 14, 2026

@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>
Copy link
Contributor Author

Copilot AI commented Feb 14, 2026

@copilot 更新现有example,增加 preview 运行模式,更新文档。

已在 1909884 中完成更新:

  1. examples/app-host/objectstack.config.ts — 新增 PreviewHostExample,包含完整的 KernelContext preview 模式使用文档和示例代码
  2. examples/app-host/README.md — 新增 Preview Mode 章节,包含 OS_MODE=preview 快速启动指南、PreviewModeConfig 属性参考表和安全提示
  3. content/docs/references/kernel/context.mdx — 更新 RuntimeMode 文档新增 preview,新增 PreviewModeConfig schema 参考
  4. examples/README.md — 更新 System Protocol 覆盖表新增 Preview Mode,更新 App Host 描述

Copilot AI changed the title feat(cloud): add preview/demo mode protocol for marketplace listings feat(kernel): add preview/demo runtime mode with auto-login and simulated identity Feb 14, 2026
@hotlong hotlong marked this pull request as ready for review February 14, 2026 08:30
Copilot AI review requested due to automatic review settings February 14, 2026 08:30
@hotlong hotlong merged commit 8c3a868 into main Feb 14, 2026
5 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 RuntimeMode with preview and added PreviewModeConfigSchema plus optional previewMode on KernelContextSchema.
  • 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.
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling: the codebase consistently uses American English “behavior”. Consider changing “behaviour” to “behavior” here for consistency (also aligns with other schema docs/descriptions).

Suggested change
* Configures the kernel's preview/demo mode behaviour.
* Configures the kernel's preview/demo mode behavior.

Copilot uses AI. Check for mistakes.
Comment on lines +17 to 21
import { KernelContext, RuntimeMode, PreviewModeConfig } from '@objectstack/spec/kernel';
import type { KernelContext, RuntimeMode, PreviewModeConfig } from '@objectstack/spec/kernel';

// Validate data
const result = KernelContext.parse(data);
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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);

Copilot uses AI. Check for mistakes.

## PreviewModeConfig

Configures the kernel's preview/demo mode behaviour. When `mode` is set to `'preview'`, the platform
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling: the repo overwhelmingly uses “behavior” (American English). Consider changing “behaviour” to “behavior” in this new PreviewModeConfig section for consistency.

Suggested change
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

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants