Fix templater execution timing for code block buttons#274
Merged
Conversation
- Remove parse-time templater processing from src/index.ts - Update click-time templater processing in src/button.ts to work for all buttons, not just inline - This ensures templater scripts like tp.date.now() execute at click time instead of button creation time - Fixes issue where time-sensitive templater commands would be frozen at button creation Resolves Discord bug report about templater scripts not updating on button click.
✅ Deploy Preview for buttons-docs canceled.
|
- Remove inline-only restriction from livePreview.ts templater processing - Update error messages to be consistent with button.ts changes - This ensures templater commands work in both editing and reading modes This completes the fix for the templater execution timing issue.
🚨 Bugbot Trial ExpiredYour Bugbot trial has expired. Please purchase a license in the Cursor dashboard to continue using Bugbot. |
- Create processedArgs copy instead of mutating original args object - This prevents templater results from being cached/stuck between clicks - Update all button handlers to use processedArgs for action-related operations - Fixes the core issue where templater commands like tp.date.now() would get processed once and then reuse the same result on subsequent clicks The problem was that args.action was being permanently modified from '<% tp.date.now() %>' to '14:30:15', so subsequent clicks would use the static processed result instead of re-executing the templater command.
🚨 Bugbot Trial ExpiredYour Bugbot trial has expired. Please purchase a license in the Cursor dashboard to continue using Bugbot. |
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.
Problem
Fixes a bug reported on Discord where templater scripts inside append text buttons with timestamps fail to update with the actual time. The templater scripts were being executed at button creation/parse time instead of at button click time, causing time-sensitive commands like
tp.date.now()to be "frozen" at the time the button was created.Root Cause
There was an inconsistency in when templater scripts are processed:
src/index.ts, not when clicked ❌Solution
src/index.ts(lines 82-92)src/button.tsto work for all buttons, not just inline onessrc/index.tsChanges
src/index.ts: Removed parse-time templater processing and unused importsrc/button.ts: Removed inline-only restriction for templater processingTesting
Impact
This ensures that templater scripts like
<% tp.date.now("HH:mm:ss") %>will execute fresh on each button click, providing the current time instead of the time when the button was created.Resolves Discord bug report about templater scripts not updating on button click.