From b472b7c60889235acb0b2d014aa20610d5e7d754 Mon Sep 17 00:00:00 2001 From: Adeel Ahmad Date: Sun, 18 Oct 2026 06:09:41 +0000 Subject: [PATCH 1/2] =?UTF-8?q?feat(web):=20Settings=20=E2=80=BA=20Secrets?= =?UTF-8?q?,=20and=20a=20Vaultwarden=20picker=20beside=20every=20secret=20?= =?UTF-8?q?field?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Settings › Secrets sets up the Vaultwarden vault secret fields can refer to and tests its sign-in, and lists every field that refers to it with whether it could be read. Every secret field gets From Vaultwarden, which lists the vault's items by name and fills in a reference; a saved reference shows itself and its read status, never a value. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_019okSDRfFHV74BTpMzinTFg --- CHANGELOG.md | 3 +- README.md | 3 +- docs/requirements.md | 2 +- docs/secrets.md | 18 +- .../__tests__/settings-secrets.test.tsx | 226 ++++++++++++++++++ .../components/settings/bodies.tsx | 152 ++++++++++++ .../components/settings/fields.tsx | 71 +++++- nextjs-frontend/components/settings/find.ts | 5 +- nextjs-frontend/components/settings/model.ts | 63 +++++ .../components/settings/section.tsx | 7 +- .../components/settings/settings-shell.tsx | 2 + .../components/settings/vault-picker.tsx | 174 ++++++++++++++ 12 files changed, 703 insertions(+), 23 deletions(-) create mode 100644 nextjs-frontend/__tests__/settings-secrets.test.tsx create mode 100644 nextjs-frontend/components/settings/vault-picker.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index 15df2881e..e26642a28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,7 +63,8 @@ The backend (`fastapi_backend`) and the frontend (`nextjs-frontend`) are version `POST /api/v1/secrets/test`), the MCP tools `list_secrets`, `list_vault_items` and `set_secret_reference`, and the assistant's `list_secrets` and `vault_items` show references and whether they could be read, never a value. The client (python-vaultwarden, Apache-2.0) is fetched once a Vaultwarden address is set. Secrets saved in Lens stay - the default ([Secrets](docs/secrets.md)). + the default. In the web app, Settings › Secrets sets the vault up and tests it, and every secret field gets From + Vaultwarden, a picker of the vault's items that fills in the reference ([Secrets](docs/secrets.md)). - **A decide node for judgement calls.** An automation's workflow can ask the decision model a question with a few options ("Does this need me today?") and go on along the option it picked, or along `unsure` when it isn't sure enough, none is set up or the budget is spent. The email it reads is marked as outside text, the answer is kept per diff --git a/README.md b/README.md index 5ae26c359..ecde332da 100644 --- a/README.md +++ b/README.md @@ -267,8 +267,7 @@ Next, and not in a pull request yet; each links to where it is tracked: activity ledger ([speech providers](docs/speech-providers.md)). - **Storage:** uploads and assets' media in the file store, and a storage key to download ([storage](docs/storage.md)). -- **Secrets:** Settings › Secrets in the web app, with a picker for the vault's items, and references in sources' - credentials and MCP servers ([secrets](docs/secrets.md)). +- **Secrets:** references in sources' credentials and MCP servers ([secrets](docs/secrets.md)). - **Logging:** sending straight to Loki or another HTTP endpoint, and client certificates for TLS ([logging](docs/logging.md)). - **Proof:** each release tested by upgrading an install of the last one, holding data diff --git a/docs/requirements.md b/docs/requirements.md index b35f43647..5e592e93c 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -254,7 +254,7 @@ request, to another check that proves the same thing; loosening a requirement or | Passkeys instead of passwords | [test_passkeys.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_passkeys.py) `test_first_admin_with_a_passkey_and_no_password`, `test_sign_in_with_a_passkey` | | A passkey at another of Lens's addresses (remote access, HTTPS) added from a signed-in one: Open signed in, then one fingerprint | [test_passkeys.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_passkeys.py) `test_taking_your_sign_in_to_another_address`, `test_the_addresses_lens_opens_at`; [passkeys-panel.test.tsx](https://github.com/adeelahmad/lense/blob/main/nextjs-frontend/__tests__/passkeys-panel.test.tsx) `opens an address you have no passkey for signed in, to add one there`; [webauthn.test.ts](https://github.com/adeelahmad/lense/blob/main/nextjs-frontend/__tests__/webauthn.test.ts) `points a failed sign-in to the address the passkey was made at` | | Encryption at rest, with a key per namespace | [test_keyring.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/domain/test_keyring.py) `test_each_namespace_gets_its_own_key_kept_only_wrapped`; [test_encryption.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_encryption.py) `test_a_new_archive_encrypts_and_still_plays_seeks_and_processes` | -| Secret fields that refer to a Vaultwarden or Bitwarden vault, read by Lens and never shown to anyone, agents included | [test_secrets.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_secrets.py) `test_a_secret_field_reads_its_value_from_the_vault`, `test_the_vault_is_read_again_and_what_vanishes_stops_being_used`, `test_the_vault_is_set_up_and_checked_in_the_app`, `test_agents_refer_to_secrets_and_never_read_them` | +| Secret fields that refer to a Vaultwarden or Bitwarden vault, read by Lens and never shown to anyone, agents included | [test_secrets.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_secrets.py) `test_a_secret_field_reads_its_value_from_the_vault`, `test_the_vault_is_read_again_and_what_vanishes_stops_being_used`, `test_the_vault_is_set_up_and_checked_in_the_app`, `test_agents_refer_to_secrets_and_never_read_them`; [settings-secrets.test.tsx](https://github.com/adeelahmad/lense/blob/main/nextjs-frontend/__tests__/settings-secrets.test.tsx) `is picked from the vault's items, and only the reference is saved`, `shows its reference and whether it was read, never a value` | | Roles per namespace: viewer, editor, owner, or custom roles made of permissions | [test_roles.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_roles.py) `test_builtin_roles_keep_their_meaning`, `test_custom_roles_allow_exactly_their_permissions`; [journeys.mjs](https://github.com/adeelahmad/lense/blob/main/ci/clicks/journeys.mjs) `person-add` | | Email invitations, and removing someone for good | [test_users.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_users.py) `test_invites_are_emailed_when_mail_is_set_up`, `test_admins_remove_people_for_good` | | An audit log | [test_settings.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_settings.py) `test_settings_are_editable_and_secret`; [test_files.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_files.py) `test_change_a_file_and_the_audit_log` | diff --git a/docs/secrets.md b/docs/secrets.md index bee66cc73..07d899114 100644 --- a/docs/secrets.md +++ b/docs/secrets.md @@ -10,8 +10,8 @@ and whether it could be read, but never the value. | | | |---|---| -| Built | References in Settings' secret fields; Vaultwarden (and Bitwarden) as the first password manager; the API, the assistant's tools and MCP tools for them | -| Planned | Settings › Secrets in the web app, with a picker for the vault's items; references in other stores of secrets (sources, MCP servers, sign-in providers); more password managers | +| Built | References in Settings' secret fields; Vaultwarden (and Bitwarden) as the first password manager; Settings › Secrets in the web app, and a picker for the vault's items beside every secret field; the API, the assistant's tools and MCP tools for them | +| Planned | References in other stores of secrets (sources, MCP servers, sign-in providers); more password managers | ## References @@ -43,10 +43,16 @@ of the vault: 2. Make a folder called `Lens` in it. Put the items Lens may read there, or share them into it. Lens reads that folder only. 3. In that account, open **Settings › Security › Keys › View API key**. Copy the `client_id` and `client_secret`. -4. Give Lens the vault's address, the account's email, the API key and the account's master password with - `PUT /api/v1/settings/secrets`, or ask the admin assistant to (`change_settings`, which asks first). Then - `POST /api/v1/secrets/test` signs in and counts the items in the folder. (Settings › Secrets in the web app is - planned.) +4. In Lens, open **Settings › Secrets** (under Security and access). Set the vault's address, the account's email, the + API key and the account's master password, save, then click **Test**. It signs in and counts the items in the + folder. Agents do the same with `PUT /api/v1/settings/secrets` and `POST /api/v1/secrets/test`, or the admin + assistant's `change_settings` (which asks first). + +Then, in any secret field in Settings, **From Vaultwarden** lists the folder's items by name with their fields: +pick one, or type part of a name and press Enter for the first. The field fills with its reference, shown in plain +text since it isn't a secret, and saves like any change. A saved reference shows as **From Vaultwarden · +vaultwarden://Item/field**, with when it was last read or why it couldn't be. Settings › Secrets lists every field +that refers to the vault, each linked to its place in Settings. The vault encrypts its items end to end, so the server holds them only encrypted. The master password is what opens them, so Lens needs it as well as the API key. Both are sealed with the server's key, like any other secret in diff --git a/nextjs-frontend/__tests__/settings-secrets.test.tsx b/nextjs-frontend/__tests__/settings-secrets.test.tsx new file mode 100644 index 000000000..1ae9b504e --- /dev/null +++ b/nextjs-frontend/__tests__/settings-secrets.test.tsx @@ -0,0 +1,226 @@ +import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; +import { fireEvent, render, screen, waitFor } from "@testing-library/react"; +import "@testing-library/jest-dom"; + +import { Admin } from "@/app/openapi-client"; +import { SettingsSection } from "@/components/settings/section"; +import type { SectionId, SettingsView } from "@/components/settings/model"; +import { TooltipProvider } from "@/components/ui/tooltip"; + +jest.mock("@/app/openapi-client", () => ({ + Admin: { + updateSettings: jest.fn(), + getSecrets: jest.fn(), + listVaultItems: jest.fn(), + testSecrets: jest.fn(), + testMail: jest.fn(), + }, + Metadata: {}, +})); +jest.mock("next-auth/react", () => ({ useSession: () => ({ data: { accessToken: "t" } }) })); +jest.mock("next/navigation", () => ({ useRouter: () => ({ push: jest.fn() }) })); +jest.mock("@/lib/hooks/session", () => ({ useArchive: () => ({ namespaces: [] }) })); +jest.mock("@/components/ui/toast", () => ({ useToast: () => jest.fn() })); + +const ok = (data: unknown) => Promise.resolve({ data, response: { ok: true, status: 200 } }); +const REF = "vaultwarden://Mail/password"; +const VAULT = { + id: "vaultwarden", + label: "Vaultwarden", + scheme: "vaultwarden", + configured: true, + url: "https://vault.example.com", + folder: "Lens", +}; +const SECRETS = { + providers: [{ id: "builtin", label: "Saved in Lens", scheme: null, configured: true }, VAULT], + references: [ + { + section: "mail", + key: "password", + ref: REF, + provider: "vaultwarden", + read: true, + error: null, + read_at: new Date().toISOString(), + missing: false, + }, + ], + fields: [], +}; + +const mail = (password: unknown) => + ({ + mail: { + values: { + server: "smtp.example.com", + port: 587, + security: "starttls", + username: "lens", + password, + from_address: "lens@example.com", + from_name: "Lens", + }, + }, + }) as unknown as SettingsView; + +const secrets = (values: Record) => + ({ + secrets: { + values: { + cache_minutes: 10, + vaultwarden_url: null, + vaultwarden_email: null, + vaultwarden_client_id: null, + vaultwarden_client_secret: null, + vaultwarden_password: null, + vaultwarden_folder: "Lens", + ...values, + }, + }, + }) as unknown as SettingsView; + +function show(id: SectionId, view: SettingsView) { + const qc = new QueryClient({ defaultOptions: { queries: { retry: false }, mutations: { retry: false } } }); + return render( + + + undefined} /> + + , + ); +} + +beforeEach(() => { + (Admin.updateSettings as jest.Mock).mockReset().mockImplementation(() => ok({ ok: true })); + (Admin.getSecrets as jest.Mock).mockReset().mockImplementation(() => ok(SECRETS)); + (Admin.testSecrets as jest.Mock).mockReset(); + (Admin.listVaultItems as jest.Mock).mockReset().mockImplementation(() => + ok({ + provider: "vaultwarden", + items: [ + { + name: "Mail", + type: "login", + fields: ["username", "password"], + ref: REF, + refs: { username: "vaultwarden://Mail/username", password: REF }, + }, + ], + }), + ); +}); + +describe("Settings › Secrets", () => { + it("sets up Vaultwarden, keeping the key and password write-only", async () => { + show("secrets", secrets({})); + fireEvent.change(screen.getByLabelText("Vaultwarden address"), { target: { value: "https://vault.example.com" } }); + fireEvent.change(screen.getByLabelText("Lens’s account"), { target: { value: "lens@example.com" } }); + fireEvent.change(screen.getByLabelText("API key client_id"), { target: { value: "user.1234" } }); + fireEvent.change(screen.getByLabelText("API key client_secret"), { target: { value: "s3cret" } }); + fireEvent.change(screen.getByLabelText("Master password"), { target: { value: "correct horse" } }); + // the vault's own sign-in can't be a reference, so there's no picker here + expect(screen.queryByRole("button", { name: /From Vaultwarden/ })).not.toBeInTheDocument(); + fireEvent.click(screen.getByRole("button", { name: "Save" })); + await waitFor(() => expect(Admin.updateSettings).toHaveBeenCalledTimes(1)); + expect((Admin.updateSettings as jest.Mock).mock.calls[0][0]).toMatchObject({ + path: { section: "secrets" }, + body: { + vaultwarden_url: "https://vault.example.com", + vaultwarden_email: "lens@example.com", + vaultwarden_client_id: "user.1234", + vaultwarden_client_secret: "s3cret", + vaultwarden_password: "correct horse", + }, + }); + }); + + it("refuses an address with a password in it before saving", () => { + show("secrets", secrets({})); + fireEvent.change(screen.getByLabelText("Vaultwarden address"), { + target: { value: "https://me:pw@vault.example.com" }, + }); + expect(screen.getByText(/no user name, password or query/)).toBeInTheDocument(); + }); + + it("tests the saved sign-in and lists the fields that refer to the vault", async () => { + (Admin.testSecrets as jest.Mock).mockImplementation(() => + ok({ ok: true, items: 3, folder: "Lens", account: "lens@example.com" }), + ); + show( + "secrets", + secrets({ + vaultwarden_url: "https://vault.example.com", + vaultwarden_email: "lens@example.com", + vaultwarden_client_id: "user.1234", + vaultwarden_client_secret: { secret: true, set: true }, + vaultwarden_password: { secret: true, set: true }, + }), + ); + expect(await screen.findByText(REF)).toBeInTheDocument(); + expect(screen.getByRole("link", { name: "Email › Password" })).toHaveAttribute( + "href", + "/settings/mail?field=mail.password", + ); + expect(screen.getByText(/Read from Vaultwarden/)).toBeInTheDocument(); + fireEvent.click(screen.getByRole("button", { name: "Test" })); + expect(await screen.findByText(/3 item\(s\) in the folder Lens of lens@example.com/)).toBeInTheDocument(); + expect(Admin.testSecrets).toHaveBeenCalledWith(expect.objectContaining({ body: { provider: "vaultwarden" } })); + }); +}); + +describe("a secret field that refers to the vault", () => { + it("shows its reference and whether it was read, never a value", async () => { + show( + "mail", + mail({ + secret: true, + set: true, + ref: REF, + provider: "vaultwarden", + read: false, + error: "there's no item called Mail", + }), + ); + expect(screen.getByText(REF)).toBeInTheDocument(); + expect(screen.getByText(/From Vaultwarden/)).toBeInTheDocument(); + expect(screen.getByText(/Not read: there's no item called Mail/)).toBeInTheDocument(); + }); + + it("is picked from the vault's items, and only the reference is saved", async () => { + show("mail", mail({ secret: true, set: true })); + fireEvent.click(screen.getByRole("button", { name: "Replace" })); + fireEvent.click(await screen.findByRole("button", { name: /From Vaultwarden/ })); + fireEvent.click(await screen.findByRole("button", { name: "password" })); + const input = screen.getByLabelText("Password"); + expect(input).toHaveValue(REF); + expect(input).toHaveAttribute("type", "text"); // a reference isn't a secret to hide + fireEvent.click(screen.getByRole("button", { name: "Save" })); + await waitFor(() => expect(Admin.updateSettings).toHaveBeenCalledTimes(1)); + expect((Admin.updateSettings as jest.Mock).mock.calls[0][0]).toMatchObject({ + path: { section: "mail" }, + body: { password: REF }, + }); + expect(Admin.listVaultItems).toHaveBeenCalledWith( + expect.objectContaining({ query: expect.objectContaining({ provider: "vaultwarden" }) }), + ); + }); + + it("Enter in the vault's search picks the first item", async () => { + show("mail", mail(null)); + fireEvent.click(await screen.findByRole("button", { name: /From Vaultwarden/ })); + const search = screen.getByRole("searchbox", { name: "Find an item in Vaultwarden" }); + await screen.findByText("Mail"); + fireEvent.keyDown(search, { key: "Enter" }); + expect(screen.getByLabelText("Password")).toHaveValue(REF); + }); + + it("has no picker when no vault is set up", async () => { + (Admin.getSecrets as jest.Mock).mockImplementation(() => + ok({ ...SECRETS, providers: [{ ...VAULT, configured: false }], references: [] }), + ); + show("mail", mail(null)); + await waitFor(() => expect(Admin.getSecrets).toHaveBeenCalled()); + expect(screen.queryByRole("button", { name: /From Vaultwarden/ })).not.toBeInTheDocument(); + }); +}); diff --git a/nextjs-frontend/components/settings/bodies.tsx b/nextjs-frontend/components/settings/bodies.tsx index 1482acc5e..029ca5715 100644 --- a/nextjs-frontend/components/settings/bodies.tsx +++ b/nextjs-frontend/components/settings/bodies.tsx @@ -29,12 +29,16 @@ import { SandboxGatewaySwitch } from "@/components/settings/sandbox-gateway"; import { ScalingGroups } from "@/components/settings/scaling-panel"; import { SignInProviders } from "@/components/settings/sign-in-providers"; import { UpdatesPanel } from "@/components/settings/updates-panel"; +import { settingHref } from "@/components/settings/find"; +import { ReferenceStatus } from "@/components/settings/vault-picker"; import { VoicePicker } from "@/components/settings/voice-picker"; import { AddConnection } from "@/components/storage/add-connection"; import { NOT_STORAGE, fileStoreTry } from "@/components/storage/file-store"; import { AI_TOOLS, BACKUP_SCHEDULES, + FIELDS, + SECTIONS, SPEECH_PROVIDERS, UPLOAD_TYPES, type FieldSpec, @@ -573,6 +577,8 @@ export function SectionBody({ ctx }: { ctx: BodyCtx }) { ); case "encryption": return ; + case "secrets": + return ; case "backups": return ; case "storage": @@ -711,6 +717,7 @@ function LlmBody({ ctx }: { ctx: BodyCtx }) { key={ctx.view.llm?.updated_at ?? "none"} label="API key" isSet={Boolean(secret.set)} + saved={secret} updatedBy={ctx.view.llm?.updated_by} updatedAt={ctx.view.llm?.updated_at} value={key.value as string | undefined} @@ -912,6 +919,7 @@ function TelemetryBody({ ctx }: { ctx: BodyCtx }) { label={locked.includes("headers") ? "Headers (set by LENS_TELEMETRY_HEADERS in .env)" : "Headers"} placeholder="Authorization=Bearer%20token,X-Scope-OrgID=home" isSet={Boolean(secret.set)} + saved={secret} updatedBy={t?.updated_by} updatedAt={t?.updated_at} value={headers.value as string | undefined} @@ -978,6 +986,7 @@ function TelemetryBody({ ctx }: { ctx: BodyCtx }) { } placeholder="16 or more letters and digits, e.g. from openssl rand -hex 32" isSet={Boolean(promSecret.set)} + saved={promSecret} updatedBy={t?.updated_by} updatedAt={t?.updated_at} value={promToken.value as string | undefined} @@ -1131,6 +1140,7 @@ function AnalyticsBody({ ctx }: { ctx: BodyCtx }) { } placeholder="From GA: Admin → Data streams → your stream → Measurement Protocol API secrets" isSet={Boolean(secret.set)} + saved={secret} updatedBy={a?.updated_by} updatedAt={a?.updated_at} value={apiSecret.value as string | undefined} @@ -1214,6 +1224,131 @@ function EncryptionBody({ ctx }: { ctx: BodyCtx }) { ); } +/** Settings › Secrets: the Vaultwarden vault secret fields can refer to (docs/secrets.md), a check of its sign-in, and + * the fields that refer to it with whether each could be read. Never a value. */ +function SecretsBody({ ctx }: { ctx: BodyCtx }) { + const client = useApiClient(); + const s = ctx.view.secrets; + const secret = (k: string) => (s?.values?.[k] ?? {}) as { set?: boolean }; + const clientSecret = ctx.state("secrets.vaultwarden_client_secret"); + const password = ctx.state("secrets.vaultwarden_password"); + const saved = Boolean(s?.values?.vaultwarden_url); + const refs = useQuery({ + queryKey: ["secrets", s?.updated_at ?? null], + queryFn: () => data(Admin.getSecrets({ client })), + }); + const test = useMutation({ + mutationFn: () => data(Admin.testSecrets({ client, body: { provider: "vaultwarden" } })), + }); + const where = (section: string, key: string) => { + const f = FIELDS.find((x) => x.section === section && x.key === key); + const sec = SECTIONS.find((x) => x.backend.includes(section)); + return { label: f?.label ?? `${section}.${key}`, section: sec, href: sec ? settingHref(sec.id, f) : null }; + }; + const references = refs.data?.references ?? []; + return ( + <> +

+ Any secret field in Settings can hold a reference to an item in your vault, like vaultwarden://OpenAI/password, + instead of the secret. Lens reads the value and keeps only the reference; nobody sees the value, agents + included. Give Lens an account of its own on the vault, and put the items it may read in one folder. +

+ +
+ + +
+ clientSecret.onChange(x)} + /> + password.onChange(x)} + hint="The vault encrypts its items end to end, so it opens them" + /> + +
+ + +
+
+ {saved && ( + <> +
+ + + {ctx.dirty + ? "Uses the saved settings, not your unsaved changes" + : "Signs in to the vault and counts the items Lens may read"} + +
+ {test.data && + (test.data.ok ? ( + + {test.data.items ?? 0} item(s) in the folder {test.data.folder} of {test.data.account}. + + ) : ( + + {test.data.error} + + ))} + {test.isError && {test.error.message}} + + )} + Fields that refer to the vault + {refs.isPending ? ( + + ) : references.length === 0 ? ( +

+ None yet. In any secret field, pick From Vaultwarden, or paste a reference like vaultwarden://Item/field. +

+ ) : ( +
    + {references.map((r) => { + const w = where(r.section, r.key); + return ( +
  • + + {w.href ? ( + + {w.section?.label} › {w.label} + + ) : ( + {w.label} + )} + {r.ref} + + + + +
  • + ); + })} +
+ )} + + ); +} + function BackupsBody({ ctx }: { ctx: BodyCtx }) { const client = useApiClient(); const conns = useQuery({ queryKey: ["sources"], queryFn: () => data(Sources.listSources({ client })) }); @@ -1392,6 +1527,7 @@ function FedoraBody({ ctx }: { ctx: BodyCtx }) { label={locked.includes("password") ? "Password (set by LENS_FEDORA_PASSWORD in .env)" : "Password"} placeholder="fedoraAdmin" isSet={Boolean(secret.set)} + saved={secret} updatedBy={f?.updated_by} updatedAt={f?.updated_at} value={password.value as string | undefined} @@ -1674,6 +1810,7 @@ function MailBody({ ctx }: { ctx: BodyCtx }) { key={m?.updated_at ?? "none"} label="Password" isSet={Boolean(((m?.values?.password ?? {}) as { set?: boolean }).set)} + saved={m?.values?.password} updatedBy={m?.updated_by} updatedAt={m?.updated_at} value={pw.value as string | undefined} @@ -1875,6 +2012,7 @@ function HttpsBody({ ctx }: { ctx: BodyCtx }) { label="Its fields, as JSON" placeholder='{"api_token": "…"}' isSet={secret("dns_credentials")} + saved={t?.values?.dns_credentials} updatedBy={t?.updated_by} updatedAt={t?.updated_at} value={creds.value as string | undefined} @@ -1952,6 +2090,7 @@ function HttpsBody({ ctx }: { ctx: BodyCtx }) { label="EAB HMAC key" placeholder="Paste the HMAC key" isSet={secret("eab_hmac_key")} + saved={t?.values?.eab_hmac_key} updatedBy={t?.updated_by} updatedAt={t?.updated_at} value={eab.value as string | undefined} @@ -2045,6 +2184,7 @@ function TunnelBody({ ctx }: { ctx: BodyCtx }) { label="Cloudflare API token" placeholder="Paste a Cloudflare API token" isSet={secret("api_token")} + saved={t?.values?.api_token} updatedBy={t?.updated_by} updatedAt={t?.updated_at} value={apiToken.value as string | undefined} @@ -2064,6 +2204,7 @@ function TunnelBody({ ctx }: { ctx: BodyCtx }) { label="Tunnel token" placeholder="Paste the tunnel’s token" isSet={secret("token")} + saved={t?.values?.token} updatedBy={t?.updated_by} updatedAt={t?.updated_at} value={token.value as string | undefined} @@ -2146,6 +2287,7 @@ function BridgeBody({ ctx }: { ctx: BodyCtx }) { key={b?.updated_at ?? "none"} label="API token" isSet={Boolean(((b?.values?.token ?? {}) as { set?: boolean }).set)} + saved={b?.values?.token} updatedBy={b?.updated_by} updatedAt={b?.updated_at} value={token.value as string | undefined} @@ -2255,6 +2397,7 @@ function TelegramBody({ ctx }: { ctx: BodyCtx }) { key={t?.updated_at ?? "none"} label="Bot token" isSet={Boolean(((t?.values?.token ?? {}) as { set?: boolean }).set)} + saved={t?.values?.token} updatedBy={t?.updated_by} updatedAt={t?.updated_at} value={token.value as string | undefined} @@ -2312,6 +2455,7 @@ function SlackToken({ ctx, id, label }: { ctx: BodyCtx; id: "bot_token" | "app_t key={sl?.updated_at ?? "none"} label={label} isSet={Boolean(((sl?.values?.[id] ?? {}) as { set?: boolean }).set)} + saved={sl?.values?.[id]} updatedBy={sl?.updated_by} updatedAt={sl?.updated_at} value={st.value as string | undefined} @@ -2488,6 +2632,7 @@ function MailboxBody({ ctx }: { ctx: BodyCtx }) { label="Password" placeholder="The mailbox’s password (an app password, for most providers)" isSet={Boolean(((m?.values?.password ?? {}) as { set?: boolean }).set)} + saved={m?.values?.password} updatedBy={m?.updated_by} updatedAt={m?.updated_at} value={password.value as string | undefined} @@ -2558,6 +2703,7 @@ function MatterbridgeSecret({ ctx, id, label }: { ctx: BodyCtx; id: string; labe key={m?.updated_at ?? "none"} label={label} isSet={Boolean(((m?.values?.[id] ?? {}) as { set?: boolean }).set)} + saved={m?.values?.[id]} updatedBy={m?.updated_by} updatedAt={m?.updated_at} value={st.value as string | undefined} @@ -2782,6 +2928,7 @@ function AiBody({ ctx }: { ctx: BodyCtx }) { key={ctx.view.voice?.updated_at ?? "none"} label="Speech server API key" isSet={Boolean(((ctx.view.voice?.values?.tts_api_key ?? {}) as { set?: boolean }).set)} + saved={ctx.view.voice?.values?.tts_api_key} updatedBy={ctx.view.voice?.updated_by} updatedAt={ctx.view.voice?.updated_at} value={ctx.state("voice.tts_api_key").value as string | undefined} @@ -2847,6 +2994,7 @@ function WebSearch({ ctx }: { ctx: BodyCtx }) { key={web?.updated_at ?? "none"} label={`${provider === "brave" ? "Brave Search" : "Tavily"} API key`} isSet={Boolean(((web?.values?.api_key ?? {}) as { set?: boolean }).set)} + saved={web?.values?.api_key} updatedBy={web?.updated_by} updatedAt={web?.updated_at} value={ctx.state("web.api_key").value as string | undefined} @@ -2933,6 +3081,7 @@ function RoutineChoices({ ctx }: { ctx: BodyCtx }) { key={d?.updated_at ?? "none"} label="Decision model API key" isSet={Boolean(secret.set)} + saved={secret} updatedBy={d?.updated_by} updatedAt={d?.updated_at} value={key.value as string | undefined} @@ -3011,6 +3160,7 @@ function SearchBody({ ctx }: { ctx: BodyCtx }) { key={search?.updated_at ?? "none"} label="Password" isSet={Boolean(((search?.values?.opensearch_password ?? {}) as { set?: boolean }).set)} + saved={search?.values?.opensearch_password} updatedBy={search?.updated_by} updatedAt={search?.updated_at} value={osPassword.value as string | undefined} @@ -3039,6 +3189,7 @@ function SearchBody({ ctx }: { ctx: BodyCtx }) { key={ctx.view.embeddings?.updated_at ?? "none"} label="API key" isSet={Boolean(secret.set)} + saved={secret} updatedBy={ctx.view.embeddings?.updated_by} updatedAt={ctx.view.embeddings?.updated_at} value={key.value as string | undefined} @@ -3421,6 +3572,7 @@ function SpeechProvidersBody({ ctx }: { ctx: BodyCtx }) { key={view?.updated_at ?? "none"} label={`${p.label} API key`} isSet={Boolean(((view?.values?.[`${p.id}_api_key`] ?? {}) as { set?: boolean }).set)} + saved={view?.values?.[`${p.id}_api_key`]} updatedBy={view?.updated_by} updatedAt={view?.updated_at} value={ctx.state(`speech.${p.id}_api_key`).value as string | undefined} diff --git a/nextjs-frontend/components/settings/fields.tsx b/nextjs-frontend/components/settings/fields.tsx index 2593ac6c2..6409e9cb5 100644 --- a/nextjs-frontend/components/settings/fields.tsx +++ b/nextjs-frontend/components/settings/fields.tsx @@ -1,10 +1,19 @@ "use client"; -import { KeyRound, Lock, LockOpen } from "lucide-react"; +import { KeyRound, KeySquare, Lock, LockOpen } from "lucide-react"; import { useEffect, useId, useRef, useState, type ReactNode } from "react"; import { ChoiceCards, Pills } from "@/components/settings/controls"; import { fieldId, type FieldSpec } from "@/components/settings/model"; +import { + isReference, + providerLabel, + ReferenceStatus, + savedReference, + useVaults, + VaultButton, + VaultPicker, +} from "@/components/settings/vault-picker"; import { Button } from "@/components/ui/button"; import { Checkbox, Input, Select, Switch, Textarea } from "@/components/ui/field"; import { absolute } from "@/lib/format"; @@ -168,7 +177,9 @@ export function SettingField({ /** * A write-only secret, in its three states (Settings ST3): not set · set ("updated by … on …", Clear, Replace) · - * replacing (Cancel). `value` undefined = unchanged, "" = clear, text = replace. + * replacing (Cancel). `value` undefined = unchanged, "" = clear, text = replace. A secret can also be a reference to a + * password manager's item (vaultwarden://Item/field, docs/secrets.md): `saved` is the field as Settings shows it, so a + * saved reference shows itself and whether it could be read; with a vault set up, "From Vaultwarden" picks one. */ export function SecretSetting({ label, @@ -180,6 +191,7 @@ export function SecretSetting({ placeholder = "Paste an API key", hint, focus = 0, + saved, }: { label: string; isSet: boolean; @@ -191,9 +203,15 @@ export function SecretSetting({ hint?: ReactNode; /** Changed to ask for a key now (a cloud provider was picked): the field takes the focus, replacing a saved key. */ focus?: number; + /** The saved field as Settings shows it ({set, ref, read, …}): a reference shows itself and its status. */ + saved?: unknown; }) { const id = useId(); const [replacing, setReplacing] = useState(false); + const [picking, setPicking] = useState(false); + const vault = useVaults()[0]; + const ref = isSet ? savedReference(saved) : null; + const typedRef = isReference(value); const box = "flex h-10 items-center gap-1.5 rounded-sm border pl-3 pr-1"; const showSet = isSet && !replacing && value === undefined; const input = useRef(null); @@ -224,10 +242,22 @@ export function SecretSetting({ ) : showSet ? (
- + {ref ? ( + + ) : ( + + )} - Set{updatedBy ? ` · updated by ${updatedBy}` : ""} - {updatedAt ? ` on ${absolute(updatedAt)}` : ""} + {ref ? ( + <> + From {providerLabel(ref.ref ?? "")} · {ref.ref} + + ) : ( + <> + Set{updatedBy ? ` · updated by ${updatedBy}` : ""} + {updatedAt ? ` on ${absolute(updatedAt)}` : ""} + + )}
)} + {picking && vault && !showSet && value !== "" && ( + { + setPicking(false); + onChange(r); + }} + /> + )}

{hint && <>{hint}. } - {showSet - ? "The value is never shown again, not even to admins." - : isSet && value !== "" - ? "The old key keeps working until you save." - : "Stored encrypted with the server’s key."} + {showSet && ref ? ( + <> + The value is never shown, not even to admins. + + ) : showSet ? ( + "The value is never shown again, not even to admins." + ) : typedRef ? ( + "Lens reads it from the vault when you save, and only the reference is kept." + ) : isSet && value !== "" ? ( + "The old key keeps working until you save." + ) : ( + "Stored encrypted with the server’s key." + )}

); diff --git a/nextjs-frontend/components/settings/find.ts b/nextjs-frontend/components/settings/find.ts index 68676c536..3f27463d4 100644 --- a/nextjs-frontend/components/settings/find.ts +++ b/nextjs-frontend/components/settings/find.ts @@ -18,7 +18,10 @@ export const SETTINGS_GROUPS: { label: string; sections: SectionId[] }[] = [ { label: "Speech and voices", sections: ["transcription", "speaker-separation", "voice-ids", "speech-providers"] }, { label: "Media and documents", sections: ["uploads", "documents", "video", "nsfw", "reports", "iiif"] }, { label: "Chat and email", sections: ["telegram", "slack", "bridge", "mailbox", "mail", "notifications"] }, - { label: "Security and access", sections: ["sign-in", "tokens", "encryption", "access", "remote-access", "https"] }, + { + label: "Security and access", + sections: ["sign-in", "tokens", "encryption", "secrets", "access", "remote-access", "https"], + }, { label: "Files and devices", sections: ["storage", "shares", "smb", "nfs", "fedora", "sensors"] }, { label: "System", diff --git a/nextjs-frontend/components/settings/model.ts b/nextjs-frontend/components/settings/model.ts index d0264b431..16157dfb5 100644 --- a/nextjs-frontend/components/settings/model.ts +++ b/nextjs-frontend/components/settings/model.ts @@ -81,6 +81,7 @@ export type SectionId = | "https" | "sign-in" | "encryption" + | "secrets" | "notifications" | "mail" | "bridge" @@ -226,6 +227,13 @@ export const SECTIONS: SectionSpec[] = [ description: "Whether the files Lens keeps (uploads, renditions, frames, reports, exports) are encrypted on disk with their namespace’s key. Vaults stay encrypted either way.", }, + { + id: "secrets", + label: "Secrets", + backend: ["secrets"], + description: + "Keep API keys, tokens and passwords in a Vaultwarden vault: any secret field can refer to an item there instead of holding it. Secrets saved in Lens stay the default.", + }, { id: "components", label: "Components", @@ -1157,6 +1165,55 @@ export const FIELDS: FieldSpec[] = [ hint: "Its JSON output must be on (search.formats: json in its settings.yml).", }, { section: "web", key: "api_key", label: "Search API key", kind: "secret" }, + // Secrets: a password manager secret fields can refer to (docs/secrets.md) + { + section: "secrets", + key: "vaultwarden_url", + label: "Vaultwarden address", + kind: "text", + nullable: true, + mono: true, + placeholder: "https://vault.example.com", + hint: "The address of your Vaultwarden server, as you open it in a browser.", + }, + { + section: "secrets", + key: "vaultwarden_email", + label: "Lens’s account", + kind: "text", + nullable: true, + placeholder: "lens@example.com", + hint: "The email of an account of Lens’s own on the vault: everything it holds, Lens can read.", + }, + { + section: "secrets", + key: "vaultwarden_client_id", + label: "API key client_id", + kind: "text", + nullable: true, + mono: true, + placeholder: "user.…", + hint: "In that account: Settings › Security › Keys › View API key.", + }, + { section: "secrets", key: "vaultwarden_client_secret", label: "API key client_secret", kind: "secret" }, + { section: "secrets", key: "vaultwarden_password", label: "Master password", kind: "secret" }, + { + section: "secrets", + key: "vaultwarden_folder", + label: "Folder Lens reads", + kind: "text", + hint: "Only the items in this folder can be referred to; put the ones Lens needs there, or share them into it.", + }, + { + section: "secrets", + key: "cache_minutes", + label: "Read values again after", + kind: "int", + min: 1, + max: 1440, + unit: "minutes", + hint: "Values are kept in memory this long, then read again in the background, so a key changed in the vault reaches Lens by itself.", + }, { section: "web", key: "results", @@ -3950,6 +4007,12 @@ export function crossErrors(values: Record): Record mx) e["diarize.max_speakers"] = "Max speakers can’t be below min speakers"; + const vault = values["secrets.vaultwarden_url"]; + if (typeof vault === "string" && vault && !/^https?:\/\/[^\s/?#@]+(\/[^\s?#]*)?$/i.test(vault)) + e["secrets.vaultwarden_url"] = "An http:// or https:// address, with no user name, password or query in it"; + const account = values["secrets.vaultwarden_email"]; + if (typeof account === "string" && account && !/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(account)) + e["secrets.vaultwarden_email"] = "The email address of the account Lens signs in as"; const hosts = values["server.allowed_hosts"] as string[] | undefined; if (hosts) { if (!hosts.length) e["server.allowed_hosts"] = "List at least one host name (or * for any)"; diff --git a/nextjs-frontend/components/settings/section.tsx b/nextjs-frontend/components/settings/section.tsx index 8ea07e52a..8c322676a 100644 --- a/nextjs-frontend/components/settings/section.tsx +++ b/nextjs-frontend/components/settings/section.tsx @@ -25,6 +25,7 @@ import { type SettingsView, } from "@/components/settings/model"; import { useUnsavedGuard } from "@/components/settings/use-unsaved-guard"; +import { SecretsProvider } from "@/components/settings/vault-picker"; import { Banner } from "@/components/ui/banner"; import { Button } from "@/components/ui/button"; import { Dialog } from "@/components/ui/dialog"; @@ -205,6 +206,7 @@ export function SettingsSection({ setServerErrors({}); setNsInitial(nsAccess); await qc.invalidateQueries({ queryKey: ["settings"] }); + if (specs.some((f) => f.kind === "secret")) void qc.invalidateQueries({ queryKey: ["secrets"] }); if (nsChanges.length) void qc.invalidateQueries({ queryKey: ["namespace-metadata"] }); toast({ title: `Saved ${spec.label}`, @@ -278,7 +280,10 @@ export function SettingsSection({ {banner} )} - + {/* the vault secret fields can refer to (Settings › Secrets); its own sign-in can't be a reference */} + f.kind === "secret")}> + + {id !== "startup" && (dirty || errorCount > 0) && ( diff --git a/nextjs-frontend/components/settings/settings-shell.tsx b/nextjs-frontend/components/settings/settings-shell.tsx index 050c05d1c..e7867b209 100644 --- a/nextjs-frontend/components/settings/settings-shell.tsx +++ b/nextjs-frontend/components/settings/settings-shell.tsx @@ -21,6 +21,7 @@ import { EyeOff, HardDrive, FileLock, + KeySquare, FileType, FolderTree, Gauge, @@ -99,6 +100,7 @@ const ICON: Record = { https: Lock, "sign-in": LockKeyhole, encryption: FileLock, + secrets: KeySquare, notifications: Bell, mail: Mail, bridge: MessagesSquare, diff --git a/nextjs-frontend/components/settings/vault-picker.tsx b/nextjs-frontend/components/settings/vault-picker.tsx new file mode 100644 index 000000000..4b0e39813 --- /dev/null +++ b/nextjs-frontend/components/settings/vault-picker.tsx @@ -0,0 +1,174 @@ +"use client"; + +/** + * Secret fields that refer to a password manager (docs/secrets.md): what a saved reference shows (its reference and + * whether the server could read it, never a value), and the picker that fills a field with a reference to one of the + * vault's items. Settings provides whether a vault is set up (SecretsProvider); outside it, there's no picker. + */ +import { useQuery } from "@tanstack/react-query"; +import { KeySquare } from "lucide-react"; +import { createContext, useContext, useState, type ReactNode } from "react"; + +import { Admin } from "@/app/openapi-client"; +import type { SecretProvider, VaultItem } from "@/app/openapi-client/types.gen"; +import { Button } from "@/components/ui/button"; +import { SearchInput } from "@/components/ui/field"; +import { data, useApiClient } from "@/lib/api/browser"; +import { relative } from "@/lib/format"; +import { cn } from "@/lib/utils"; + +/** A secret field's saved value as Settings shows it: set, and for a reference, the reference and its read status. */ +export type SavedSecret = { + set?: boolean; + ref?: string; + provider?: string; + read?: boolean | null; + error?: string | null; + read_at?: string | null; + missing?: boolean; +}; + +const SCHEMES = ["vaultwarden"]; + +/** Whether text is a reference to a password manager's item, like vaultwarden://OpenAI/password. */ +export function isReference(v: unknown): v is string { + if (typeof v !== "string") return false; + const m = /^\s*([a-z][a-z0-9+.-]*):\/\//i.exec(v); + return Boolean(m && SCHEMES.includes(m[1].toLowerCase())); +} + +export function savedReference(saved: unknown): SavedSecret | null { + const s = saved as SavedSecret | null | undefined; + return s && typeof s === "object" && typeof s.ref === "string" ? s : null; +} + +const LABELS: Record = { vaultwarden: "Vaultwarden" }; + +/** "Vaultwarden" for vaultwarden://… */ +export function providerLabel(ref: string): string { + const scheme = ref.split("://")[0].toLowerCase(); + return LABELS[scheme] ?? scheme; +} + +/** The status line under a saved reference: when it was read, or why not. */ +export function ReferenceStatus({ saved }: { saved: SavedSecret }) { + if (saved.read) + return ( + + Read from {providerLabel(saved.ref ?? "")} + {saved.read_at ? ` ${relative(saved.read_at)}` : ""}. + + ); + if (saved.read === false) + return Not read: {saved.error || "the vault didn’t answer"}.; + return Not read on this server yet.; +} + +type Vaults = { providers: SecretProvider[] }; +const SecretsContext = createContext(null); + +/** Whether a password manager is set up here, for the secret fields inside (only admins see Settings). */ +export function SecretsProvider({ enabled, children }: { enabled: boolean; children: ReactNode }) { + const client = useApiClient(); + const q = useQuery({ + queryKey: ["secrets"], + queryFn: () => data(Admin.getSecrets({ client })), + enabled, + staleTime: 60_000, + }); + return ( + + {children} + + ); +} + +/** The password managers set up, which a secret field can refer to. */ +export function useVaults(): SecretProvider[] { + const v = useContext(SecretsContext); + return (v?.providers ?? []).filter((p) => p.scheme && p.configured); +} + +/** The vault's items (names and field names, never values): pick a field, and its reference fills the secret. */ +export function VaultPicker({ provider, onPick }: { provider: SecretProvider; onPick: (ref: string) => void }) { + const client = useApiClient(); + const [q, setQ] = useState(""); + const items = useQuery({ + queryKey: ["secrets", "items", provider.id, q], + queryFn: () => + data(Admin.listVaultItems({ client, query: { provider: provider.id, q: q || undefined, limit: 50 } })), + staleTime: 30_000, + }); + const list: VaultItem[] = items.data?.items ?? []; + const first = list[0]; + const firstRef = first ? (first.ref ?? Object.values(first.refs ?? {})[0]) : undefined; + return ( +
+ setQ(e.target.value)} + onKeyDown={(e) => { + if (e.key === "Enter" && firstRef) { + e.preventDefault(); + onPick(firstRef); + } + }} + /> + {items.isPending ? ( +

Reading the vault…

+ ) : items.isError ? ( +

+ {items.error.message} +

+ ) : list.length === 0 ? ( +

+ {q ? `No item in ${provider.label}’s folder is called that.` : `${provider.label}’s folder has no items yet.`} +

+ ) : ( +
    + {list.map((it) => ( +
  • + {it.name} + {it.type} + {Object.entries(it.refs ?? {}).map(([field, ref]) => ( + + ))} +
  • + ))} +
+ )} +

Only the reference is saved. Lens reads the value from the vault.

+
+ ); +} + +/** The button beside a secret field that opens the picker, when a vault is set up. */ +export function VaultButton({ open, onClick }: { open: boolean; onClick: () => void }) { + const vaults = useVaults(); + if (!vaults.length) return null; + return ( + + ); +} From 897120a35e93fde4559743dbec6c41fd2a5baec1 Mon Sep 17 00:00:00 2001 From: Adeel Ahmad Date: Sun, 18 Oct 2026 07:50:40 +0000 Subject: [PATCH 2/2] docs(readme): list the assistant's answers about Lens itself as built #400 shipped in 0.15.0, so make requirements failed on main with it still under In progress. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_019okSDRfFHV74BTpMzinTFg --- README.md | 8 ++++---- docs/requirements.md | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ecde332da..8a3b932b2 100644 --- a/README.md +++ b/README.md @@ -88,11 +88,13 @@ listed under [In progress](#in-progress), and what comes next under [Planned](#p cost), opened from its header. It reads answers aloud with a speech provider, macOS `say` or StyleTTS2 on this machine (opt-in), any message in one click. Long conversations are summarised before they fill the model's context, and `/clear` and `/compact` start afresh or summarise now. Conversations title themselves after their first answer, unless - you name them. Each namespace can have its own assistant with - its own name, instructions and memory, answering in Telegram and Slack (built in, with voice notes and files), in + you name them. It answers questions about Lens itself, from its docs and this server. Each namespace can have its + own assistant with its own name, instructions and memory, answering in Telegram and Slack (built in, with voice + notes and files), in Discord, Matrix, WhatsApp and other chat rooms through Matterbridge, and by email at an address of its own that you email or forward things to. ([Chat](docs/assistant.md), [web search](docs/assistant.md#web-search-and-reading-pages), [mail, calendars and files](docs/assistant.md#mail-calendars-and-files), [code sandbox](docs/assistant.md#code-sandbox), [answer records](docs/assistant.md#what-each-answer-records), + [questions about Lens](docs/assistant.md#questions-about-lens-itself), [chat rooms](docs/chat-rooms.md), [email](docs/assistant-email.md), [speech providers](docs/speech-providers.md); [checks](docs/requirements.md#ask-and-get-cited-answers)) - **Extend the assistant.** Add tools (a prompt, a web request, a graph drawn on the canvas, or sandboxed Python), @@ -240,8 +242,6 @@ still loading. ([Components](docs/components.md), These are open pull requests, not yet part of Lens: -- **The assistant** answering questions about Lens itself, from its docs and this server - ([#400](https://github.com/adeelahmad/lense/pull/400)). - **Chat:** a conversation exported as Markdown, PDF or JSON ([#474](https://github.com/adeelahmad/lense/pull/474)). - **Pictures:** low-quality images enhanced before they're read ([#479](https://github.com/adeelahmad/lense/pull/479)). - **Web clipper:** signing in, or using your API token, not only an import webhook's diff --git a/docs/requirements.md b/docs/requirements.md index 5e592e93c..c5e1521f8 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -90,6 +90,7 @@ request, to another check that proves the same thing; loosening a requirement or | Any message read aloud in one click, one at a time, its audio kept so a replay costs nothing | [chat-read-aloud.test.tsx](https://github.com/adeelahmad/lense/blob/main/nextjs-frontend/__tests__/chat-read-aloud.test.tsx) `plays an answer by the speech model in one click, stops on the next, and keeps its audio`, `reads one message at a time: starting another stops the first`, `reads a long answer piece by piece, asking for the next while one plays` | | Conversations title themselves after their first answer, and a name you give is kept | [test_chat_titles.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_chat_titles.py) `test_a_first_answer_titles_the_conversation`, `test_a_title_you_give_is_kept`, `test_agents_rename_and_retitle_over_mcp` | | Long conversations summarised before they fill the model's context, and `/clear` and `/compact` | [test_compaction.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_compaction.py) `test_older_messages_are_folded_into_a_summary`, `test_the_context_window_is_the_model_servers`, `test_a_long_conversation_is_folded_in_runs_that_fit_the_summary_model`, `test_a_conversation_that_doesnt_fit_is_folded_in_and_asked_again`, `test_what_tools_returned_is_cut_to_fit_the_model`, `test_clear_starts_afresh_and_compact_folds_everything_now`, `test_commands_in_the_app`; [chat-summary-mark.test.tsx](https://github.com/adeelahmad/lense/blob/main/nextjs-frontend/__tests__/chat-summary-mark.test.tsx) `says how many messages the summary stands for, and shows it on request` | +| It answers questions about Lens itself, from its docs and this server, in chat and to agents over MCP | [test_lens_help.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_lens_help.py) `test_the_assistant_answers_about_lens_itself`, `test_admins_see_where_each_setting_is`, `test_agents_ask_lens_over_mcp` | | A namespace's own assistant, with its own name, instructions and memory | [test_ns_assistant.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_ns_assistant.py) `test_off_by_default_and_owners_turn_it_on`, `test_remembers_across_conversations_with_citations`; [ns-assistant.test.tsx](https://github.com/adeelahmad/lense/blob/main/nextjs-frontend/__tests__/ns-assistant.test.tsx) `saving a name and forgetting a memory` | | Telegram and Slack built in, with voice notes and files | [test_telegram.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_telegram.py) `test_it_answers_private_chats_and_what_is_said_to_it_in_groups`, `test_voice_notes_are_heard`, `test_files_are_held_for_the_assistant_to_import`; [test_slack.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_slack.py) `test_it_answers_direct_messages_mentions_and_the_slash_command`, `test_voice_clips_are_heard_and_files_held` | | Other chat rooms through Matterbridge | [test_bridge.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_bridge.py) `test_it_answers_what_is_said_to_it_and_nothing_else`; [test_matterbridge_run.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_matterbridge_run.py) `test_chat_networks_are_set_in_the_app_and_become_matterbridges_config`, `test_the_bridge_talks_to_the_matterbridge_lens_runs`; [matterbridge.yml](https://github.com/adeelahmad/lense/blob/main/.github/workflows/matterbridge.yml) `Lens writes a config, and Matterbridge starts with it` |