Skip to content

Fix call tag variable assignments using Proxy-based context#181

Open
Copilot wants to merge 14 commits intodevelopfrom
copilot/fix-call-tag-functionality
Open

Fix call tag variable assignments using Proxy-based context#181
Copilot wants to merge 14 commits intodevelopfrom
copilot/fix-call-tag-functionality

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 22, 2025

The call tag was not updating exported scene variables. Assignments like <call method="hoge = 1" /> created local variables instead of modifying the scene context, breaking conditional logic and variable expansion.

Root Cause

executeCode() passed scene properties by value, making assignments local-only:

// Before: assignments create local variables
const context = { ...this.sceneFile }
const func = new Function(...Object.keys(context), code)
return func.apply(null, Object.values(context))

Changes

  • Modified executeCode() to use Proxy: Intercepts property access/assignment to modify sceneFile directly
  • Uses with statement: Enables natural variable syntax while maintaining reference to source object
  • Added comprehensive unit tests: Covers assignment, conditions, expansion, and the reported if_test scenario
  • Enhanced if_test.scene demo: Updated the demo scene with 4 comprehensive test sections showcasing basic assignment, value modification, increment operations, and complex expressions
  • Created standalone demo HTML: Added demo_call_tag_fix.html - a self-contained, browser-ready demo file with no dependencies or server setup required
  • Fixed example project configuration: Updated the example to properly use the built package from dist/ directory, ensuring local testing works correctly
// After: assignments modify sceneFile properties
const context = new Proxy(this.sceneFile, {
  get: (target, key) => target[key],
  set: (target, key, value) => {
    target[key] = value
    return true
  }
})
const func = new Function('context', `with(context) { ${code} }`)
return func.call(null, context)

Verification

Manual test confirms proper behavior:

Variable assignments now propagate correctly to conditionals (if="hoge==1") and expansions ({{hoge}}).

Demo Scene

The updated if_test.scene provides a comprehensive demonstration:

■テスト1: 値の代入 - Basic value assignment (hoge = 1)
■テスト2: 値の変更 - Value modification (hoge = 2)
■テスト3: 計算式 - Increment operations (count = count + 1, executed twice)
■テスト4: 複雑な式 - Complex expressions (result = hoge * count)

Each test section displays variable values before and after operations using {{variable}} syntax, with visual success/error indicators (✓/✗) to confirm conditional logic works correctly.

Standalone Demo

demo_call_tag_fix.html provides an easy way to verify the fix without any setup:

  • Can be opened directly in any browser (no server required)
  • Self-contained with all CSS/JS inline
  • Beautiful gradient UI with visual test results
  • Includes re-runnable tests
  • See DEMO_README.md for usage instructions

Testing the Example

To test the fix with the example project:

  1. Build and pack the package:

    npm run build
    npm pack
  2. Install in example:

    cd example
    npm install ../webtalekit-alpha-0.2.12.tgz
    npm run dev
  3. Open http://localhost:8080?scene=if_test in your browser

See TESTING_EXAMPLE.md for detailed testing instructions and troubleshooting.

Original prompt

This section details on the original issue you should resolve

<issue_title>callタグが機能しない</issue_title>
<issue_description>IF属性デモで、値が変わらない


Trelloから移行 (doing): https://trello.com/c/zxmRmJus</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 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.

Copilot AI and others added 3 commits December 22, 2025 05:03
Co-authored-by: EndoHizumi <5486808+EndoHizumi@users.noreply.github.com>
Use Proxy and 'with' statement to execute code in sceneFile context, allowing assignments to modify the original properties instead of creating local variables.

Co-authored-by: EndoHizumi <5486808+EndoHizumi@users.noreply.github.com>
…omment

Co-authored-by: EndoHizumi <5486808+EndoHizumi@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix call tag functionality in IF attribute demo Fix call tag variable assignments using Proxy-based context Dec 22, 2025
Copilot AI requested a review from EndoHizumi December 22, 2025 05:12
@EndoHizumi EndoHizumi changed the base branch from main to develop February 19, 2026 04:57
@EndoHizumi EndoHizumi marked this pull request as ready for review February 19, 2026 05:58
@EndoHizumi
Copy link
Copy Markdown
Owner

@copilot この確認デモ用に、if-test.sceneを書き換えて

Enhanced the demo scene to better showcase the call tag fix:
- Added 4 test sections with clear labels and visual separators
- Test 1: Basic value assignment (hoge = 1)
- Test 2: Value modification (hoge = 2)
- Test 3: Increment operations (count = count + 1)
- Test 4: Complex expressions (result = hoge * count)
- Added additional variables (count, result) to demonstrate various scenarios
- Clear success/error indicators for conditional display
- Shows variable values before and after each operation using {{variable}} expansion

Co-authored-by: EndoHizumi <5486808+EndoHizumi@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Feb 19, 2026

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

Project Deployment Actions Updated (UTC)
webtalekit-demo Error Error Mar 22, 2026 4:55pm

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 19, 2026

@copilot この確認デモ用に、if-test.sceneを書き換えて

if_test.sceneを更新しました(コミット: b7f7707

更新内容:

  • 4つのテストセクションで機能を段階的に確認
  • テスト1: 基本的な代入 (hoge = 1)
  • テスト2: 値の変更 (hoge = 2)
  • テスト3: インクリメント操作 (count = count + 1)
  • テスト4: 複雑な式 (result = hoge * count)
  • 各操作の前後で変数値を表示
  • 条件分岐の動作を✓/✗マークで視覚的に確認可能

実行時の出力イメージ:

【callタグ機能テスト】

■初期状態
変数hogeの初期値: 2
変数countの初期値: 0

■テスト1: 値の代入
callタグで hoge = 1 を実行します。
実行後のhogeの値: 1
✓ hoge==1 の条件で表示(正常)

■テスト2: 値の変更
callタグで hoge = 2 を実行します。
実行後のhogeの値: 2
✓ hoge==2 の条件で表示(正常)

■テスト3: 計算式
callタグで count = count + 1 を実行します。
実行後のcountの値: 1
✓ count==1 の条件で表示(正常)

もう一度実行します。
実行後のcountの値: 2
✓ count==2 の条件で表示(正常)

■テスト4: 複雑な式
callタグで result = hoge * count を実行します。
実行後のresultの値: 4
(2 × 2 = 4)
✓ result==4 の条件で表示(正常)

【テスト完了】
callタグとifグローバル属性が正常に動作しています!

@EndoHizumi
Copy link
Copy Markdown
Owner

@copilot こちらで、動作確認できるURLとか出せる? ローカルだとうまく確認できてない。

Created demo_call_tag_fix.html - a standalone HTML file that demonstrates the call tag fix without requiring local dev server setup. Can be opened directly in browser or hosted on GitHub Pages.

Features:
- Self-contained demo with all CSS/JS inline
- Visual test results with success/error indicators
- 4 comprehensive test sections
- Re-runnable test button
- Beautiful gradient UI with clear sections
- No dependencies required

Also added DEMO_README.md with usage instructions.

Co-authored-by: EndoHizumi <5486808+EndoHizumi@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 19, 2026

@copilot こちらで、動作確認できるURLとか出せる? ローカルだとうまく確認できてない。

スタンドアロンのデモHTMLファイルを作成しました(コミット: faf199b

ファイル: demo_call_tag_fix.html

確認方法

オプション1: ファイルを直接開く(最も簡単)

リポジトリをcloneして、demo_call_tag_fix.html をブラウザで直接開いてください(ダブルクリック)。すぐに動作します。

オプション2: GitHubでRawファイルを開く

このPRがマージされた後、以下のようなURLでアクセス可能になります:

https://raw.githubusercontent.com/EndoHizumi/webTaleKit/[branch]/demo_call_tag_fix.html

オプション3: GitHub Pagesで公開

このブランチをGitHub Pagesにデプロイすれば、オンラインURLで確認できます。

デモの内容

  • ✅ 4つのテストセクション(代入、変更、計算式、複雑な式)
  • ✅ 各操作の前後で変数値を表示
  • ✅ 条件分岐の動作を✓/✗マークで視覚的に確認
  • ✅ テスト再実行ボタン付き
  • ✅ グラデーション背景の美しいUI

すべてのCSSとJavaScriptがインライン化されているため、サーバー不要で単一ファイルで完結します。

詳細な使用方法は DEMO_README.md に記載しています。

Copy link
Copy Markdown
Owner

@EndoHizumi EndoHizumi left a comment

Choose a reason for hiding this comment

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

@copilot exampleのifテストを動かしても、変化がないよ

…ckage

The example needs to use the packaged/built version of webtalekit-alpha to work properly. Changes:
- Updated import path from 'webtalekit-alpha/src/core/' to 'webtalekit-alpha/dist/src/core/'
- Added webtalekit-alpha as a local dependency (installed from tarball)
- Fixed webpack config regex escaping
- Made parser/cli.js executable

To test the example:
1. npm run build (in root to build the package)
2. npm pack (in root to create tarball)
3. cd example && npm install ../webtalekit-alpha-0.2.12.tgz
4. npm run dev (in example directory)
5. Open http://localhost:8080?scene=if_test to see the if test demo

Co-authored-by: EndoHizumi <5486808+EndoHizumi@users.noreply.github.com>
Agent-Logs-Url: https://github.com/EndoHizumi/webTaleKit/sessions/1a2ebdba-ff81-4c4b-b14a-3872ee06b6ce
Added TESTING_EXAMPLE.md with detailed instructions on how to properly build, install, and test the example to verify the call tag fix works correctly.

Co-authored-by: EndoHizumi <5486808+EndoHizumi@users.noreply.github.com>
Agent-Logs-Url: https://github.com/EndoHizumi/webTaleKit/sessions/1a2ebdba-ff81-4c4b-b14a-3872ee06b6ce
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 22, 2026

@copilot exampleのifテストを動かしても、変化がないよ

問題を修正しました(コミット: 70cd925, d3b7b59

原因

exampleがwebtalekit-alpha/src/core/をインポートしていましたが、パッケージにはdistのビルド済みファイルしか含まれておらず、修正が反映されていませんでした。

修正内容

  1. インポートパスをwebtalekit-alpha/dist/src/core/に変更
  2. webtalekit-alphaをローカルパッケージとしてインストール
  3. webpack設定を修正

テスト手順

詳細は TESTING_EXAMPLE.md に記載していますが、簡単な手順は以下の通りです:

# ルートディレクトリで
npm install
npm run build
npm pack

# exampleディレクトリで
cd example
npm install ../webtalekit-alpha-0.2.12.tgz
npm run dev

その後、ブラウザで http://localhost:8080?scene=if_test を開いてください。

期待される動作

  • ✓ 変数hogeが1→2と正しく変更される
  • ✓ if条件が正しく評価される(✓マークが表示、✗マークは非表示)
  • ✓ {{変数}}展開で最新の値が表示される
  • ✓ count変数のインクリメント動作(0→1→2)
  • ✓ 複雑な式の計算(result = hoge × count = 4)

これでexampleのif_testが正常に動作するはずです。

Copilot AI requested a review from EndoHizumi March 22, 2026 16:16
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.

callタグが機能しない

2 participants