From 1d1ca9a1b4e0eb35631472cfd2ccde60d9aaa696 Mon Sep 17 00:00:00 2001 From: Aarush-wadhia Date: Thu, 5 Sep 2024 13:05:03 +0530 Subject: [PATCH] fix(Marketplace): changed github author name in marketplace listing --- vscode/media/market-place/market-place.js | 28 ++++++++++++++++++---- vscode/src/providers/chat_view_provider.ts | 1 - 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/vscode/media/market-place/market-place.js b/vscode/media/market-place/market-place.js index c0c3963..c22dc7e 100644 --- a/vscode/media/market-place/market-place.js +++ b/vscode/media/market-place/market-place.js @@ -3,6 +3,11 @@ const userIcon = `; +const githubIcon = + ` + + `; + const downloadIcon = ` @@ -86,6 +91,21 @@ function parseAgents(agents) { return { agents: {}, agentsList: [] }; } +const formatGithubUrl = (url) => { + const urlObj = new URL(url); + const paths = urlObj.pathname.split("/").filter(Boolean); + const [author, repo] = paths.slice(-2); + return { author, repo }; +}; + +function formatText(url, maxLength) { + const { author, repo } = formatGithubUrl(url); + const formattedText = `${author}/${repo}`; + return formattedText.length > maxLength + ? formattedText.slice(0, maxLength) + "..." + : formattedText; +} + function renderAgentsList(_agents) { _agents.forEach(agent => { // Create li element @@ -157,12 +177,12 @@ function renderAgentsList(_agents) { divRowInner.className = "inline-flex flex-row"; const spanAuthor = document.createElement("span"); - spanAuthor.className = "text-xs text-gray-400 px-1 border-b border-gray-500"; - spanAuthor.innerHTML = `${agent.author.github_id}`; + spanAuthor.className = "text-xs text-gray-400 px-1 border-b border-gray-500 ml-1"; + spanAuthor.innerHTML = `${formatText(agent.author.source_url, 20)}`; const divAuthor = document.createElement("div"); divAuthor.className = "inline-flex flex-row items-center w-full justify-between"; - divAuthor.innerHTML = userIcon; + divAuthor.innerHTML = githubIcon; divAuthor.appendChild(spanAuthor); divRowInner.appendChild(divAuthor); @@ -201,7 +221,7 @@ function loadOnErrorImage(agentImage) { agentImage.remove(); const svgContainer = document.createElement("div"); - svgContainer.innerHTML = userIcon; + svgContainer.innerHTML = githubIcon; agentImage.parentElement.appendChild(svgContainer); } diff --git a/vscode/src/providers/chat_view_provider.ts b/vscode/src/providers/chat_view_provider.ts index 4cdf956..b2f2133 100644 --- a/vscode/src/providers/chat_view_provider.ts +++ b/vscode/src/providers/chat_view_provider.ts @@ -171,7 +171,6 @@ export class FlutterGPTViewProvider implements vscode.WebviewViewProvider { }); this._fetchAgentsAPI(true); this._migrateAgentsStorage(); - this.setupManager.deleteGithub(); // StorageManager.instance.deleteAgents(); webviewView.onDidChangeVisibility(() => {