From 0ee3f522759c079a8bafe92e2022955ae129b2c6 Mon Sep 17 00:00:00 2001 From: Anish Palakurthi Date: Fri, 28 Jun 2024 10:31:56 -0700 Subject: [PATCH 1/9] fixed UI icon in fiddle --- .../playground-common/src/shared/FunctionPanel.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/typescript/playground-common/src/shared/FunctionPanel.tsx b/typescript/playground-common/src/shared/FunctionPanel.tsx index bc9397ce5..56b924949 100644 --- a/typescript/playground-common/src/shared/FunctionPanel.tsx +++ b/typescript/playground-common/src/shared/FunctionPanel.tsx @@ -7,7 +7,7 @@ import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '../compone import { TooltipProvider } from '../components/ui/tooltip' import { PromptChunk } from './ImplPanel' import FunctionTestSnippet from './TestSnippet' -import { FiCopy } from 'react-icons/fi' +import { Copy } from 'lucide-react' import { Button } from '../components/ui/button' const handleCopy = (text: string) => () => { navigator.clipboard.writeText(text) @@ -31,8 +31,11 @@ const PromptPreview: React.FC = () => { return (
-
Date: Fri, 28 Jun 2024 12:05:07 -0700 Subject: [PATCH 2/9] removed extra tokens --- engine/baml-lib/jinja/src/lib.rs | 17 +++++++++-------- .../src/internal/llm_client/traits/mod.rs | 2 +- .../baml-runtime/src/types/context_manager.rs | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/engine/baml-lib/jinja/src/lib.rs b/engine/baml-lib/jinja/src/lib.rs index 237d72ba8..ca87bbe87 100644 --- a/engine/baml-lib/jinja/src/lib.rs +++ b/engine/baml-lib/jinja/src/lib.rs @@ -196,7 +196,6 @@ fn render_minijinja( let mut chat_messages = vec![]; let mut role = None; - for chunk in rendered.split(MAGIC_CHAT_ROLE_DELIMITER) { if chunk.starts_with(":baml-start-baml:") && chunk.ends_with(":baml-end-baml:") { role = Some( @@ -236,16 +235,18 @@ fn render_minijinja( ))?; } } - } else if part.is_empty() { - // only whitespace, so discard - } else { + } else if !part.trim().is_empty() { parts.push(ChatMessagePart::Text(part.trim().to_string())); } } - chat_messages.push(RenderedChatMessage { - role: role.unwrap_or(&default_role).to_string(), - parts, - }); + + // Only add the message if it contains meaningful content + if !parts.is_empty() { + chat_messages.push(RenderedChatMessage { + role: role.unwrap_or(&default_role).to_string(), + parts, + }); + } } } diff --git a/engine/baml-runtime/src/internal/llm_client/traits/mod.rs b/engine/baml-runtime/src/internal/llm_client/traits/mod.rs index cf8ed30bd..cb07775ef 100644 --- a/engine/baml-runtime/src/internal/llm_client/traits/mod.rs +++ b/engine/baml-runtime/src/internal/llm_client/traits/mod.rs @@ -324,7 +324,7 @@ fn to_curl_command( let mut curl_command = format!("curl -X {} '{}'", method, url); for (key, value) in headers.iter() { - let header = format!(" -H '{}: {}'", key.as_str(), value.to_str().unwrap()); + let header = format!(" -H \"{}: {}\"", key.as_str(), value.to_str().unwrap()); curl_command.push_str(&header); } diff --git a/engine/baml-runtime/src/types/context_manager.rs b/engine/baml-runtime/src/types/context_manager.rs index 1e65775da..93a1e7b95 100644 --- a/engine/baml-runtime/src/types/context_manager.rs +++ b/engine/baml-runtime/src/types/context_manager.rs @@ -129,7 +129,7 @@ impl RuntimeContextManager { let ctx = self.context.lock().unwrap(); let env_vars = env_vars - .map(|x| (x.as_ref().to_string(), "".to_string())) + .map(|x| (x.as_ref().to_string(), format!("${{{}}}", x.as_ref()))) .chain(self.env_vars.iter().map(|(k, v)| (k.clone(), v.clone()))); RuntimeContext { From a7032e6048bd98b9d02edd6579ebfd486cfe53ce Mon Sep 17 00:00:00 2001 From: Anish Palakurthi Date: Fri, 28 Jun 2024 16:53:10 -0700 Subject: [PATCH 3/9] port handling uses callback rather than timeout --- .../src/baml_wasm_web/EventListener.tsx | 48 +++++- .../packages/vscode/src/extension.ts | 151 +++++++++--------- .../vscode/src/panels/WebPanelView.ts | 15 +- 3 files changed, 128 insertions(+), 86 deletions(-) diff --git a/typescript/playground-common/src/baml_wasm_web/EventListener.tsx b/typescript/playground-common/src/baml_wasm_web/EventListener.tsx index 07b4af994..d6b3a23b8 100644 --- a/typescript/playground-common/src/baml_wasm_web/EventListener.tsx +++ b/typescript/playground-common/src/baml_wasm_web/EventListener.tsx @@ -8,14 +8,27 @@ import { AlertTriangle, CheckCircle, XCircle } from 'lucide-react' import { useCallback, useEffect } from 'react' import CustomErrorBoundary from '../utils/ErrorFallback' import { sessionStore, vscodeLocalStorageStore } from './JotaiProvider' -import { availableProjectsAtom, projectFamilyAtom, projectFilesAtom, runtimeFamilyAtom } from './baseAtoms' +import { + availableProjectsAtom, + projectFamilyAtom, + projectFilesAtom, + runtimeFamilyAtom, + // portReadyAtom, +} from './baseAtoms' import type { WasmDiagnosticError, WasmParam, WasmRuntime } from '@gloo-ai/baml-schema-wasm-web/baml_schema_build' // const wasm = await import("@gloo-ai/baml-schema-wasm-web/baml_schema_build"); // const { WasmProject, WasmRuntime, WasmRuntimeContext, version: RuntimeVersion } = wasm; +const postMessageToExtension = (message: any) => { + const vscode = acquireVsCodeApi() + console.log(`Sending message to extension ${message}`) + vscode.postMessage(message) +} + const defaultEnvKeyValues: [string, string][] = (() => { if ((window as any).next?.version) { console.log('Running in nextjs') + const domain = window?.location?.origin || '' if (domain.includes('localhost')) { // we can do somehting fancier here later if we want to test locally. @@ -23,6 +36,7 @@ const defaultEnvKeyValues: [string, string][] = (() => { } return [['BOUNDARY_PROXY_URL', 'https://fiddle-proxy.fly.dev']] } else { + postMessageToExtension({ command: 'get_port' }) console.log('Not running in a Next.js environment, set default value') // Not running in a Next.js environment, set default value return [['BOUNDARY_PROXY_URL', 'http://localhost:0000']] @@ -121,8 +135,6 @@ export const selectedFunctionAtom = atom( const functions = get(availableFunctionsAtom) if (functions.find((f) => f.name === func)) { set(selectedFunctionStorageAtom, func) - } else { - // console.error(`Function ${func} not found in ${functions.map((f) => f.name).join(', ')}`) } } }, @@ -474,6 +486,29 @@ export const EventListener: React.FC<{ children: React.ReactNode }> = ({ childre const wasm = useAtomValue(wasmAtom) const setSelectedFunction = useSetAtom(selectedFunctionAtom) const envVars = useAtomValue(envVarsAtom) + // const [portReady, setPortReady] = useAtom(portReadyAtom) + + useEffect(() => { + setEnvKeyValueStorage((prev) => { + let [proxy_env_name, orig_value] = defaultEnvKeyValues[0] + let keyExists = false + const updated: [string, string][] = prev.map(([key, value]) => { + if (key === proxy_env_name) { + keyExists = true + return [key, orig_value] + } + return [key, value] + }) + + if (!keyExists) { + updated.push([proxy_env_name, orig_value]) + } + return updated + }) + // setPortReady(false) + // postMessageToExtension({ command: 'get_port' }) + // setPortReady(true) + }, []) const createRuntimeCb = useAtomCallback( useCallback( @@ -548,7 +583,6 @@ export const EventListener: React.FC<{ children: React.ReactNode }> = ({ childre >, ) => { const { command, content } = event.data - console.log('select Received message', command, content) switch (command) { case 'modify_file': @@ -581,6 +615,12 @@ export const EventListener: React.FC<{ children: React.ReactNode }> = ({ childre case 'port_number': console.log('Setting port number', content.port) + + if (content.port === 0) { + console.error('Port number is 0, not setting') + return + } + setEnvKeyValueStorage((prev) => { let keyExists = false const updated: [string, string][] = prev.map(([key, value]) => { diff --git a/typescript/vscode-ext/packages/vscode/src/extension.ts b/typescript/vscode-ext/packages/vscode/src/extension.ts index 9641a803f..63b42126d 100644 --- a/typescript/vscode-ext/packages/vscode/src/extension.ts +++ b/typescript/vscode-ext/packages/vscode/src/extension.ts @@ -5,8 +5,6 @@ import { WebPanelView } from './panels/WebPanelView' import plugins from './plugins' import { requestDiagnostics } from './plugins/language-server' import { telemetry } from './plugins/language-server' -import httpProxy from 'http-proxy' -import express from 'express' import cors from 'cors' import { createProxyMiddleware } from 'http-proxy-middleware' import { type LanguageClient, type ServerOptions, TransportKind } from 'vscode-languageclient/node' @@ -146,6 +144,8 @@ async function runDiagnostics(): Promise { statusBarItem.hide() } +import type { Express } from 'express' + export function activate(context: vscode.ExtensionContext) { console.log('BAML extension activating') @@ -164,12 +164,73 @@ export function activate(context: vscode.ExtensionContext) { context.subscriptions.push(codeActionProvider) + const app: Express = require('express')() + app.use(cors()) + var port = 123 + const server = app.listen(0, () => { + console.log('Server started on port ' + getPort()) + // WebPanelView.currentPanel?.postMessage('port_number', { + // port: port, + // }) + }) + + const getPort = () => { + let addr = server.address() + if (addr === null) { + return 0 + } + if (typeof addr === 'string') { + return parseInt(addr) + } + return addr.port + } + + app.use( + createProxyMiddleware({ + changeOrigin: true, + pathRewrite: (path, req) => { + // Ensure the URL does not end with a slash + if (path.endsWith('/')) { + return path.slice(0, -1) + } + return path + }, + router: (req) => { + // Extract the original target URL from the custom header + let originalUrl = req.headers['baml-original-url'] + if (typeof originalUrl === 'string') { + delete req.headers['baml-original-url'] + delete req.headers['baml-render-url'] + req.headers['origin'] = `http://localhost:${port}` + + // Ensure the URL does not end with a slash + if (originalUrl.endsWith('/')) { + originalUrl = originalUrl.slice(0, -1) + } + return originalUrl + } else { + throw new Error('baml-original-url header is missing or invalid') + } + }, + logger: console, + on: { + proxyRes: (proxyRes, req, res) => { + proxyRes.headers['Access-Control-Allow-Origin'] = '*' + }, + error: (error) => { + console.error('proxy error:', error) + }, + }, + }), + ) + const bamlPlaygroundCommand = vscode.commands.registerCommand( 'baml.openBamlPanel', (args?: { projectId?: string; functionName?: string; implName?: string; showTests?: boolean }) => { const config = vscode.workspace.getConfiguration() config.update('baml.bamlPanelOpen', true, vscode.ConfigurationTarget.Global) - WebPanelView.render(context.extensionUri) + + WebPanelView.render(context.extensionUri, getPort) if (telemetry) { telemetry.sendTelemetryEvent({ event: 'baml.openBamlPanel', @@ -183,29 +244,8 @@ export function activate(context: vscode.ExtensionContext) { root_path: 'default', function_name: args?.functionName ?? 'default', }) - // to account for some delays (this is a hack, sorry) - setTimeout(() => { - WebPanelView.currentPanel?.postMessage('select_function', { - root_path: 'default', - function_name: args?.functionName ?? 'default', - }) - WebPanelView.currentPanel?.postMessage('port_number', { - port: port, - }) - }, 200) - - // adding the select_function here causes glitches (cause it's way too delayed) - // for now lets resend only the port until we have a more reliable way to request this data. - setTimeout(() => { - WebPanelView.currentPanel?.postMessage('port_number', { - port: port, - }) - }, 1000) console.info('Opening BAML panel') - WebPanelView.currentPanel?.postMessage('port_number', { - port: port, - }) }, ) @@ -243,6 +283,14 @@ export function activate(context: vscode.ExtensionContext) { } }) + // Listen for messages from the webview + + if (!WebPanelView.currentPanel) { + console.warn('WebPanelView.currentPanel is not initialized') + } else { + console.log('WebPanelView.currentPanel is initialized') + } + plugins.map(async (plugin) => { const enabled = await plugin.enabled() if (enabled) { @@ -260,61 +308,6 @@ export function activate(context: vscode.ExtensionContext) { vscode.commands.executeCommand('baml.openBamlPanel') } - try { - const app = require('express')() - app.use(cors()) - var port: number - const server = app.listen(0, () => { - port = server.address().port - console.log('Server started on port ' + port) - WebPanelView.currentPanel?.postMessage('port_number', { - port: port, - }) - }) - - app.use( - createProxyMiddleware({ - changeOrigin: true, - pathRewrite: (path, req) => { - // Ensure the URL does not end with a slash - if (path.endsWith('/')) { - return path.slice(0, -1) - } - return path - }, - router: (req) => { - // Extract the original target URL from the custom header - let originalUrl = req.headers['baml-original-url'] - if (typeof originalUrl === 'string') { - delete req.headers['baml-original-url'] - delete req.headers['baml-render-url'] - req.headers['origin'] = `http://localhost:${port}` - - // Ensure the URL does not end with a slash - if (originalUrl.endsWith('/')) { - originalUrl = originalUrl.slice(0, -1) - } - return originalUrl - } else { - throw new Error('baml-original-url header is missing or invalid') - } - }, - logger: console, - on: { - proxyRes: (proxyRes, req, res) => { - proxyRes.headers['Access-Control-Allow-Origin'] = '*' - }, - error: (error) => { - console.error('proxy error:', error) - }, - }, - }), - ) - } catch (error) { - console.error('Failed to start proxy server:', error) - vscode.window.showErrorMessage('Failed to BAML localhost server. Contact support for help.') - } - // TODO: Reactivate linter. // runDiagnostics(); } diff --git a/typescript/vscode-ext/packages/vscode/src/panels/WebPanelView.ts b/typescript/vscode-ext/packages/vscode/src/panels/WebPanelView.ts index ebc549b31..a51ac67a3 100644 --- a/typescript/vscode-ext/packages/vscode/src/panels/WebPanelView.ts +++ b/typescript/vscode-ext/packages/vscode/src/panels/WebPanelView.ts @@ -27,6 +27,7 @@ export class WebPanelView { public static currentPanel: WebPanelView | undefined private readonly _panel: WebviewPanel private _disposables: Disposable[] = [] + private _port: () => number /** * The WebPanelView class private constructor (called only from the render method). @@ -34,8 +35,9 @@ export class WebPanelView { * @param panel A reference to the webview panel * @param extensionUri The URI of the directory containing the extension */ - private constructor(panel: WebviewPanel, extensionUri: Uri) { + private constructor(panel: WebviewPanel, extensionUri: Uri, portLoader: () => number) { this._panel = panel + this._port = portLoader // Set an event listener to listen for when the panel is disposed (i.e. when the user closes // the panel or when the panel is closed programmatically) @@ -54,7 +56,7 @@ export class WebPanelView { * * @param extensionUri The URI of the directory containing the extension. */ - public static render(extensionUri: Uri) { + public static render(extensionUri: Uri, portLoader: () => number) { if (WebPanelView.currentPanel) { // If the webview panel already exists reveal it WebPanelView.currentPanel._panel.reveal(ViewColumn.Beside) @@ -81,7 +83,7 @@ export class WebPanelView { }, ) - WebPanelView.currentPanel = new WebPanelView(panel, extensionUri) + WebPanelView.currentPanel = new WebPanelView(panel, extensionUri, portLoader) } } @@ -161,6 +163,13 @@ export class WebPanelView { const text = message.text switch (command) { + case 'get_port': + // Code that should run in response to the hello message command + console.log(`Sending port from WebPanelView: ${this._port()}`) + this.postMessage('port_number', { + port: this._port(), + }) + return case 'receiveData': // Code that should run in response to the hello message command window.showInformationMessage(text) From 7ddbe98d83c5d2b3eb1da2d3500d07d7c558e001 Mon Sep 17 00:00:00 2001 From: Anish Palakurthi Date: Fri, 28 Jun 2024 17:03:19 -0700 Subject: [PATCH 4/9] added banner --- .../playground-common/src/baml_wasm_web/EventListener.tsx | 1 + typescript/vscode-ext/packages/vscode/src/extension.ts | 3 ++- .../vscode-ext/packages/vscode/src/panels/WebPanelView.ts | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/typescript/playground-common/src/baml_wasm_web/EventListener.tsx b/typescript/playground-common/src/baml_wasm_web/EventListener.tsx index d6b3a23b8..84a10cf2f 100644 --- a/typescript/playground-common/src/baml_wasm_web/EventListener.tsx +++ b/typescript/playground-common/src/baml_wasm_web/EventListener.tsx @@ -618,6 +618,7 @@ export const EventListener: React.FC<{ children: React.ReactNode }> = ({ childre if (content.port === 0) { console.error('Port number is 0, not setting') + return } diff --git a/typescript/vscode-ext/packages/vscode/src/extension.ts b/typescript/vscode-ext/packages/vscode/src/extension.ts index 63b42126d..31c54756e 100644 --- a/typescript/vscode-ext/packages/vscode/src/extension.ts +++ b/typescript/vscode-ext/packages/vscode/src/extension.ts @@ -166,7 +166,7 @@ export function activate(context: vscode.ExtensionContext) { const app: Express = require('express')() app.use(cors()) - var port = 123 + var port: number const server = app.listen(0, () => { console.log('Server started on port ' + getPort()) // WebPanelView.currentPanel?.postMessage('port_number', { @@ -177,6 +177,7 @@ export function activate(context: vscode.ExtensionContext) { const getPort = () => { let addr = server.address() if (addr === null) { + vscode.window.showErrorMessage('Failed to start server. Please try reloading the window, or restarting VSCode.') return 0 } if (typeof addr === 'string') { diff --git a/typescript/vscode-ext/packages/vscode/src/panels/WebPanelView.ts b/typescript/vscode-ext/packages/vscode/src/panels/WebPanelView.ts index a51ac67a3..af6b41603 100644 --- a/typescript/vscode-ext/packages/vscode/src/panels/WebPanelView.ts +++ b/typescript/vscode-ext/packages/vscode/src/panels/WebPanelView.ts @@ -170,6 +170,10 @@ export class WebPanelView { port: this._port(), }) return + + case 'show_port_error': + vscode.window.showErrorMessage('Failed to run diagnostics') + return case 'receiveData': // Code that should run in response to the hello message command window.showInformationMessage(text) From 51e215281f277756c37fc366f738191988298dd8 Mon Sep 17 00:00:00 2001 From: Anish Palakurthi Date: Fri, 28 Jun 2024 17:18:53 -0700 Subject: [PATCH 5/9] ports all stable --- .../src/baml_wasm_web/EventListener.tsx | 33 ++----------------- .../packages/vscode/src/extension.ts | 4 ++- 2 files changed, 5 insertions(+), 32 deletions(-) diff --git a/typescript/playground-common/src/baml_wasm_web/EventListener.tsx b/typescript/playground-common/src/baml_wasm_web/EventListener.tsx index 84a10cf2f..b71600c58 100644 --- a/typescript/playground-common/src/baml_wasm_web/EventListener.tsx +++ b/typescript/playground-common/src/baml_wasm_web/EventListener.tsx @@ -8,13 +8,7 @@ import { AlertTriangle, CheckCircle, XCircle } from 'lucide-react' import { useCallback, useEffect } from 'react' import CustomErrorBoundary from '../utils/ErrorFallback' import { sessionStore, vscodeLocalStorageStore } from './JotaiProvider' -import { - availableProjectsAtom, - projectFamilyAtom, - projectFilesAtom, - runtimeFamilyAtom, - // portReadyAtom, -} from './baseAtoms' +import { availableProjectsAtom, projectFamilyAtom, projectFilesAtom, runtimeFamilyAtom } from './baseAtoms' import type { WasmDiagnosticError, WasmParam, WasmRuntime } from '@gloo-ai/baml-schema-wasm-web/baml_schema_build' // const wasm = await import("@gloo-ai/baml-schema-wasm-web/baml_schema_build"); @@ -486,29 +480,6 @@ export const EventListener: React.FC<{ children: React.ReactNode }> = ({ childre const wasm = useAtomValue(wasmAtom) const setSelectedFunction = useSetAtom(selectedFunctionAtom) const envVars = useAtomValue(envVarsAtom) - // const [portReady, setPortReady] = useAtom(portReadyAtom) - - useEffect(() => { - setEnvKeyValueStorage((prev) => { - let [proxy_env_name, orig_value] = defaultEnvKeyValues[0] - let keyExists = false - const updated: [string, string][] = prev.map(([key, value]) => { - if (key === proxy_env_name) { - keyExists = true - return [key, orig_value] - } - return [key, value] - }) - - if (!keyExists) { - updated.push([proxy_env_name, orig_value]) - } - return updated - }) - // setPortReady(false) - // postMessageToExtension({ command: 'get_port' }) - // setPortReady(true) - }, []) const createRuntimeCb = useAtomCallback( useCallback( @@ -617,7 +588,7 @@ export const EventListener: React.FC<{ children: React.ReactNode }> = ({ childre console.log('Setting port number', content.port) if (content.port === 0) { - console.error('Port number is 0, not setting') + console.error('Port number is 0, cannot launch BAML extension') return } diff --git a/typescript/vscode-ext/packages/vscode/src/extension.ts b/typescript/vscode-ext/packages/vscode/src/extension.ts index 31c54756e..778c0e6e0 100644 --- a/typescript/vscode-ext/packages/vscode/src/extension.ts +++ b/typescript/vscode-ext/packages/vscode/src/extension.ts @@ -177,7 +177,9 @@ export function activate(context: vscode.ExtensionContext) { const getPort = () => { let addr = server.address() if (addr === null) { - vscode.window.showErrorMessage('Failed to start server. Please try reloading the window, or restarting VSCode.') + vscode.window.showErrorMessage( + 'Failed to start BAML extension server. Please try reloading the window, or restarting VSCode.', + ) return 0 } if (typeof addr === 'string') { From c3171ff7a6453278682a5a45380f6e016ee1a833 Mon Sep 17 00:00:00 2001 From: Anish Palakurthi Date: Fri, 28 Jun 2024 18:30:59 -0700 Subject: [PATCH 6/9] fixed requesting --- .../playground-common/src/baml_wasm_web/EventListener.tsx | 6 ++++-- .../vscode-ext/packages/vscode/src/panels/WebPanelView.ts | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/typescript/playground-common/src/baml_wasm_web/EventListener.tsx b/typescript/playground-common/src/baml_wasm_web/EventListener.tsx index b71600c58..6fed34adb 100644 --- a/typescript/playground-common/src/baml_wasm_web/EventListener.tsx +++ b/typescript/playground-common/src/baml_wasm_web/EventListener.tsx @@ -10,12 +10,12 @@ import CustomErrorBoundary from '../utils/ErrorFallback' import { sessionStore, vscodeLocalStorageStore } from './JotaiProvider' import { availableProjectsAtom, projectFamilyAtom, projectFilesAtom, runtimeFamilyAtom } from './baseAtoms' import type { WasmDiagnosticError, WasmParam, WasmRuntime } from '@gloo-ai/baml-schema-wasm-web/baml_schema_build' +const vscode = acquireVsCodeApi() // const wasm = await import("@gloo-ai/baml-schema-wasm-web/baml_schema_build"); // const { WasmProject, WasmRuntime, WasmRuntimeContext, version: RuntimeVersion } = wasm; const postMessageToExtension = (message: any) => { - const vscode = acquireVsCodeApi() - console.log(`Sending message to extension ${message}`) + console.log(`Sending message to extension ${message.command}`) vscode.postMessage(message) } @@ -31,6 +31,8 @@ const defaultEnvKeyValues: [string, string][] = (() => { return [['BOUNDARY_PROXY_URL', 'https://fiddle-proxy.fly.dev']] } else { postMessageToExtension({ command: 'get_port' }) + postMessageToExtension({ command: 'add_project' }) + console.log('Not running in a Next.js environment, set default value') // Not running in a Next.js environment, set default value return [['BOUNDARY_PROXY_URL', 'http://localhost:0000']] diff --git a/typescript/vscode-ext/packages/vscode/src/panels/WebPanelView.ts b/typescript/vscode-ext/packages/vscode/src/panels/WebPanelView.ts index af6b41603..f7b9d0ad9 100644 --- a/typescript/vscode-ext/packages/vscode/src/panels/WebPanelView.ts +++ b/typescript/vscode-ext/packages/vscode/src/panels/WebPanelView.ts @@ -6,6 +6,7 @@ import { getUri } from '../utils/getUri' import { type Config, adjectives, animals, colors, uniqueNamesGenerator } from 'unique-names-generator' import { URI } from 'vscode-uri' +import { requestDiagnostics } from '../plugins/language-server' const customConfig: Config = { dictionaries: [adjectives, colors, animals], @@ -171,9 +172,8 @@ export class WebPanelView { }) return - case 'show_port_error': - vscode.window.showErrorMessage('Failed to run diagnostics') - return + case 'add_project': + requestDiagnostics() case 'receiveData': // Code that should run in response to the hello message command window.showInformationMessage(text) From 11e0e9303b44e35e43c93d2a580b6108f9c9f6c2 Mon Sep 17 00:00:00 2001 From: Anish Palakurthi Date: Fri, 28 Jun 2024 18:37:38 -0700 Subject: [PATCH 7/9] added basic port sending, debug console may error on this but no consequence --- typescript/vscode-ext/packages/vscode/src/extension.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/typescript/vscode-ext/packages/vscode/src/extension.ts b/typescript/vscode-ext/packages/vscode/src/extension.ts index 778c0e6e0..88c08a029 100644 --- a/typescript/vscode-ext/packages/vscode/src/extension.ts +++ b/typescript/vscode-ext/packages/vscode/src/extension.ts @@ -169,9 +169,9 @@ export function activate(context: vscode.ExtensionContext) { var port: number const server = app.listen(0, () => { console.log('Server started on port ' + getPort()) - // WebPanelView.currentPanel?.postMessage('port_number', { - // port: port, - // }) + WebPanelView.currentPanel?.postMessage('port_number', { + port: port, + }) }) const getPort = () => { From c736193a1bea071483e2042e13a7e8da9f13b331 Mon Sep 17 00:00:00 2001 From: Anish Palakurthi Date: Fri, 28 Jun 2024 18:38:36 -0700 Subject: [PATCH 8/9] removed log --- typescript/vscode-ext/packages/vscode/src/extension.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/typescript/vscode-ext/packages/vscode/src/extension.ts b/typescript/vscode-ext/packages/vscode/src/extension.ts index 88c08a029..51640909f 100644 --- a/typescript/vscode-ext/packages/vscode/src/extension.ts +++ b/typescript/vscode-ext/packages/vscode/src/extension.ts @@ -288,12 +288,6 @@ export function activate(context: vscode.ExtensionContext) { // Listen for messages from the webview - if (!WebPanelView.currentPanel) { - console.warn('WebPanelView.currentPanel is not initialized') - } else { - console.log('WebPanelView.currentPanel is initialized') - } - plugins.map(async (plugin) => { const enabled = await plugin.enabled() if (enabled) { From e90140b0e80876fc5615909dd68d65b5a441c02d Mon Sep 17 00:00:00 2001 From: hellovai Date: Sat, 29 Jun 2024 00:59:46 -0700 Subject: [PATCH 9/9] Update WebPanelView.ts --- typescript/vscode-ext/packages/vscode/src/panels/WebPanelView.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/typescript/vscode-ext/packages/vscode/src/panels/WebPanelView.ts b/typescript/vscode-ext/packages/vscode/src/panels/WebPanelView.ts index f7b9d0ad9..e6673dff6 100644 --- a/typescript/vscode-ext/packages/vscode/src/panels/WebPanelView.ts +++ b/typescript/vscode-ext/packages/vscode/src/panels/WebPanelView.ts @@ -174,6 +174,7 @@ export class WebPanelView { case 'add_project': requestDiagnostics() + return case 'receiveData': // Code that should run in response to the hello message command window.showInformationMessage(text)