Commit Graph

163 Commits

Author SHA1 Message Date
9779dd7a79 fix: refresh agents on tab focus + hide stale nextRun + add cron logging
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 42s
- Add visibilitychange listener: refreshes agent data immediately when
  user returns to the tab (more reliable than interval-only polling)
- Only show toast for actions created within last 5 minutes to avoid
  false positives on page reload
- Hide "Prochaine exécution" line entirely if nextRun is in the past
  instead of showing confusing "En attente de déclenchement"
- Add detailed logging to cron endpoint for debugging

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 13:16:32 +02:00
f0999263a0 fix: remove nextRun recalculation from getAgents() that blocked cron
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 42s
The getAgents() function was recalculating nextRun to future dates when
it found past values. This prevented the cron scheduler from ever
finding due agents (nextRun <= now was always false since getAgents
had already pushed it to the future).

Also fix toast polling: use null sentinel for agents without initial
actions so first execution is still detected. Limit cron to 3 agents
per cycle and add logging.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 13:00:55 +02:00
1b4c6123c2 fix: use node http for cron scheduler + add toast notifications
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 40s
- Replace wget with node http.request in entrypoint (guaranteed
  available, better error handling)
- Add 30s polling in agents page to detect new agent executions
- Show toast notification when an agent finishes (success or failure)
- Add logging in scheduler for visibility in docker logs

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 12:39:09 +02:00
17e4a58da2 feat: auto-trigger scheduled agents + fix stale nextRun display
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 41s
- Add background scheduler in entrypoint: calls /api/cron/agents every
  5 minutes to trigger due agents automatically
- Recalculate stale nextRun (past dates) in getAgents() so the display
  always shows a future time
- Agent card shows "En attente de déclenchement" instead of "il y a X"
  when nextRun is in the past

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 12:28:38 +02:00
5d960cad4e fix: correct month/day swap in schedule time calculation
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 41s
The en-US Intl format is MM/DD/YYYY but the regex parsing was assigning
capture group 1 (month) to day and capture group 2 (day) to month.
For day 26+ this created an invalid month value (26), causing
RangeError: Invalid time value when formatting the date.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 12:12:09 +02:00
950f024aa9 fix: add new migration to ensure agent schedule columns exist
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 1m3s
Previous migration (20260426130000) may be recorded as failed in
_prisma_migrations after a db push conflict. This new migration with
a different timestamp will be seen as pending and applied with
idempotent SQL that handles both cases.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 11:51:43 +02:00
9e9e17ed96 fix: make agent schedule migration idempotent for production
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 1m1s
Use DO blocks with EXCEPTION WHEN duplicate_column to safely handle
columns that may already exist from a previous db push.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 11:35:50 +02:00
102ccd13d4 fix: revert entrypoint to migrate deploy, add proper migration file
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 1m1s
Create migration 20260426130000_add_agent_schedule_fields with the 3 new
Agent columns (scheduledTime, scheduledDay, timezone). Reverts entrypoint
back to prisma migrate deploy. Removes redundant migration step from
deploy.yaml.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 11:12:23 +02:00
434bb3ad71 fix: use prisma db push in entrypoint instead of migrate deploy
Some checks failed
Deploy to Production / Build and Deploy (push) Has been cancelled
The app uses db push (no migration files), so migrate deploy was a no-op.
Also removes the redundant migration step from deploy.yaml since the
entrypoint now handles schema sync on every container start.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 11:06:07 +02:00
88d7bc8b24 ci: add automatic prisma db push to deploy pipeline
Some checks failed
Deploy to Production / Build and Deploy (push) Has been cancelled
Run database migration after build and before container startup
so schema changes are always applied before the app goes live.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 10:53:31 +02:00
73de1cd26d feat: implement agent scheduled execution with cron and time picker
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 1m9s
- Add scheduledTime, scheduledDay, timezone fields to Agent schema
- Create calculateNextRun() helper with timezone-aware scheduling
- Add POST /api/cron/agents endpoint for external scheduler
- Calculate nextRun on agent create, update, and after execution
- Add time/day picker in agent form (daily/weekly/monthly)
- Show "Next run" countdown in agent card
- Add i18n keys for schedule UI (FR + EN)

External scheduler (N8N, Vercel Cron) should call /api/cron/agents
every 5-15 min. Requires `prisma db push` to apply schema changes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 10:45:48 +02:00
dc18dc3de4 fix: exclude trashed notes from notebook counts + wire up trash restore/delete
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 39s
- Add trashedAt: null filter to notebook note count queries in /api/notebooks
- Pass isTrashView, onRestore, onPermanentDelete from NoteCard to NoteActions
- Implement handleRestore and handlePermanentDelete in NoteCard

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 10:04:06 +02:00
e83f1d1e52 fix: sync sidebar notebook counts after note creation
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 39s
Add triggerRefresh() call after note creation in both masonry (home-client)
and tabs (notes-tabs-view) modes so NotebooksContext reloads notebook counts.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 09:45:30 +02:00
e76572ccd5 fix: mise a jour immediate UI apres suppression en mode liste - appel triggerRefresh dans NotesTabsView
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 1m13s
Made-with: Cursor
2026-04-26 00:20:51 +02:00
ce6166fa88 fix: use correct Prisma field names (log/status) in AgentAction update
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 34s
Made-with: Cursor
2026-04-26 00:05:55 +02:00
7718e32e01 fix: remove duplicate triggerRefresh declaration in note-card
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 30s
Made-with: Cursor
2026-04-26 00:04:04 +02:00
310904e5a3 fix: move useEffect after loadNotebooks declaration (TS error)
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 22s
Made-with: Cursor
2026-04-26 00:02:03 +02:00
1164a4a30e fix: optimistic note removal on delete + triggerRefresh for count update
Some checks failed
Deploy to Production / Build and Deploy (push) Has been cancelled
Made-with: Cursor
2026-04-26 00:01:32 +02:00
ffd6fb9373 feat: add web search test button in admin tools, update Resend docs
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 30s
Made-with: Cursor
2026-04-25 23:59:10 +02:00
3fe69b65a5 fix: notebook count updates on note delete, detect model without tool calling support
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 5s
Made-with: Cursor
2026-04-25 23:12:58 +02:00
70a9e070fc ci: fix upsert - remove all occurrences before adding to prevent duplicates
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 4s
Made-with: Cursor
2026-04-25 23:00:19 +02:00
99ac686ac0 fix: pass full config to sendViaResend, force-recreate container after env update
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 39s
Made-with: Cursor
2026-04-25 22:48:05 +02:00
266551e82b ci: fix heredoc typo ENVSSH → ENDSSH
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 39s
Made-with: Cursor
2026-04-25 22:41:50 +02:00
3ef75f9f44 docs: add GITEA-ACTIONS.md, fix Resend test mode error message
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 2s
Made-with: Cursor
2026-04-25 22:30:29 +02:00
f1097f76b0 ci: manage all .env.docker vars from Gitea variables & secrets
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 2s
Made-with: Cursor
2026-04-25 22:25:22 +02:00
ea57c022fb fix: Resend from address - reject IP/localhost, use SMTP_FROM if set
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 38s
Made-with: Cursor
2026-04-25 22:22:24 +02:00
9e777acef2 fix: load all env vars in getSystemConfig (email, tools), normalize openrouter→custom
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 38s
Made-with: Cursor
2026-04-25 22:20:13 +02:00
edfd67b8bd fix: add overflow-y-auto to admin content area (email section truncated)
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 40s
Made-with: Cursor
2026-04-25 22:16:14 +02:00
8d8b9cde85 ci: add workflow_dispatch for manual trigger
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 4s
Made-with: Cursor
2026-04-25 22:06:42 +02:00
716e15c0b7 ci: update NEXTAUTH_URL and ADMIN_EMAIL from Gitea vars on deploy
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 4s
Made-with: Cursor
2026-04-25 22:03:42 +02:00
8aefedcaee ci: check port 80 (via Nginx) instead of 3000
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 4s
Made-with: Cursor
2026-04-25 21:54:28 +02:00
5bf2d7b983 ci: check http://192.168.1.190:3000 from runner, fix healthcheck node http
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 4s
Made-with: Cursor
2026-04-25 21:51:41 +02:00
4e84b03575 ci: fix healthcheck (use wget), increase timeout to 180s
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 3m13s
Made-with: Cursor
2026-04-25 21:44:09 +02:00
3944f699bd ci: fix git safe.directory for /opt/memento
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 3m51s
Made-with: Cursor
2026-04-25 21:16:22 +02:00
01d36a5956 ci: remove rsync, use git pull via SSH instead
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 2s
Made-with: Cursor
2026-04-25 21:10:00 +02:00
22d816fd39 ci: test deploy via SSH
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 7s
Made-with: Cursor
2026-04-25 21:06:59 +02:00
5915bd567c ci: fix runner label to ubuntu-24.04, deploy via SSH to 192.168.1.190
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 47s
Made-with: Cursor
2026-04-25 20:59:35 +02:00
acb784edbb ci: fix deploy workflow - use GITHUB_WORKSPACE env var and robust healthcheck
Some checks failed
Deploy to Production / Build and Deploy (push) Has been cancelled
Made-with: Cursor
2026-04-25 20:51:35 +02:00
986d438738 fix: resolve React Error #310 and refactor admin section
Some checks failed
Deploy to Production / Build and Deploy (push) Has been cancelled
- Fix React bug #33580: remove Suspense boundaries co-located with Link components
- Delete settings/loading.tsx and admin/loading.tsx (root cause of race condition)
- Convert all admin navigation from Next.js Link to anchor tags
- Move admin pages to dedicated (admin) route group
- Add AdminHeader matching main header visual design
- Add AdminSidebar with anchor-based navigation
- Add /api/admin/models route handler (replaces server actions for GET)
- Add /api/debug/client-error for server-side browser error reporting
- Add useNoteRefreshOptional() to fix crash in AdminHeader
- Hide Admin Dashboard menu for non-admin users
- Change app icons from yellow to blue (#3A7CA5) matching brand primary
- Fix admin search bar width to match main header

Made-with: Cursor
2026-04-25 20:46:10 +02:00
Sepehr Ramezani
1d53c16cc2 docs: add AI agents and external tools section to guides
Some checks failed
Deploy to Production / Build and Deploy (push) Has been cancelled
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-25 14:13:18 +02:00
Sepehr Ramezani
0c743ee679 ci: install runner on target server, eliminate SSH complexity
Some checks failed
Deploy to Production / Build and Deploy (push) Has been cancelled
Better architecture: act_runner runs directly on 192.168.1.190.
- No SSH keys needed, no secrets to configure in Gitea
- Runner executes docker compose commands locally
- Workflow uses rsync + docker compose build + healthcheck
- Updated DEPLOY.md with complete step-by-step guide

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-21 23:10:48 +02:00
Sepehr Ramezani
97163bfb89 fix: production deployment hardening
Some checks failed
Deploy to Production / Deploy to 192.168.1.190 (push) Has been cancelled
Docker:
- Restrict PostgreSQL port to 127.0.0.1 only (not exposed to LAN)
- Add APP_BASE_URL for MCP server to reach Next.js via Docker network
- Fix MCP healthcheck (remove always-passing fallback)
- Add resource limits to mcp-server container

Dockerfile:
- Remove full node_modules copy (standalone already includes deps)
  Reduces image size by ~500MB+

Config:
- Add MCP_SERVER_MODE and MCP_SERVER_URL to deploy.sh and .env.docker.example
- Deploy script now auto-sets MCP_SERVER_URL based on NEXTAUTH_URL

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-21 23:09:22 +02:00
Sepehr Ramezani
8d37115e1d docs: add complete deployment guide (DEPLOY.md)
Some checks failed
Deploy to Production / Deploy to 192.168.1.190 (push) Has been cancelled
Covers: server setup, Gitea Runner installation (systemd + Docker),
SSH key configuration, CI/CD workflow explanation, Nginx reverse
proxy config with SSE support, HTTPS with Let's Encrypt, admin
user creation, and a full deployment checklist.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-21 23:07:00 +02:00
Sepehr Ramezani
f3b58b32fd ci: add deploy script and simplify CI/CD workflow
Some checks failed
Deploy to Production / Deploy to 192.168.1.190 (push) Has been cancelled
- scripts/deploy.sh: automated deployment with interactive env setup
  (--env-only, --build, --full)
- Supports OpenRouter, OpenAI, Ollama, DeepSeek providers
- Auto-generates NEXTAUTH_SECRET and postgres password
- Waits for healthchecks, initializes DB, shows status
- CI/CD workflow simplified to call deploy.sh --build

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-21 22:55:15 +02:00
Sepehr Ramezani
106dac9ca4 ci: add Gitea Actions workflow for auto-deploy on push to main
Some checks failed
Deploy to Production / Deploy to 192.168.1.190 (push) Has been cancelled
SSH-based deployment to 192.168.1.190 via Gitea Runner.
Builds Docker images and restarts containers automatically.

Required Gitea secrets: DEPLOY_HOST, DEPLOY_USER, DEPLOY_SSH_KEY, DEPLOY_PATH

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-21 22:34:18 +02:00
Sepehr Ramezani
cff36d9619 fix: MCP server Docker deployment, healthchecks, and minor fixes
MCP server:
- Fix Prisma imports from stale client-generated path to @prisma/client
- Switch schema from SQLite to PostgreSQL for Docker compatibility
- Add prisma generate step to Dockerfile with proper binaryTargets
- Include index-sse.js in Docker build (was excluded by .dockerignore)
- Install openssl and libc6-compat in Alpine image for Prisma runtime

Docker:
- Fix memento-note healthcheck (wget unavailable in bullseye-slim)

Minor fixes:
- scrape.service SSRF protection, middleware route coverage
- canvas-board and note-input type fixes
- next.config turbopack and devIndicators adjustments

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-21 22:22:02 +02:00
Sepehr Ramezani
1c659ce42f fix: comprehensive security, consistency, and dead code cleanup
Security:
- Add auth + file type/size validation to upload API
- Add admin auth to /api/admin/ endpoints
- Add SSRF protection to scrape action
- Whitelist fields in PUT /api/notes/[id] to prevent mass assignment
- Protect /lab, /agents, /chat, /canvas, /notebooks routes in middleware

AI provider fixes:
- Add deepseek/openrouter to factory ProviderType (was silently falling back to ollama)
- Fix title-suggestion.service.ts to use factory instead of hardcoded OpenAI
- Fix getAIProvider→getChatProvider in memory-echo, notebook-summary, agent-executor
- Fix getAIProvider→getTagsProvider in notebook-suggestion, title-suggestions, transform-markdown

Functional bugs:
- Fix ALLOW_REGISTRATION AND→OR logic
- Fix note-editor.tsx passing stale props to useAutoTagging instead of local state
- Fix stale Note.embedding type (migrated to NoteEmbedding table)
- Remove hardcoded SQLite path from prisma.ts

Frontend:
- Add AbortController to useAutoTagging and useTitleSuggestions hooks
- Add error rollback to optimistic UI in note-inline-editor
- Remove stale closure over notebookId/language in useAutoTagging

Cleanup:
- Rename docker-compose from keepnotes→memento
- Remove unused unstable_cache import from config.ts
- Remove dead useUndoRedo hook
- Fix TagSuggestion type (add isNewLabel, reasoning)
- Remove dead AIConfig/AIProviderType types
- Fix ghost-tags unused isEmpty var and as any cast
- Fix note-editor titleSuggestions typed as any[]

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-21 22:22:02 +02:00
Sepehr Ramezani
3c8e347576 fix: use getTagsProvider for all auto-labeling paths, allow suggestions without notebook
- app/api/ai/tags/route.ts: getAIProvider → getTagsProvider (was using
  embedding model instead of tags model for legacy tag generation)
- lib/ai/services/auto-label-creation.service.ts: same fix
- hooks/use-auto-tagging.ts: remove notebookId gate that blocked all
  suggestions in "General Notes" — the API has a legacy path for this
- app/actions/admin-settings.ts: revalidateTag → updateTag (Next.js 16
  requires 2 args for revalidateTag)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-21 22:22:02 +02:00
Sepehr Ramezani
5cd828c7d7 fix: Resend rejects noreply@localhost as from address
When NEXTAUTH_URL=http://localhost:3000, the hostname resolves to
'localhost' which Resend rejects. Fall back to onboarding@resend.dev
when hostname is localhost.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-21 22:22:02 +02:00
Sepehr Ramezani
5b652698cc revert: restore original mail.ts and admin email form
Reverted all changes to lib/mail.ts and the email section of
admin-settings-form.tsx. The original Resend code was working fine;
my "fixes" for the from field broke it. Restored the exact original
code that was functional.

Kept: auto-tagging fix (getTagsProvider), language detection, revalidateTag
fix, debug logging, docker-compose fix, setup wizard.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-21 22:22:02 +02:00