Files
DeepTutor/web/components/common/BrandIcon.tsx
Bingxi Zhao (Frank) 44fa7a1552 release: v1.5.8
Memory. A v1.5.7 source deployment grew past 14 GB before V8 aborted; the
causes were independent, so this cut fixes each one and bounds what was
previously unbounded.

- The dev server was never actually capped: `next dev` renders in a worker it
  spawns, and V8 flags in argv are not inherited, so
  `node --max-old-space-size=4096 .../next dev` never reached the process
  holding the memory. Next then substituted 50% of total RAM — a 12 GB heap on
  a 24 GB machine. web/scripts/dev.mjs routes the ceiling through NODE_OPTIONS
  (which the worker inherits and Next honors), clamped to 4 GB and sized off
  the cgroup limit in a container.
- Source installs serve a production build: `deeptutor start` builds once into
  .next-deeptutor and reuses it until a fingerprint over the web/ tree, the
  version file, or the build-time public settings changes. `--dev` is the
  opt-in for HMR and keeps using .next, so neither mode invalidates the other.
- LLM clients and providers come from a bounded event-loop-local LRU pool of 2
  instead of one per turn, closed on shutdown and retired on a settings
  reload; only the selected backend's SDK is imported.
- Caches gained ceilings: knowledge-task log streams cap events and bytes per
  task with a 1h TTL and a completion tombstone, the completed-task table
  keeps 256, the LlamaIndex index cache drops 8 -> 2 with a 10-minute idle
  evict, and a book runtime is released when its queue drains.
- After a turn, a finished book job, or a completed KB task, cycles are
  collected and glibc is asked to return free pages via malloc_trim; the
  container and launcher set MALLOC_ARENA_MAX=2 and a lower trim threshold,
  both operator-overridable.
- Every uvicorn launch sets --timeout-keep-alive 300. web/proxy.ts forwards
  over Node's http.globalAgent, whose 5s idle reaper matched uvicorn's default
  exactly; both ends raced to close the same socket and the loser's request
  died with ECONNRESET ("Failed to load sessions").
- deeptutor.agents, deeptutor.core.agentic, provider_core, the document
  extractor's parser libraries and the LLM error-mapping rules resolve on
  first use. `python -m deeptutor.api.run_server` no longer reloads by
  default (DEEPTUTOR_DEV_RELOAD=1 restores it).

README prose and all ten translated READMEs now describe the production-build
default instead of dev mode. Release notes: assets/releases/ver1-5-8.md
2026-08-02 13:23:45 +08:00

122 lines
3.4 KiB
TypeScript

"use client";
import { useTranslation } from "react-i18next";
import {
brandIconFor,
brandInitials,
type BrandNamespace,
} from "@/lib/brand-icons";
/**
* The square mark in front of a store entry: the product's own logo when we have
* it, an initials monogram when we do not.
*
* Rendered inline from a bundled CC0 path — no image request, so opening the
* store does not tell a vendor that this person is looking at their service.
*
* Monochrome (`currentColor`) rather than the brand's own hex, for two reasons:
* a dozen brand colours in one grid reads as noise next to DeepTutor's own
* restrained palette, and several brand hexes fail contrast against one of the
* two themes. The hex is kept in the generated data if an accent is ever wanted.
*/
export default function BrandIcon({
namespace,
id,
name,
size = "sm",
className = "",
}: {
namespace: BrandNamespace;
/** Catalog entry id — what the slug tables are keyed on. */
id: string;
/** Display name, used for the monogram and the accessible label. */
name: string;
size?: "sm" | "lg";
className?: string;
}) {
const icon = brandIconFor(namespace, id);
const box =
size === "lg" ? "h-11 w-11 text-[14px]" : "mt-0.5 h-7 w-7 text-[10.5px]";
const glyph = size === "lg" ? 20 : 14;
return (
<span
// The name is already adjacent in every current caller, so the mark is
// decorative and announcing it again would just double every row.
aria-hidden
title={icon ? icon.title : name}
className={`flex shrink-0 items-center justify-center rounded-lg border border-[var(--border)]/60 bg-[var(--background)] font-semibold tracking-tight text-[var(--muted-foreground)] ${box} ${className}`}
>
{icon ? (
<svg
viewBox="0 0 24 24"
width={glyph}
height={glyph}
fill="currentColor"
role="presentation"
>
<path d={icon.path} />
</svg>
) : (
brandInitials(name)
)}
</span>
);
}
/**
* The attribution these marks require.
*
* Simple Icons ships the *paths* under CC0, which is why they can be bundled —
* but each mark is still its owner's trademark. Shown once per store rather than
* per row: it is a legal notice, not a caption.
*/
export function TrademarkNote({ className = "" }: { className?: string }) {
const { t } = useTranslation();
return (
<p
className={`text-[11px] leading-relaxed text-[var(--muted-foreground)]/70 ${className}`}
>
{t(
"Product names and logos are trademarks of their respective owners, shown for identification only.",
)}
</p>
);
}
/**
* The bare mark, with no box — for a row that already has its own leading glyph
* and a settled rhythm. Returns `null` when there is no logo, so the caller keeps
* whatever generic icon it had rather than being handed a monogram that would not
* fit the slot.
*/
export function BrandGlyph({
namespace,
id,
size = 14,
className = "",
}: {
namespace: BrandNamespace;
id: string;
size?: number;
className?: string;
}) {
const icon = brandIconFor(namespace, id);
if (!icon) return null;
return (
<svg
viewBox="0 0 24 24"
width={size}
height={size}
fill="currentColor"
role="presentation"
aria-hidden
className={className}
>
<title>{icon.title}</title>
<path d={icon.path} />
</svg>
);
}