Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,11 @@ repos:
files: ^baml_language/
priority: 4
stages: [manual]

- id: textmate-grammar
name: textmate grammar (yaml → json)
entry: bash -c 'cd typescript2 && pnpm exec tsx textmate-grammar/build-grammar.ts && git diff --exit-code app-vscode-ext/syntaxes/baml.tmLanguage.json app-vscode-ext/syntaxes/jinja.tmLanguage.json app-promptfiddle/syntaxes/baml.tmLanguage.json app-promptfiddle/syntaxes/jinja.tmLanguage.json'
language: system
pass_filenames: false
files: ^typescript2/textmate-grammar/(baml\.tmLanguage\.yaml|jinja\.tmLanguage\.json)$
priority: 1
Comment on lines +104 to +110
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider including the build script in the trigger pattern.

The hook triggers on changes to baml.tmLanguage.yaml and jinja.tmLanguage.json, but not on changes to build-grammar.ts itself. If someone modifies the build script logic, the hook won't run, and the generated JSONs could become stale.

♻️ Proposed fix
-        files: ^typescript2/textmate-grammar/(baml\.tmLanguage\.yaml|jinja\.tmLanguage\.json)$
+        files: ^typescript2/textmate-grammar/(baml\.tmLanguage\.yaml|jinja\.tmLanguage\.json|build-grammar\.ts)$

40 changes: 20 additions & 20 deletions typescript2/app-promptfiddle/src/playground/MonacoEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export const MonacoEditor: FC<MonacoEditorProps> = ({ files, onFilesChange, heig
import('@codingame/monaco-vscode-secret-storage-service-override'),
import('@codingame/monaco-vscode-storage-service-override'),
import('vscode'),
import('./baml.tmLanguage.json'),
import('../../syntaxes/baml.tmLanguage.json'),
]);

if (disposed || !containerRef.current) return;
Expand Down Expand Up @@ -491,7 +491,7 @@ export const MonacoEditor: FC<MonacoEditorProps> = ({ files, onFilesChange, heig

async renderInput(input: any): Promise<{ dispose: () => void }> {
const el = this._el;
if (!el) return { dispose() {} };
if (!el) return { dispose() { } };

el.innerHTML = '';
this._img = null;
Expand All @@ -500,7 +500,7 @@ export const MonacoEditor: FC<MonacoEditorProps> = ({ files, onFilesChange, heig
if (!uri?.path) {
el.textContent = 'No image to display';
Object.assign(el.style, { color: '#ccc', padding: '2em' });
return { dispose() {} };
return { dispose() { } };
}

const filename = String(uri.path).startsWith(WORKSPACE_PREFIX)
Expand All @@ -520,7 +520,7 @@ export const MonacoEditor: FC<MonacoEditorProps> = ({ files, onFilesChange, heig
console.error('[ImagePreview] readFile failed:', err);
el.textContent = `Failed to load image: ${err}`;
Object.assign(el.style, { color: '#ccc', padding: '2em' });
return { dispose() {} };
return { dispose() { } };
}
}

Expand Down Expand Up @@ -628,7 +628,7 @@ export const MonacoEditor: FC<MonacoEditorProps> = ({ files, onFilesChange, heig
if (disposed) return;

// Focus Explorer so file tree shows
vscode.commands.executeCommand('workbench.view.explorer').then(() => {}, () => {});
vscode.commands.executeCommand('workbench.view.explorer').then(() => { }, () => { });

// Workbench ready — editor is visible, hide skeleton
setReady(true);
Expand Down Expand Up @@ -776,17 +776,17 @@ export const MonacoEditor: FC<MonacoEditorProps> = ({ files, onFilesChange, heig
);
workerRef.current = worker;

// Listen for the 'ready' message IMMEDIATELY — before any awaits —
// so we don't miss it if WASM loads fast (e.g. from cache).
const workerReadyPromise = new Promise<void>((resolve) => {
const onMsg = (event: MessageEvent) => {
if (event.data?.type === 'ready') {
worker!.removeEventListener('message', onMsg);
resolve();
}
};
worker!.addEventListener('message', onMsg);
});
// Listen for the 'ready' message IMMEDIATELY — before any awaits —
// so we don't miss it if WASM loads fast (e.g. from cache).
const workerReadyPromise = new Promise<void>((resolve) => {
const onMsg = (event: MessageEvent) => {
if (event.data?.type === 'ready') {
worker!.removeEventListener('message', onMsg);
resolve();
}
};
worker!.addEventListener('message', onMsg);
});

// Listen for VFS mutations from the WASM runtime (worker → main).
const onVfsChange = (event: MessageEvent) => {
Expand All @@ -812,7 +812,7 @@ export const MonacoEditor: FC<MonacoEditorProps> = ({ files, onFilesChange, heig
const { path: relPath } = data as { path: string };
delete lf[relPath];
const absPath = `/workspace/${relPath}`;
fsp.delete(vs.Uri.file(absPath), { recursive: false, useTrash: false, atomic: false }).catch(() => {});
fsp.delete(vs.Uri.file(absPath), { recursive: false, useTrash: false, atomic: false }).catch(() => { });
if (isMediaPath(relPath)) remBlob(relPath);
onFilesChangeRef.current({ ...lf });
} else if (data?.type === 'buildTime') {
Expand Down Expand Up @@ -928,7 +928,7 @@ export const MonacoEditor: FC<MonacoEditorProps> = ({ files, onFilesChange, heig
worker = null;
}
};
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const isDev = process.env.NODE_ENV === "development";
Expand Down Expand Up @@ -963,8 +963,8 @@ export const MonacoEditor: FC<MonacoEditorProps> = ({ files, onFilesChange, heig
const delta = Math.floor(Date.now() / 1000) - wasmBuildTime;
const rel = delta < 60 ? `${delta}s ago`
: delta < 3600 ? `${Math.floor(delta / 60)}m ago`
: delta < 86400 ? `${Math.floor(delta / 3600)}h ago`
: `${Math.floor(delta / 86400)}d ago`;
: delta < 86400 ? `${Math.floor(delta / 3600)}h ago`
: `${Math.floor(delta / 86400)}d ago`;
return (
<span className="truncate max-w-[250px]">
Built: {abs} ({rel})
Expand Down
171 changes: 0 additions & 171 deletions typescript2/app-promptfiddle/src/playground/baml-monarch.ts

This file was deleted.

Loading
Loading