8000 feat(setup): first-run setup wizard answered by .env, and startup on a fresh database by adeelahmad · Pull Request #19 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(setup): first-run setup wizard answered by .env, and startup on a fresh database - #19

Merged
adeelahmad merged 2 commits into
mainfrom
claude/setup-wizard-mair8k
Oct 2, 2026
Merged

adeelahmad merged 2 commits into
mainfrom
claude/setup-wizard-mair8k

Conversation

@adeelahmad
Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: a fresh install only asked for the first admin (with the setup code from the log). The namespace, model provider and storage had to be found in archive.yaml or Settings. If archive.yaml had no namespaces, the API failed to start on SurrealDB 3 with "table 'seq' does not exist".

After: once the first admin exists, the web app walks them through a short wizard at /welcome. It covers the namespace, the model provider (with a connection test) and storage (where data lives, the largest upload, and an optional folder inside sources.local_roots to watch). Every step can be skipped, and so can the whole wizard. .env can answer it instead. Values from the environment win, and the wizard and Settings show them locked. A fresh database with no namespaces now starts.

How

  • app/domain/setup.py: when the API first starts with no accounts, it writes a setup:wizard marker. Installs that already had accounts never see the wizard. At startup it also applies LENS_ADMIN_EMAIL/LENS_ADMIN_PASSWORD/LENS_ADMIN_NAME and LENS_NAMESPACE. LENS_SETUP_WIZARD=off turns the wizard off.
  • settings.ENV_OVERRIDES now also covers LENS_LLM_BASE_URL/_MODEL/_API_KEY/_VISION_MODEL, and these win over saved settings. A key from the environment is masked in every view.
  • New admin-only routes under /api/v1/setup (GET, POST /namespace, PUT /llm, PUT /storage, POST /finish). GET /auth/status gains wizard_pending.
  • Frontend: the (setup)/welcome page and components/setup/setup-wizard.tsx. Admins are redirected there from the app layout while the wizard is pending. The setup form now lands on /welcome after creating the admin.
  • The admin step still needs the one-time setup code, or the env admin, so a stranger can't claim a public server.
  • Startup fix: DEFINE TABLE IF NOT EXISTS seq is now part of the schema. I reproduced the failure against a real SurrealDB 3.2.4 server, then confirmed the fix on the same server.

Motivation and Context

Frictionless first run from the browser, alongside .env configuration for automated installs.

Notes for the packaging PRs (#10 Proxmox, #11 Synology, #12 Cloudron, #13 QNAP)

Nothing breaks. They keep the same setup-code mechanism (LENS_SETUP_CODE, the log line, /setup), and after the admin is created the user lands in the wizard. Optional follow-ups once this merges:

  • The seeded media namespace is no longer needed to get around the 'seq' bug. Keeping it is fine, because a namespace that already exists counts as set up and the wizard just shows it. Dropping it lets the user pick the name.
  • Fully unattended installs can set LENS_ADMIN_EMAIL/LENS_ADMIN_PASSWORD (no setup code), LENS_NAMESPACE, LENS_LLM_*, and LENS_SETUP_WIZARD=off.
  • Post-install text can say "open the web app, enter the setup code, and follow the setup steps".

Screenshots (if appropriate):

Driven end to end in Chromium against a fresh embedded database: setup code → admin → namespace → model provider → storage → home. Screenshots are in the project thread.

Steps to reproduce (if appropriate):

Start with an empty data folder and an archive.yaml with no namespaces, open the web app, and create the admin with the setup code.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires documentation updates.
  • I have updated the documentation accordingly. (configuration.md#first-run-setup, authentication.md, get-started.md, .env.example, CHANGELOG)
  • My change requires dependencies updates.
  • I have updated the dependencies accordingly.

Tests: tests/api/test_setup.py (6 tests, passing on in-memory and on a SurrealDB 3.2.4 server) and __tests__/setupWizard.test.tsx (4 tests). The full backend suite passes except test_office_and_text_files_become_documents, which fails because LibreOffice can't load the file in this container. That test is unrelated to this change. All 503 frontend tests pass. ruff, mypy, tsc and eslint are clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WjEWJZ9XYFxL19mNfXgfPK


Generated by Claude Code

…artup on a fresh database

A fresh install walks its first admin through the first namespace, the model
provider and storage in the web app, after the admin account (still behind the
one-time setup code). LENS_ADMIN_*, LENS_NAMESPACE and LENS_LLM_* in .env answer
it instead; environment values win and show locked. Installs that already had
accounts never see it.

Define the seq table with the schema: SurrealDB 3 refused to read it before
anything wrote to it, so the API failed to start on a fresh database whose
archive.yaml had no namespaces.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WjEWJZ9XYFxL19mNfXgfPK
@adeelahmad adeelahmad self-assigned this Oct 2, 2026
…MESPACE only while there is none

The prod stack lists its environment explicitly, so LENS_ADMIN_*, LENS_NAMESPACE,
LENS_LLM_*, LENS_SETUP_WIZARD and LENS_SETUP_CODE never reached the backend and
worker. LENS_NAMESPACE no longer re-creates a namespace deleted later.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WjEWJZ9XYFxL19mNfXgfPK
@adeelahmad adeelahmad changed the title First-run setup wizard, with .env values that answer it; fix startup on a fresh database feat(setup): first-run setup wizard answered by .env, and startup on a fresh database Oct 2, 2026
@adeelahmad
adeelahmad marked this pull request as ready for review October 2, 2026 13:07
@adeelahmad
adeelahmad merged commit ddaff6c into main Oct 2, 2026
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0