Self-hosted MCP server + dashboard giving Claude Code, Cursor & Hermes agents shared long-term memory over a git-backed markdown vault. Agent-native, Obsidian-compatible second brain — markdown RAG, no vector DB.
TypeScript agent-memoryai-agentsanthropicclaude-codecursorgitknowledge-baseknowledge-graphllmmarkdownmcpmcp-servermodel-context-protocolnote-takingobsidianpkmragsecond-brainself-hostedzettelkasten
fix(mobile): merge nav bars, shrinkable recents, token dialog, agent dropdown
Ronalds Palacis4db8ab367137
diff --git a/app/(app)/connect/page.tsx b/app/(app)/connect/page.tsxindex d212b8b..9701b89 100644--- a/app/(app)/connect/page.tsx+++ b/app/(app)/connect/page.tsx@@ -2,9 +2,11 @@import { useEffect, useState } from "react";import useSWR, { useSWRConfig } from "swr";-import { Check, Copy, Trash2 } from "lucide-react";+import { Check, Copy, Plus, Trash2 } from "lucide-react";import { fetcher } from "@/lib/client";import { cn } from "@/lib/utils";+import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";function Copyable({ text }: { text: string }) {const [copied, setCopied] = useState(false);@@ -38,6 +40,66 @@ interface TokenMeta {scope: TokenScope;}+/** The name + scope + create controls, shared by the inline (desktop) and dialog (mobile) forms. */+function TokenFields({+ newName,+ setNewName,+ scope,+ setScope,+ creating,+ onCreate,+ className,+}: {+ newName: string;+ setNewName: (v: string) => void;+ scope: TokenScope;+ setScope: (s: TokenScope) => void;+ creating: boolean;+ onCreate: () => void;+ className?: string;+}) {+ return (+ <div className={cn("flex flex-col gap-2 sm:flex-row sm:items-center", className)}>+ <input+ value={newName}+ onChange={(e) => setNewName(e.target.value)}+ onKeyDown={(e) => e.key === "Enter" && onCreate()}+ placeholder="Token name"+ className="min-w-0 flex-1 rounded-md border border-border bg-background px-2.5 py-1.5 text-sm outline-none placeholder:text-muted-foreground sm:w-56 sm:flex-none"+ />+ <div className="flex items-center gap-2">+ <div className="inline-flex shrink-0 rounded-md border border-border p-0.5" role="group" aria-label="Token scope">+ {(["read", "write"] as const).map((sc) => (+ <button+ key={sc}+ type="button"+ onClick={() => setScope(sc)}+ title={+ sc === "read"+ ? "The agent can search and read your notes, but cannot change them."+ : "The agent can create, edit, move and delete notes."+ }+ className={cn(+ "rounded px-3 py-1.5 text-xs font-medium capitalize transition-colors",+ scope === sc ? "bg-foreground text-background" : "text-muted-foreground hover:text-foreground",+ )}+ >+ {sc}+ </button>+ ))}+ </div>+ <button+ onClick={onCreate}+ disabled={creating}+ className="rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground disabled:opacity-50"+ >+ {creating ? "Creating…" : "Create"}+ </button>+ </div>+ </div>+ );+}+export default function ConnectPage() {const [origin, setOrigin] = useState("");useEffect(() => setOrigin(window.location.origin), []);@@ -49,14 +111,37 @@ export default function ConnectPage() {const [creating, setCreating] = useState(false);const [justCreated, setJustCreated] = useState<{ name: string; token: string } | null>(null);const [scope, setScope] = useState<TokenScope>("write");+ const [dialogOpen, setDialogOpen] = useState(false);+ const [agent, setAgent] = useState("claude-code");const mcp = origin ? `${origin}/api/mcp` : "…";const needsToken = feat?.mcpAuthRequired !== false;const tokenForCmd = justCreated?.token ?? "<MCP_TOKEN>";const tokenLine = needsToken || justCreated ? ` \\\n --header "Authorization: Bearer ${tokenForCmd}"` : "";const claudeCmd = `claude mcp add --transport http engram ${mcp}${tokenLine}`;+ const jsonConfig = `{+ "mcpServers": {+ "engram": {+ "url": "${mcp}",+ "headers": { "Authorization": "Bearer ${tokenForCmd}" }+ }+ }+}`;const hermes = `mcp_servers:\n engram:\n url: ${mcp}\n headers:\n Authorization: "Bearer ${tokenForCmd}"`;+ // One dropdown, one set of instructions — beats a wall of near-identical config blocks.+ const AGENTS: { id: string; label: string; instruction: React.ReactNode; snippet: string }[] = [+ { id: "claude-code", label: "Claude Code", instruction: "Run in a terminal, then the brain_* tools are available in your sessions:", snippet: claudeCmd },+ { id: "cursor", label: "Cursor", instruction: <>Add to <code className="rounded bg-muted px-1">~/.cursor/mcp.json</code> (or a project <code className="rounded bg-muted px-1">.cursor/mcp.json</code>):</>, snippet: jsonConfig },+ { id: "claude-desktop", label: "Claude Desktop", instruction: <>Settings → Developer → Edit Config, add to <code className="rounded bg-muted px-1">claude_desktop_config.json</code>:</>, snippet: jsonConfig },+ { id: "windsurf", label: "Windsurf", instruction: <>Add to <code className="rounded bg-muted px-1">~/.codeium/windsurf/mcp_config.json</code>:</>, snippet: jsonConfig },+ { id: "cline", label: "Cline", instruction: "Cline → MCP Servers → Configure, add:", snippet: jsonConfig },+ { id: "hermes", label: "Hermes", instruction: <>Add to <code className="rounded bg-muted px-1">~/.hermes/config.yaml</code>:</>, snippet: hermes },+ { id: "codex", label: "Codex", instruction: <>Add an HTTP MCP server pointing at the endpoint below, with header <code className="rounded bg-muted px-1">Authorization: Bearer <token></code>.</>, snippet: mcp },+ { id: "other", label: "Other MCP client", instruction: <>Add a streamable-HTTP MCP server with this URL{needsToken || justCreated ? <> and header <code className="rounded bg-muted px-1">Authorization: Bearer <token></code></> : null}:</>, snippet: mcp },+ ];+ const selected = AGENTS.find((a) => a.id === agent) ?? AGENTS[0];+async function create() {if (creating) return;setCreating(true);@@ -69,6 +154,7 @@ export default function ConnectPage() {const d = await res.json();if (d.token) setJustCreated({ name: d.name, token: d.token });setNewName("");+ setDialogOpen(false);mutate("/api/tokens");mutate("/api/features");} finally {@@ -83,10 +169,11 @@ export default function ConnectPage() {}const tokens = tokData?.tokens ?? [];+ const fieldProps = { newName, setNewName, scope, setScope, creating, onCreate: create };return (<div className="scrollbar-none h-full overflow-y-auto">- <div className="mx-auto max-w-3xl px-8 py-10">+ <div className="mx-auto max-w-3xl px-4 py-8 sm:px-8 sm:py-10"><h1 className="text-2xl font-semibold tracking-tight">Connect an agent</h1><p className="mt-2 max-w-xl text-sm text-muted-foreground">Point any MCP client at this brain. Agents read + write over the tools — nothing keeps a@@ -103,41 +190,22 @@ export default function ConnectPage() {</p></div>- <div className="flex gap-2">- <input- value={newName}- onChange={(e) => setNewName(e.target.value)}- onKeyDown={(e) => e.key === "Enter" && create()}- placeholder="Token name"- className="w-56 rounded-md border border-border bg-background px-2.5 py-1.5 text-sm outline-none placeholder:text-muted-foreground"- />- <div className="inline-flex shrink-0 rounded-md border border-border p-0.5" role="group" aria-label="Token scope">- {(["read", "write"] as const).map((sc) => (- <button- key={sc}- type="button"- onClick={() => setScope(sc)}- title={- sc === "read"- ? "The agent can search and read your notes, but cannot change them."- : "The agent can create, edit, move and delete notes."- }- className={cn(- "rounded px-3 py-1.5 text-xs font-medium capitalize transition-colors",- scope === sc ? "bg-foreground text-background" : "text-muted-foreground hover:text-foreground",- )}- >- {sc}+ {/* Inline creator on desktop; a button + dialog on mobile. */}+ <TokenFields {...fieldProps} className="hidden md:flex" />+ <div className="md:hidden">+ <Dialog open={dialogOpen} onOpenChange={setDialogOpen}>+ <DialogTrigger asChild>+ <button className="inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground">+ <Plus size={15} /> New token</button>- ))}- </div>- <button- onClick={create}- disabled={creating}- className="rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground disabled:opacity-50"- >- {creating ? "Creating…" : "Create token"}- </button>+ </DialogTrigger>+ <DialogContent>+ <DialogHeader>+ <DialogTitle>New access token</DialogTitle>+ </DialogHeader>+ <TokenFields {...fieldProps} />+ </DialogContent>+ </Dialog></div>{justCreated && (@@ -150,13 +218,13 @@ export default function ConnectPage() {)}{tokens.length > 0 ? (- <div className="overflow-hidden rounded-lg border border-border">+ <div className="overflow-x-auto rounded-lg border border-border"><table className="w-full text-sm"><thead><tr className="border-b border-border text-left text-xs text-muted-foreground"><th className="px-3 py-2 font-medium">Name</th><th className="px-3 py-2 font-medium">Scope</th>- <th className="px-3 py-2 font-medium">Created</th>+ <th className="hidden px-3 py-2 font-medium sm:table-cell">Created</th><th className="px-3 py-2 text-right font-medium">Revoke</th></tr></thead>@@ -169,7 +237,7 @@ export default function ConnectPage() {{t.scope === "read" ? "read-only" : "read & write"}</span></td>- <td className="px-3 py-2 text-muted-foreground">{new Date(t.created).toLocaleDateString()}</td>+ <td className="hidden px-3 py-2 text-muted-foreground sm:table-cell">{new Date(t.created).toLocaleDateString()}</td><td className="px-3 py-2 text-right"><buttononClick={() => revoke(t.id)}@@ -191,31 +259,23 @@ export default function ConnectPage() {)}</section>- <section className="mt-8 space-y-2">- <h2 className="text-sm font-medium">MCP endpoint</h2>- <Copyable text={mcp} />- </section>-- <section className="mt-6 space-y-2">- <h2 className="text-sm font-medium">Claude Code</h2>- <Copyable text={claudeCmd} />- <p className="text-xs text-muted-foreground">Run in a terminal; then the brain_* tools are available in your Claude Code sessions.</p>- </section>-- <section className="mt-6 space-y-2">- <h2 className="text-sm font-medium">Hermes — ~/.hermes/config.yaml</h2>- <Copyable text={hermes} />- </section>-- <section className="mt-6 space-y-2">- <h2 className="text-sm font-medium">Cursor / other MCP clients</h2>- <p className="text-sm text-muted-foreground">- Add an HTTP MCP server with URL <code className="rounded bg-muted px-1">{mcp}</code>- {(needsToken || justCreated) && (- <> and header <code className="rounded bg-muted px-1">Authorization: Bearer <token></code></>- )}- .- </p>+ {/* One dropdown instead of a section per client. */}+ <section className="mt-8 space-y-3">+ <div className="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">+ <h2 className="text-sm font-medium">Connect</h2>+ <Select value={agent} onValueChange={setAgent}>+ <SelectTrigger className="w-full sm:w-56">+ <SelectValue placeholder="Choose your agent" />+ </SelectTrigger>+ <SelectContent>+ {AGENTS.map((a) => (+ <SelectItem key={a.id} value={a.id}>{a.label}</SelectItem>+ ))}+ </SelectContent>+ </Select>+ </div>+ <p className="text-sm text-muted-foreground">{selected.instruction}</p>+ <Copyable text={selected.snippet} /></section></div></div>diff --git a/components/recent-notes.tsx b/components/recent-notes.tsxindex 7b75857..27cbd0d 100644--- a/components/recent-notes.tsx+++ b/components/recent-notes.tsx@@ -26,7 +26,7 @@ export function RecentNotes({ heading = "Jump back in", limit = 6 }: { heading?:key={r.path}href={`/n/${r.path}`}data-nav-item- className={`flex items-center gap-2.5 rounded-lg border border-border bg-card px-3 py-2 transition-colors hover:border-ring ${navItemClass}`}+ className={`flex min-w-0 items-center gap-2.5 rounded-lg border border-border bg-card px-3 py-2 transition-colors hover:border-ring ${navItemClass}`}><span className="size-1.5 shrink-0 rounded-full" style={{ background: folderColor(folder) }} /><span className="min-w-0 flex-1">diff --git a/components/sidebar.tsx b/components/sidebar.tsxindex b091e52..ebee8f5 100644--- a/components/sidebar.tsx+++ b/components/sidebar.tsx@@ -79,17 +79,18 @@ export function Sidebar() {return (<aside className="flex h-dvh w-64 shrink-0 flex-col border-r border-border bg-sidebar">- <div className="flex h-12 shrink-0 items-center gap-2 px-3">+ {/* Hidden on mobile — the mobile top bar already shows the app name + search. */}+ <div className="hidden h-12 shrink-0 items-center gap-2 px-3 md:flex"><div className="size-2 rounded-full bg-primary" /><span className="text-sm font-medium tracking-tight">{appName}</span></div><WorkspaceSwitcher />- <div className="flex gap-1 px-2 pb-2">+ <div className="flex gap-1 px-2 pb-2 pt-2 md:pt-0"><buttononClick={() => (window as unknown as { __openPalette?: () => void }).__openPalette?.()}- className="flex flex-1 items-center gap-2 rounded-md border border-border px-2 py-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground"+ className="hidden flex-1 items-center gap-2 rounded-md border border-border px-2 py-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground md:flex"><Search size={13} /> Search<kbd className="ml-auto font-mono text-[10px] opacity-60">⌘K</kbd>