Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.
TypeScript browser-shellcontrol-planefile-managerhomelabmobile-firstnextjsptyreactself-hostedserver-managementshadcn-uisysadmintailwindcssterminaltypescriptvpsweb-desktopweb-terminal
perf(appshell): memoise chat rows and show human tool identity
MSOb06a0771ea1f
diff --git a/frontend/slices/appshell/components/alfa-thread.tsx b/frontend/slices/appshell/components/alfa-thread.tsxindex b8510598..29aebbbf 100644--- a/frontend/slices/appshell/components/alfa-thread.tsx+++ b/frontend/slices/appshell/components/alfa-thread.tsx@@ -39,7 +39,11 @@ export function AlfaThread({ ctx, placeholder }: { ctx: AlfaContext; placeholderconst approvals = useAlfaApprovalCount();useEffect(() => {- bottom.current?.scrollIntoView({ behavior: "smooth", block: "end" });+ // Coalesce into one rAF and force instant: streaming appends a message per+ // token, and a smooth scroll restarted every token both janks and forces a+ // layout each frame. Matches the Assistant panel's own scroll effect.+ const id = requestAnimationFrame(() => bottom.current?.scrollIntoView({ behavior: "auto", block: "end" }));+ return () => cancelAnimationFrame(id);}, [messages]);const titleOf = (id?: string) => apps.find((a) => a.id === id)?.title ?? id;diff --git a/frontend/slices/appshell/components/approval-card.test.tsx b/frontend/slices/appshell/components/approval-card.test.tsxindex c6b0c1d5..fd97bf74 100644--- a/frontend/slices/appshell/components/approval-card.test.tsx+++ b/frontend/slices/appshell/components/approval-card.test.tsx@@ -39,3 +39,32 @@ describe("approval argument disclosure", () => {expect(canonicalToolInput(input)).toBe(JSON.stringify(input, null, 2));});});++describe("human-readable tool identity (OpenDots parity)", () => {+ it("shows a human label + state word, with the raw name kept for audit", () => {+ const write = renderToStaticMarkup(<ApprovalCard message={card("fs.write", { path: "/tmp/a" })} onResolve={vi.fn()} />);+ expect(write).toContain("Saving file");+ expect(write).toContain("fs.write");+ expect(write).toContain("Needs your approval");+ const exec = renderToStaticMarkup(<ApprovalCard message={card("exec.run", { cmd: "ls" })} onResolve={vi.fn()} />);+ expect(exec).toContain("Running command");+ });++ it("falls back to the raw name for an unknown tool", () => {+ const html = renderToStaticMarkup(<ApprovalCard message={card("future.tool", {})} onResolve={vi.fn()} />);+ expect(html).toContain("future.tool");+ });++ it("uses Denied, never Failed, for a denied call", () => {+ const denied: ChatMessage = {+ id: "d",+ role: "tool",+ text: "",+ tool: { name: "fs.delete", input: { path: "/tmp/x" }, effect: "mutate", status: "denied" },+ };+ const html = renderToStaticMarkup(<ApprovalCard message={denied} onResolve={vi.fn()} />);+ expect(html).toContain("Deleting file");+ expect(html).toContain("Denied");+ });+});+diff --git a/frontend/slices/appshell/components/approval-card.tsx b/frontend/slices/appshell/components/approval-card.tsxindex e71deaae..d0acb29e 100644--- a/frontend/slices/appshell/components/approval-card.tsx+++ b/frontend/slices/appshell/components/approval-card.tsx@@ -1,18 +1,81 @@"use client";-import { useState } from "react";-import { Check, Loader2, ShieldAlert, Wrench, X } from "lucide-react";+import { memo, useState } from "react";+import {+ Check,+ FilePlus,+ FileText,+ FolderPlus,+ FolderSearch,+ ListTree,+ Loader2,+ MemoryStick,+ Play,+ ShieldAlert,+ Terminal,+ Trash2,+ Wrench,+ X,+ type LucideIcon,+} from "lucide-react";import { Button } from "@/components/ui/button";import { Switch } from "@/components/ui/switch";import { cn } from "@/lib/utils";-import type { ChatMessage } from "./message-bubble";+import type { ChatMessage, ToolStatus } from "./message-bubble";import { canRememberAlfaTool } from "../lib/alfa-approval-policy";+// Human-readable tool identity, OpenDots-style: the transcript says "Saving file",+// not "fs.write". Icons + labels live in one table so the card reads like a status+// line instead of a raw function dump. Unknown/new tools fall back to the raw name.+const TOOLS: Record<string, { label: string; icon: LucideIcon }> = {+ "fs.read": { label: "Reading file", icon: FileText },+ "fs.write": { label: "Saving file", icon: FilePlus },+ "fs.list": { label: "Listing files", icon: ListTree },+ "fs.search": { label: "Searching files", icon: FolderSearch },+ "fs.usage": { label: "Checking disk usage", icon: ListTree },+ "fs.mkdir": { label: "Creating folder", icon: FolderPlus },+ "fs.move": { label: "Moving file", icon: FileText },+ "fs.copy": { label: "Copying file", icon: FileText },+ "fs.delete": { label: "Deleting file", icon: Trash2 },+ "exec.run": { label: "Running command", icon: Terminal },+ "memory.remember": { label: "Remembering", icon: MemoryStick },+ "memory.forget": { label: "Forgetting", icon: MemoryStick },+ "skills.list": { label: "Listing skills", icon: ListTree },+ "skills.read": { label: "Reading skill", icon: FileText },+ "skills.search": { label: "Searching skills", icon: FolderSearch },+ "app.open": { label: "Opening app", icon: Play },+ "apps.list": { label: "Listing apps", icon: ListTree },+ "apps.logs": { label: "Reading app logs", icon: FileText },+ "apps.power": { label: "Toggling app", icon: Play },+ "browser.status": { label: "Checking browser", icon: Wrench },+ "browser.power": { label: "Toggling browser", icon: Play },+ "sys.stats": { label: "Reading system stats", icon: Wrench },+ "sys.processes": { label: "Listing processes", icon: Wrench },+};++// State word shown on the right, OpenDots-style. Never invent "success": a read that+// has not started is Pending, and a denied call is Denied, not Failed.+const STATE: Record<ToolStatus, string> = {+ pending: "Needs your approval",+ running: "Working",+ ok: "Finished",+ error: "Needs attention",+ denied: "Denied",+};++export function toolIdentity(name: string): { label: string; icon: LucideIcon } {+ return TOOLS[name] ?? { label: name, icon: Wrench };+}++// Renders a role:"tool" message — one host tool call. A pending MUTATE call shows// the full args + Approve/Deny (the agent loop is parked awaiting the click);// reads and finished calls render as compact status chips. Colours use theme// tokens only (primary = mutate/ok, destructive = denied/refused).-export function ApprovalCard({+//+// memoised: the transcript re-renders on every streamed token, but a parked card+// is unchanged — without this each token re-ran the full-args render.+export const ApprovalCard = memo(function ApprovalCard({message,onResolve,}: {@@ -22,6 +85,7 @@ export function ApprovalCard({const [remember, setRemember] = useState(false);const t = message.tool;if (!t) return null;+ const { label, icon: Icon } = toolIdentity(t.name);const pending = t.status === "pending";const bad = t.status === "error" || t.status === "denied";return (@@ -32,8 +96,11 @@ export function ApprovalCard({)}><div className="flex items-center gap-1.5">- <Wrench className="size-3.5 shrink-0 text-muted-foreground" />- <span className="font-mono font-medium">{t.name}</span>+ <Icon className="size-3.5 shrink-0 text-muted-foreground" />+ <span className="font-medium">{label}</span>+ {/* Raw tool name kept as a dimmed mono breadcrumb: the human label is for+ scanning, but the exact capability stays visible for audit. */}+ <code className="truncate text-[10px] text-muted-foreground/70">{t.name}</code><spanclassName={cn("rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",@@ -42,9 +109,12 @@ export function ApprovalCard({>{t.effect}</span>- {t.status === "running" && <Loader2 className="ml-auto size-3.5 animate-spin text-muted-foreground" />}- {t.status === "ok" && <Check className="ml-auto size-3.5 text-primary" />}- {(t.status === "error" || t.status === "denied") && <X className="ml-auto size-3.5 text-destructive" />}+ {t.status === "running" && <Loader2 className="size-3.5 animate-spin text-muted-foreground" />}+ {t.status === "ok" && <Check className="size-3.5 text-primary" />}+ {(t.status === "error" || t.status === "denied") && <X className="size-3.5 text-destructive" />}+ <span className={cn("ml-auto shrink-0 text-[10px]", bad ? "text-destructive" : "text-muted-foreground")}>+ {STATE[t.status]}+ </span></div><ToolArgs name={t.name} input={t.input} />@@ -79,7 +149,7 @@ export function ApprovalCard({)}</div>);-}+});// The exact input object passed to the tool is the approval artifact. Mutation-critical// values are never truncated; large values stay fully present inside a bounded scroll area.diff --git a/frontend/slices/appshell/components/chat-memo.test.tsx b/frontend/slices/appshell/components/chat-memo.test.tsxnew file mode 100644index 00000000..bfdc5db3--- /dev/null+++ b/frontend/slices/appshell/components/chat-memo.test.tsx@@ -0,0 +1,19 @@+import { describe, expect, it } from "vitest";+import { MessageBubble } from "./message-bubble";+import { ApprovalCard } from "./approval-card";++// Streaming appends a message per token, re-rendering the whole transcript. These+// two leaf rows must be memoised or every prior row re-parses its markdown and its+// timestamp on every token. memo() wraps the component in an object with `$$typeof`+// React.memo marker; a plain function export would have neither.+const MEMO = Symbol.for("react.memo");++describe("chat transcript rows are memoised", () => {+ it("MessageBubble is a React.memo component", () => {+ expect((MessageBubble as unknown as { $$typeof?: symbol }).$$typeof).toBe(MEMO);+ });++ it("ApprovalCard is a React.memo component", () => {+ expect((ApprovalCard as unknown as { $$typeof?: symbol }).$$typeof).toBe(MEMO);+ });+});diff --git a/frontend/slices/appshell/components/message-bubble.tsx b/frontend/slices/appshell/components/message-bubble.tsxindex 59920d9f..76559cd4 100644--- a/frontend/slices/appshell/components/message-bubble.tsx+++ b/frontend/slices/appshell/components/message-bubble.tsx@@ -1,5 +1,6 @@"use client";+import { memo } from "react";import { Sparkles, User } from "lucide-react";import { cn } from "@/lib/utils";import { mdToHtml } from "../features/widgets/components/md";@@ -38,7 +39,11 @@ function legacyMessageTime(id: string): number | undefined {return match ? Number(match[1]) : undefined;}-export function MessageBubble({ message, ios }: { message: ChatMessage; ios?: boolean }) {+// memoised: the transcript re-renders on every streamed token, but only the last+// assistant bubble actually changes — without this every prior row re-parsed its+// markdown and recomputed its timestamp per token. Props are the message object+// (stable unless that row was patched) + ios, so the default shallow compare holds.+export const MessageBubble = memo(function MessageBubble({ message, ios }: { message: ChatMessage; ios?: boolean }) {const createdAt = message.createdAt || legacyMessageTime(message.id);const time = createdAt ? new Date(createdAt).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", second: "2-digit", hour12: false }) : null;const isUser = message.role === "user";@@ -110,4 +115,4 @@ export function MessageBubble({ message, ios }: { message: ChatMessage; ios?: bo</div></div>);-}+});