Reliability: fix result correlation (ES3 toISOString) + read-only bridge-status probe#33
Open
juansilvadesign wants to merge 1 commit into
Open
Conversation
…probe The bridge could not reliably tell a fresh result from a stale one, which made initial diagnosis painful. Root causes and fixes: - ExtendScript's Date has no toISOString (ES3), so the panel's result-stamping threw and was swallowed, writing results WITHOUT their correlation fields. Add an ES3 toISOString polyfill so stamping succeeds. - Correlate results to requests by a per-command `commandId` (echoed back by the panel as `_commandId`) instead of a wall-clock "file older than 30s" heuristic, which false-positives on shared/mounted bridge dirs (e.g. WSL /mnt/c) and on simple re-reads. get-results and waitForBridgeResult now match on commandId. - Add `bridge-status`: a read-only liveness probe (ping) that reports whether the panel is open and its round-trip latency, WITHOUT mutating the project (unlike run-bridge-test, which applies effects). - Support `AE_MCP_BRIDGE_DIR` to point both sides at a shared bridge folder when the MCP host and After Effects run in different OS contexts (WSL <-> Windows). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
The file-based bridge couldn't reliably tell a fresh result from an old one, which made the very first "is this even working?" diagnosis painful. This PR fixes the root causes and adds a read-only way to confirm the panel is alive. All changes are backward-compatible.
What was broken
toISOStringthrows in ExtendScript. The panel stamps each result vianew Date().toISOString(), but ExtendScript'sDateis ES3 and has notoISOString. The call throws, the surroundingtry/catchswallows it, and the result is written without its correlation fields (_commandExecuted,_responseTimestamp). That silently brokewaitForBridgeResult(), which matches on_commandExecuted— so, for example, thecompositionsresource could only ever time out.get-resultsreturned"Result file appears to be stale"whenever the result file's mtime was more than 30s old. On a shared/mounted bridge dir (e.g. WSL/mnt/cdriving Windows AE) clock skew and simple re-reads trip that on perfectly correct data.run-bridge-test, applies effects to the open project.Changes
toISOStringpolyfill in the panel so result-stamping succeeds.commandId(echoed back by the panel as_commandId) instead of wall-clock mtime.get-resultsandwaitForBridgeResultnow match on it, and the false "stale" path is gone. If the panel predates the field, it falls back gracefully to returning the raw content.bridge-status— a read-only liveness probe (ping) that reports whether the panel is open and its round-trip latency, without mutating the project.AE_MCP_BRIDGE_DIRso the server and panel can rendezvous on a shared folder when the MCP host and After Effects run in different OS contexts (WSL ↔ Windows). The panel honours the same variable via$.getenv.Testing
npm run build(esbuild) passes; the panel.jsxpasses a syntax parse. The bridge round-trip andbridge-statuswere exercised against After Effects 2024 on Windows, driven from Node in WSL.Notes
A companion PR (community tool bundle) lives in a separate branch to keep this one focused on reliability.
🤖 Generated with Claude Code