From b42eae810af329a558e803b108aacb83938eeec0 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Thu, 24 Sep 2026 11:27:55 +0200 Subject: [PATCH] =?UTF-8?q?chore:=20remove=20connectivity=20probe=20(examp?= =?UTF-8?q?le.com)=20=E2=80=94=20internet=20access=20now=20via=20CORS=20pr?= =?UTF-8?q?oxy;=20drop=20example.com=20from=20proxy=20allowlist;=20bump=20?= =?UTF-8?q?0.1.20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/main.ts | 18 +----------------- src/ui.tsx | 12 ++---------- 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index 02d444a..705808d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "figma-ai-plugin", - "version": "0.1.19", + "version": "0.1.20", "private": true, "dependencies": { "@create-figma-plugin/ui": "^4.0.3", diff --git a/src/main.ts b/src/main.ts index f525190..234b7f8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,23 +3,12 @@ import { emit, on, showUI } from '@create-figma-plugin/utilities' // CORS proxy (dev). Figma plugin has origin:null, so direct calls to APIs without // Access-Control-Allow-Origin fail. Route external requests through this proxy, which // adds `Access-Control-Allow-Origin: *`. Target host must be in the proxy allowlist -// (api.apinex.bond, apinex.bond, example.com) — no token needed for those. +// (api.apinex.bond, apinex.bond) — no token needed for those. const CORS_PROXY = 'https://ai-assistant-fig.dynv6.net/proxy' function viaProxy (target: string): string { return CORS_PROXY + '?url=' + encodeURIComponent(target) } -// Probe whether the plugin sandbox can reach the public internet. -// Used on plugin open (so the user sees network status immediately) and before each model fetch. -async function probeConnectivity () { - try { - const pr = await fetch(viaProxy('https://example.com')) - emit('PROBE_RESULT', { msg: 'example.com reachable · status=' + pr.status }) - } catch (pe) { - emit('PROBE_RESULT', { msg: 'example.com UNREACHABLE · ' + (pe != null ? (typeof pe === 'string' ? pe : JSON.stringify(pe)) : 'unknown') }) - } -} - export default function () { // Глобальный ярлык relaunch в правой панели Figma (команда runAI из manifest.json) figma.root.setRelaunchData({ runAI: '' }) @@ -531,8 +520,6 @@ export default function () { emit('MODELS_RESULT', { ok: false, error: 'fetch is not available in the plugin main thread', models: [], status: 0, requestEcho: echo }) return } - // Diagnostic: can the sandbox reach the public internet at all? - await probeConnectivity() const base = String(payload.baseUrl == null ? '' : payload.baseUrl) .replace(/`/g, '') // drop stray markdown backticks .replace(/^@url:\s*/i, '') // drop '@url:' annotation if pasted from chat @@ -586,9 +573,6 @@ export default function () { showUI({ width: 380, height: 480, themeColors: true, title: 'AI assistant (MVP)' }) - // On open, proactively probe connectivity so the user sees network status without clicking Fetch. - setTimeout(function () { probeConnectivity() }, 600) - // Restore persisted window placement (saved in clientStorage on the Figma file). // Default when nothing is stored: behave like the Center button (50% viewport, centered). try { diff --git a/src/ui.tsx b/src/ui.tsx index f8c0610..ac4c051 100644 --- a/src/ui.tsx +++ b/src/ui.tsx @@ -30,7 +30,7 @@ const MIN_WINDOW_SIZE = { width: 320, height: 200 } // very high — actual clamp is done by main via clampWindowSize (bounds*zoom). // Full plugin version shown in the footer status bar. Keep in sync with package.json "version". -const PLUGIN_VERSION = '0.1.19' +const PLUGIN_VERSION = '0.1.20' const fieldStyle = { display: 'flex', @@ -137,14 +137,6 @@ function SettingsPanel (props: { settings: Settings, setSettings: (s: Settings) return dispose }, []) - useEffect(function () { - const dispose = on('PROBE_RESULT', function (p: { msg: string }) { - setFetching(false) - logEvent('PROBE: ' + p.msg) - }) - return dispose - }, []) - function patch (p: Partial) { if (provider == null) return setSettings({ @@ -608,7 +600,7 @@ function Plugin () { ? : Loading…} - {/* Live log — shows the actual request flow (PROBE / FETCH / RESULT) from main.ts */} + {/* Live log — shows the actual request flow (FETCH / RESULT) from main.ts */}
Request log {log.length === 0