Skip to content

Conversation

@aaronvg
Copy link
Contributor

@aaronvg aaronvg commented Nov 6, 2025

  • design-docs v1
  • plans 1-3
  • move baml-graphs files over
  • add tests
  • test runner changes
  • wip migrating old code to sdk

Note

Refactors playground to use a new SDK-based runtime/selection model, adds ReactFlow workflow graph with auto‑layout and detail panel, centralizes navigation/test execution, and replaces direct WASM/mermaid paths.

  • SDK Core:
    • Introduces BamlRuntime (WASM) and MockBamlRuntime, unified interface/types, and JotaiStorage for state.
    • Consolidates atoms (diagnostics, selection, tests, files, feature flags) and adds unified unifiedSelectionAtom with SelectionBridge.
    • Adds navigation heuristic (navigationHeuristic) and cursor/test selection syncing.
  • Graph & Detail Panel:
    • Replaces Mermaid view with ReactFlow graph (GraphView) + ELK auto‑layout, custom nodes/edges, and camera pan utilities.
    • Adds DetailPanel (I/O, logs, history) and workflow UI components (toolbar/indicator).
  • Test Execution:
    • Routes test runs through SDK (tests.run/runAll/cancel), adds watch notifications, flashing regions, and history atoms.
  • Prompt Preview:
    • Renders prompts/cURL via SDK runtime (renderPromptForTest/renderCurlForTest), updates media rendering and token stats.
  • Playground Integration:
    • Unifies Preview/Graph in UnifiedPromptPreview, introduces bottom panel switching, updates sidebar and function/test items.
  • Build/Config:
    • Vite/Tailwind tweaks, new vitest config, dependency bumps.
  • Docs/Tests:
    • Adds design/implementation docs and vitest suites for navigation and runtime integration.

Written by Cursor Bugbot for commit ec4b57c. This will update automatically on new commits. Configure here.

@aaronvg aaronvg temporarily deployed to boundary-tools-dev November 6, 2025 23:35 — with GitHub Actions Inactive
@aaronvg aaronvg temporarily deployed to boundary-tools-dev November 6, 2025 23:35 — with GitHub Actions Inactive
@aaronvg aaronvg temporarily deployed to boundary-tools-dev November 6, 2025 23:35 — with GitHub Actions Inactive
@vercel
Copy link

vercel bot commented Nov 6, 2025

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

Project Deployment Preview Comments Updated (UTC)
promptfiddle Error Error Nov 10, 2025 2:06am

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

// Main message handler - routes IDE/LSP messages to SDK methods
useEffect(() => {
const fn = (event: MessageEvent<VscodeToWebviewCommand>) => {
const handler = async (event: MessageEvent<VscodeToWebviewCommand>) => {

Check warning

Code scanning / CodeQL

Missing origin verification in `postMessage` handler Medium

Postmessage handler has no origin check.

Copilot Autofix

AI 12 days ago

To address this issue, we need to verify the event.origin property in the main 'message' event handler before any processing occurs. This means modifying the handler function (defined at line 95) so that it only routes messages if they originate from a trusted source.

General steps:

  • Define an allow-list of trusted origins (for example: only window.origin, or a set of specific URLs, whatever fits the application's security model).
  • In the handler, early return if event.origin does not match a trusted origin.
  • Optionally, add logging for denied origins.

Best way in this code:

  • Since the handler runs in the webview/SPA, and likely only communicates with itself (e.g., the origin of the webapp), use window.location.origin as the only trusted origin.
  • Add a check: if (event.origin !== window.location.origin) { return; } at the beginning of the handler.
    • Optionally, log or warn if a message is ignored for documentation/debugging.
  • These changes are all done inside the existing handler definition, and no additional dependencies are needed.

Files/lines to change:
Edit typescript/packages/playground-common/src/baml_wasm_web/EventListener.tsx, inside the handler defined at line 95.

No external imports or new methods are needed.


Suggested changeset 1
typescript/packages/playground-common/src/baml_wasm_web/EventListener.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/typescript/packages/playground-common/src/baml_wasm_web/EventListener.tsx b/typescript/packages/playground-common/src/baml_wasm_web/EventListener.tsx
--- a/typescript/packages/playground-common/src/baml_wasm_web/EventListener.tsx
+++ b/typescript/packages/playground-common/src/baml_wasm_web/EventListener.tsx
@@ -93,6 +93,11 @@
   // Main message handler - routes IDE/LSP messages to SDK methods
   useEffect(() => {
     const handler = async (event: MessageEvent<VscodeToWebviewCommand>) => {
+      // Only accept messages from same origin
+      if (event.origin !== window.location.origin) {
+        console.warn('[EventListener] Ignoring message from untrusted origin:', event.origin);
+        return;
+      }
       const { source, payload } = event.data;
       console.debug('[EventListener] Handling command:', { source, payload });
 
EOF
@@ -93,6 +93,11 @@
// Main message handler - routes IDE/LSP messages to SDK methods
useEffect(() => {
const handler = async (event: MessageEvent<VscodeToWebviewCommand>) => {
// Only accept messages from same origin
if (event.origin !== window.location.origin) {
console.warn('[EventListener] Ignoring message from untrusted origin:', event.origin);
return;
}
const { source, payload } = event.data;
console.debug('[EventListener] Handling command:', { source, payload });

Copilot is powered by AI and may make mistakes. Always verify output.
@github-actions
Copy link

github-actions bot commented Nov 6, 2025

@aaronvg aaronvg temporarily deployed to boundary-tools-dev November 8, 2025 02:54 — with GitHub Actions Inactive
@aaronvg aaronvg temporarily deployed to boundary-tools-dev November 8, 2025 02:54 — with GitHub Actions Inactive
@aaronvg aaronvg temporarily deployed to boundary-tools-dev November 8, 2025 02:54 — with GitHub Actions Inactive
@github-actions
Copy link

github-actions bot commented Nov 8, 2025

@github-actions
Copy link

github-actions bot commented Nov 8, 2025

@aaronvg aaronvg temporarily deployed to boundary-tools-dev November 8, 2025 03:10 — with GitHub Actions Inactive
@aaronvg aaronvg temporarily deployed to boundary-tools-dev November 9, 2025 21:36 — with GitHub Actions Inactive
@aaronvg aaronvg temporarily deployed to boundary-tools-dev November 9, 2025 21:36 — with GitHub Actions Inactive
@aaronvg aaronvg temporarily deployed to boundary-tools-dev November 9, 2025 21:36 — with GitHub Actions Inactive
@github-actions
Copy link

github-actions bot commented Nov 9, 2025

@github-actions
Copy link

github-actions bot commented Nov 9, 2025

@aaronvg aaronvg temporarily deployed to boundary-tools-dev November 10, 2025 01:08 — with GitHub Actions Inactive
@aaronvg aaronvg temporarily deployed to boundary-tools-dev November 10, 2025 01:08 — with GitHub Actions Inactive
@aaronvg aaronvg temporarily deployed to boundary-tools-dev November 10, 2025 01:08 — with GitHub Actions Inactive
@github-actions
Copy link

@github-actions
Copy link

? outsidePoint.y - h - y
: y - h - outsidePoint.y;
r = (R * q) / Q;
const res = {
Copy link

Choose a reason for hiding this comment

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

Bug: Division by Zero: Order of Operations Flaw

Division by zero vulnerability when Q equals zero. At line 73, r = (R * q) / Q performs division without checking if Q is zero. While there's a check if (Q === 0) at line 87 that sets res.y, the division at line 73 executes first and will produce Infinity or NaN when Q is zero, corrupting the calculation before the check can fix it. The check should occur before the division.

Fix in Cursor Fix in Web

r = x - w - outsidePoint.x;
}
const q = (Q * r) / R;
let _x =
Copy link

Choose a reason for hiding this comment

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

Bug: Division by Zero: Check Order Matters

Division by zero vulnerability when R equals zero. At line 100, const q = (Q * r) / R performs division without checking if R is zero. While there's a check if (R === 0) at line 108 that sets _x, the division at line 100 executes first and will produce Infinity or NaN when R is zero, corrupting the calculation before the check can fix it. The check should occur before the division.

Fix in Cursor Fix in Web

return runtime?.getWorkflows() ?? [];
}, (get, set, update: FunctionWithCallGraph[]) => {
set(workflowsAtom, update);
});
Copy link

Choose a reason for hiding this comment

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

Bug: Atom Write Recursion: Breaking the Jotai Model

Infinite recursion in workflowsAtom write function. The setter calls set(workflowsAtom, update) which recursively invokes itself, causing a stack overflow. The write function should update an internal state atom rather than calling itself. This pattern breaks Jotai's derived atom model where the read function should be the source of truth derived from runtimeInstanceAtom.

Fix in Cursor Fix in Web

@aaronvg aaronvg temporarily deployed to boundary-tools-dev November 10, 2025 01:44 — with GitHub Actions Inactive
@aaronvg aaronvg temporarily deployed to boundary-tools-dev November 10, 2025 01:44 — with GitHub Actions Inactive
@aaronvg aaronvg temporarily deployed to boundary-tools-dev November 10, 2025 01:44 — with GitHub Actions Inactive
@github-actions
Copy link

@github-actions
Copy link

@aaronvg aaronvg temporarily deployed to boundary-tools-dev November 10, 2025 01:50 — with GitHub Actions Inactive
@aaronvg aaronvg temporarily deployed to boundary-tools-dev November 10, 2025 01:50 — with GitHub Actions Inactive
@aaronvg aaronvg temporarily deployed to boundary-tools-dev November 10, 2025 01:50 — with GitHub Actions Inactive
@github-actions
Copy link

@github-actions
Copy link

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