From aceeb72a6b6bd01ccc7a8a9b887ecadc11f2ce62 Mon Sep 17 00:00:00 2001 From: iURi <151236693+Cheewye@users.noreply.github.com> Date: Mon, 29 Sep 2025 04:45:04 -0300 Subject: [PATCH 1/4] =?UTF-8?q?feat(memory):=20UI=20Memoria=20+=20servicio?= =?UTF-8?q?s=20fishermen/memory=20e=20integraci=C3=B3n=20en=20App;=20fix?= =?UTF-8?q?=20deploy.yml=20(#2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 31 ++++++++ src/App.tsx | 25 ++++++ src/components/MemoryConsole.tsx | 132 +++++++++++++++++++++++++++++++ src/services/fishermen.ts | 44 +++++++++++ src/services/memory.ts | 34 ++++++++ 5 files changed, 266 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 src/App.tsx create mode 100644 src/components/MemoryConsole.tsx create mode 100644 src/services/fishermen.ts create mode 100644 src/services/memory.ts diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 000000000..b3b554d4e --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,31 @@ +name: Deploy +on: + push: + branches: [ main ] + +jobs: + deploy: + runs-on: ubuntu-latest + environment: production + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20.11' + cache: 'npm' + - name: Build + run: npm ci && npm run build + + - name: Add SSH key + uses: webfactory/ssh-agent@v0.9.0 + with: + ssh-private-key: | + ${{ secrets.SSH_PRIVATE_KEY }} + + - name: Sync dist to server & reload nginx + env: + SSH_HOST: ${{ secrets.SSH_HOST }} + SSH_USER: ${{ secrets.SSH_USER }} + SSH_PATH: ${{ secrets.SSH_PATH }} + run: | + bash scripts/deploy.sh diff --git a/src/App.tsx b/src/App.tsx new file mode 100644 index 000000000..ab3adeb3a --- /dev/null +++ b/src/App.tsx @@ -0,0 +1,25 @@ +import React, { useState } from 'react' +import MemoryConsole from './components/MemoryConsole' + +function App() { + const [view, setView] = useState<'home'|'memory'>('home') + return ( +
+
+

iURi React App

+
+ + +
+
+ {view==='home' && ( +

Build limpio y verificable

+ )} + {view==='memory' && ( + + )} +
+ ) +} + +export default App diff --git a/src/components/MemoryConsole.tsx b/src/components/MemoryConsole.tsx new file mode 100644 index 000000000..074741792 --- /dev/null +++ b/src/components/MemoryConsole.tsx @@ -0,0 +1,132 @@ +import React, { useEffect, useMemo, useState } from 'react'; +import { appendEntry, fetchEntries, fetchStats, type MemoryEntry } from '../services/memory'; + +export default function MemoryConsole() { + const [query, setQuery] = useState(''); + const [limit, setLimit] = useState(100); + const [loading, setLoading] = useState(false); + const [entries, setEntries] = useState([]); + const [stats, setStats] = useState | null>(null); + const [text, setText] = useState(''); + const [tags, setTags] = useState(''); + const [error, setError] = useState(null); + + const parsedTags = useMemo(() => ( + tags + .split(',') + .map(s => s.trim()) + .filter(Boolean) + ), [tags]); + + async function load() { + setLoading(true); + setError(null); + try { + const [e, s] = await Promise.all([ + fetchEntries(query, limit), + fetchStats().catch(() => null), + ]); + setEntries(e); + setStats(s as Record | null); + } catch (err: any) { + setError(err?.message ?? 'Error cargando memoria'); + } finally { + setLoading(false); + } + } + + async function onAppend() { + if (!text.trim()) return; + setLoading(true); + setError(null); + try { + await appendEntry(text.trim(), parsedTags); + setText(''); + setTags(''); + await load(); + } catch (err: any) { + setError(err?.message ?? 'Error agregando entrada'); + } finally { + setLoading(false); + } + } + + useEffect(() => { + load(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + return ( +
+

🧠 Memoria iURi

+ +
+
+

Agregar nota

+