From 916154499c0347087427813bd4f3746326c831f4 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Wed, 9 Apr 2025 19:58:41 +0900 Subject: [PATCH] Some updates --- .../WelsonJS.Launcher/MainForm.cs | 5 +--- WelsonJS.Toolkit/WelsonJS.Launcher/Program.cs | 13 +++++++-- .../ResourceTools/AzureAi.cs | 29 +++++++++++++++++++ .../WelsonJS.Launcher.csproj | 2 +- .../WelsonJS.Launcher/editor.html | 25 ++++++---------- 5 files changed, 51 insertions(+), 23 deletions(-) create mode 100644 WelsonJS.Toolkit/WelsonJS.Launcher/ResourceTools/AzureAi.cs diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/MainForm.cs b/WelsonJS.Toolkit/WelsonJS.Launcher/MainForm.cs index 11e21e5..dcb3ce2 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/MainForm.cs +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/MainForm.cs @@ -242,10 +242,7 @@ namespace WelsonJS.Launcher private void startCodeEditorToolStripMenuItem_Click(object sender, EventArgs e) { - if (Program.resourceServer == null) - { - Program.resourceServer = new ResourceServer(Program.GetAppConfig("ResourceServerPrefix"), "editor.html"); - } + Program.StartResourceServer(); if (!Program.resourceServer.IsRunning()) { diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/Program.cs b/WelsonJS.Toolkit/WelsonJS.Launcher/Program.cs index aebad66..f7abf6b 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/Program.cs +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/Program.cs @@ -138,13 +138,22 @@ namespace WelsonJS.Launcher return workingDirectory; } + public static void StartResourceServer() + { + if (resourceServer == null) + { + resourceServer = new ResourceServer(GetAppConfig("ResourceServerPrefix"), "editor.html"); + } + } + public static void OpenWebBrowser(string url) { string userDataDir = Path.Combine(GetAppDataPath(), "EdgeUserProfile"); - string remoteAllowOrigins = "http://localhost:3000"; + string remoteAllowOrigins = GetAppConfig("ResourceServerPrefix"); + int remoteDebuggingPort = new Uri(GetAppConfig("DevToolsPrefix")).Port; string[] arguments = { $"\"{url}\"", - "--remote-debugging-port=9222", + $"--remote-debugging-port={remoteDebuggingPort}", $"--remote-allow-origins={remoteAllowOrigins}", // for security reason $"--user-data-dir=\"{userDataDir}\"" }; diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/ResourceTools/AzureAi.cs b/WelsonJS.Toolkit/WelsonJS.Launcher/ResourceTools/AzureAi.cs new file mode 100644 index 0000000..34440a4 --- /dev/null +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/ResourceTools/AzureAi.cs @@ -0,0 +1,29 @@ +using System; +using System.Net; +using System.Threading.Tasks; + +namespace WelsonJS.Launcher.ResourceTools +{ + public class AzureAi : IResourceTool + { + private ResourceServer Server; + private const string Prefix = "azure-ai/"; + + public AzureAi(ResourceServer server) + { + Server = server; + } + + public bool CanHandle(string path) + { + return path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); + } + + public async Task HandleAsync(HttpListenerContext context, string path) + { + await Task.Delay(0); + + // TODO: Pass Azure AI request to Azure AI Foundry + } + } +} \ No newline at end of file diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/WelsonJS.Launcher.csproj b/WelsonJS.Toolkit/WelsonJS.Launcher/WelsonJS.Launcher.csproj index df1cc5c..731acee 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/WelsonJS.Launcher.csproj +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/WelsonJS.Launcher.csproj @@ -74,6 +74,7 @@ + @@ -165,6 +166,5 @@ - \ No newline at end of file diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/editor.html b/WelsonJS.Toolkit/WelsonJS.Launcher/editor.html index 53a1b50..3e49309 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/editor.html +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/editor.html @@ -50,16 +50,14 @@ Save File - - - - Common + Generative
- - Network tools + Network
@@ -240,18 +237,14 @@ document.body.removeChild(a); }; - document.getElementById("btnSponsor").onclick = function () { - navigate('https://github.com/sponsors/gnh1201'); - }; - - document.getElementById("btnGenerate").onclick = function () { + document.getElementById("btnCopilot").onclick = function () { const promptMessage = prompt("Enter a prompt message:", ''); if (!promptMessage || promptMessage.trim() == '') { alert("A prompt message is required."); return; } - appendTextToEditor(`\n//${promptMessage}... Thinking with Generative AI...`); + appendTextToEditor(`\n//${promptMessage}... Generating text with Copilot...`); (async function () { const targetWsUrl = await getTargetByUrl('copilot.microsoft.com');