Compare commits

..
9 Commits
Author SHA1 Message Date
Andrew S Erwin 2ec157e160 Show the release version in the sidebar footer
release gate / check (push) Failing after 6m58s
release / smoke (push) Successful in 10m23s
release / publish (push) Failing after 9m50s
Baked at image build time: web/Dockerfile takes ARG SUPERBRAIN_VERSION
(default dev) into NEXT_PUBLIC_SUPERBRAIN_VERSION; the release workflow
passes the tag, README Option B gains the matching --build-arg, and local
compose builds show 'dev build'. Rendered muted under the sidebar footer
when expanded, so any deployment can be identified from the UI alone.
2026-11-05 13:26:12 -06:00
Andrew S Erwin 2e95190cac Record the 2026-11-03 auto-upgrader outage and the fix layers
release gate / check (push) Failing after 6m28s
upgrade-federated.timer redeployed superbrain and left it down: superbrain
is absent from EXTRA_APPS in the Core repo's lib/functions.sh, so
bin/start fell through to usage/exit 2 and upgrade_app printed Done over a
dead stack (traefik default 404 for the hostname). Carries the Core-repo
fix as a format-patch (no push access to Core from here), documents the
IMAGE_VERSION_HOLD pin and the erwin-local commit, and the migrate-ledger
aggravator (DB at 017 vs .env pinned 1.0.1).
2026-11-04 09:43:33 -06:00
Andrew S Erwin 9a6fbe0d3f release 1.2.3: bump federated service VERSION, installer image version and mcp package version
release gate / check (push) Failing after 6m55s
release / smoke (push) Successful in 10m24s
release / publish (push) Failing after 9m49s
2026-11-02 22:14:19 -06:00
Andrew S Erwin 3e0a9def1f Replace the dead default OpenRouter free model
recursive/flint-v1.0:free lost its upstreams (OpenRouter 503 'no upstreams
available'), so deployments that set only AI_API_KEY inherited a dead
default. DefaultModel and the BYO suggested-model list now use slugs
verified live on 2026-11-03; README/RUNNING examples updated. Deployments
with an explicit AI_MODEL (dev, core) were unaffected.
2026-11-02 22:14:19 -06:00
Andrew S Erwin ad9c351649 release 1.2.2: bump federated service VERSION, installer image version and mcp package version
release gate / check (push) Failing after 6m49s
release / smoke (push) Successful in 10m36s
release / publish (push) Failing after 9m54s
2026-11-02 21:56:51 -06:00
Andrew S Erwin 390b541b0a Add a visible Markdown formatting bar to pages and bookmark notes
Shared component (components/markdown-toolbar.tsx): bold/italic/
strikethrough/inline code/link with URL preselected, H1-H3, quote,
bullet/numbered/to-do line-prefix toggles across the selection, divider.
Mounted above the page editor textarea and the notes editor in the
bookmark detail sheet; the textarea stays the source of truth so
autosave/conflict handling and the notes save flow are untouched, and
the page slash menu remains as the keyboard path. Gitea issue #7.
2026-11-02 21:56:51 -06:00
Andrew S Erwin 6fbe5f23bf STRATEGY: copy-paste-ready suite-side snippets for the mcpserver link
release gate / check (push) Failing after 6m45s
Also records the product framing: the MCP attach is how the core's
already-configured AI (Superpanel -> Hermes) reaches Superbrain data with
zero per-app LLM config - apps expose tools, the house agent owns the LLM.
Superbrain's own AI features (automations/assistant) keep resolving BYO
first, then the plan-gated AI_* server env key.
2026-11-02 21:07:48 -06:00
Andrew S Erwin 9a9c3bb80d release 1.2.1: bump federated service VERSION, installer image version and mcp package version
release gate / check (push) Failing after 6m43s
release / smoke (push) Successful in 10m28s
release / publish (push) Failing after 10m0s
2026-11-02 14:49:57 -06:00
Andrew S Erwin ec33f64976 Start the UI in light mode by default
next-themes defaultTheme was 'dark'; first visit (no stored preference)
now renders light. The toggle and the persisted per-browser choice are
unchanged.
2026-11-02 14:49:57 -06:00
17 changed files with 290 additions and 24 deletions
+2
View File
@@ -117,6 +117,8 @@ jobs:
file: web/Dockerfile file: web/Dockerfile
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
# Bakes the release tag into the client bundle (sidebar footer).
build-args: SUPERBRAIN_VERSION=${{ github.ref_name }}
tags: | tags: |
federatedcomputer/superbrain-web:${{ github.ref_name }} federatedcomputer/superbrain-web:${{ github.ref_name }}
federatedcomputer/superbrain-web:latest federatedcomputer/superbrain-web:latest
+2 -1
View File
@@ -490,6 +490,7 @@ V=1.2.3
docker buildx build --platform linux/amd64,linux/arm64 --push \ docker buildx build --platform linux/amd64,linux/arm64 --push \
-t federatedcomputer/superbrain-app:$V -t federatedcomputer/superbrain-app:latest . -t federatedcomputer/superbrain-app:$V -t federatedcomputer/superbrain-app:latest .
docker buildx build --platform linux/amd64,linux/arm64 --push \ docker buildx build --platform linux/amd64,linux/arm64 --push \
--build-arg SUPERBRAIN_VERSION=$V \
-t federatedcomputer/superbrain-web:$V -t federatedcomputer/superbrain-web:latest web -t federatedcomputer/superbrain-web:$V -t federatedcomputer/superbrain-web:latest web
docker buildx build --platform linux/amd64,linux/arm64 --push \ docker buildx build --platform linux/amd64,linux/arm64 --push \
--build-context deploy=deploy/federated \ --build-context deploy=deploy/federated \
@@ -575,7 +576,7 @@ is off without it.
| Variable | Required | Default | Purpose | | Variable | Required | Default | Purpose |
|---|---|---|---| |---|---|---|---|
| `AI_API_KEY` | for the server-wide key | — | Operator fallback key; per-user BYO configs (Settings → AI) take precedence, and free/standard plans are BYO-only | | `AI_API_KEY` | for the server-wide key | — | Operator fallback key; per-user BYO configs (Settings → AI) take precedence, and free/standard plans are BYO-only |
| `AI_MODEL` | no | `recursive/flint-v1.0:free` | Any model the provider serves | | `AI_MODEL` | no | `nvidia/nemotron-3-ultra-550b-a55b:free` | Any model the provider serves |
| `AI_BASE_URL` | no | `https://openrouter.ai/api/v1` | Any OpenAI-compatible endpoint | | `AI_BASE_URL` | no | `https://openrouter.ai/api/v1` | Any OpenAI-compatible endpoint |
| `AI_PROVIDER` | no | `openai-compatible` | or `anthropic` / `gemini` | | `AI_PROVIDER` | no | `openai-compatible` | or `anthropic` / `gemini` |
+1 -1
View File
@@ -320,7 +320,7 @@ Gemini); who pays for the tokens is configuration:
```env ```env
AI_API_KEY=... # operator's key AI_API_KEY=... # operator's key
AI_MODEL=recursive/flint-v1.0:free # any model the provider serves AI_MODEL=nvidia/nemotron-3-ultra-550b-a55b:free # any model the provider serves
AI_BASE_URL=https://openrouter.ai/api/v1 # any OpenAI-compatible endpoint AI_BASE_URL=https://openrouter.ai/api/v1 # any OpenAI-compatible endpoint
AI_PROVIDER=openai-compatible # or anthropic / gemini AI_PROVIDER=openai-compatible # or anthropic / gemini
``` ```
+69 -11
View File
@@ -284,18 +284,76 @@ real API-key mechanism — is resolved. Superbrain now has:
so the gateway must talk to the app container directly — no traefik so the gateway must talk to the app container directly — no traefik
hairpin needed since the app speaks plain HTTP internally). hairpin needed since the app speaks plain HTTP internally).
Suite-side work items to finish the link (NOT in this repo): Suite-side work items to finish the link (NOT in this repo), copy-paste ready:
- `/federated/lib/mcpserver.sh`: add `superbrain` to `MCPSERVER_APPS` and - `/federated/lib/mcpserver.sh` — extend the app list and the env-var map
`mcpserver_app_env_var() { superbrain) echo "SUPERBRAIN_API_URL" ;; }` — (both load-bearing for restart/uninstall bookkeeping):
the restart/uninstall machinery keys off both.
- mcpserver image repo: add the `apps_registry.py` entry ```bash
(`"superbrain": {"required_env": "SUPERBRAIN_API_URL", MCPSERVER_APPS="listmonk nextcloud espocrm baserow bookstack n8n immich gitea plane erpnext kimai matomo wordpress vaultwarden superbrain"
"command": "superbrain-mcp", "args": []}`) and install the package into # in mcpserver_app_env_var():
the image (pipx like the other Python servers; publish `superbrain-mcp` superbrain) echo "SUPERBRAIN_API_URL" ;;
to PyPI or vendor it from the repo's `mcp/` directory). ```
- Then on a core: `/federated/bin/installapp-mcpserver superbrain` links it
and `mcphub`/Hermes pick the tools up like every other app. - mcpserver image repo — `/app/apps_registry.py` (shared by entrypoint.py and
hub_entrypoint.py) plus installing the package into the image (pipx like
the other Python servers; publish `superbrain-mcp` to PyPI or vendor it
from this repo's `mcp/`):
```python
"superbrain": {
"required_env": "SUPERBRAIN_API_URL",
"command": "superbrain-mcp",
"args": [],
},
```
- Then on a core: `/federated/bin/installapp mcpserver` (if the gateway is
not installed yet — the container stays down until the first app links)
and `/federated/bin/installapp-mcpserver superbrain`; `mcphub`/Hermes pick
the tools up like every other app. Product framing: this is how the
core's already-configured AI (Superpanel → Hermes) reaches Superbrain
data with zero per-app LLM config — apps expose tools, the house agent
owns the LLM. It does NOT enable Superbrain's own AI features
(automations/assistant); those still resolve per-user BYO first, then the
plan-gated `AI_*` server env key.
### Incident 2026-11-03: the auto-upgrader took superbrain down (and the fix)
`upgrade-federated.timer` (daily ~10:06, runs `/federated/bin/upgrade` with no
args, transcript in `/federated/logs/upgrade.log`) redeployed superbrain
(trigger: the then-new `update-superbrain` branch in the Core repo), removed
all three containers, then restarted via `/federated/bin/start superbrain` —
which fell through to `usage; exit 2` because **superbrain is absent from
`EXTRA_APPS` in `lib/functions.sh`** (the SERVICES registry). `upgrade_app`
ignored the exit status and printed "Done upgrading" over the dead stack;
traefik then answered its default 404 for the whole hostname until manual
recovery (~9 h). Aggravator: the DB ledger was already at 017 (a 1.2.0 migrate
had run during the Nov 2 operator session) while `.env` pinned 1.0.1, so any
restart attempt hit migrate.sh's "applied chain must stay complete" refusal.
Recovery: pinned `IMAGE_VERSION="1.2.0"` + restored the `AI_*` lines,
`compose up -d`.
Fix layers, outermost first:
1. **Pin (immediate, house mechanism):** `IMAGE_VERSION_HOLD=1` in
`/federated/apps/superbrain/.env` — `upgrade_app` returns before touching
anything. REMOVE once layer 3 lands and auto-upgrades are wanted again
(until then, upgrades are manual: `/federated/bin/upgrade superbrain`).
2. **erwin-local (defense in depth, live now):** commit `a1eae10` in the
host's `/federated` checkout adds superbrain to `EXTRA_APPS` and makes
`upgrade_app` check the start exit status + container liveness, alerting
via `send_matrix_alert` instead of printing success over a dead stack.
Verified: `/federated/bin/start superbrain` now dispatches ("already
running") instead of usage. **This commit cannot be pushed**: the box's
`installcore` token is pull-only (403) and andrew's account cannot even
read the Core repo — so erwin's suite master sits one commit ahead of
origin. When the maintainer merges the equivalent change, reset erwin's
`/federated` to origin/master to avoid a diverged pull.
3. **Core repo (permanent, all cores):** `core-fix-upgrade-superbrain.patch`
next to this document is `a1eae10` in `git format-patch` form — hand it to
the Core maintainer (the `update-superbrain` branch convention is the
house landing path for suite-side app changes).
### Not applicable ### Not applicable
@@ -0,0 +1,62 @@
From a1eae10112af01b9c35130fa69d149427a83a365 Mon Sep 17 00:00:00 2001
From: andrew <andrew@federated.computer>
Date: Wed, 4 Nov 2026 15:39:12 +0000
Subject: [PATCH] Register superbrain in EXTRA_APPS; fail upgrade_app when the
app does not come back up
The 2026-11-03 upgrade-federated.timer run stopped superbrain, then
/federated/bin/start superbrain fell through to usage/exit 2 because
superbrain was absent from SERVICES (CORE_APPS/EXTRA_APPS); upgrade_app
ignored the exit status and printed Done upgrading over a dead stack,
which left traefik answering its default 404 for the whole hostname.
- add superbrain to EXTRA_APPS so bin/start can dispatch it
- upgrade_app: after the post-redeploy start, check the exit status AND
that the primary container is actually running; otherwise
send_matrix_alert and return 1 instead of reporting success
---
lib/functions.sh | 7 ++++++-
services/superbrain/service | 2 +-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/functions.sh b/lib/functions.sh
index c00c444..9bd2fba 100644
--- a/lib/functions.sh
+++ b/lib/functions.sh
@@ -31,7 +31,7 @@
# Define all services
CORE_APPS=("pdnsmysql" "pdns" "pdnsadmin" "traefik" "postgresql" "ldap" "mail" "authelia")
-EXTRA_APPS=("collabora" "nextcloud" "matrix" "element" "listmonk" "vaultwarden" "panel" "wireguard" "jitsi" "baserow" "gitea" "caddy" "autodiscover" "castopod" "wordpress" "coturn" "bookstack" "freescout" "msp" "espocrm" "nginx" "matrixslack" "matrixsignal" "matrixwhatsapp" "dashboard" "jitsiopenid" "roundcube" "redis" "discourse" "wordpressshop" "plane" "calcom" "headscale" "headplane" "dittofeed" "kimai" "nodeexporter" "tailscale" "gitearunner" "nextcloudtalk" "clickhouseserver" "plausible" "docuseal" "mautic" "matomo" "superpanel" "n8n" "immich" "mcpserver" "erpnext" "hermes")
+EXTRA_APPS=("collabora" "nextcloud" "matrix" "element" "listmonk" "vaultwarden" "panel" "wireguard" "jitsi" "baserow" "gitea" "caddy" "autodiscover" "castopod" "wordpress" "coturn" "bookstack" "freescout" "msp" "espocrm" "nginx" "matrixslack" "matrixsignal" "matrixwhatsapp" "dashboard" "jitsiopenid" "roundcube" "redis" "discourse" "wordpressshop" "plane" "calcom" "headscale" "headplane" "dittofeed" "kimai" "nodeexporter" "tailscale" "gitearunner" "nextcloudtalk" "clickhouseserver" "plausible" "docuseal" "mautic" "matomo" "superpanel" "n8n" "immich" "mcpserver" "erpnext" "hermes" "superbrain")
SERVICES=("${CORE_APPS[@]}" "${EXTRA_APPS[@]}")
failts() {
@@ -345,6 +345,11 @@ upgrade_app() {
echo -ne "$APP was already shut down so we won't be starting it.\n"
else
/federated/bin/start $APP
+ if [ $? -ne 0 ] && [ "$(docker container inspect -f '{{.State.Running}}' $APP 2>/dev/null)" != "true" ]; then
+ send_matrix_alert "$DOMAIN ($EXTERNALIP): upgrade of $APP to $VERSION finished but the app did not come back up - investigate now, the service is likely DOWN"
+ echo -ne "ERROR: start $APP failed during upgrade - app may be DOWN, not reporting success.\n"
+ return 1
+ fi
if [ -x "/federated/services/${APP}/upgrade/post" ]; then
if ! /federated/services/${APP}/upgrade/post ${IMAGE_VERSION} ${VERSION}; then
echo "Post-upgrade script for ${APP} failed, verify the app still works"
diff --git a/services/superbrain/service b/services/superbrain/service
index 7ad6015..a6e9b31 100644
--- a/services/superbrain/service
+++ b/services/superbrain/service
@@ -2,7 +2,7 @@ NAME=Superbrain
DESCRIPTION="Bookmark & Knowledge Base"
DOCS=https://github.com/andrew/superbrain
CONTAINER=federatedcomputer/superbrain-app
-VERSION=1.0.1
+VERSION=1.2.0
INTERNAL_IP=192.168.0.93
DEPENDS="postgresql"
PORTS=3000
--
2.53.0
+1 -1
View File
@@ -48,7 +48,7 @@ SUPERBRAIN_APP_IP="192.168.0.94"
SUPERBRAIN_MIGRATE_IP="192.168.0.95" SUPERBRAIN_MIGRATE_IP="192.168.0.95"
# Release to install; the generic `upgrade` flow keeps .env in step with the # Release to install; the generic `upgrade` flow keeps .env in step with the
# service file's VERSION afterwards. # service file's VERSION afterwards.
SUPERBRAIN_IMAGE_VERSION="1.2.0" SUPERBRAIN_IMAGE_VERSION="1.2.3"
# render_superbrain_compose writes the app-dir compose file. Called by # render_superbrain_compose writes the app-dir compose file. Called by
# config_superbrain (install) and by deploy/federated/update.sh after a lib # config_superbrain (install) and by deploy/federated/update.sh after a lib
+1 -1
View File
@@ -2,7 +2,7 @@ NAME=superbrain
DESCRIPTION="Bookmark & Knowledge Base" DESCRIPTION="Bookmark & Knowledge Base"
DOCS=https://github.com/andrew/superbrain DOCS=https://github.com/andrew/superbrain
CONTAINER=federatedcomputer/superbrain-app CONTAINER=federatedcomputer/superbrain-app
VERSION=1.2.0 VERSION=1.2.3
INTERNAL_IP=192.168.0.93 INTERNAL_IP=192.168.0.93
DEPENDS="postgresql" DEPENDS="postgresql"
PORTS=3000 PORTS=3000
+5 -2
View File
@@ -42,8 +42,11 @@ import (
) )
// DefaultModel is the fallback for the server env config (OpenRouter free // DefaultModel is the fallback for the server env config (OpenRouter free
// tier). User configs always carry an explicit model. // tier). User configs always carry an explicit model. Free slugs rotate on
const DefaultModel = "recursive/flint-v1.0:free" // OpenRouter (recursive/flint-v1.0:free lost its upstreams around 2026-11);
// when swapping this, probe /api/v1/models for ":free" ids first — and note
// deployments that set AI_MODEL explicitly are unaffected either way.
const DefaultModel = "nvidia/nemotron-3-ultra-550b-a55b:free"
const defaultOpenAIBase = "https://openrouter.ai/api/v1" const defaultOpenAIBase = "https://openrouter.ai/api/v1"
+1 -1
View File
@@ -7,7 +7,7 @@ name = "superbrain-mcp"
# Versioned in lockstep with the Superbrain release it speaks to (house # Versioned in lockstep with the Superbrain release it speaks to (house
# tooling tracks one version per app); the federated mcpserver gateway # tooling tracks one version per app); the federated mcpserver gateway
# installs this package and spawns `superbrain-mcp` per linked instance. # installs this package and spawns `superbrain-mcp` per linked instance.
version = "1.2.0" version = "1.2.3"
description = "MCP server for Superbrain — bookmarks, tags and pages over the Superbrain REST API" description = "MCP server for Superbrain — bookmarks, tags and pages over the Superbrain REST API"
readme = "README.md" readme = "README.md"
requires-python = ">=3.10" requires-python = ">=3.10"
+1 -1
View File
@@ -1,3 +1,3 @@
"""Superbrain MCP server — bookmarks, tags and pages for AI tooling.""" """Superbrain MCP server — bookmarks, tags and pages for AI tooling."""
__version__ = "1.2.0" __version__ = "1.2.3"
+5 -1
View File
@@ -8,7 +8,11 @@ FROM node:22.23.3-alpine3.24 AS build
WORKDIR /app WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules COPY --from=deps /app/node_modules ./node_modules
COPY . . COPY . .
ENV NEXT_TELEMETRY_DISABLED=1 # Release version baked into the client bundle (sidebar footer). The release
# workflow passes the tag as SUPERBRAIN_VERSION; every other build keeps the
# default and the UI shows "dev build".
ARG SUPERBRAIN_VERSION=dev
ENV NEXT_TELEMETRY_DISABLED=1 NEXT_PUBLIC_SUPERBRAIN_VERSION=$SUPERBRAIN_VERSION
RUN yarn build RUN yarn build
FROM node:22.23.3-alpine3.24 AS runtime FROM node:22.23.3-alpine3.24 AS runtime
+2
View File
@@ -17,6 +17,7 @@ import { Textarea } from '@/components/ui/textarea'
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog' import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover' import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
import { MarkdownToolbar } from '@/components/markdown-toolbar'
import { PageAutosave, PageConflictError, type PageSaveState } from '@/lib/page-autosave' import { PageAutosave, PageConflictError, type PageSaveState } from '@/lib/page-autosave'
import { import {
PAGES_CHANGED, collectionEmbedMarkdown, descendantPageIds, internalPageId, nextUntitledTitle, PAGES_CHANGED, collectionEmbedMarkdown, descendantPageIds, internalPageId, nextUntitledTitle,
@@ -822,6 +823,7 @@ export function PagesClient({ initialId }: { initialId: string | null }) {
{mode === 'edit' ? ( {mode === 'edit' ? (
<div className="relative"> <div className="relative">
<MarkdownToolbar textareaRef={textareaRef} value={content} onChange={onContentChange} className="mb-2" />
<Textarea <Textarea
ref={textareaRef} ref={textareaRef}
value={content} value={content}
+1 -1
View File
@@ -34,7 +34,7 @@ const PROVIDERS: Record<string, { label: string; defaultBase: string; models: st
'openai-compatible': { 'openai-compatible': {
label: 'OpenAI-compatible (OpenRouter, OpenAI, Grok, Groq, Ollama, …)', label: 'OpenAI-compatible (OpenRouter, OpenAI, Grok, Groq, Ollama, …)',
defaultBase: 'https://openrouter.ai/api/v1', defaultBase: 'https://openrouter.ai/api/v1',
models: ['gpt-4o-mini', 'gpt-4o', 'recursive/flint-v1.0:free'], models: ['gpt-4o-mini', 'gpt-4o', 'nvidia/nemotron-3-ultra-550b-a55b:free', 'google/gemma-4-31b-it:free'],
}, },
anthropic: { anthropic: {
label: 'Anthropic (Claude)', label: 'Anthropic (Claude)',
+7 -2
View File
@@ -1,6 +1,6 @@
'use client' 'use client'
import { useState, useEffect, useCallback } from 'react' import { useState, useEffect, useCallback, useRef } from 'react'
import { Sheet, SheetContent, SheetHeader, SheetTitle } from '@/components/ui/sheet' import { Sheet, SheetContent, SheetHeader, SheetTitle } from '@/components/ui/sheet'
import { Button } from '@/components/ui/button' import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input' import { Input } from '@/components/ui/input'
@@ -11,6 +11,7 @@ import { toast } from 'sonner'
import type { Bookmark } from '@/components/app-shell' import type { Bookmark } from '@/components/app-shell'
import ReactMarkdown from 'react-markdown' import ReactMarkdown from 'react-markdown'
import remarkGfm from 'remark-gfm' import remarkGfm from 'remark-gfm'
import { MarkdownToolbar } from '@/components/markdown-toolbar'
import { BookmarkExtras } from '@/components/bookmark-extras' import { BookmarkExtras } from '@/components/bookmark-extras'
import { fetchReference } from '@/lib/reference-data' import { fetchReference } from '@/lib/reference-data'
import { format } from 'date-fns' import { format } from 'date-fns'
@@ -22,6 +23,7 @@ interface Props {
} }
export function BookmarkDetailSheet({ bookmark, onClose, onUpdate }: Props) { export function BookmarkDetailSheet({ bookmark, onClose, onUpdate }: Props) {
const notesRef = useRef<HTMLTextAreaElement>(null)
const [editing, setEditing] = useState(false) const [editing, setEditing] = useState(false)
const [notes, setNotes] = useState('') const [notes, setNotes] = useState('')
const [kanban, setKanban] = useState('INBOX') const [kanban, setKanban] = useState('INBOX')
@@ -261,7 +263,10 @@ export function BookmarkDetailSheet({ bookmark, onClose, onUpdate }: Props) {
</Button> </Button>
</div> </div>
{editing ? ( {editing ? (
<Textarea value={notes} onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => setNotes(e.target.value)} rows={6} placeholder="Markdown notes..." /> <div className="space-y-2">
<MarkdownToolbar textareaRef={notesRef} value={notes} onChange={setNotes} />
<Textarea ref={notesRef} value={notes} onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => setNotes(e.target.value)} rows={6} placeholder="Markdown notes..." />
</div>
) : ( ) : (
<div className="prose prose-sm dark:prose-invert max-w-none rounded-lg bg-muted/50 p-3 min-h-[60px]"> <div className="prose prose-sm dark:prose-invert max-w-none rounded-lg bg-muted/50 p-3 min-h-[60px]">
{notes ? <ReactMarkdown remarkPlugins={[remarkGfm]}>{notes}</ReactMarkdown> : <span className="text-muted-foreground text-xs">No notes</span>} {notes ? <ReactMarkdown remarkPlugins={[remarkGfm]}>{notes}</ReactMarkdown> : <span className="text-muted-foreground text-xs">No notes</span>}
+118
View File
@@ -0,0 +1,118 @@
'use client'
// Shared Markdown formatting bar (Gitea-issue #7): a visible, always-there
// toolbar for Markdown textareas — pages AND bookmark notes. The slash menu
// in the page editor stays (keyboard path); this is the discoverable mouse
// path david asked for ("the / menu may be missed").
//
// The textarea remains the source of truth: every action rewrites the value
// through the parent's onChange and restores focus/selection afterwards, so
// autosave, conflict handling and the notes save flow are untouched.
import { useEffect, useRef } from 'react'
import { Button } from '@/components/ui/button'
import {
Bold, Code, Heading1, Heading2, Heading3, Italic, Link2, List, ListOrdered,
ListTodo, Minus, Quote, Strikethrough,
} from 'lucide-react'
type Props = {
textareaRef: React.RefObject<HTMLTextAreaElement | null>
value: string
onChange: (next: string) => void
className?: string
}
type Sel = [number, number]
export function MarkdownToolbar({ textareaRef, value, onChange, className }: Props) {
// Selection to restore once the rewritten value reaches the textarea.
const pendingSel = useRef<Sel | null>(null)
useEffect(() => {
const sel = pendingSel.current
const ta = textareaRef.current
if (!sel || !ta) return
pendingSel.current = null
ta.focus()
ta.setSelectionRange(sel[0], sel[1])
}, [value, textareaRef])
const currentSel = (): Sel => {
const ta = textareaRef.current
if (ta) return [ta.selectionStart, ta.selectionEnd]
return [value.length, value.length]
}
const commit = (next: string, sel: Sel) => {
pendingSel.current = sel
onChange(next)
}
// Wrap the selection (or an inserted placeholder) in a marker pair.
const wrap = (marker: string, placeholder: string) => {
const [s, e] = currentSel()
const inner = value.slice(s, e) || placeholder
const next = value.slice(0, s) + marker + inner + marker + value.slice(e)
commit(next, [s + marker.length, s + marker.length + inner.length])
}
// Toggle a line prefix on every line the selection touches.
const linePrefix = (prefix: string) => {
const [s, e] = currentSel()
const start = value.lastIndexOf('\n', Math.max(0, s - 1)) + 1
const endIdx = value.indexOf('\n', e)
const end = endIdx === -1 ? value.length : endIdx
const block = value.slice(start, end)
const lines = block.split('\n')
const allHave = lines.every((l) => l.startsWith(prefix))
const nextBlock = lines
.map((l) => (allHave ? l.slice(prefix.length) : (l.startsWith(prefix) ? l : prefix + l)))
.join('\n')
const next = value.slice(0, start) + nextBlock + value.slice(end)
commit(next, [start, start + nextBlock.length])
}
// Insert a standalone block at the caret with blank-line padding.
const insertBlock = (snippet: string) => {
const [s] = currentSel()
const before = value.slice(0, s)
const after = value.slice(s)
const lead = before && !before.endsWith('\n') ? '\n\n' : ''
const trail = after.startsWith('\n') ? '' : '\n'
const next = before + lead + snippet + trail + after
const at = before.length + lead.length + snippet.length
commit(next, [at, at])
}
const link = () => {
const [s, e] = currentSel()
const label = value.slice(s, e) || 'label'
const snippet = `[${label}](https://)`
const next = value.slice(0, s) + snippet + value.slice(e)
// Select the URL part so typing replaces it.
const urlStart = s + label.length + 3
commit(next, [urlStart, urlStart + 8])
}
const btn = 'h-7 w-7 p-0 text-muted-foreground hover:text-foreground'
return (
<div className={`flex flex-wrap items-center gap-0.5 rounded-md border bg-muted/40 p-1 ${className ?? ''}`} role="toolbar" aria-label="Markdown formatting">
<Button type="button" variant="ghost" size="sm" className={btn} aria-label="Bold" title="Bold" onMouseDown={(e) => e.preventDefault()} onClick={() => wrap('**', 'bold text')}><Bold className="h-3.5 w-3.5" /></Button>
<Button type="button" variant="ghost" size="sm" className={btn} aria-label="Italic" title="Italic" onMouseDown={(e) => e.preventDefault()} onClick={() => wrap('*', 'italic text')}><Italic className="h-3.5 w-3.5" /></Button>
<Button type="button" variant="ghost" size="sm" className={btn} aria-label="Strikethrough" title="Strikethrough" onMouseDown={(e) => e.preventDefault()} onClick={() => wrap('~~', 'struck text')}><Strikethrough className="h-3.5 w-3.5" /></Button>
<Button type="button" variant="ghost" size="sm" className={btn} aria-label="Inline code" title="Inline code" onMouseDown={(e) => e.preventDefault()} onClick={() => wrap('`', 'code')}><Code className="h-3.5 w-3.5" /></Button>
<Button type="button" variant="ghost" size="sm" className={btn} aria-label="Link" title="Link" onMouseDown={(e) => e.preventDefault()} onClick={link}><Link2 className="h-3.5 w-3.5" /></Button>
<span className="mx-1 h-4 w-px bg-border" aria-hidden />
<Button type="button" variant="ghost" size="sm" className={btn} aria-label="Heading 1" title="Heading 1" onMouseDown={(e) => e.preventDefault()} onClick={() => linePrefix('# ')}><Heading1 className="h-3.5 w-3.5" /></Button>
<Button type="button" variant="ghost" size="sm" className={btn} aria-label="Heading 2" title="Heading 2" onMouseDown={(e) => e.preventDefault()} onClick={() => linePrefix('## ')}><Heading2 className="h-3.5 w-3.5" /></Button>
<Button type="button" variant="ghost" size="sm" className={btn} aria-label="Heading 3" title="Heading 3" onMouseDown={(e) => e.preventDefault()} onClick={() => linePrefix('### ')}><Heading3 className="h-3.5 w-3.5" /></Button>
<Button type="button" variant="ghost" size="sm" className={btn} aria-label="Quote" title="Quote" onMouseDown={(e) => e.preventDefault()} onClick={() => linePrefix('> ')}><Quote className="h-3.5 w-3.5" /></Button>
<span className="mx-1 h-4 w-px bg-border" aria-hidden />
<Button type="button" variant="ghost" size="sm" className={btn} aria-label="Bulleted list" title="Bulleted list" onMouseDown={(e) => e.preventDefault()} onClick={() => linePrefix('- ')}><List className="h-3.5 w-3.5" /></Button>
<Button type="button" variant="ghost" size="sm" className={btn} aria-label="Numbered list" title="Numbered list" onMouseDown={(e) => e.preventDefault()} onClick={() => linePrefix('1. ')}><ListOrdered className="h-3.5 w-3.5" /></Button>
<Button type="button" variant="ghost" size="sm" className={btn} aria-label="To-do list" title="To-do list" onMouseDown={(e) => e.preventDefault()} onClick={() => linePrefix('- [ ] ')}><ListTodo className="h-3.5 w-3.5" /></Button>
<Button type="button" variant="ghost" size="sm" className={btn} aria-label="Divider" title="Divider" onMouseDown={(e) => e.preventDefault()} onClick={() => insertBlock('---\n')}><Minus className="h-3.5 w-3.5" /></Button>
</div>
)
}
+1 -1
View File
@@ -8,7 +8,7 @@ import { ChunkLoadErrorHandler } from '@/components/chunk-load-error-handler'
export function Providers({ children }: { children: React.ReactNode }) { export function Providers({ children }: { children: React.ReactNode }) {
return ( return (
<SessionProvider> <SessionProvider>
<ThemeProvider attribute="class" defaultTheme="dark" enableSystem disableTransitionOnChange> <ThemeProvider attribute="class" defaultTheme="light" enableSystem disableTransitionOnChange>
{children} {children}
<Toaster /> <Toaster />
<ChunkLoadErrorHandler /> <ChunkLoadErrorHandler />
+11
View File
@@ -3,6 +3,12 @@
import Link from 'next/link' import Link from 'next/link'
import { useRouter, useSearchParams } from 'next/navigation' import { useRouter, useSearchParams } from 'next/navigation'
import { Suspense, useCallback, useEffect, useRef, useState, useSyncExternalStore } from 'react' import { Suspense, useCallback, useEffect, useRef, useState, useSyncExternalStore } from 'react'
// Release version baked into the client bundle at image build time
// (web/Dockerfile ARG SUPERBRAIN_VERSION; CI passes the tag, local builds
// keep "dev"). Shown in the sidebar footer so any deployment can be
// identified from the UI alone.
const APP_VERSION = process.env.NEXT_PUBLIC_SUPERBRAIN_VERSION || ''
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
import { import {
Calendar, Tags, Users, Kanban, Link2, Settings, ChevronLeft, ChevronRight, ChevronDown, Calendar, Tags, Users, Kanban, Link2, Settings, ChevronLeft, ChevronRight, ChevronDown,
@@ -110,6 +116,11 @@ export function Sidebar({ open, onToggle, onQuickFind, pathname, isAdmin = false
<Button variant="ghost" size="icon-sm" onClick={onToggle} className="w-full" aria-label={open ? 'Collapse sidebar' : 'Expand sidebar'}> <Button variant="ghost" size="icon-sm" onClick={onToggle} className="w-full" aria-label={open ? 'Collapse sidebar' : 'Expand sidebar'}>
{open ? <ChevronLeft className="h-4 w-4" /> : <ChevronRight className="h-4 w-4" />} {open ? <ChevronLeft className="h-4 w-4" /> : <ChevronRight className="h-4 w-4" />}
</Button> </Button>
{open && APP_VERSION && (
<p className="px-3 pt-0.5 text-[10px] text-muted-foreground/70 select-none" title={`Superbrain ${APP_VERSION}`}>
{APP_VERSION === 'dev' ? 'dev build' : `v${APP_VERSION}`}
</p>
)}
</div> </div>
</aside> </aside>
) )