Skip to content

fix(playground): inject Vue cardIdSymbol for Angular saveState - #264

Merged
rhlin merged 3 commits into
devfrom
fix/playground-angular-save-state
Sep 1, 2026
Merged

fix(playground): inject Vue cardIdSymbol for Angular saveState#264
rhlin merged 3 commits into
devfrom
fix/playground-angular-save-state

Conversation

@lhuans

@lhuans lhuans commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • 修复演练场 Angular 渲染路径下 saveState / continueChat 无法持久化卡片 state 的问题
  • message-renderer-angular 桥接层为 action 注入 Vue 侧的 cardIdSymbol
  • @opentiny/genui-sdk-vue 导出 cardIdSymbol,保证与 GenuiChat 使用同一 Symbol 引用

Bug 原因

演练场 Angular 卡片复用了 Vue Chat 创建的 saveStateAction,但卡片 ID 的传递依赖 context 上的 Symbol 键:

  • Vue:cardIdSymbol = Symbol('schema-card-id')useChat.ts
  • Angular:CARD_ID = Symbol('schema-card-id')genui-renderer.ts

二者描述字符串相同,但 Symbol('x') === Symbol('x') 恒为 false。Angular 渲染器用自己的 Symbol 写入 context,Vue 的 saveState 用自己的 Symbol 读取,得到 undefinedgetCardMessage 找不到消息,导致 saveState 静默失败。

一般情况下业务不会同时混用 Angular 渲染器与 Vue Chat,因此未在 SDK 层统一 Symbol(如 Symbol.for),仅在演练场这一跨框架桥接场景做兼容。

解决方案

sites/playground/web/src/ng-renderer/message-renderer-angular.ts 中包装 saveState / continueChat:执行前将 [cardIdSymbol]: schemaCardProps.id 写入 context,使 Vue Chat 能正确定位消息并持久化 state。同时从 vue 包导出 cardIdSymbol,避免引用到不同模块实例。

Summary by CodeRabbit

  • Bug Fixes

    • Improved Angular chat actions so continuing conversations and saving message state work more reliably.
    • Ensured actions correctly retain the context of the message or card they belong to.
  • Improvements

    • Expanded Vue chat integration capabilities for developers building custom chat experiences.

Angular renderer and Vue Chat used different Symbol instances for card id,
so saveState could not locate the message. Bind cardId into actions at the
playground Angular bridge.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 55a63a96-4d29-4d93-b0fe-cf78bcda1d12

📥 Commits

Reviewing files that changed from the base of the PR and between 515d020 and 8761385.

📒 Files selected for processing (1)
  • sites/playground/web/src/message-renderers/message-renderer-angular.ts

Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.


Walkthrough

The Vue chat package now exports cardIdSymbol. The Angular message renderer binds the current schema card ID to continueChat and saveState action execution contexts.

Changes

Card ID context propagation

Layer / File(s) Summary
Expose the card ID symbol
packages/frameworks/vue/src/chat/index.ts
The Vue chat index re-exports cardIdSymbol from useChat.js.
Bind card IDs to Angular actions
sites/playground/web/src/message-renderers/message-renderer-angular.ts
The renderer wraps continueChat and saveState with bindCardIdToAction. Each action receives schemaCardProps.id under cardIdSymbol during execution.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: 🔵 Low · up to 87613

This change enables Angular-rendered cards to persist state through the existing chat flow. If card IDs are duplicated or reused, saving one card could update the wrong matching card; the PR is otherwise mergeable with explicit owner awareness of ID uniqueness.

Suggested reviewers: jiahaomo

Poem

A rabbit reads each line,
The patch grows clear beneath the moon,
Small changes hop in place,
Tests guard the garden path,
Reviews bloom before the dawn.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: injecting Vue's cardIdSymbol into the Angular playground flow for saveState. It is concise and directly related to the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/playground-angular-save-state

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread sites/playground/web/src/ng-renderer/message-renderer-angular.ts Outdated
lhuans and others added 2 commits September 1, 2026 17:17
…derer

Address review feedback by moving bound continueChat/saveState actions
out of the h() props object for clearer render structure.

Co-authored-by: Cursor <cursoragent@cursor.com>
@rhlin
rhlin merged commit c446f8f into dev Sep 1, 2026
1 check passed
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.

3 participants