dzen.nstarikov.ru/docs/superpowers/plans/2026-08-08-editor-settings-plan.md
nstarikov f3a557cf17
Some checks failed
Deploy Dzen assistant / deploy (push) Failing after 22s
chore: make dzen assistant repository root
2026-08-15 14:21:59 +03:00

2.7 KiB

Editor Settings Implementation Plan

For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task.

Goal: Add a settings page with a reusable Editor.js footer signature and extra LLM instructions, then use both settings in draft editing and article generation.

Architecture: Store two named values in a small SQLite app_settings table. Expose authenticated GET/PUT settings endpoints. The admin SPA adds a settings view and loads the saved signature when opening a draft, appending it as an editable final block; the worker appends extra instructions to the existing system prompt only when non-empty.

Tech Stack: FastAPI, SQLAlchemy/SQLite, Celery, React/Vite, Editor.js, existing shadcn components and lucide-react.


Task 1: Persist and expose settings

Files:

  • Modify: app/models.py

  • Modify: app/routes.py

  • Modify: app/database.py

  • Add an AppSetting model with unique key and text value columns.

  • Add GET /api/settings returning signatureHtml and llmInstructions.

  • Add PUT /api/settings accepting both fields, trimming values, and committing them atomically.

  • Ensure database initialization creates the table for existing installations.

Task 2: Apply extra LLM instructions

Files:

  • Modify: app/worker.py

  • Read llmInstructions from the settings table at article-generation time.

  • Append it to ARTICLE_SYSTEM_PROMPT under a clearly delimited additional-instructions section.

  • Keep generation unchanged when the field is empty.

Task 3: Settings screen and navigation

Files:

  • Modify: admin/src/App.tsx

  • Add a simple view switch between the production dashboard and settings.

  • Build the settings form with the existing shadcn Card, Input/controls, Button, and Editor.js instance.

  • Load settings on entry, save both values together, show saving/error status, and destroy the Editor.js instance on exit.

Task 4: Signature in the article editor

Files:

  • Modify: admin/src/App.tsx

  • Load the saved signature along with the article when opening a draft.

  • Append signature blocks to the editor data only when the article does not already contain the saved signature, avoiding duplicates on re-open.

  • Keep the appended blocks editable and include them in the normal article save operation.

Task 5: Verification and deployment

Files:

  • No new files.

  • Run Python compilation and frontend production build.

  • Deploy api, worker, and beat so API and generation use the same image.

  • Verify health, settings GET/PUT with admin authentication, and that the admin bundle contains the settings view.