Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

feat(web): translate the overview page and architecture map for zh-CN (#4882)

Raghav Chamadiyade78b5c4b985
diff --git a/packages/ui/src/graph/graph-flow.tsx b/packages/ui/src/graph/graph-flow.tsx
index e4e44187a..548e9e862 100644
--- a/packages/ui/src/graph/graph-flow.tsx
+++ b/packages/ui/src/graph/graph-flow.tsx
@@ -31,15 +31,25 @@ import { useGraphSearch } from "./use-graph-search";
import { useCommunityFilter } from "./use-community-filter";
import { useModuleFilter, filterGraphToModule } from "./use-module-filter";
import { useGraphKeyboardShortcuts } from "./use-graph-keyboard-shortcuts";
-import { GraphToolbar, type ColorMode, type ViewMode, type GraphTheme } from "./graph-toolbar";
-import { GraphLegend } from "./graph-legend";
+import {
+ GraphToolbar,
+ type ColorMode,
+ type ViewMode,
+ type GraphTheme,
+ type GraphToolbarCopy,
+ type GraphNodeFilterCopy,
+} from "./graph-toolbar";
+import { GraphLegend, type GraphLegendCopy } from "./graph-legend";
import { GraphNodeFilter } from "./graph-toolbar";
import { GraphCanvasShell } from "./graph-canvas-shell";
import { GraphContextMenu } from "./graph-context-menu";
import { GraphInspectionPanel } from "./graph-inspection-panel";
import { GraphFlowPanel } from "./graph-flow-panel";
import { GraphShortcutHelp } from "./graph-shortcut-help";
-import { GraphPopulationControl } from "./graph-population-control";
+import {
+ GraphPopulationControl,
+ type GraphPopulationControlCopy,
+} from "./graph-population-control";
import { GraphUnclusteredPanel } from "./graph-unclustered-panel";
import type {
GraphExport,
@@ -66,6 +76,27 @@ import { useEgoFilter } from "./sigma/use-ego-filter";
import { filterOverviewData, getOverviewMeta, layoutFilesOverview } from "./sigma/files-overview";
import { CommunityColorContext, communityColorSlots } from "./community-colors";
+export interface GraphFlowCopy {
+ toolbar?: Partial<GraphToolbarCopy> | undefined;
+ nodeFilter?: Partial<GraphNodeFilterCopy> | undefined;
+ legend?: Partial<GraphLegendCopy> | undefined;
+ population?: Partial<GraphPopulationControlCopy> | undefined;
+ /** Breadcrumb root when the host gives no repo name. */
+ allCommunities: string;
+ /** Description inside one community. */
+ insideCommunity: string;
+ /** Appended to {@link insideCommunity} when files open on double-click. */
+ openFileHint: string;
+ communityFallback: (id: number) => string;
+}
+
+export const GRAPH_FLOW_COPY: GraphFlowCopy = {
+ allCommunities: "All communities",
+ insideCommunity: "How the files in this group depend on each other.",
+ openFileHint: "Double-click a file to open it.",
+ communityFallback: (id) => `Community ${id}`,
+};
+
export interface GraphFlowProps {
fullGraph: GraphExport | undefined;
isLoadingFullGraph: boolean;
@@ -193,6 +224,7 @@ export interface GraphFlowProps {
/** Host-owned rail content, e.g. a documentation panel. Takes the rail over
* the community and inspection panels; see the precedence in the render. */
rail?: ReactNode;
+ copy?: Partial<GraphFlowCopy> | undefined;
}
export function GraphFlow(props: GraphFlowProps) {
@@ -243,6 +275,7 @@ export function GraphFlow(props: GraphFlowProps) {
banner,
rail,
} = props;
+ const copy = { ...GRAPH_FLOW_COPY, ...props.copy };
const sigmaRef = useRef<SigmaCanvasHandle>(null);
const focusTimerRef = useRef<ReturnType<typeof setTimeout>>(undefined);
@@ -1429,7 +1462,7 @@ export function GraphFlow(props: GraphFlowProps) {
const activeCommunityLabel =
activeCommunity !== null
- ? (communityLabels?.get(activeCommunity) ?? `Community ${activeCommunity}`)
+ ? (communityLabels?.get(activeCommunity) ?? copy.communityFallback(activeCommunity))
: null;
return (
@@ -1438,7 +1471,7 @@ export function GraphFlow(props: GraphFlowProps) {
breadcrumb={
isInsideCommunity && activeCommunityLabel ? (
<GraphScopeBreadcrumb
- rootLabel={repoName ?? "All communities"}
+ rootLabel={repoName ?? copy.allCommunities}
leafLabel={activeCommunityLabel}
onRoot={leaveCommunity}
/>
@@ -1449,9 +1482,7 @@ export function GraphFlow(props: GraphFlowProps) {
// out, and the narrowing select names it a third time. Prose repeating
// it is noise, so this says what the picture is, not what it is called.
isInsideCommunity
- ? `How the files in this group depend on each other.${
- onNodeViewDocs ? " Double-click a file to open it." : ""
- }`
+ ? `${copy.insideCommunity}${onNodeViewDocs ? ` ${copy.openFileHint}` : ""}`
: description
}
titleActions={
@@ -1462,6 +1493,7 @@ export function GraphFlow(props: GraphFlowProps) {
population={population}
breakdown={constellationGraph?.population}
onChange={onPopulationChange}
+ copy={copy.population}
/>
)}
<GraphToolbar
@@ -1484,6 +1516,7 @@ export function GraphFlow(props: GraphFlowProps) {
searchMatchCount={searchResults.length}
searchTotalCount={displayGraph?.order ?? 0}
onSearchKeyDown={handleSearchKeyDown}
+ copy={copy.toolbar}
/>
</div>
}
@@ -1527,6 +1560,7 @@ export function GraphFlow(props: GraphFlowProps) {
<GraphNodeFilter
viewMode={viewMode}
onViewChange={handleViewChange}
+ copy={copy.nodeFilter}
/>
)
}
@@ -1551,6 +1585,7 @@ export function GraphFlow(props: GraphFlowProps) {
}
overview={overviewLegend}
trailing={shortcutsButton}
+ copy={copy.legend}
/>
{hasCanvasStatus && (
<div className="flex flex-wrap items-center gap-x-3 gap-y-1">
diff --git a/packages/ui/src/graph/graph-legend.tsx b/packages/ui/src/graph/graph-legend.tsx
index 9c73d41a6..0c4c1193b 100644
--- a/packages/ui/src/graph/graph-legend.tsx
+++ b/packages/ui/src/graph/graph-legend.tsx
@@ -24,37 +24,131 @@ const COMMUNITY_ROWS = 8;
* because it was also in the default visible set, "cross-community only" read
* as a two-kind default.
*/
-const EDGE_KINDS = [
- { type: "crossCommunity", label: "Cross-community" },
- { type: "internal", label: "Internal" },
- { type: "dynamic", label: "Co-change" },
- { type: "lowConfidence", label: "Low confidence" },
-] as const;
+const EDGE_KINDS = ["crossCommunity", "internal", "dynamic", "lowConfidence"] as const;
-/** The same kinds, worded for a canvas holding one community. */
-const SCOPED_EDGE_KINDS = [
- { type: "internal", label: "Within this group" },
- { type: "crossCommunity", label: "Leaving this group" },
- { type: "dynamic", label: "Co-change" },
- { type: "lowConfidence", label: "Low confidence" },
-] as const;
+export type LegendEdgeKind = (typeof EDGE_KINDS)[number];
-/** The overview draws cross-community edges as bands between clusters. */
-const OVERVIEW_EDGE_LABELS: Partial<Record<string, string>> = {
- crossCommunity: "Between communities",
- internal: "Within a community",
-};
+/** The same kinds, in the order a canvas holding one community keys them. */
+const SCOPED_EDGE_KINDS = ["internal", "crossCommunity", "dynamic", "lowConfidence"] as const;
+/** Language names stay as written; only the two catch-all rows are copy. */
const LANGUAGE_LEGEND = [
{ lang: "python", color: LANGUAGE_COLORS.python, label: "Python" },
{ lang: "typescript", color: LANGUAGE_COLORS.typescript, label: "TypeScript" },
{ lang: "go", color: LANGUAGE_COLORS.go, label: "Go" },
{ lang: "rust", color: LANGUAGE_COLORS.rust, label: "Rust" },
{ lang: "java", color: LANGUAGE_COLORS.java, label: "Java" },
- { lang: "config", color: LANGUAGE_COLORS.config, label: "Config" },
- { lang: "other", color: LANGUAGE_COLORS.other, label: "Other" },
+ { lang: "config", color: LANGUAGE_COLORS.config, label: null },
+ { lang: "other", color: LANGUAGE_COLORS.other, label: null },
];
+export interface GraphLegendCopy {
+ communities: (count: number) => string;
+ noCommunities: string;
+ smallerNotListed: (count: number) => string;
+ notGrouped: string;
+ notGroupedTitle: string;
+ /** Header inside one community. */
+ scopedSummary: (members: number, boundary: number, edges: number) => string;
+ outsideGroup: string;
+ /** Files overview header parts, joined with " · ". */
+ overviewFiles: (count: number) => string;
+ overviewThirdParty: (count: number) => string;
+ overviewDependencies: (count: number) => string;
+ nodesEdges: (nodes: number, edges: number) => string;
+ thirdPartyShown: string;
+ thirdPartyHidden: (count: number) => string;
+ show: string;
+ hide: string;
+ showThirdParty: string;
+ hideThirdParty: string;
+ unlinkedNotDrawn: (count: number) => string;
+ unlinkedTitle: string;
+ weakerLinksNotDrawn: (count: number) => string;
+ weakerLinksTitle: string;
+ languageGroup: string;
+ communityGroup: string;
+ edgesGroup: string;
+ focusGroup: string;
+ configLanguage: string;
+ otherLanguage: string;
+ deselectAll: string;
+ selectAll: string;
+ /** Placeholder rows before community labels load (1-based). */
+ communityPlaceholder: (n: number) => string;
+ edgeKinds: Record<LegendEdgeKind, string>;
+ /** Inside one community. */
+ scopedEdgeKinds: Record<LegendEdgeKind, string>;
+ /** The overview draws cross-community edges as bands between clusters. */
+ overviewEdgeKinds: Partial<Record<LegendEdgeKind, string>>;
+ imports: string;
+ importedBy: string;
+ toggleEdges: (label: string) => string;
+ toggleCommunity: (label: string) => string;
+ viewCaptions: { dead: string; hotfiles: string; unified: string };
+}
+
+export const GRAPH_LEGEND_COPY: GraphLegendCopy = {
+ communities: (count) => `${count} communit${count === 1 ? "y" : "ies"}`,
+ noCommunities: "No communities detected",
+ smallerNotListed: (count) => `+${count} smaller not listed`,
+ notGrouped: "Not grouped",
+ notGroupedTitle: "Files with no dependency on the rest of the repo",
+ scopedSummary: (members, boundary, edges) =>
+ `${members} file${members === 1 ? "" : "s"}${boundary > 0 ? ` · ${boundary} outside` : ""} · ${edges} edge${edges === 1 ? "" : "s"} shown`,
+ outsideGroup: "Outside this group",
+ overviewFiles: (count) => `${count.toLocaleString()} files`,
+ overviewThirdParty: (count) => `${count.toLocaleString()} third-party`,
+ overviewDependencies: (count) => `${count.toLocaleString()} dependencies`,
+ nodesEdges: (nodes, edges) => `${nodes} nodes · ${edges} edges`,
+ thirdPartyShown: "Third-party modules shown",
+ thirdPartyHidden: (count) => `${count.toLocaleString()} third-party modules hidden`,
+ show: "Show",
+ hide: "Hide",
+ showThirdParty: "Show third-party modules",
+ hideThirdParty: "Hide third-party modules",
+ unlinkedNotDrawn: (count) => `${count.toLocaleString()} unlinked files not drawn`,
+ unlinkedTitle:
+ "Files with no dependency edge to anything drawn have no place in the layout and nothing to reveal on hover.",
+ weakerLinksNotDrawn: (count) => `${count.toLocaleString()} weaker community links not drawn`,
+ weakerLinksTitle:
+ "Pairs of communities with too few dependencies between them to band. Their edges still show on a hovered or selected file.",
+ languageGroup: "Language",
+ communityGroup: "Community",
+ edgesGroup: "Edges",
+ focusGroup: "Hover or select a file",
+ configLanguage: "Config",
+ otherLanguage: "Other",
+ deselectAll: "Deselect all",
+ selectAll: "Select all",
+ communityPlaceholder: (n) => `Community ${n}`,
+ edgeKinds: {
+ crossCommunity: "Cross-community",
+ internal: "Internal",
+ dynamic: "Co-change",
+ lowConfidence: "Low confidence",
+ },
+ scopedEdgeKinds: {
+ internal: "Within this group",
+ crossCommunity: "Leaving this group",
+ dynamic: "Co-change",
+ lowConfidence: "Low confidence",
+ },
+ overviewEdgeKinds: {
+ crossCommunity: "Between communities",
+ internal: "Within a community",
+ },
+ imports: "imports",
+ importedBy: "imported by",
+ toggleEdges: (label) => `Toggle ${label} edges`,
+ toggleCommunity: (label) => `Toggle community ${label}`,
+ viewCaptions: {
+ dead: "Showing unreachable files",
+ hotfiles: "Most-committed files (30d)",
+ unified: "Dead and high-churn files",
+ },
+};
+
/**
* Legend chrome, shared by the constellation and the file/module readings.
*
@@ -172,6 +266,7 @@ interface GraphLegendProps {
overview?: OverviewLegend | undefined;
/** Rendered at the row's far end in every reading (the shortcuts button). */
trailing?: ReactNode | undefined;
+ copy?: Partial<GraphLegendCopy> | undefined;
}
export interface OverviewLegend {
@@ -227,7 +322,9 @@ export const GraphLegend = memo(function GraphLegend({
drawnCommunityIds,
overview,
trailing,
+ copy,
}: GraphLegendProps) {
+ const c = { ...GRAPH_LEGEND_COPY, ...copy };
// Open by default: every node is painted from this key, so a collapsed one
// ships a field of coloured circles with no way to read them.
const [expanded, setExpanded] = useState(true);
@@ -243,16 +340,14 @@ export const GraphLegend = memo(function GraphLegend({
return (
<div className={shellClass}>
<button onClick={() => setExpanded((s) => !s)} className={headerClass}>
- <span className={countClass}>
- {allEntries.length} communit{allEntries.length === 1 ? "y" : "ies"}
- </span>
+ <span className={countClass}>{c.communities(allEntries.length)}</span>
<Chevron expanded={expanded} />
</button>
{expanded && (
<div className="flex flex-wrap items-center gap-x-3 gap-y-1">
{entries.length === 0 && (
<p className="text-[11px] text-[var(--color-text-tertiary)]">
- No communities detected
+ {c.noCommunities}
</p>
)}
{entries.map((e) => {
@@ -273,7 +368,7 @@ export const GraphLegend = memo(function GraphLegend({
})}
{overflow > 0 && (
<p className="text-[10px] text-[var(--color-text-tertiary)]">
- +{overflow} smaller not listed
+ {c.smallerNotListed(overflow)}
</p>
)}
{constellationUnclustered && constellationUnclustered.count > 0 && (
@@ -281,10 +376,10 @@ export const GraphLegend = memo(function GraphLegend({
type="button"
onClick={constellationUnclustered.onClick}
className={rowClass}
- title="Files with no dependency on the rest of the repo"
+ title={c.notGroupedTitle}
>
<Swatch color="var(--color-text-tertiary)" />
- <span>Not grouped</span>
+ <span>{c.notGrouped}</span>
<span className="shrink-0 tabular-nums text-[10px] text-[var(--color-text-tertiary)]">
{constellationUnclustered.count}
</span>
@@ -327,9 +422,7 @@ export const GraphLegend = memo(function GraphLegend({
<div className={shellClass}>
<button onClick={() => setExpanded((s) => !s)} className={headerClass}>
<span className={countClass}>
- {members} file{members === 1 ? "" : "s"}
- {boundary > 0 ? ` · ${boundary} outside` : ""} &middot;{" "}
- {drawnEdgeCount} edge{drawnEdgeCount === 1 ? "" : "s"} shown
+ {c.scopedSummary(members, boundary, drawnEdgeCount)}
</span>
<Chevron expanded={expanded} />
</button>
@@ -352,7 +445,7 @@ export const GraphLegend = memo(function GraphLegend({
<div className={rowClass}>
{/* The faded ring was explained in prose and keyed nowhere. */}
<span className="h-2 w-2 shrink-0 rounded-full border border-[var(--color-text-tertiary)]" />
- <span>Outside this group</span>
+ <span>{c.outsideGroup}</span>
<span className="shrink-0 tabular-nums text-[10px] text-[var(--color-text-tertiary)]">
{boundary}
</span>
@@ -360,19 +453,20 @@ export const GraphLegend = memo(function GraphLegend({
)}
{onEdgeTypeToggle && visibleEdgeTypes && (
<>
- <p className={groupClass}>Edges</p>
- {SCOPED_EDGE_KINDS.map((et) => {
- const checked = visibleEdgeTypes.has(et.type);
+ <p className={groupClass}>{c.edgesGroup}</p>
+ {SCOPED_EDGE_KINDS.map((type) => {
+ const checked = visibleEdgeTypes.has(type);
+ const label = c.scopedEdgeKinds[type];
return (
- <div key={et.type} className={rowClass}>
+ <div key={type} className={rowClass}>
<SwatchToggle
- color={edgeColors[et.type]}
+ color={edgeColors[type]}
checked={checked}
- label={`Toggle ${et.label} edges`}
- onToggle={() => onEdgeTypeToggle(et.type)}
+ label={c.toggleEdges(label)}
+ onToggle={() => onEdgeTypeToggle(type)}
/>
<span className={`truncate ${checked ? "" : "opacity-45"}`}>
- {et.label}
+ {label}
</span>
</div>
);
@@ -396,15 +490,13 @@ export const GraphLegend = memo(function GraphLegend({
<span className={countClass}>
{overview
? [
- `${(nodeCount - overview.shownExternal).toLocaleString()} files`,
- overview.shownExternal > 0
- ? `${overview.shownExternal.toLocaleString()} third-party`
- : null,
- `${overview.dependencies.toLocaleString()} dependencies`,
+ c.overviewFiles(nodeCount - overview.shownExternal),
+ overview.shownExternal > 0 ? c.overviewThirdParty(overview.shownExternal) : null,
+ c.overviewDependencies(overview.dependencies),
]
.filter(Boolean)
.join(" · ")
- : `${nodeCount} nodes · ${drawnEdgeCount} edges`}
+ : c.nodesEdges(nodeCount, drawnEdgeCount)}
</span>
<Chevron expanded={expanded} />
</button>
@@ -416,30 +508,24 @@ export const GraphLegend = memo(function GraphLegend({
{(overview.hiddenExternal > 0 || overview.showExternal) && (
<span className="inline-flex items-center gap-1.5">
{overview.showExternal
- ? "Third-party modules shown"
- : `${overview.hiddenExternal.toLocaleString()} third-party modules hidden`}
+ ? c.thirdPartyShown
+ : c.thirdPartyHidden(overview.hiddenExternal)}
<button
type="button"
onClick={() => overview.onShowExternalChange(!overview.showExternal)}
aria-pressed={overview.showExternal}
- aria-label={
- overview.showExternal ? "Hide third-party modules" : "Show third-party modules"
- }
+ aria-label={overview.showExternal ? c.hideThirdParty : c.showThirdParty}
className="rounded px-1 py-0.5 font-medium text-[var(--color-accent-primary)] hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]"
>
- {overview.showExternal ? "Hide" : "Show"}
+ {overview.showExternal ? c.hide : c.show}
</button>
</span>
)}
{overview.hiddenUnlinked > 0 && (
- <span title="Files with no dependency edge to anything drawn have no place in the layout and nothing to reveal on hover.">
- {overview.hiddenUnlinked.toLocaleString()} unlinked files not drawn
- </span>
+ <span title={c.unlinkedTitle}>{c.unlinkedNotDrawn(overview.hiddenUnlinked)}</span>
)}
{overview.omittedLinks > 0 && (
- <span title="Pairs of communities with too few dependencies between them to band. Their edges still show on a hovered or selected file.">
- {overview.omittedLinks.toLocaleString()} weaker community links not drawn
- </span>
+ <span title={c.weakerLinksTitle}>{c.weakerLinksNotDrawn(overview.omittedLinks)}</span>
)}
</span>
)}
@@ -448,7 +534,7 @@ export const GraphLegend = memo(function GraphLegend({
<div className="flex flex-wrap items-center gap-x-3 gap-y-1">
{(colorMode === "language" || hasCommunityRows) && (
<p className={groupClass}>
- {colorMode === "language" ? "Language" : "Community"}
+ {colorMode === "language" ? c.languageGroup : c.communityGroup}
</p>
)}
@@ -459,7 +545,9 @@ export const GraphLegend = memo(function GraphLegend({
className="inline-flex items-center gap-1.5 text-[11px] text-[var(--color-text-secondary)]"
>
<Swatch color={l.color} />
- <span className="truncate">{l.label}</span>
+ <span className="truncate">
+ {l.label ?? (l.lang === "config" ? c.configLanguage : c.otherLanguage)}
+ </span>
</div>
))}
@@ -479,7 +567,7 @@ export const GraphLegend = memo(function GraphLegend({
onClick={() => onToggleAllCommunities(!allSelected)}
className="shrink-0 text-[10px] font-medium text-[var(--color-accent-primary)] hover:underline"
>
- {allSelected ? "Deselect all" : "Select all"}
+ {allSelected ? c.deselectAll : c.selectAll}
</button>
)}
{entries
@@ -495,7 +583,7 @@ export const GraphLegend = memo(function GraphLegend({
<SwatchToggle
color={color}
checked={checked}
- label={`Toggle community ${label}`}
+ label={c.toggleCommunity(label)}
onToggle={() => onCommunityToggle(cid)}
/>
) : (
@@ -521,12 +609,12 @@ export const GraphLegend = memo(function GraphLegend({
className="inline-flex items-center gap-1.5 text-[11px] text-[var(--color-text-secondary)]"
>
<Swatch color={communityFamily(i).hub} />
- <span className="truncate">Community {i + 1}</span>
+ <span className="truncate">{c.communityPlaceholder(i + 1)}</span>
</div>
))}
{overflow > 0 && (
<p className="text-[10px] text-[var(--color-text-tertiary)]">
- +{overflow} smaller not listed
+ {c.smallerNotListed(overflow)}
</p>
)}
</>
@@ -534,19 +622,19 @@ export const GraphLegend = memo(function GraphLegend({
})()}
{onEdgeTypeToggle && visibleEdgeTypes && (() => {
- const toggle = (et: (typeof EDGE_KINDS)[number]) => {
- const checked = visibleEdgeTypes.has(et.type);
- const label = (overview && OVERVIEW_EDGE_LABELS[et.type]) || et.label;
+ const toggle = (type: LegendEdgeKind) => {
+ const checked = visibleEdgeTypes.has(type);
+ const label = (overview && c.overviewEdgeKinds[type]) || c.edgeKinds[type];
return (
- <div key={et.type} className={rowClass}>
+ <div key={type} className={rowClass}>
<SwatchToggle
// The overview draws these in community hues (bands,
// cluster texture) or in the direction hues on a focused
// file, never in the kind colours, so it keys none of them.
- color={overview ? "var(--color-text-secondary)" : edgeColors[et.type]}
+ color={overview ? "var(--color-text-secondary)" : edgeColors[type]}
checked={checked}
- label={`Toggle ${label} edges`}
- onToggle={() => onEdgeTypeToggle(et.type)}
+ label={c.toggleEdges(label)}
+ onToggle={() => onEdgeTypeToggle(type)}
/>
<span className={`truncate ${checked ? "" : "opacity-45"}`}>
{label}
@@ -557,7 +645,7 @@ export const GraphLegend = memo(function GraphLegend({
if (!overview) {
return (
<>
- <p className={groupClass}>Edges</p>
+ <p className={groupClass}>{c.edgesGroup}</p>
{EDGE_KINDS.map(toggle)}
</>
);
@@ -567,30 +655,30 @@ export const GraphLegend = memo(function GraphLegend({
// than beside kinds that change the picture at rest.
return (
<>
- <p className={groupClass}>Edges</p>
- {EDGE_KINDS.filter((et) => !FOCUS_ONLY_KINDS.has(et.type)).map(toggle)}
+ <p className={groupClass}>{c.edgesGroup}</p>
+ {EDGE_KINDS.filter((type) => !FOCUS_ONLY_KINDS.has(type)).map(toggle)}
{/* A focused file's edges carry direction, in two hues that
must be named: colour alone cannot say which way a
dependency points. */}
- <p className={groupClass}>Hover or select a file</p>
+ <p className={groupClass}>{c.focusGroup}</p>
<span className="inline-flex items-center gap-1.5 text-[11px] text-[var(--color-text-secondary)]">
<LineSwatch color="var(--color-accent-primary)" />
- imports
+ {c.imports}
</span>
<span className="inline-flex items-center gap-1.5 text-[11px] text-[var(--color-text-secondary)]">
<LineSwatch color="var(--color-accent-secondary)" />
- imported by
+ {c.importedBy}
</span>
- {EDGE_KINDS.filter((et) => FOCUS_ONLY_KINDS.has(et.type)).map(toggle)}
+ {EDGE_KINDS.filter((type) => FOCUS_ONLY_KINDS.has(type)).map(toggle)}
</>
);
})()}
{viewMode !== "full" && (
<p className="text-[10px] text-[var(--color-text-tertiary)]">
- {viewMode === "dead" && "Showing unreachable files"}
- {viewMode === "hotfiles" && "Most-committed files (30d)"}
- {viewMode === "unified" && "Dead and high-churn files"}
+ {viewMode === "dead" && c.viewCaptions.dead}
+ {viewMode === "hotfiles" && c.viewCaptions.hotfiles}
+ {viewMode === "unified" && c.viewCaptions.unified}
</p>
)}
</div>
diff --git a/packages/ui/src/graph/graph-population-control.tsx b/packages/ui/src/graph/graph-population-control.tsx
index 845c6d1f0..1ec6bdcf0 100644
--- a/packages/ui/src/graph/graph-population-control.tsx
+++ b/packages/ui/src/graph/graph-population-control.tsx
@@ -6,12 +6,41 @@ import { Popover, PopoverTrigger, PopoverContent } from "../ui/popover";
import { formatNumber } from "../lib/format";
import type { GraphPopulation, PopulationBreakdown } from "@repowise-dev/types/graph";
-const ROWS: { key: keyof GraphPopulation; label: string; count: keyof PopulationBreakdown }[] = [
- { key: "tests", label: "Tests", count: "tests" },
- { key: "examples", label: "Examples and benchmarks", count: "examples" },
- { key: "docs", label: "Docs and config", count: "docs" },
+const ROWS: { key: keyof GraphPopulation; count: keyof PopulationBreakdown }[] = [
+ { key: "tests", count: "tests" },
+ { key: "examples", count: "examples" },
+ { key: "docs", count: "docs" },
];
+export interface GraphPopulationControlCopy {
+ allCounted: (total: number) => string;
+ someCounted: (visible: number, total: number) => string;
+ /** Before the breakdown loads. */
+ allFiles: string;
+ productionFiles: string;
+ /** Trigger label; `summary` is one of the four above. */
+ ariaLabel: (summary: string) => string;
+ popoverLabel: string;
+ explainer: string;
+ rows: Record<keyof GraphPopulation, string>;
+}
+
+export const GRAPH_POPULATION_CONTROL_COPY: GraphPopulationControlCopy = {
+ allCounted: (total) => `All ${formatNumber(total)} files`,
+ someCounted: (visible, total) => `${formatNumber(visible)} of ${formatNumber(total)} files`,
+ allFiles: "All files",
+ productionFiles: "Production files",
+ ariaLabel: (summary) => `Files counted: ${summary}`,
+ popoverLabel: "Files counted",
+ explainer:
+ "Production code is always counted. Turning a kind on re-sizes and re-ranks every group.",
+ rows: {
+ tests: "Tests",
+ examples: "Examples and benchmarks",
+ docs: "Docs and config",
+ },
+};
+
/**
* Which files the community views count. Production is always in; the three
* toggles add the rest. The server recomputes sizes, ranking, labels and the
@@ -23,6 +52,7 @@ export function GraphPopulationControl({
breakdown,
onChange,
className,
+ copy,
}: {
population: GraphPopulation;
/** From the architecture payload; absent while it loads or in a scope that
@@ -30,23 +60,25 @@ export function GraphPopulationControl({
breakdown?: PopulationBreakdown | null | undefined;
onChange: (next: GraphPopulation) => void;
className?: string | undefined;
+ copy?: Partial<GraphPopulationControlCopy> | undefined;
}) {
+ const c = { ...GRAPH_POPULATION_CONTROL_COPY, ...copy };
const [open, setOpen] = useState(false);
const allOn = population.tests && population.examples && population.docs;
const summary = breakdown
? allOn || breakdown.visible === breakdown.total
- ? `All ${formatNumber(breakdown.total)} files`
- : `${formatNumber(breakdown.visible)} of ${formatNumber(breakdown.total)} files`
+ ? c.allCounted(breakdown.total)
+ : c.someCounted(breakdown.visible, breakdown.total)
: allOn
- ? "All files"
- : "Production files";
+ ? c.allFiles
+ : c.productionFiles;
return (
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
<button
type="button"
- aria-label={`Files counted: ${summary}`}
+ aria-label={c.ariaLabel(summary)}
className={`inline-flex h-7 items-center gap-1.5 rounded-md border border-[var(--color-border-default)] px-2 text-xs text-[var(--color-text-secondary)] transition-colors hover:text-[var(--color-text-primary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] ${className ?? ""}`}
>
<Filter className="h-3 w-3" />
@@ -54,10 +86,9 @@ export function GraphPopulationControl({
<ChevronDown className="h-3 w-3" />
</button>
</PopoverTrigger>
- <PopoverContent align="end" aria-label="Files counted" className="w-64 p-2">
+ <PopoverContent align="end" aria-label={c.popoverLabel} className="w-64 p-2">
<p className="px-1 pb-1.5 text-[11px] text-[var(--color-text-secondary)]">
- Production code is always counted. Turning a kind on re-sizes and
- re-ranks every group.
+ {c.explainer}
</p>
{ROWS.map((row) => {
const count = breakdown?.[row.count];
@@ -73,7 +104,7 @@ export function GraphPopulationControl({
onChange={(e) => onChange({ ...population, [row.key]: e.target.checked })}
className="h-3.5 w-3.5 accent-[var(--color-accent-primary)]"
/>
- {row.label}
+ {c.rows[row.key]}
</span>
{typeof count === "number" && (
<span className="tabular-nums text-[11px] text-[var(--color-text-tertiary)]">
diff --git a/packages/ui/src/graph/graph-scope-controls.tsx b/packages/ui/src/graph/graph-scope-controls.tsx
index ef4af35b1..df6cff90f 100644
--- a/packages/ui/src/graph/graph-scope-controls.tsx
+++ b/packages/ui/src/graph/graph-scope-controls.tsx
@@ -18,40 +18,50 @@ import type { CommunitySummaryItem } from "@repowise-dev/types/graph";
*/
export type GraphScope = "communities" | "files" | "tree";
-const SCOPES: { id: GraphScope; label: string; hint: string }[] = [
- {
- id: "communities",
- label: "Communities",
- hint: "One circle per detected community",
- },
- {
- id: "files",
+export interface GraphScopeSwitcherCopy {
+ label: string;
+ scopes: Record<GraphScope, { label: string; hint: string }>;
+}
+
+export const GRAPH_SCOPE_SWITCHER_COPY: GraphScopeSwitcherCopy = {
+ label: "Graph scope",
+ scopes: {
+ communities: {
+ label: "Communities",
+ hint: "One circle per detected community",
+ },
// Not "Full". It draws the most-connected slice of the repo, and the
// caption under the tabs says exactly how big that slice is.
- label: "Files",
- hint: "Individual files and how they depend on each other",
- },
- {
- id: "tree",
+ files: {
+ label: "Files",
+ hint: "Individual files and how they depend on each other",
+ },
// The same file graph, read as an outline rather than as a canvas. It is
// the same axis as the two above — how the file graph is presented — so it
// lives in the same control, not in a tab of its own.
- label: "Tree",
- hint: "The same files as an outline, with what each one imports",
+ tree: {
+ label: "Tree",
+ hint: "The same files as an outline, with what each one imports",
+ },
},
-];
+};
+
+const SCOPES: GraphScope[] = ["communities", "files", "tree"];
export function GraphScopeSwitcher({
scope,
onScopeChange,
className,
+ copy,
}: {
scope: GraphScope;
onScopeChange: (scope: GraphScope) => void;
className?: string;
+ copy?: Partial<GraphScopeSwitcherCopy> | undefined;
}) {
+ const c = { ...GRAPH_SCOPE_SWITCHER_COPY, ...copy };
const onKeyDown = (e: ReactKeyboardEvent) => {
- const i = SCOPES.findIndex((s) => s.id === scope);
+ const i = SCOPES.indexOf(scope);
if (i < 0) return;
let next = i;
if (e.key === "ArrowRight" || e.key === "ArrowDown") next = (i + 1) % SCOPES.length;
@@ -60,27 +70,28 @@ export function GraphScopeSwitcher({
else return;
e.preventDefault();
const target = SCOPES[next];
- if (target) onScopeChange(target.id);
+ if (target) onScopeChange(target);
};
return (
<div
role="radiogroup"
- aria-label="Graph scope"
+ aria-label={c.label}
onKeyDown={onKeyDown}
className={`inline-flex rounded-md border border-[var(--color-border-default)] p-0.5 ${className ?? ""}`}
>
- {SCOPES.map((s) => {
- const active = scope === s.id;
+ {SCOPES.map((id) => {
+ const s = c.scopes[id];
+ const active = scope === id;
return (
<button
- key={s.id}
+ key={id}
type="button"
role="radio"
aria-checked={active}
tabIndex={active ? 0 : -1}
title={s.hint}
- onClick={() => onScopeChange(s.id)}
+ onClick={() => onScopeChange(id)}
className={`rounded px-2.5 py-1 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] ${
active
? "bg-[var(--color-bg-elevated)] font-semibold text-[var(--color-text-primary)]"
@@ -153,6 +164,25 @@ export function ModuleFilterSelect({
}
+export interface GraphNarrowingSelectCopy {
+ showing: string;
+ allFiles: string;
+ community: string;
+ module: string;
+ smallerModules: string;
+ /** Option text for a community with no loaded label. */
+ communityFallback: (id: number) => string;
+}
+
+export const GRAPH_NARROWING_SELECT_COPY: GraphNarrowingSelectCopy = {
+ showing: "Showing",
+ allFiles: "All files",
+ community: "Community",
+ module: "Module",
+ smallerModules: "Smaller modules",
+ communityFallback: (id) => `Community ${id}`,
+};
+
/**
* The one narrowing control: "Showing all files / community X / module Y".
*
@@ -173,6 +203,7 @@ export function GraphNarrowingSelect({
activeCommunityLabel,
onChange,
className,
+ copy,
}: {
modules: ModuleGroup[];
/** Communities offered as narrowing targets. Empty hides that group. */
@@ -183,7 +214,9 @@ export function GraphNarrowingSelect({
/** Exactly one of the two is ever non-null. */
onChange: (next: { module: string | null; community: number | null }) => void;
className?: string | undefined;
+ copy?: Partial<GraphNarrowingSelectCopy> | undefined;
}) {
+ const c = { ...GRAPH_NARROWING_SELECT_COPY, ...copy };
const hasCommunities = (communities?.length ?? 0) > 0;
if (modules.length < 2 && !hasCommunities && activeCommunity === null && !activeModule) return null;
@@ -222,7 +255,7 @@ export function GraphNarrowingSelect({
className={`inline-flex items-center gap-1.5 text-xs text-[var(--color-text-secondary)] ${className ?? ""}`}
>
<span className="font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--color-text-secondary)]">
- Showing
+ {c.showing}
</span>
<select
value={value}
@@ -234,13 +267,13 @@ export function GraphNarrowingSelect({
}}
className="max-w-[15rem] rounded-md border border-[var(--color-border-default)] bg-[var(--color-bg-elevated)] px-2 py-1 text-xs text-[var(--color-text-primary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]"
>
- <option value="">All files</option>
+ <option value="">{c.allFiles}</option>
{staleModule && <option value={`m:${staleModule}`}>{staleModule} · 0</option>}
{(hasCommunities || staleCommunity !== null) && (
- <optgroup label="Community">
+ <optgroup label={c.community}>
{staleCommunity !== null && (
<option value={`c:${staleCommunity}`}>
- {activeCommunityLabel ?? `Community ${staleCommunity}`}
+ {activeCommunityLabel ?? c.communityFallback(staleCommunity)}
</option>
)}
{communities?.map((c) => (
@@ -251,7 +284,7 @@ export function GraphNarrowingSelect({
</optgroup>
)}
{modules.length > 0 && (
- <optgroup label="Module">
+ <optgroup label={c.module}>
{prominent.map((g) => (
<option key={g.id} value={`m:${g.id}`}>
{g.id} · {formatNumber(g.fileCount)}
@@ -260,7 +293,7 @@ export function GraphNarrowingSelect({
</optgroup>
)}
{rest.length > 0 && (
- <optgroup label="Smaller modules">
+ <optgroup label={c.smallerModules}>
{rest.map((g) => (
<option key={g.id} value={`m:${g.id}`}>
{g.id} · {formatNumber(g.fileCount)}
diff --git a/packages/ui/src/graph/graph-toolbar.tsx b/packages/ui/src/graph/graph-toolbar.tsx
index 55f27d21b..2ff4cbfe4 100644
--- a/packages/ui/src/graph/graph-toolbar.tsx
+++ b/packages/ui/src/graph/graph-toolbar.tsx
@@ -135,8 +135,36 @@ interface GraphToolbarProps {
onToggleHelp?: (() => void) | undefined;
/** @deprecated See {@link GraphToolbarProps.layoutMode}. */
hierarchicalDisabledReason?: string | undefined;
+ copy?: Partial<GraphToolbarCopy> | undefined;
}
+export interface GraphToolbarCopy {
+ trace: string;
+ traceTitle: string;
+ /** Title when the host has no path finder. */
+ traceTitleFlowsOnly: string;
+ traceAriaPathOpen: string;
+ traceAriaFlowsOpen: string;
+ findPath: string;
+ executionFlows: string;
+ searchPlaceholder: string;
+ searchLabel: string;
+ clearSearch: string;
+}
+
+export const GRAPH_TOOLBAR_COPY: GraphToolbarCopy = {
+ trace: "Trace",
+ traceTitle: "Trace a dependency path or an execution flow",
+ traceTitleFlowsOnly: "Trace an execution flow",
+ traceAriaPathOpen: "Trace: dependency path open",
+ traceAriaFlowsOpen: "Trace: execution flows open",
+ findPath: "Find dependency path",
+ executionFlows: "Execution flows",
+ searchPlaceholder: "Search nodes…",
+ searchLabel: "Search graph nodes",
+ clearSearch: "Clear search",
+};
+
// No scope cluster here. Scope is one axis and it now has one control, in the
// section header (`GraphScopeSwitcher`), following the Code Health precedent —
// floating it over the diagram while the page tabs steered the same axis is
@@ -146,12 +174,26 @@ interface GraphToolbarProps {
// files are near-disjoint sets, so the old pair of independent toggles read
// as an AND filter and mostly produced an empty view when both were lit; a
// single exclusive control matches how the affordance is read.
-const NODE_FILTERS: { id: Overlay | "all"; icon?: typeof Skull; label: string; hint: string }[] = [
- { id: "all", label: "All", hint: "Show every node" },
- { id: "hot", icon: Flame, label: "Hot", hint: "High-churn files" },
- { id: "dead", icon: Skull, label: "Dead", hint: "Dead-code files" },
+const NODE_FILTERS: { id: Overlay | "all"; icon?: typeof Skull }[] = [
+ { id: "all" },
+ { id: "hot", icon: Flame },
+ { id: "dead", icon: Skull },
];
+export interface GraphNodeFilterCopy {
+ label: string;
+ filters: Record<Overlay | "all", { label: string; hint: string }>;
+}
+
+export const GRAPH_NODE_FILTER_COPY: GraphNodeFilterCopy = {
+ label: "Node filter",
+ filters: {
+ all: { label: "All", hint: "Show every node" },
+ hot: { label: "Hot", hint: "High-churn files" },
+ dead: { label: "Dead", hint: "Dead-code files" },
+ },
+};
+
// Trace sits beside the scope switcher and reads as its peer: the same 12px
// type and hairline border. It was a 10px tertiary glyph-and-word, which is
// the size and tone the contrast audit fails.
@@ -186,11 +228,14 @@ export function GraphNodeFilter({
viewMode,
onViewChange,
className,
+ copy,
}: {
viewMode: ViewMode;
onViewChange: (mode: ViewMode) => void;
className?: string | undefined;
+ copy?: Partial<GraphNodeFilterCopy> | undefined;
}) {
+ const c = { ...GRAPH_NODE_FILTER_COPY, ...copy };
const { scope, overlays } = viewModeToScopeOverlays(viewMode);
const active: Overlay | "all" = overlays.has("dead")
? "dead"
@@ -201,7 +246,7 @@ export function GraphNodeFilter({
return (
<div
role="radiogroup"
- aria-label="Node filter"
+ aria-label={c.label}
className={`${segmentGroupClass} ${className ?? ""}`}
>
{NODE_FILTERS.map((f) => {
@@ -213,7 +258,7 @@ export function GraphNodeFilter({
type="button"
role="radio"
aria-checked={isActive}
- title={f.hint}
+ title={c.filters[f.id].hint}
onClick={() =>
onViewChange(
scopeOverlaysToViewMode(
@@ -230,7 +275,7 @@ export function GraphNodeFilter({
>
<span className="inline-flex items-center gap-1">
{Icon && <Icon className="h-3 w-3" />}
- {f.label}
+ {c.filters[f.id].label}
</span>
</button>
);
@@ -259,7 +304,9 @@ export const GraphToolbar = memo(function GraphToolbar({
searchMatchCount,
searchTotalCount,
onSearchKeyDown,
+ copy,
}: GraphToolbarProps) {
+ const c = { ...GRAPH_TOOLBAR_COPY, ...copy };
const [traceOpen, setTraceOpen] = useState(false);
// Derive scope from the legacy ViewMode so this component remains the single
// source of truth — callers can continue to round-trip the wire-format
@@ -284,25 +331,21 @@ export const GraphToolbar = memo(function GraphToolbar({
<button
type="button"
className={`${itemClass} ${traceActive ? itemActiveClass : itemIdleClass}`}
- title={
- pathFinderAvailable
- ? "Trace a dependency path or an execution flow"
- : "Trace an execution flow"
- }
+ title={pathFinderAvailable ? c.traceTitle : c.traceTitleFlowsOnly}
// Not colour alone. The two buttons this replaced each carried
// their own `aria-pressed`; without this a reader who cannot see
// the accent has to open the menu to learn a trace panel is
// already open.
aria-label={
showPathFinder
- ? "Trace: dependency path open"
+ ? c.traceAriaPathOpen
: showFlows
- ? "Trace: execution flows open"
- : "Trace"
+ ? c.traceAriaFlowsOpen
+ : c.trace
}
>
<Route className="w-3 h-3" />
- <span>Trace</span>
+ <span>{c.trace}</span>
<ChevronDown className="w-3 h-3" />
</button>
</PopoverTrigger>
@@ -322,7 +365,7 @@ export const GraphToolbar = memo(function GraphToolbar({
}`}
>
<Route className="h-3.5 w-3.5 shrink-0" />
- Find dependency path
+ {c.findPath}
</button>
)}
<button
@@ -339,7 +382,7 @@ export const GraphToolbar = memo(function GraphToolbar({
}`}
>
<Workflow className="h-3.5 w-3.5 shrink-0" />
- Execution flows
+ {c.executionFlows}
</button>
</PopoverContent>
</Popover>
@@ -354,8 +397,8 @@ export const GraphToolbar = memo(function GraphToolbar({
value={searchQuery}
onChange={(e) => onSearchChange(e.target.value)}
onKeyDown={onSearchKeyDown}
- placeholder="Search nodes…"
- aria-label="Search graph nodes"
+ placeholder={c.searchPlaceholder}
+ aria-label={c.searchLabel}
className={cn(FIELD_CLASS, "w-40 py-1.5 pl-7 pr-14 text-xs sm:w-36 lg:w-48")}
/>
<span className="absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-1">
@@ -367,7 +410,7 @@ export const GraphToolbar = memo(function GraphToolbar({
{searchQuery && (
<button
onClick={() => onSearchChange("")}
- aria-label="Clear search"
+ aria-label={c.clearSearch}
className="text-[var(--color-text-tertiary)] hover:text-[var(--color-text-primary)]"
>
<X className="h-3 w-3" />
diff --git a/packages/ui/src/graph/graph-truncation-banner.tsx b/packages/ui/src/graph/graph-truncation-banner.tsx
index dd569bb86..f7f1f9416 100644
--- a/packages/ui/src/graph/graph-truncation-banner.tsx
+++ b/packages/ui/src/graph/graph-truncation-banner.tsx
@@ -14,6 +14,7 @@
* Lives in `packages/ui` so the hosted frontend can reuse it.
*/
+import type { ReactNode } from "react";
import { cn } from "../lib/cn";
import { formatNumber } from "../lib/format";
@@ -33,6 +34,27 @@ export const LOAD_MORE_CEILING = 3000;
const SLOW_HINT_THRESHOLD = 3000;
+export interface GraphTruncationBannerCopy {
+ /** `shown` and `total` arrive as emphasised figures. */
+ showing: (shown: ReactNode, total: ReactNode) => ReactNode;
+ /** Follows the sentence directly, so it carries its own leading space. */
+ slowerHint: string;
+ seeAllGrouped: string;
+ /** `count` is already formatted. */
+ loadMore: (count: string) => string;
+}
+
+export const GRAPH_TRUNCATION_BANNER_COPY: GraphTruncationBannerCopy = {
+ showing: (shown, total) => (
+ <>
+ Showing the {shown} most-connected files of {total}.
+ </>
+ ),
+ slowerHint: " Loading more will be slower.",
+ seeAllGrouped: "See all of them grouped",
+ loadMore: (count) => `Load ${count} more`,
+};
+
export interface GraphTruncationBannerProps {
shown: number;
total: number;
@@ -43,6 +65,7 @@ export interface GraphTruncationBannerProps {
/** When known, suggests a healthier scope to switch to. */
onSwitchToArchitecture?: () => void;
className?: string;
+ copy?: Partial<GraphTruncationBannerCopy> | undefined;
}
const linkClass =
@@ -55,7 +78,9 @@ export function GraphTruncationBanner({
onLoadMore,
onSwitchToArchitecture,
className,
+ copy,
}: GraphTruncationBannerProps) {
+ const c = { ...GRAPH_TRUNCATION_BANNER_COPY, ...copy };
const nextLimit = Math.min(limit + LOAD_MORE_STEP, LOAD_MORE_CEILING, total);
const canLoadMore = nextLimit > limit;
const slowHint = nextLimit > SLOW_HINT_THRESHOLD;
@@ -70,20 +95,19 @@ export function GraphTruncationBanner({
)}
>
<p className="min-w-0 flex-1">
- Showing the{" "}
- <span className="font-medium tabular-nums text-[var(--color-text-primary)]">
- {formatNumber(shown)}
- </span>{" "}
- most-connected files of{" "}
- <span className="font-medium tabular-nums text-[var(--color-text-primary)]">
- {formatNumber(total)}
- </span>
- .
- {slowHint && canLoadMore && " Loading more will be slower."}
+ {c.showing(
+ <span className="font-medium tabular-nums text-[var(--color-text-primary)]">
+ {formatNumber(shown)}
+ </span>,
+ <span className="font-medium tabular-nums text-[var(--color-text-primary)]">
+ {formatNumber(total)}
+ </span>,
+ )}
+ {slowHint && canLoadMore && c.slowerHint}
</p>
{onSwitchToArchitecture && (
<button type="button" onClick={onSwitchToArchitecture} className={linkClass}>
- See all of them grouped
+ {c.seeAllGrouped}
</button>
)}
{onLoadMore && canLoadMore && (
@@ -92,7 +116,7 @@ export function GraphTruncationBanner({
onClick={() => onLoadMore(nextLimit)}
className={linkClass}
>
- Load {formatNumber(Math.min(LOAD_MORE_STEP, nextLimit - limit))} more
+ {c.loadMore(formatNumber(Math.min(LOAD_MORE_STEP, nextLimit - limit)))}
</button>
)}
</div>
diff --git a/packages/ui/src/health/severity-mark.tsx b/packages/ui/src/health/severity-mark.tsx
index 5e67c1288..c9765a9ad 100644
--- a/packages/ui/src/health/severity-mark.tsx
+++ b/packages/ui/src/health/severity-mark.tsx
@@ -32,10 +32,13 @@ const SEVERITY_TEXT: Record<Severity, string> = {
export function SeverityMark({
severity,
compact = false,
+ label,
className,
}: {
severity: Severity;
compact?: boolean;
+ /** The severity word. English by default. */
+ label?: string | undefined;
className?: string;
}) {
return (
@@ -48,7 +51,7 @@ export function SeverityMark({
className={`h-1.5 w-1.5 shrink-0 rounded-full ${SEVERITY_DOT[severity]}`}
aria-hidden
/>
- <span className={compact ? "sr-only" : undefined}>{SEVERITY_LABEL[severity]}</span>
+ <span className={compact ? "sr-only" : undefined}>{label ?? SEVERITY_LABEL[severity]}</span>
</span>
);
}
diff --git a/packages/ui/src/lib/format.ts b/packages/ui/src/lib/format.ts
index 334cb1423..c00f17225 100644
--- a/packages/ui/src/lib/format.ts
+++ b/packages/ui/src/lib/format.ts
@@ -67,8 +67,10 @@ export function formatCost(usd: number): string {
}).format(usd);
}
-/** Format a datetime to a relative string: "2h ago", "3d ago", "just now" */
-export function formatRelativeTime(date: string | Date): string {
+export type RelativeTimeUnit = "now" | "s" | "m" | "h" | "d" | "w" | "mo" | "y";
+
+/** The bucket `formatRelativeTime` picks, for hosts that word it themselves. */
+export function relativeTimeParts(date: string | Date): { unit: RelativeTimeUnit; value: number } {
const d = parseDate(date);
const now = Date.now();
const diff = now - d.getTime();
@@ -79,14 +81,20 @@ export function formatRelativeTime(date: string | Date): string {
const weeks = Math.floor(days / 7);
const months = Math.floor(days / 30);
- if (seconds < 10) return "just now";
- if (seconds < 60) return `${seconds}s ago`;
- if (minutes < 60) return `${minutes}m ago`;
- if (hours < 24) return `${hours}h ago`;
- if (days < 7) return `${days}d ago`;
- if (weeks < 5) return `${weeks}w ago`;
- if (months < 12) return `${months}mo ago`;
- return `${Math.floor(months / 12)}y ago`;
+ if (seconds < 10) return { unit: "now", value: 0 };
+ if (seconds < 60) return { unit: "s", value: seconds };
+ if (minutes < 60) return { unit: "m", value: minutes };
+ if (hours < 24) return { unit: "h", value: hours };
+ if (days < 7) return { unit: "d", value: days };
+ if (weeks < 5) return { unit: "w", value: weeks };
+ if (months < 12) return { unit: "mo", value: months };
+ return { unit: "y", value: Math.floor(months / 12) };
+}
+
+/** Format a datetime to a relative string: "2h ago", "3d ago", "just now" */
+export function formatRelativeTime(date: string | Date): string {
+ const { unit, value } = relativeTimeParts(date);
+ return unit === "now" ? "just now" : `${value}${unit} ago`;
}
/** Relative time that tolerates null/invalid input, returning `fallback`
diff --git a/packages/ui/src/overview/attention-areas.tsx b/packages/ui/src/overview/attention-areas.tsx
index b1daa7ac5..028380926 100644
--- a/packages/ui/src/overview/attention-areas.tsx
+++ b/packages/ui/src/overview/attention-areas.tsx
@@ -5,6 +5,21 @@ import { biomarkerLabel } from "../health/biomarker-glossary";
import { SeverityMark } from "../health/severity-mark";
import { FilePath } from "../shared/file-path";
import { formatNumber } from "../lib/format";
+import type { Severity } from "../health/tokens";
+
+/** Area names, the empty line and severity words. English by default. */
+export interface AttentionAreasCopy {
+ areaLabel: (key: string) => string;
+ empty: string;
+ severity: (severity: Severity) => string | undefined;
+}
+
+export const ATTENTION_AREAS_COPY: AttentionAreasCopy = {
+ areaLabel: attentionSourceLabel,
+ empty: "Nothing needs attention right now.",
+ // Undefined keeps SeverityMark's own word.
+ severity: () => undefined,
+};
/** What to call the lead item's kind. Health findings name their biomarker. */
function leadKind(lead: NonNullable<OverviewAttentionAreaRow["lead"]>): string {
@@ -38,16 +53,19 @@ export function AttentionAreas({
areas,
prefix,
LinkComponent,
+ copy,
}: {
/** `unit` names what the count is in, e.g. "open findings". */
areas: InventoryArea[];
prefix: string;
LinkComponent?: React.ElementType | undefined;
+ copy?: Partial<AttentionAreasCopy> | undefined;
}) {
const A = LinkComponent ?? "a";
+ const c = { ...ATTENTION_AREAS_COPY, ...copy };
if (areas.length === 0) {
return (
- <p className="text-xs text-[var(--color-success)]">Nothing needs attention right now.</p>
+ <p className="text-xs text-[var(--color-success)]">{c.empty}</p>
);
}
@@ -61,7 +79,7 @@ export function AttentionAreas({
className="group flex flex-col gap-1 py-3 text-xs no-underline sm:flex-row sm:items-baseline sm:gap-4"
>
<span className="shrink-0 font-medium text-[var(--color-text-primary)] group-hover:text-[var(--color-accent-primary)] sm:w-32">
- {attentionSourceLabel(area.key)}
+ {c.areaLabel(area.key)}
</span>
<span className="shrink-0 text-[var(--color-text-tertiary)] sm:w-48">
@@ -72,7 +90,7 @@ export function AttentionAreas({
</span>
<span className="min-w-0 flex-1 text-[var(--color-text-tertiary)]">
- <AreaLead area={area} />
+ <AreaLead area={area} severityLabel={c.severity(area.severity)} />
</span>
<span
@@ -92,7 +110,13 @@ export function AttentionAreas({
type InventoryArea = OverviewAttentionAreaRow & { unit?: string };
/** The worst item in an area, its severity, and what the count is made of. */
-function AreaLead({ area }: { area: InventoryArea }) {
+function AreaLead({
+ area,
+ severityLabel,
+}: {
+ area: InventoryArea;
+ severityLabel: string | undefined;
+}) {
const lead = area.lead;
if (!lead) {
return area.detail ? (
@@ -103,7 +127,7 @@ function AreaLead({ area }: { area: InventoryArea }) {
const isPath = !!lead.target_id && lead.title === lead.target_id;
return (
<>
- <SeverityMark severity={area.severity} className="mr-2" />
+ <SeverityMark severity={area.severity} label={severityLabel} className="mr-2" />
{kind && <span className="text-[var(--color-text-secondary)]">{kind} · </span>}
{isPath ? (
<FilePath
diff --git a/packages/ui/src/overview/attention-section.tsx b/packages/ui/src/overview/attention-section.tsx
index dddf29968..28f4d6f84 100644
--- a/packages/ui/src/overview/attention-section.tsx
+++ b/packages/ui/src/overview/attention-section.tsx
@@ -2,9 +2,9 @@ import * as React from "react";
import type { OverviewSummaryResponse } from "@repowise-dev/types/overview";
import { getDefaultHref } from "../dashboard/attention-href";
import { formatNumber } from "../lib/format";
-import { AttentionAreas } from "./attention-areas";
+import { AttentionAreas, type AttentionAreasCopy } from "./attention-areas";
import { AttentionRows } from "./attention-rows";
-import { inventoryRows } from "./overview-model";
+import { inventoryRows, type InventoryCopy } from "./overview-model";
import { OverviewSection } from "./section";
/** Ranked rows shown when the server predates the area rollup. */
@@ -17,12 +17,39 @@ export interface AttentionSectionProps {
/** Fold it as the inventory behind "Do next" instead of leading with it. */
inventory?: boolean;
LinkComponent?: React.ElementType | undefined;
+ copy?: Partial<AttentionSectionCopy> | undefined;
}
+/** Headings, counts and row words. English by default. */
+export interface AttentionSectionCopy {
+ title: string;
+ description: string;
+ inventoryTitle: string;
+ inventoryDescription: string;
+ scopeAreas: (areas: number) => string;
+ scopeOpen: (open: number) => string;
+ areas?: Partial<AttentionAreasCopy> | undefined;
+ inventory?: Partial<InventoryCopy> | undefined;
+}
+
+export const ATTENTION_SECTION_COPY: AttentionSectionCopy = {
+ title: "Needs attention",
+ description: "Each area of work, led by the worst thing in it.",
+ inventoryTitle: "Everything we found",
+ inventoryDescription:
+ "Every detector's open count by area. The actions above are the part worth doing.",
+ scopeAreas: (areas) => `${formatNumber(areas)} ${areas === 1 ? "area" : "areas"}`,
+ scopeOpen: (open) => `${formatNumber(open)} open`,
+};
+
/** Areas count different things, so the header counts areas, not their sum. */
-function scopeLabel(summary: OverviewSummaryResponse, areaCount: number): string {
- if (areaCount > 0) return `${formatNumber(areaCount)} ${areaCount === 1 ? "area" : "areas"}`;
- return `${formatNumber(summary.attention_summary?.total ?? summary.attention.length)} open`;
+function scopeLabel(
+ summary: OverviewSummaryResponse,
+ areaCount: number,
+ c: AttentionSectionCopy,
+): string {
+ if (areaCount > 0) return c.scopeAreas(areaCount);
+ return c.scopeOpen(summary.attention_summary?.total ?? summary.attention.length);
}
/**
@@ -35,23 +62,21 @@ export function AttentionSection({
base,
inventory = false,
LinkComponent,
+ copy,
}: AttentionSectionProps) {
+ const c = { ...ATTENTION_SECTION_COPY, ...copy };
// Counts read from the same basis as the explore cards and the pages they
// link to. The areas count different things (findings, files,
// opportunities), so the header counts areas rather than summing them.
- const areas = inventoryRows(summary);
+ const areas = inventoryRows(summary, c.inventory);
const hasAttention = areas.length > 0 || summary.attention.length > 0;
- const scope = scopeLabel(summary, areas.length);
+ const scope = scopeLabel(summary, areas.length, c);
if (!hasAttention) return null;
return (
<OverviewSection
- title={inventory ? "Everything we found" : "Needs attention"}
- description={
- inventory
- ? "Every detector's open count by area. The actions above are the part worth doing."
- : "Each area of work, led by the worst thing in it."
- }
+ title={inventory ? c.inventoryTitle : c.title}
+ description={inventory ? c.inventoryDescription : c.description}
collapsible={inventory}
defaultOpen={!inventory}
hint={inventory ? scope : undefined}
@@ -65,7 +90,7 @@ export function AttentionSection({
}
>
{areas.length > 0 ? (
- <AttentionAreas areas={areas} prefix={base} LinkComponent={LinkComponent} />
+ <AttentionAreas areas={areas} prefix={base} LinkComponent={LinkComponent} copy={c.areas} />
) : (
// A server predating the area rollup still sends ranked items, and
// rendering those is strictly better than rendering nothing.
diff --git a/packages/ui/src/overview/change-line.tsx b/packages/ui/src/overview/change-line.tsx
index 5e9ed8534..a47d1b5d4 100644
--- a/packages/ui/src/overview/change-line.tsx
+++ b/packages/ui/src/overview/change-line.tsx
@@ -8,6 +8,18 @@ export interface ChangeStat {
label: string;
}
+export interface ChangeLineCopy {
+ /** The lead-in. `relative` is the previous index's age, e.g. "2d ago". */
+ since: (relative: string) => string;
+ /** Words the previous index's age, e.g. "2d ago". */
+ relativeTime: (iso: string) => string;
+}
+
+export const CHANGE_LINE_COPY: ChangeLineCopy = {
+ since: (relative) => `Since the previous index, ${relative}`,
+ relativeTime: formatRelativeTime,
+};
+
export interface ChangeLineProps {
/**
* ISO timestamp of the PREVIOUS index snapshot — the point the figures are
@@ -15,6 +27,7 @@ export interface ChangeLineProps {
*/
since: string | null;
stats: ChangeStat[];
+ copy?: Partial<ChangeLineCopy> | undefined;
}
/**
@@ -35,8 +48,9 @@ export interface ChangeLineProps {
* Renders nothing without two snapshots to compare, or when nothing moved: an
* all-zeroes strip is noise pretending to be news.
*/
-export function ChangeLine({ since, stats }: ChangeLineProps) {
+export function ChangeLine({ since, stats, copy }: ChangeLineProps) {
if (!since || stats.length === 0) return null;
+ const c = { ...CHANGE_LINE_COPY, ...copy };
return (
<div className="flex flex-wrap items-baseline gap-x-4 gap-y-1 border-y border-[var(--color-border-default)] py-2.5 text-xs text-[var(--color-text-secondary)]">
@@ -44,7 +58,7 @@ export function ChangeLine({ since, stats }: ChangeLineProps) {
className="font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--color-text-tertiary)]"
title={formatDateTime(since)}
>
- Since the previous index, {formatRelativeTime(since)}
+ {c.since(c.relativeTime(since))}
</span>
{stats.map((s) => (
<span key={s.label}>
diff --git a/packages/ui/src/overview/health-lede.tsx b/packages/ui/src/overview/health-lede.tsx
index a08d131b7..adedcd49c 100644
--- a/packages/ui/src/overview/health-lede.tsx
+++ b/packages/ui/src/overview/health-lede.tsx
@@ -1,11 +1,18 @@
import * as React from "react";
import { healthBand } from "../health/tokens";
-import { formatScore } from "@repowise-dev/types/health";
+import {
+ bandForScore,
+ formatScore,
+ HEALTH_BAND_LABEL,
+ type HealthBand,
+} from "@repowise-dev/types/health";
import { LedeLink, PageLede } from "../shared/page-lede";
export interface HealthLedeCopy {
label: string;
unit: string;
+ /** The band word beside the figure. */
+ band: (band: HealthBand) => string;
reportLink: string;
/** Shown before the first health run. */
empty: string;
@@ -20,6 +27,7 @@ export interface HealthLedeCopy {
export const HEALTH_LEDE_COPY: HealthLedeCopy = {
label: "Code health",
unit: "out of 10",
+ band: (band) => HEALTH_BAND_LABEL[band],
reportLink: "Full health report",
empty:
"Health scores land with the first index: complexity, duplication, coverage, churn and ownership across every file.",
@@ -79,7 +87,7 @@ export function HealthLede({
);
}
- const band = healthBand(score);
+ const band = { ...healthBand(score), label: c.band(bandForScore(score)) };
const hot = hotspotCount > 0 && hotspotHealth != null ? hotspotHealth : null;
return (
diff --git a/packages/ui/src/overview/index.ts b/packages/ui/src/overview/index.ts
index fe7e7713b..d5020cdcf 100644
--- a/packages/ui/src/overview/index.ts
+++ b/packages/ui/src/overview/index.ts
@@ -23,18 +23,20 @@ export { RepoRows } from "./repo-rows";
export type { RepoRow, RepoRowsProps } from "./repo-rows";
export { HealthLede } from "./health-lede";
-export type { HealthLedeProps } from "./health-lede";
+export type { HealthLedeCopy, HealthLedeProps } from "./health-lede";
export { ReadsColumn } from "./reads-column";
export type { ReadItem, ReadBarSegment } from "./reads-column";
export { ChangeLine } from "./change-line";
-export type { ChangeLineProps, ChangeStat } from "./change-line";
+export type { ChangeLineCopy, ChangeLineProps, ChangeStat } from "./change-line";
export { CommitRows, DecisionRows } from "./activity-lists";
export type { CommitRow, DecisionRow } from "./activity-lists";
export { AttentionAreas } from "./attention-areas";
+export type { AttentionAreasCopy } from "./attention-areas";
+export type { AttentionSectionCopy } from "./attention-section";
export { AttentionRows } from "./attention-rows";
export { AttentionSources } from "./attention-sources";
export type { AttentionRowItem } from "./attention-rows";
@@ -42,7 +44,7 @@ export type { AttentionRowItem } from "./attention-rows";
export { HotspotTable } from "./hotspot-table";
export { actionHref } from "./action-href";
export { NextActions, renderActionTitle } from "./next-actions";
-export type { NextActionsProps } from "./next-actions";
+export type { NextActionsCopy, NextActionsProps } from "./next-actions";
export { ExploreList } from "./explore-list";
export { ExploreCards } from "./explore-cards";
export type { ExploreCard, ExploreCardsProps } from "./explore-cards";
@@ -64,4 +66,10 @@ export {
previousSnapshotAt,
resolveOverviewRoutes,
} from "./overview-model";
-export type { OverviewRoutes, ResolvedOverviewRoutes } from "./overview-model";
+export type {
+ ExploreEntryKey,
+ InventoryCopy,
+ OverviewModelCopy,
+ OverviewRoutes,
+ ResolvedOverviewRoutes,
+} from "./overview-model";
diff --git a/packages/ui/src/overview/next-actions.tsx b/packages/ui/src/overview/next-actions.tsx
index 85d5b03de..bbf771368 100644
--- a/packages/ui/src/overview/next-actions.tsx
+++ b/packages/ui/src/overview/next-actions.tsx
@@ -16,6 +16,7 @@ import {
import { useAiPromptAction } from "../health/ai-prompt-action";
import type { AiPromptFlavor } from "../health/ai-prompt-builder";
import { EFFORT_LABEL } from "../health/labels";
+import type { Severity } from "../health/tokens";
import { RowPromptAction } from "../health/row-prompt-action";
import { SeverityMark } from "../health/severity-mark";
import { CLICKABLE_ROW_CLS, clickableRowProps } from "../shared/responsive-table";
@@ -53,8 +54,82 @@ export interface NextActionsProps {
*/
defaultOpen?: boolean;
LinkComponent?: ElementType | undefined;
+ /** The list's own words. English by default; the actions' text is the server's. */
+ copy?: Partial<NextActionsCopy> | undefined;
}
+export interface NextActionsCopy {
+ title: string;
+ /** The folded heading, which carries the count. */
+ titleCount: (count: number) => string;
+ timeFrame: string;
+ week: string;
+ weekHint: string;
+ quarter: string;
+ quarterHint: string;
+ tier: (tier: ActionTier) => string;
+ allAnswered: string;
+ showFewer: string;
+ showAll: (count: number) => string;
+ listing: (shown: number, total: number) => string;
+ answered: (count: number) => string;
+ /** `checks` is the comma-joined list of checks that did not run. */
+ notChecked: (checks: string) => string;
+ emptyChecks: (count: number) => string;
+ undo: string;
+ undoFailed: string;
+ saveFailed: string;
+ openDetails: string;
+ markDone: string;
+ markedDone: string;
+ snooze: string;
+ snoozed: string;
+ dismiss: string;
+ dismissed: string;
+ effort: (effort: NextAction["effort"]) => string;
+ worthCheck: string;
+ inferred: string;
+ openRow: (title: string) => string;
+ moreFor: (title: string) => string;
+ /** Undefined keeps SeverityMark's own word. */
+ severity: (severity: Severity) => string | undefined;
+}
+
+export const NEXT_ACTIONS_COPY: NextActionsCopy = {
+ title: "Do next",
+ titleCount: (count) => `Do next · ${count.toLocaleString("en-US")}`,
+ timeFrame: "Time frame",
+ week: "This week",
+ weekHint: "What the last 7 days of commits changed",
+ quarter: "This quarter",
+ quarterHint: "What the last 90 days say is worth planning",
+ tier: (tier) => ACTION_TIER_LABELS[tier] ?? tier,
+ allAnswered: "You have answered everything listed here. Answers are kept until the facts change.",
+ showFewer: "Show fewer",
+ showAll: (count) => `Show all ${count.toLocaleString()}`,
+ listing: (shown, total) => `Listing ${shown.toLocaleString()} of ${total.toLocaleString()}.`,
+ answered: (count) => `${plural(count, "action")} answered (done, snoozed or dismissed).`,
+ notChecked: (checks) => `Not checked: ${checks}.`,
+ emptyChecks: (count) =>
+ `Repowise ran ${plural(count, "check")} over this index and none of them produced work for this time frame.`,
+ undo: "Undo",
+ undoFailed: "Could not undo",
+ saveFailed: "Could not save that; the action is back in the list",
+ openDetails: "Open details",
+ markDone: "Mark done",
+ markedDone: "Marked done. It returns if the facts change.",
+ snooze: "Snooze for 14 days",
+ snoozed: "Snoozed for 14 days",
+ dismiss: "Dismiss",
+ dismissed: "Dismissed. It returns if the facts change.",
+ effort: (effort) => `${EFFORT_LABEL[effort]} effort`,
+ worthCheck: "worth a check",
+ inferred: "(inferred)",
+ openRow: (title) => `Open ${title}`,
+ moreFor: (title) => `More for ${title}`,
+ severity: () => undefined,
+};
+
type ActionPromptLoader = (action: NextAction, flavor: AiPromptFlavor) => Promise<string>;
/**
@@ -145,7 +220,9 @@ export function NextActions({
showCliCommands,
defaultOpen = true,
LinkComponent,
+ copy,
}: NextActionsProps) {
+ const c = { ...NEXT_ACTIONS_COPY, ...copy };
// Open on the week unless it holds no work and the quarter does: a lone
// "add a coverage report" is not a reason to show an empty week first.
// Counts come from `data` alone, like the sentence, so the two agree; both
@@ -185,27 +262,27 @@ export function NextActions({
() =>
toast.success(message, {
action: {
- label: "Undo",
+ label: c.undo,
onClick: () => {
restore();
- void onSetState(action, null).catch(() => toast.error("Could not undo"));
+ void onSetState(action, null).catch(() => toast.error(c.undoFailed));
},
},
}),
() => {
restore();
- toast.error("Could not save that; the action is back in the list");
+ toast.error(c.saveFailed);
},
);
};
const timeFrame = (
<Segmented
- label="Time frame"
+ label={c.timeFrame}
value={horizon}
options={[
- { value: "week", label: "This week", count: String(work("week")), hint: "What the last 7 days of commits changed" },
- { value: "quarter", label: "This quarter", count: String(work("quarter")), hint: "What the last 90 days say is worth planning" },
+ { value: "week", label: c.week, count: String(work("week")), hint: c.weekHint },
+ { value: "quarter", label: c.quarter, count: String(work("quarter")), hint: c.quarterHint },
]}
onChange={(v) => {
setHorizon(v);
@@ -216,7 +293,7 @@ export function NextActions({
return (
<OverviewSection
- title={defaultOpen ? "Do next" : `Do next · ${work(horizon).toLocaleString("en-US")}`}
+ title={defaultOpen ? c.title : c.titleCount(work(horizon))}
description={data.summary?.[horizon] ?? fallbackSummary(data, horizon)}
// A folded section has no header action slot, so the time frame sits
// under the summary, above the list it filters, and the toggle carries
@@ -228,16 +305,16 @@ export function NextActions({
{!defaultOpen && timeFrame}
{shown.length === 0 && [...answered.values()].some((a) => a.horizons.includes(horizon)) ? (
<p className="py-2 text-sm text-[var(--color-text-secondary)]">
- You have answered everything listed here. Answers are kept until the facts change.
+ {c.allAnswered}
</p>
) : shown.length === 0 ? (
- <EmptyActions data={data} />
+ <EmptyActions data={data} copy={c} />
) : (
<div className="flex flex-col">
{groupByTier(shown).map(([tier, items]) => (
<div key={tier} className="flex flex-col">
<h3 className="pb-1 pt-3 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--color-text-tertiary)] first:pt-0">
- {ACTION_TIER_LABELS[tier] ?? tier}
+ {c.tier(tier)}
</h3>
<ul className="flex flex-col divide-y divide-[var(--color-border-default)]">
{items.map((action) => (
@@ -248,6 +325,7 @@ export function NextActions({
onOpen={() => setOpened(action)}
onPrompt={loadPrompt ? () => openActionPrompt(action, loadPrompt) : undefined}
onAnswer={onSetState ? (state, message) => answer(action, state, message) : undefined}
+ copy={c}
/>
))}
</ul>
@@ -263,23 +341,22 @@ export function NextActions({
onClick={() => setExpanded((e) => !e)}
className="rounded text-[var(--color-accent-primary)] hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]"
>
- {expanded ? "Show fewer" : `Show all ${Math.min(rows.length, total).toLocaleString()}`}
+ {expanded ? c.showFewer : c.showAll(Math.min(rows.length, total))}
</button>
)}
{total > rows.length && (
<span className="tabular-nums">
- {`Listing ${rows.length.toLocaleString()} of ${total.toLocaleString()}.`}
+ {c.listing(rows.length, total)}
</span>
)}
{h.hidden + (h.actions.length - rows.length) > 0 && (
- <span className="tabular-nums">{`${plural(
- h.hidden + (h.actions.length - rows.length),
- "action",
- )} answered (done, snoozed or dismissed).`}</span>
+ <span className="tabular-nums">
+ {c.answered(h.hidden + (h.actions.length - rows.length))}
+ </span>
)}
{unavailable.length > 0 && (
<span>
- {`Not checked: ${unavailable.join(", ").replace(/_/g, " ")}.`}
+ {c.notChecked(unavailable.join(", ").replace(/_/g, " "))}
{unavailableHint === undefined ? (
<>
{" Run "}
@@ -346,6 +423,7 @@ export function ActionRow({
selected = false,
onPrompt,
onAnswer,
+ copy,
}: {
action: NextAction;
/** Open the action's drawer; the whole row is the trigger. */
@@ -354,34 +432,36 @@ export function ActionRow({
/** Open the agent prompt for this action. Omit to hide the row's prompt verb. */
onPrompt?: (() => void) | undefined;
onAnswer?: ((state: ActionStateValue, message: string) => void) | undefined;
+ copy?: Partial<NextActionsCopy> | undefined;
}) {
+ const c = { ...NEXT_ACTIONS_COPY, ...copy };
const plainTitle = action.title.replace(/`/g, "");
const location = actionLocation(action);
const items = [
- { label: "Open details", icon: PanelRight, onSelect: onOpen },
+ { label: c.openDetails, icon: PanelRight, onSelect: onOpen },
...(onAnswer
? [
{
- label: "Mark done",
+ label: c.markDone,
icon: Check,
- onSelect: () => onAnswer("done", "Marked done. It returns if the facts change."),
+ onSelect: () => onAnswer("done", c.markedDone),
},
{
- label: "Snooze for 14 days",
+ label: c.snooze,
icon: BellOff,
- onSelect: () => onAnswer("snoozed", "Snoozed for 14 days"),
+ onSelect: () => onAnswer("snoozed", c.snoozed),
},
{
- label: "Dismiss",
+ label: c.dismiss,
icon: X,
- onSelect: () => onAnswer("dismissed", "Dismissed. It returns if the facts change."),
+ onSelect: () => onAnswer("dismissed", c.dismissed),
},
]
: []),
];
return (
<li
- aria-label={`Open ${plainTitle}`}
+ aria-label={c.openRow(plainTitle)}
aria-current={selected ? "true" : undefined}
data-selected={selected ? "true" : undefined}
className={`${CLICKABLE_ROW_CLS} group group/row flex items-start gap-3 px-1 py-3.5 sm:gap-4 ${
@@ -392,7 +472,11 @@ export function ActionRow({
<div className="min-w-0 flex-1">
<div className="flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1">
{action.tier === "act_now" && (
- <SeverityMark severity={action.severity} className="translate-y-[-1px]" />
+ <SeverityMark
+ severity={action.severity}
+ label={c.severity(action.severity)}
+ className="translate-y-[-1px]"
+ />
)}
<p className="min-w-0 text-[15px] font-semibold leading-snug text-[var(--color-text-primary)] [text-wrap:pretty] group-hover:text-[var(--color-accent-primary)]">
{renderActionTitle(action.title)}
@@ -419,7 +503,7 @@ export function ActionRow({
>
{w.value}
{w.basis === "inferred" && (
- <span className="ml-1 font-sans text-[var(--color-text-tertiary)]">(inferred)</span>
+ <span className="ml-1 font-sans text-[var(--color-text-tertiary)]">{c.inferred}</span>
)}
</dd>
</div>
@@ -428,27 +512,27 @@ export function ActionRow({
</div>
<div className="flex shrink-0 items-center gap-2">
<span className="text-xs text-[var(--color-text-tertiary)]">
- <span className="hidden sm:inline">{`${EFFORT_LABEL[action.effort]} effort`}</span>
+ <span className="hidden sm:inline">{c.effort(action.effort)}</span>
{action.confidence === "medium" && (
<>
<span className="hidden sm:inline">, </span>
- <span>worth a check</span>
+ <span>{c.worthCheck}</span>
</>
)}
</span>
{onPrompt && <RowPromptAction subject={plainTitle} onClick={onPrompt} />}
- <RowOverflow label={`More for ${plainTitle}`} items={items} />
+ <RowOverflow label={c.moreFor(plainTitle)} items={items} />
</div>
</li>
);
}
-function EmptyActions({ data }: { data: ActionsResponse }) {
+function EmptyActions({ data, copy }: { data: ActionsResponse; copy: NextActionsCopy }) {
const checked = data.rules.filter((r) => r.status === "evaluated").length;
const skipped = data.rules.filter((r) => r.status === "not_applicable");
return (
<div className="flex flex-col gap-1 py-2 text-sm text-[var(--color-text-secondary)]">
- <p>{`Repowise ran ${plural(checked, "check")} over this index and none of them produced work for this time frame.`}</p>
+ <p>{copy.emptyChecks(checked)}</p>
{skipped.length > 0 && (
<p className="text-xs text-[var(--color-text-tertiary)]">
{skipped.map((r) => r.reason).join(" ")}
diff --git a/packages/ui/src/overview/overview-body.tsx b/packages/ui/src/overview/overview-body.tsx
index 55d0616d8..18cd89b9e 100644
--- a/packages/ui/src/overview/overview-body.tsx
+++ b/packages/ui/src/overview/overview-body.tsx
@@ -3,11 +3,11 @@ import type { OverviewSummaryResponse } from "@repowise-dev/types/overview";
import { formatNumber } from "../lib/format";
import { fileEntityPath } from "../shared/entity";
import { PageFrame } from "../shared/page-shell";
-import { AttentionSection } from "./attention-section";
+import { AttentionSection, type AttentionSectionCopy } from "./attention-section";
import type { CommitRow } from "./activity-lists";
-import { ChangeLine } from "./change-line";
+import { ChangeLine, type ChangeLineCopy } from "./change-line";
import { ExploreCards } from "./explore-cards";
-import { HealthLede } from "./health-lede";
+import { HealthLede, type HealthLedeCopy } from "./health-lede";
import { HotspotTable } from "./hotspot-table";
import {
buildChangeStats,
@@ -16,6 +16,7 @@ import {
buildReads,
previousSnapshotAt,
resolveOverviewRoutes,
+ type OverviewModelCopy,
type OverviewRoutes,
} from "./overview-model";
import { ReadsColumn } from "./reads-column";
@@ -63,6 +64,12 @@ export interface OverviewBodyProps {
export interface OverviewBodyCopy {
exploreTitle: string;
exploreMore: string;
+ /** Forwarded to the children; each falls back to its own English. */
+ healthLede?: Partial<HealthLedeCopy> | undefined;
+ changeLine?: Partial<ChangeLineCopy> | undefined;
+ /** Rows the model builds: reads, explore cards and further doors. */
+ model?: Partial<OverviewModelCopy> | undefined;
+ attention?: Partial<AttentionSectionCopy> | undefined;
}
export const OVERVIEW_BODY_COPY: OverviewBodyCopy = {
@@ -101,17 +108,17 @@ export function OverviewBody({
const { base } = resolved;
const { stats, health } = summary;
- const reads = buildReads(summary, routes);
- const cards = buildExploreCards(summary, routes);
+ const reads = buildReads(summary, routes, c.model);
+ const cards = buildExploreCards(summary, routes, c.model);
const carded = new Set(cards.map((card) => card.key));
- const moreDoors = buildExplore(summary, routes).filter((e) => !carded.has(e.key));
- const changeStats = buildChangeStats(summary);
+ const moreDoors = buildExplore(summary, routes, c.model).filter((e) => !carded.has(e.key));
+ const changeStats = buildChangeStats(summary, c.model);
return (
<PageFrame>
{slots.header}
- <ChangeLine since={previousSnapshotAt(summary)} stats={changeStats} />
+ <ChangeLine since={previousSnapshotAt(summary)} stats={changeStats} copy={c.changeLine} />
<div className="grid grid-cols-1 items-start gap-8 lg:grid-cols-[minmax(0,1fr)_300px] lg:gap-12">
<HealthLede
@@ -121,6 +128,7 @@ export function OverviewBody({
fileCount={stats.file_count}
href={`${base}/code-health`}
LinkComponent={LinkComponent}
+ copy={c.healthLede}
/>
<div className="flex flex-col gap-6">
<ReadsColumn items={reads} LinkComponent={LinkComponent} />
@@ -140,7 +148,12 @@ export function OverviewBody({
</OverviewSection>
{slots.actions ?? (
- <AttentionSection summary={summary} base={base} LinkComponent={LinkComponent} />
+ <AttentionSection
+ summary={summary}
+ base={base}
+ LinkComponent={LinkComponent}
+ copy={c.attention}
+ />
)}
{slots.wins}
@@ -172,7 +185,13 @@ export function OverviewBody({
{/* The areas as the inventory behind "Do next", folded at the bottom
because the list above already says what to do. */}
{slots.actions && (
- <AttentionSection summary={summary} base={base} inventory LinkComponent={LinkComponent} />
+ <AttentionSection
+ summary={summary}
+ base={base}
+ inventory
+ LinkComponent={LinkComponent}
+ copy={c.attention}
+ />
)}
</PageFrame>
);
diff --git a/packages/ui/src/overview/overview-model.ts b/packages/ui/src/overview/overview-model.ts
index b49fc8075..c6279d1b8 100644
--- a/packages/ui/src/overview/overview-model.ts
+++ b/packages/ui/src/overview/overview-model.ts
@@ -33,6 +33,156 @@ import type { ReadItem } from "./reads-column";
import type { RibbonStat } from "../stats/stat-ribbon";
import { formatLOC, formatNumber } from "../lib/format";
+/** Keys of the further doors {@link buildExplore} lists. */
+export type ExploreEntryKey =
+ | "docs"
+ | "chat"
+ | "files"
+ | "architecture"
+ | "code-health"
+ | "knowledge-graph"
+ | "coupling"
+ | "commits"
+ | "decisions"
+ | "contributors"
+ | "stats"
+ | "costs";
+
+/** The words the builders below put into rows. Counts arrive raw, so a host
+ * can pluralise them. English by default. */
+export interface OverviewModelCopy {
+ /** Change line: the word after a file-count delta. */
+ changeFiles: (delta: number) => string;
+ changeCodeHealth: string;
+ changeHotspotHealth: string;
+ docsLabel: string;
+ docsUnit: string;
+ docsSplit: (prose: number, withoutProse: number) => string;
+ docsModules: (modules: number) => string;
+ docsProseBar: string;
+ docsIndexBar: string;
+ cardHealth: string;
+ cardOwnership: string;
+ cardArchitecture: string;
+ cardDecisions: string;
+ cardRefactoring: string;
+ cardTests: string;
+ healthScored: string;
+ healthHotspots: (hotspots: number, files: number) => string;
+ ownershipEmpty: string;
+ ownershipSole: (files: number) => string;
+ architectureModules: (modules: number, entryPoints: number) => string;
+ decisionsEmpty: string;
+ decisionsRecorded: (accepted: number, candidates: number) => string;
+ refactoringEmpty: string;
+ refactoringOpen: (opportunities: number) => string;
+ testsCoverage: string;
+ testsUnknown: string;
+ testsNone: string;
+ /** Further doors: label per key. */
+ exploreLabels: Record<ExploreEntryKey, string>;
+ /** Further doors: the tooltip per key. */
+ exploreDocs: (pages: number, modules: number) => string;
+ exploreFiles: (files: number) => string;
+ exploreArchitecture: (entryPoints: number) => string;
+ exploreCodeHealth: (findings: number) => string;
+ exploreChat: string;
+ exploreKnowledgeGraph: string;
+ exploreCoupling: string;
+ exploreCommits: string;
+ exploreDecisions: string;
+ exploreContributors: string;
+ exploreStats: string;
+ exploreCosts: string;
+}
+
+export const OVERVIEW_MODEL_COPY: OverviewModelCopy = {
+ changeFiles: (delta) => (Math.abs(delta) === 1 ? "file" : "files"),
+ changeCodeHealth: "code health",
+ changeHotspotHealth: "hotspot health",
+ docsLabel: "Documentation",
+ docsUnit: "pages",
+ docsSplit: (prose, withoutProse) =>
+ `${formatNumber(prose)} with model-written prose, ${formatNumber(withoutProse)} built from the index`,
+ docsModules: (modules) => `Across ${formatNumber(modules)} modules`,
+ docsProseBar: "Pages with model-written prose",
+ docsIndexBar: "Pages built from the index alone",
+ cardHealth: "Code health map",
+ cardOwnership: "Ownership",
+ cardArchitecture: "Architecture",
+ cardDecisions: "Decisions",
+ cardRefactoring: "Refactoring",
+ cardTests: "Tests",
+ healthScored: "files scored",
+ healthHotspots: (hotspots, files) =>
+ `${plural(hotspots, "hotspot", "hotspots")} across ${formatNumber(files)} files`,
+ ownershipEmpty: "Who knows each file, and what depends on them",
+ ownershipSole: (files) => `sole-owned ${plural(files, "file", "files")}: one author, no second reader`,
+ architectureModules: (modules, entryPoints) =>
+ `${plural(modules, "module", "modules")}, ${formatNumber(entryPoints)} entry points`,
+ decisionsEmpty: "No decisions recorded yet",
+ decisionsRecorded: (accepted, candidates) =>
+ `recorded, of which ${formatNumber(accepted)} accepted and ${formatNumber(candidates)} awaiting review`,
+ refactoringEmpty: "No refactoring analysis yet",
+ refactoringOpen: (opportunities) =>
+ `open ${plural(opportunities, "opportunity", "opportunities")}, one per file`,
+ testsCoverage: "line coverage from the latest report",
+ testsUnknown: "Coverage and the tests that reach each file",
+ testsNone: "No coverage report yet. Run your tests with coverage on, then add the report:",
+ exploreLabels: {
+ docs: "Docs",
+ chat: "Chat",
+ files: "Files",
+ architecture: "Architecture",
+ "code-health": "Code health",
+ "knowledge-graph": "Knowledge graph",
+ coupling: "Change coupling",
+ commits: "Commits",
+ decisions: "Decisions",
+ contributors: "Contributors",
+ stats: "Stats",
+ costs: "Costs",
+ },
+ exploreDocs: (pages, modules) => `${formatNumber(pages)} pages across ${formatNumber(modules)} modules`,
+ exploreFiles: (files) => `${formatNumber(files)} files with per-file docs, health and history`,
+ exploreArchitecture: (entryPoints) =>
+ `Dependency graph, layers, and ${formatNumber(entryPoints)} entry points`,
+ exploreCodeHealth: (findings) =>
+ `Per-file scores, ${formatNumber(findings)} open findings, coverage and refactoring targets`,
+ exploreChat: "Ask this codebase a question and get an answer with its sources.",
+ exploreKnowledgeGraph: "Entities, communities, and the paths between them",
+ exploreCoupling: "Files that keep changing together, mined from commit history",
+ exploreCommits: "Change-risk ranked history with agent provenance",
+ exploreDecisions: "Why the code is shaped this way, from decision records and git history",
+ exploreContributors: "Bus factor, per-file maintainers, and the human/agent split",
+ exploreStats: "Size class, origin, lifetime churn, rhythm and records",
+ exploreCosts: "What indexing this snapshot cost, by model and by run.",
+};
+
+/** The inventory's units and detail lines. English by default. */
+export interface InventoryCopy {
+ healthUnit: string;
+ securityUnit: string;
+ securityElsewhere: (elsewhere: number) => string;
+ refactoringUnit: string;
+ decisionsUnit: string;
+ decisionsDetail: (awaiting: number, drifting: number) => string;
+ ownershipUnit: string;
+ ownershipDetail: string;
+}
+
+export const INVENTORY_COPY: InventoryCopy = {
+ healthUnit: "open findings",
+ securityUnit: "in shipped source",
+ securityElsewhere: (elsewhere) => `${formatNumber(elsewhere)} more in tests and docs`,
+ refactoringUnit: "open opportunities",
+ decisionsUnit: "to review",
+ decisionsDetail: (awaiting, drifting) =>
+ `${formatNumber(awaiting)} awaiting review, ${formatNumber(drifting)} drifting from the code`,
+ ownershipUnit: "sole-owned files",
+ ownershipDetail: "One author, no second reader",
+};
+
/**
* Where this host's links go.
*
@@ -100,7 +250,11 @@ export function resolveOverviewRoutes(routes: OverviewRoutes) {
* enters the index when a sync ingests it, and that same sync stamps the
* timestamp, so "newer than the last sync" is zero by construction.
*/
-export function buildChangeStats(summary: OverviewSummaryResponse): ChangeStat[] {
+export function buildChangeStats(
+ summary: OverviewSummaryResponse,
+ copy?: Partial<OverviewModelCopy>,
+): ChangeStat[] {
+ const c = { ...OVERVIEW_MODEL_COPY, ...copy };
const stats: ChangeStat[] = [];
const { deltas } = summary.stats;
@@ -108,15 +262,15 @@ export function buildChangeStats(summary: OverviewSummaryResponse): ChangeStat[]
const d = deltas.file_count;
stats.push({
value: `${d > 0 ? "+" : ""}${formatNumber(d)}`,
- label: Math.abs(d) === 1 ? "file" : "files",
+ label: c.changeFiles(d),
});
}
// The 0.05 floor is the point below which a score change is rounding rather
// than news: both figures render to one decimal, so anything smaller shows
// as "+0.0".
for (const [value, label] of [
- [deltas.average_health, "code health"],
- [deltas.hotspot_health, "hotspot health"],
+ [deltas.average_health, c.changeCodeHealth],
+ [deltas.hotspot_health, c.changeHotspotHealth],
] as const) {
if (value != null && Math.abs(value) >= 0.05) {
stats.push({ value: `${value > 0 ? "+" : ""}${value.toFixed(1)}`, label });
@@ -140,7 +294,12 @@ export function docPageCount(summary: OverviewSummaryResponse): number {
* The column beside the health hero: documentation, and on hosts that
* backtest it, how well the health ranking predicted bug fixes.
*/
-export function buildReads(summary: OverviewSummaryResponse, routes: OverviewRoutes): ReadItem[] {
+export function buildReads(
+ summary: OverviewSummaryResponse,
+ routes: OverviewRoutes,
+ copy?: Partial<OverviewModelCopy>,
+): ReadItem[] {
+ const c = { ...OVERVIEW_MODEL_COPY, ...copy };
const r = resolveOverviewRoutes(routes);
const { stats, health } = summary;
const docPages = docPageCount(summary);
@@ -160,25 +319,23 @@ export function buildReads(summary: OverviewSummaryResponse, routes: OverviewRou
const withoutProse = hasSplit ? Math.max(0, docPages - prosePages) : 0;
reads.push({
key: "docs",
- label: "Documentation",
+ label: c.docsLabel,
value: formatNumber(docPages),
- unit: "pages",
+ unit: c.docsUnit,
href: `${r.base}/docs`,
- why: hasSplit
- ? `${formatNumber(prosePages)} with model-written prose, ${formatNumber(withoutProse)} built from the index`
- : `Across ${formatNumber(stats.module_count)} modules`,
+ why: hasSplit ? c.docsSplit(prosePages, withoutProse) : c.docsModules(stats.module_count),
...(hasSplit
? {
bar: [
{
key: "prose",
- label: "Pages with model-written prose",
+ label: c.docsProseBar,
value: prosePages,
detail: formatNumber(prosePages),
},
{
key: "index",
- label: "Pages built from the index alone",
+ label: c.docsIndexBar,
value: withoutProse,
detail: formatNumber(withoutProse),
},
@@ -252,21 +409,26 @@ export const COVERAGE_ADD_COMMAND = "repowise coverage add";
const plural = (n: number, one: string, many: string) => (n === 1 ? one : many);
/** Coverage when a report exists; the ingest command when the server says none does. */
-function testsCard(explore: OverviewSummaryResponse["explore"], href: string, command: string): ExploreCard {
- const card = { key: "tests", label: "Tests", href };
+function testsCard(
+ explore: OverviewSummaryResponse["explore"],
+ href: string,
+ command: string,
+ c: OverviewModelCopy,
+): ExploreCard {
+ const card = { key: "tests", label: c.cardTests, href };
const coverage = explore?.coverage;
if (coverage) {
return {
...card,
value: `${coverage.line_coverage_pct.toFixed(1)}%`,
- caption: "line coverage from the latest report",
+ caption: c.testsCoverage,
};
}
// A server without the counts cannot say whether a report exists.
- if (!explore) return { ...card, caption: "Coverage and the tests that reach each file" };
+ if (!explore) return { ...card, caption: c.testsUnknown };
return {
...card,
- caption: "No coverage report yet. Run your tests with coverage on, then add the report:",
+ caption: c.testsNone,
command,
};
}
@@ -280,60 +442,62 @@ function testsCard(explore: OverviewSummaryResponse["explore"], href: string, co
export function buildExploreCards(
summary: OverviewSummaryResponse,
routes: OverviewRoutes,
+ copy?: Partial<OverviewModelCopy>,
): ExploreCard[] {
+ const c = { ...OVERVIEW_MODEL_COPY, ...copy };
const { base, tests, coverageCommand } = resolveOverviewRoutes(routes);
const { stats, explore } = summary;
return [
- { key: "code-health", label: "Code health map", href: `${base}/code-health`, ...healthFigure(stats) },
- { key: "contributors", label: "Ownership", href: `${base}/owners`, ...ownershipFigure(explore) },
+ { key: "code-health", label: c.cardHealth, href: `${base}/code-health`, ...healthFigure(stats, c) },
+ { key: "contributors", label: c.cardOwnership, href: `${base}/owners`, ...ownershipFigure(explore, c) },
{
key: "architecture",
- label: "Architecture",
+ label: c.cardArchitecture,
href: `${base}/architecture`,
value: formatNumber(stats.module_count),
- caption: `${plural(stats.module_count, "module", "modules")}, ${formatNumber(stats.entry_point_count)} entry points`,
+ caption: c.architectureModules(stats.module_count, stats.entry_point_count),
},
- { key: "decisions", label: "Decisions", href: `${base}/decisions`, ...decisionsFigure(explore) },
- { key: "refactoring", label: "Refactoring", href: `${base}/refactoring`, ...refactoringFigure(explore) },
- ...(tests == null ? [] : [testsCard(explore, tests, coverageCommand)]),
+ { key: "decisions", label: c.cardDecisions, href: `${base}/decisions`, ...decisionsFigure(explore, c) },
+ { key: "refactoring", label: c.cardRefactoring, href: `${base}/refactoring`, ...refactoringFigure(explore, c) },
+ ...(tests == null ? [] : [testsCard(explore, tests, coverageCommand, c)]),
];
}
type CardFigure = Pick<ExploreCard, "value" | "caption">;
type Explore = OverviewSummaryResponse["explore"];
-function healthFigure(stats: OverviewSummaryResponse["stats"]): CardFigure {
- if (stats.hotspot_count === 0) return { value: formatNumber(stats.file_count), caption: "files scored" };
+function healthFigure(stats: OverviewSummaryResponse["stats"], c: OverviewModelCopy): CardFigure {
+ if (stats.hotspot_count === 0) return { value: formatNumber(stats.file_count), caption: c.healthScored };
return {
value: formatNumber(stats.hotspot_count),
- caption: `${plural(stats.hotspot_count, "hotspot", "hotspots")} across ${formatNumber(stats.file_count)} files`,
+ caption: c.healthHotspots(stats.hotspot_count, stats.file_count),
};
}
-function ownershipFigure(explore: Explore): CardFigure {
+function ownershipFigure(explore: Explore, c: OverviewModelCopy): CardFigure {
const sole = explore?.ownership?.sole_owned_files;
- if (sole == null) return { caption: "Who knows each file, and what depends on them" };
+ if (sole == null) return { caption: c.ownershipEmpty };
return {
value: formatNumber(sole),
- caption: `sole-owned ${plural(sole, "file", "files")}: one author, no second reader`,
+ caption: c.ownershipSole(sole),
};
}
-function decisionsFigure(explore: Explore): CardFigure {
+function decisionsFigure(explore: Explore, c: OverviewModelCopy): CardFigure {
const d = explore?.decisions;
- if (!d || d.total === 0) return { caption: "No decisions recorded yet" };
+ if (!d || d.total === 0) return { caption: c.decisionsEmpty };
return {
value: formatNumber(d.total),
- caption: `recorded, of which ${formatNumber(d.accepted)} accepted and ${formatNumber(d.candidates)} awaiting review`,
+ caption: c.decisionsRecorded(d.accepted, d.candidates),
};
}
-function refactoringFigure(explore: Explore): CardFigure {
+function refactoringFigure(explore: Explore, c: OverviewModelCopy): CardFigure {
const r = explore?.refactoring;
- if (!r) return { caption: "No refactoring analysis yet" };
+ if (!r) return { caption: c.refactoringEmpty };
return {
value: formatNumber(r.opportunities_total),
- caption: `open ${plural(r.opportunities_total, "opportunity", "opportunities")}, one per file`,
+ caption: c.refactoringOpen(r.opportunities_total),
};
}
@@ -347,91 +511,94 @@ function refactoringFigure(explore: Explore): CardFigure {
export function buildExplore(
summary: OverviewSummaryResponse,
routes: OverviewRoutes,
+ copy?: Partial<OverviewModelCopy>,
): ExploreEntry[] {
+ const c = { ...OVERVIEW_MODEL_COPY, ...copy };
+ const l = c.exploreLabels;
const r = resolveOverviewRoutes(routes);
const { stats, health } = summary;
const docPages = docPageCount(summary);
const entries: ExploreEntry[] = [
{
key: "docs",
- label: "Docs",
+ label: l.docs,
href: `${r.base}/docs`,
- description: `${formatNumber(docPages)} pages across ${formatNumber(stats.module_count)} modules`,
+ description: c.exploreDocs(docPages, stats.module_count),
},
];
if (r.chat) {
entries.push({
key: "chat",
- label: "Chat",
+ label: l.chat,
href: r.chat,
- description: "Ask this codebase a question and get an answer with its sources.",
+ description: c.exploreChat,
});
}
entries.push(
{
key: "files",
- label: "Files",
+ label: l.files,
href: `${r.base}/files`,
- description: `${formatNumber(stats.file_count)} files with per-file docs, health and history`,
+ description: c.exploreFiles(stats.file_count),
},
{
key: "architecture",
- label: "Architecture",
+ label: l.architecture,
href: `${r.base}/architecture`,
- description: `Dependency graph, layers, and ${formatNumber(stats.entry_point_count)} entry points`,
+ description: c.exploreArchitecture(stats.entry_point_count),
},
{
key: "code-health",
- label: "Code health",
+ label: l["code-health"],
href: `${r.base}/code-health`,
- description: `Per-file scores, ${formatNumber(health.open_findings)} open findings, coverage and refactoring targets`,
+ description: c.exploreCodeHealth(health.open_findings),
},
{
key: "knowledge-graph",
- label: "Knowledge graph",
+ label: l["knowledge-graph"],
href: `${r.base}/knowledge-graph`,
- description: "Entities, communities, and the paths between them",
+ description: c.exploreKnowledgeGraph,
},
{
key: "coupling",
- label: "Change coupling",
+ label: l.coupling,
href: r.coupling,
- description: "Files that keep changing together, mined from commit history",
+ description: c.exploreCoupling,
},
{
key: "commits",
- label: "Commits",
+ label: l.commits,
href: `${r.base}/commits`,
- description: "Change-risk ranked history with agent provenance",
+ description: c.exploreCommits,
},
{
key: "decisions",
- label: "Decisions",
+ label: l.decisions,
href: `${r.base}/decisions`,
- description: "Why the code is shaped this way, from decision records and git history",
+ description: c.exploreDecisions,
},
{
key: "contributors",
- label: "Contributors",
+ label: l.contributors,
href: `${r.base}/owners`,
- description: "Bus factor, per-file maintainers, and the human/agent split",
+ description: c.exploreContributors,
},
{
key: "stats",
- label: "Stats",
+ label: l.stats,
href: `${r.base}/stats`,
- description: "Size class, origin, lifetime churn, rhythm and records",
+ description: c.exploreStats,
},
);
if (r.costs) {
entries.push({
key: "costs",
- label: "Costs",
+ label: l.costs,
href: r.costs,
- description: "What indexing this snapshot cost, by model and by run.",
+ description: c.exploreCosts,
});
}
@@ -461,27 +628,31 @@ export type InventoryRow = OverviewAttentionAreaRow & { unit?: string };
* health` print. The queue's `finding_counts.inventory` leaves zero-impact
* findings out, so it is not the number those surfaces call open findings.
*/
-export function inventoryRows(summary: OverviewSummaryResponse): InventoryRow[] {
+export function inventoryRows(
+ summary: OverviewSummaryResponse,
+ copy?: Partial<InventoryCopy>,
+): InventoryRow[] {
+ const c = { ...INVENTORY_COPY, ...copy };
const areas = summary.attention_summary?.areas ?? [];
const explore = summary.explore;
const findings = summary.health.open_findings;
return areas.map((area): InventoryRow => {
switch (area.key) {
case "health":
- return findings != null ? { ...area, total: findings, unit: "open findings" } : area;
+ return findings != null ? { ...area, total: findings, unit: c.healthUnit } : area;
case "security": {
const s = explore?.security;
if (!s) return area;
return {
...area,
total: s.source,
- unit: "in shipped source",
- detail: s.elsewhere > 0 ? `${formatNumber(s.elsewhere)} more in tests and docs` : "",
+ unit: c.securityUnit,
+ detail: s.elsewhere > 0 ? c.securityElsewhere(s.elsewhere) : "",
};
}
case "refactoring": {
const r = explore?.refactoring;
- return r ? { ...area, total: r.opportunities_total, unit: "open opportunities" } : area;
+ return r ? { ...area, total: r.opportunities_total, unit: c.refactoringUnit } : area;
}
case "decisions": {
const d = explore?.decisions;
@@ -489,8 +660,8 @@ export function inventoryRows(summary: OverviewSummaryResponse): InventoryRow[]
return {
...area,
total: d.candidates + d.needs_review,
- unit: "to review",
- detail: `${formatNumber(d.candidates)} awaiting review, ${formatNumber(d.needs_review)} drifting from the code`,
+ unit: c.decisionsUnit,
+ detail: c.decisionsDetail(d.candidates, d.needs_review),
};
}
case "ownership": {
@@ -499,8 +670,8 @@ export function inventoryRows(summary: OverviewSummaryResponse): InventoryRow[]
? {
...area,
total: o.sole_owned_files,
- unit: "sole-owned files",
- detail: "One author, no second reader",
+ unit: c.ownershipUnit,
+ detail: c.ownershipDetail,
}
: area;
}
diff --git a/packages/web/messages/en.json b/packages/web/messages/en.json
index 2fb87d2a9..497829fbb 100644
--- a/packages/web/messages/en.json
+++ b/packages/web/messages/en.json
@@ -1373,6 +1373,123 @@
"graph": {
"communitiesDescription": "Files that depend on each other more than on the rest of the repo, detected automatically. Circle size is how much code a group holds, and the nearer the centre, the nearer an entry point. Double-click a group to see the files inside it and what they depend on.",
"filesDescription": "Every file, grouped into the communities it depends on most, with a band for each strong link between communities. Hover or select a file to see exactly what it imports and what imports it."
+ },
+ "map": {
+ "communityFallback": "Community {id}",
+ "allCommunities": "All communities",
+ "insideCommunity": "How the files in this group depend on each other.",
+ "openFileHint": "Double-click a file to open it.",
+ "truncation": {
+ "showing": "Showing the <shown></shown> most-connected files of <total></total>.",
+ "slowerHint": " Loading more will be slower.",
+ "seeAllGrouped": "See all of them grouped",
+ "loadMore": "Load {count} more"
+ },
+ "scope": {
+ "label": "Graph scope",
+ "communities": "Communities",
+ "communitiesHint": "One circle per detected community",
+ "files": "Files",
+ "filesHint": "Individual files and how they depend on each other",
+ "tree": "Tree",
+ "treeHint": "The same files as an outline, with what each one imports"
+ },
+ "narrowing": {
+ "showing": "Showing",
+ "allFiles": "All files",
+ "community": "Community",
+ "module": "Module",
+ "smallerModules": "Smaller modules"
+ },
+ "nodeFilter": {
+ "label": "Node filter",
+ "all": "All",
+ "allHint": "Show every node",
+ "hot": "Hot",
+ "hotHint": "High-churn files",
+ "dead": "Dead",
+ "deadHint": "Dead-code files"
+ },
+ "toolbar": {
+ "trace": "Trace",
+ "traceTitle": "Trace a dependency path or an execution flow",
+ "traceTitleFlowsOnly": "Trace an execution flow",
+ "traceAriaPathOpen": "Trace: dependency path open",
+ "traceAriaFlowsOpen": "Trace: execution flows open",
+ "findPath": "Find dependency path",
+ "executionFlows": "Execution flows",
+ "searchPlaceholder": "Search nodes…",
+ "searchLabel": "Search graph nodes",
+ "clearSearch": "Clear search"
+ },
+ "population": {
+ "allCounted": "All {total, plural, one {# file} other {# files}}",
+ "someCounted": "{visible, number} of {total, plural, one {# file} other {# files}}",
+ "allFiles": "All files",
+ "productionFiles": "Production files",
+ "ariaLabel": "Files counted: {summary}",
+ "popoverLabel": "Files counted",
+ "explainer": "Production code is always counted. Turning a kind on re-sizes and re-ranks every group.",
+ "tests": "Tests",
+ "examples": "Examples and benchmarks",
+ "docs": "Docs and config"
+ },
+ "legend": {
+ "communities": "{count, plural, one {# community} other {# communities}}",
+ "noCommunities": "No communities detected",
+ "smallerNotListed": "+{count, number} smaller not listed",
+ "notGrouped": "Not grouped",
+ "notGroupedTitle": "Files with no dependency on the rest of the repo",
+ "scopedFiles": "{count, plural, one {# file} other {# files}}",
+ "scopedOutside": "{count, number} outside",
+ "scopedEdges": "{count, plural, one {# edge} other {# edges}} shown",
+ "outsideGroup": "Outside this group",
+ "overviewFiles": "{count, plural, one {# file} other {# files}}",
+ "overviewThirdParty": "{count, number} third-party",
+ "overviewDependencies": "{count, plural, one {# dependency} other {# dependencies}}",
+ "nodesEdges": "{nodes, plural, one {# node} other {# nodes}} · {edges, plural, one {# edge} other {# edges}}",
+ "thirdPartyShown": "Third-party modules shown",
+ "thirdPartyHidden": "{count, plural, one {# third-party module} other {# third-party modules}} hidden",
+ "show": "Show",
+ "hide": "Hide",
+ "showThirdParty": "Show third-party modules",
+ "hideThirdParty": "Hide third-party modules",
+ "unlinkedNotDrawn": "{count, plural, one {# unlinked file} other {# unlinked files}} not drawn",
+ "unlinkedTitle": "Files with no dependency edge to anything drawn have no place in the layout and nothing to reveal on hover.",
+ "weakerLinksNotDrawn": "{count, plural, one {# weaker community link} other {# weaker community links}} not drawn",
+ "weakerLinksTitle": "Pairs of communities with too few dependencies between them to band. Their edges still show on a hovered or selected file.",
+ "languageGroup": "Language",
+ "communityGroup": "Community",
+ "edgesGroup": "Edges",
+ "focusGroup": "Hover or select a file",
+ "configLanguage": "Config",
+ "otherLanguage": "Other",
+ "deselectAll": "Deselect all",
+ "selectAll": "Select all",
+ "edgeKinds": {
+ "crossCommunity": "Cross-community",
+ "internal": "Internal",
+ "dynamic": "Co-change",
+ "lowConfidence": "Low confidence"
+ },
+ "scopedEdgeKinds": {
+ "internal": "Within this group",
+ "crossCommunity": "Leaving this group"
+ },
+ "overviewEdgeKinds": {
+ "crossCommunity": "Between communities",
+ "internal": "Within a community"
+ },
+ "imports": "imports",
+ "importedBy": "imported by",
+ "toggleEdges": "Toggle {label} edges",
+ "toggleCommunity": "Toggle community {label}",
+ "viewCaptions": {
+ "dead": "Showing unreachable files",
+ "hotfiles": "Most-committed files (30d)",
+ "unified": "Dead and high-churn files"
+ }
+ }
}
},
"modelUpgrade": {
@@ -1708,6 +1825,174 @@
"worstFile": "What makes {path} the lowest-scoring file?",
"decision": "Why did we decide \"{title}\"?",
"trend": "How has code health moved since the previous index?"
+ },
+ "identity": {
+ "lines": "{lines} lines",
+ "synced": "synced {when}"
+ },
+ "ago": {
+ "now": "just now",
+ "s": "{value}s ago",
+ "m": "{value}m ago",
+ "h": "{value}h ago",
+ "d": "{value}d ago",
+ "w": "{value}w ago",
+ "mo": "{value}mo ago",
+ "y": "{value}y ago"
+ },
+ "quickActions": {
+ "sync": "Sync",
+ "resync": "Full Re-index",
+ "deadCode": "Dead Code Scan"
+ },
+ "body": {
+ "exploreTitle": "Explore this codebase",
+ "exploreMore": "Also"
+ },
+ "changeLine": {
+ "since": "Since the previous index, {when}",
+ "files": "{count, plural, one {file} other {files}}",
+ "codeHealth": "code health",
+ "hotspotHealth": "hotspot health"
+ },
+ "healthLede": {
+ "label": "Code health",
+ "unit": "out of 10",
+ "reportLink": "Full health report",
+ "empty": "Health scores land with the first index: complexity, duplication, coverage, churn and ownership across every file.",
+ "hint": "Average code health of every scored file, from 1 to 10.",
+ "hintHotspots": "Average code health of every scored file, from 1 to 10. Hotspots are the {hotspots} of {files} files that git history changes and fixes most.",
+ "hotspotsHealthy": "Hotspots average <score></score>, as healthy as the rest of the code.",
+ "hotspotsPayoff": "Hotspots average <score></score>, the place fixes pay off most."
+ },
+ "reads": {
+ "docsLabel": "Documentation",
+ "docsUnit": "pages",
+ "docsSplit": "{prose, number} with model-written prose, {withoutProse, number} built from the index",
+ "docsModules": "Across {modules, number} modules",
+ "docsProseBar": "Pages with model-written prose",
+ "docsIndexBar": "Pages built from the index alone"
+ },
+ "cards": {
+ "health": "Code health map",
+ "ownership": "Ownership",
+ "architecture": "Architecture",
+ "decisions": "Decisions",
+ "refactoring": "Refactoring",
+ "tests": "Tests",
+ "healthScored": "files scored",
+ "healthHotspots": "{hotspots, plural, one {hotspot} other {hotspots}} across {files, number} files",
+ "ownershipEmpty": "Who knows each file, and what depends on them",
+ "ownershipSole": "sole-owned {files, plural, one {file} other {files}}: one author, no second reader",
+ "architectureModules": "{modules, plural, one {module} other {modules}}, {entryPoints, number} entry points",
+ "decisionsEmpty": "No decisions recorded yet",
+ "decisionsRecorded": "recorded, of which {accepted, number} accepted and {candidates, number} awaiting review",
+ "refactoringEmpty": "No refactoring analysis yet",
+ "refactoringOpen": "open {count, plural, one {opportunity} other {opportunities}}, one per file",
+ "testsCoverage": "line coverage from the latest report",
+ "testsUnknown": "Coverage and the tests that reach each file",
+ "testsNone": "No coverage report yet. Run your tests with coverage on, then add the report:"
+ },
+ "explore": {
+ "labels": {
+ "docs": "Docs",
+ "chat": "Chat",
+ "files": "Files",
+ "architecture": "Architecture",
+ "codeHealth": "Code health",
+ "knowledgeGraph": "Knowledge graph",
+ "coupling": "Change coupling",
+ "commits": "Commits",
+ "decisions": "Decisions",
+ "contributors": "Contributors",
+ "stats": "Stats",
+ "costs": "Costs"
+ },
+ "docs": "{pages, number} pages across {modules, number} modules",
+ "files": "{files, number} files with per-file docs, health and history",
+ "architecture": "Dependency graph, layers, and {entryPoints, number} entry points",
+ "codeHealth": "Per-file scores, {findings, number} open findings, coverage and refactoring targets",
+ "chat": "Ask this codebase a question and get an answer with its sources.",
+ "knowledgeGraph": "Entities, communities, and the paths between them",
+ "coupling": "Files that keep changing together, mined from commit history",
+ "commits": "Change-risk ranked history with agent provenance",
+ "decisions": "Why the code is shaped this way, from decision records and git history",
+ "contributors": "Bus factor, per-file maintainers, and the human/agent split",
+ "stats": "Size class, origin, lifetime churn, rhythm and records",
+ "costs": "What indexing this snapshot cost, by model and by run."
+ },
+ "attention": {
+ "title": "Needs attention",
+ "description": "Each area of work, led by the worst thing in it.",
+ "inventoryTitle": "Everything we found",
+ "inventoryDescription": "Every detector's open count by area. The actions above are the part worth doing.",
+ "scopeAreas": "{count, plural, one {# area} other {# areas}}",
+ "scopeOpen": "{count, number} open",
+ "empty": "Nothing needs attention right now.",
+ "areas": {
+ "security": "Security",
+ "health": "Code health",
+ "refactoring": "Refactoring",
+ "doc_drift": "Doc drift",
+ "decisions": "Decisions",
+ "ownership": "Ownership",
+ "dead_code": "Dead code"
+ },
+ "severity": {
+ "critical": "Critical",
+ "high": "High",
+ "medium": "Medium",
+ "low": "Low"
+ },
+ "healthUnit": "open findings",
+ "securityUnit": "in shipped source",
+ "securityElsewhere": "{count, number} more in tests and docs",
+ "refactoringUnit": "open opportunities",
+ "decisionsUnit": "to review",
+ "decisionsDetail": "{awaiting, number} awaiting review, {drifting, number} drifting from the code",
+ "ownershipUnit": "sole-owned files",
+ "ownershipDetail": "One author, no second reader"
+ },
+ "next": {
+ "title": "Do next",
+ "titleCount": "Do next · {count, number}",
+ "timeFrame": "Time frame",
+ "week": "This week",
+ "weekHint": "What the last 7 days of commits changed",
+ "quarter": "This quarter",
+ "quarterHint": "What the last 90 days say is worth planning",
+ "tier": {
+ "act_now": "Now",
+ "plan": "Worth planning",
+ "improve_signal": "Improve what Repowise can see"
+ },
+ "allAnswered": "You have answered everything listed here. Answers are kept until the facts change.",
+ "showFewer": "Show fewer",
+ "showAll": "Show all {count, number}",
+ "listing": "Listing {shown, number} of {total, number}.",
+ "answered": "{count, plural, one {# action} other {# actions}} answered (done, snoozed or dismissed).",
+ "notChecked": "Not checked: {checks}.",
+ "runUpdate": "Run <code>repowise update</code> to include them.",
+ "emptyChecks": "Repowise ran {count, plural, one {# check} other {# checks}} over this index and none of them produced work for this time frame.",
+ "undo": "Undo",
+ "undoFailed": "Could not undo",
+ "saveFailed": "Could not save that; the action is back in the list",
+ "openDetails": "Open details",
+ "markDone": "Mark done",
+ "markedDone": "Marked done. It returns if the facts change.",
+ "snooze": "Snooze for 14 days",
+ "snoozed": "Snoozed for 14 days",
+ "dismiss": "Dismiss",
+ "dismissed": "Dismissed. It returns if the facts change.",
+ "effort": {
+ "S": "Small effort",
+ "M": "Medium effort",
+ "L": "Large effort"
+ },
+ "worthCheck": "worth a check",
+ "inferred": "(inferred)",
+ "openRow": "Open {title}",
+ "moreFor": "More for {title}"
}
},
"risk": {
diff --git a/packages/web/messages/zh-CN.json b/packages/web/messages/zh-CN.json
index b660bd29c..62fbfcbb3 100644
--- a/packages/web/messages/zh-CN.json
+++ b/packages/web/messages/zh-CN.json
@@ -1373,6 +1373,123 @@
"graph": {
"communitiesDescription": "相互依赖程度高于对代码仓库其余部分的文件组,自动检出。圆的大小表示该组包含的代码量,越靠近中心越接近入口点。双击一个组即可查看其中的文件以及它们依赖什么。",
"filesDescription": "每个文件按它最依赖的社区分组,社区之间的每条强连接用一条带表示。把鼠标悬停或选中某个文件,即可看到它导入了什么、又被谁导入。"
+ },
+ "map": {
+ "communityFallback": "社区 {id}",
+ "allCommunities": "全部社区",
+ "insideCommunity": "本组文件之间的依赖关系。",
+ "openFileHint": "双击文件即可打开。",
+ "truncation": {
+ "showing": "当前显示连接最多的 <shown></shown> 个文件(共 <total></total> 个)。",
+ "slowerHint": "继续加载会更慢。",
+ "seeAllGrouped": "按分组查看全部",
+ "loadMore": "再加载 {count} 个"
+ },
+ "scope": {
+ "label": "视图范围",
+ "communities": "社区",
+ "communitiesHint": "每个检测到的社区显示为一个圆",
+ "files": "文件",
+ "filesHint": "各个文件及其相互依赖",
+ "tree": "树形",
+ "treeHint": "以大纲形式查看同一批文件,以及每个文件导入的内容"
+ },
+ "narrowing": {
+ "showing": "显示",
+ "allFiles": "全部文件",
+ "community": "社区",
+ "module": "模块",
+ "smallerModules": "较小的模块"
+ },
+ "nodeFilter": {
+ "label": "节点筛选",
+ "all": "全部",
+ "allHint": "显示所有节点",
+ "hot": "热点",
+ "hotHint": "高频变更的文件",
+ "dead": "死代码",
+ "deadHint": "含死代码的文件"
+ },
+ "toolbar": {
+ "trace": "追踪",
+ "traceTitle": "追踪依赖路径或执行流",
+ "traceTitleFlowsOnly": "追踪执行流",
+ "traceAriaPathOpen": "追踪:依赖路径已打开",
+ "traceAriaFlowsOpen": "追踪:执行流已打开",
+ "findPath": "查找依赖路径",
+ "executionFlows": "执行流",
+ "searchPlaceholder": "搜索节点…",
+ "searchLabel": "搜索图中的节点",
+ "clearSearch": "清除搜索"
+ },
+ "population": {
+ "allCounted": "全部 {total, number} 个文件",
+ "someCounted": "{visible, number} / {total, number} 个文件",
+ "allFiles": "全部文件",
+ "productionFiles": "生产代码文件",
+ "ariaLabel": "统计范围:{summary}",
+ "popoverLabel": "统计范围",
+ "explainer": "生产代码始终计入。开启某一类文件后,所有分组的大小和排名都会重新计算。",
+ "tests": "测试",
+ "examples": "示例与基准测试",
+ "docs": "文档与配置"
+ },
+ "legend": {
+ "communities": "{count, plural, other {# 个社区}}",
+ "noCommunities": "未检测到社区",
+ "smallerNotListed": "另有 {count, number} 个较小的社区未列出",
+ "notGrouped": "未分组",
+ "notGroupedTitle": "与仓库其余部分没有依赖关系的文件",
+ "scopedFiles": "{count, plural, other {# 个文件}}",
+ "scopedOutside": "组外 {count, number} 个",
+ "scopedEdges": "已显示 {count, plural, other {# 条边}}",
+ "outsideGroup": "组外",
+ "overviewFiles": "{count, plural, other {# 个文件}}",
+ "overviewThirdParty": "{count, number} 个第三方模块",
+ "overviewDependencies": "{count, plural, other {# 条依赖}}",
+ "nodesEdges": "{nodes, plural, other {# 个节点}} · {edges, plural, other {# 条边}}",
+ "thirdPartyShown": "已显示第三方模块",
+ "thirdPartyHidden": "已隐藏 {count, plural, other {# 个第三方模块}}",
+ "show": "显示",
+ "hide": "隐藏",
+ "showThirdParty": "显示第三方模块",
+ "hideThirdParty": "隐藏第三方模块",
+ "unlinkedNotDrawn": "{count, plural, other {# 个孤立文件未显示}}",
+ "unlinkedTitle": "这些文件与图中其他内容之间没有依赖边,无法参与布局,悬停时也没有可显示的关系。",
+ "weakerLinksNotDrawn": "{count, plural, other {# 条较弱的社区连接未显示}}",
+ "weakerLinksTitle": "这些社区之间的依赖太少,不足以绘制连接带。悬停或选中文件时,仍会显示它们之间的边。",
+ "languageGroup": "语言",
+ "communityGroup": "社区",
+ "edgesGroup": "边",
+ "focusGroup": "悬停或选中文件时",
+ "configLanguage": "配置",
+ "otherLanguage": "其他",
+ "deselectAll": "取消全选",
+ "selectAll": "全选",
+ "edgeKinds": {
+ "crossCommunity": "跨社区",
+ "internal": "内部",
+ "dynamic": "共同变更",
+ "lowConfidence": "低置信度"
+ },
+ "scopedEdgeKinds": {
+ "internal": "组内",
+ "crossCommunity": "指向组外"
+ },
+ "overviewEdgeKinds": {
+ "crossCommunity": "社区之间",
+ "internal": "社区内部"
+ },
+ "imports": "导入",
+ "importedBy": "被导入",
+ "toggleEdges": "显示/隐藏「{label}」边",
+ "toggleCommunity": "显示/隐藏社区「{label}」",
+ "viewCaptions": {
+ "dead": "显示不可达的文件",
+ "hotfiles": "近 30 天提交最多的文件",
+ "unified": "死代码与高频变更文件"
+ }
+ }
}
},
"modelUpgrade": {
@@ -1708,6 +1825,174 @@
"worstFile": "{path} 为什么是得分最低的文件?",
"decision": "我们为什么决定「{title}」?",
"trend": "自上次索引以来,代码健康度有什么变化?"
+ },
+ "identity": {
+ "lines": "{lines} 行",
+ "synced": "{when}同步"
+ },
+ "ago": {
+ "now": "刚刚",
+ "s": "{value} 秒前",
+ "m": "{value} 分钟前",
+ "h": "{value} 小时前",
+ "d": "{value} 天前",
+ "w": "{value} 周前",
+ "mo": "{value} 个月前",
+ "y": "{value} 年前"
+ },
+ "quickActions": {
+ "sync": "同步",
+ "resync": "全量重新索引",
+ "deadCode": "死代码扫描"
+ },
+ "body": {
+ "exploreTitle": "探索代码库",
+ "exploreMore": "更多:"
+ },
+ "changeLine": {
+ "since": "较上次索引({when})",
+ "files": "个文件",
+ "codeHealth": "代码健康",
+ "hotspotHealth": "热点健康"
+ },
+ "healthLede": {
+ "label": "代码健康",
+ "unit": "/ 10",
+ "reportLink": "查看完整健康报告",
+ "empty": "首次索引完成后即可看到健康分,涵盖每个文件的复杂度、重复度、覆盖率、变更频率和所有权。",
+ "hint": "所有已评分文件的平均代码健康分,范围 1 到 10。",
+ "hintHotspots": "所有已评分文件的平均代码健康分,范围 1 到 10。热点是 git 历史中改动和修复最多的 {hotspots} 个文件(共 {files} 个文件)。",
+ "hotspotsHealthy": "热点平均 <score></score> 分,和其余代码一样健康。",
+ "hotspotsPayoff": "热点平均 <score></score> 分,修复这里收益最大。"
+ },
+ "reads": {
+ "docsLabel": "文档",
+ "docsUnit": "页",
+ "docsSplit": "{prose, number} 页由模型撰写,{withoutProse, number} 页直接从索引生成",
+ "docsModules": "覆盖 {modules, number} 个模块",
+ "docsProseBar": "由模型撰写的页面",
+ "docsIndexBar": "仅从索引生成的页面"
+ },
+ "cards": {
+ "health": "代码健康地图",
+ "ownership": "代码所有权",
+ "architecture": "架构",
+ "decisions": "决策",
+ "refactoring": "重构",
+ "tests": "测试",
+ "healthScored": "个文件已评分",
+ "healthHotspots": "个热点,共 {files, number} 个文件",
+ "ownershipEmpty": "每个文件谁最熟悉,又有哪些代码依赖它",
+ "ownershipSole": "个文件只有一位作者,没有第二个人熟悉",
+ "architectureModules": "个模块,{entryPoints, number} 个入口点",
+ "decisionsEmpty": "还没有记录任何决策",
+ "decisionsRecorded": "条已记录,其中 {accepted, number} 条已接受,{candidates, number} 条待审阅",
+ "refactoringEmpty": "还没有重构分析",
+ "refactoringOpen": "条待处理的重构机会,每个文件一条",
+ "testsCoverage": "最新报告中的行覆盖率",
+ "testsUnknown": "覆盖率,以及覆盖每个文件的测试",
+ "testsNone": "还没有覆盖率报告。运行带覆盖率的测试,然后添加报告:"
+ },
+ "explore": {
+ "labels": {
+ "docs": "文档",
+ "chat": "对话",
+ "files": "文件",
+ "architecture": "架构",
+ "codeHealth": "代码健康",
+ "knowledgeGraph": "知识图谱",
+ "coupling": "变更耦合",
+ "commits": "提交",
+ "decisions": "决策",
+ "contributors": "贡献者",
+ "stats": "统计",
+ "costs": "成本"
+ },
+ "docs": "{modules, number} 个模块,共 {pages, number} 页文档",
+ "files": "{files, number} 个文件,每个都有文档、健康度和历史",
+ "architecture": "依赖图、分层和 {entryPoints, number} 个入口点",
+ "codeHealth": "逐文件评分、{findings, number} 个未解决问题、覆盖率和重构目标",
+ "chat": "向代码库提问,回答会附上出处。",
+ "knowledgeGraph": "实体、社区及其之间的路径",
+ "coupling": "从提交历史中找出总是一起改动的文件",
+ "commits": "按变更风险排序的提交历史,标注智能体来源",
+ "decisions": "从决策记录和 git 历史看代码为何这样设计",
+ "contributors": "巴士系数、各文件维护者,以及人和智能体的分工",
+ "stats": "规模、来源、累计变更、提交节奏和纪录",
+ "costs": "索引这个快照花了多少钱,按模型和运行拆分。"
+ },
+ "attention": {
+ "title": "需要关注",
+ "description": "按工作领域分组,每组先列出最严重的一项。",
+ "inventoryTitle": "全部发现",
+ "inventoryDescription": "各检测器按领域统计的未解决数量。真正值得做的是上面的行动项。",
+ "scopeAreas": "{count, number} 个领域",
+ "scopeOpen": "{count, number} 项未解决",
+ "empty": "目前没有需要关注的事项。",
+ "areas": {
+ "security": "安全",
+ "health": "代码健康",
+ "refactoring": "重构",
+ "doc_drift": "文档漂移",
+ "decisions": "决策",
+ "ownership": "代码所有权",
+ "dead_code": "死代码"
+ },
+ "severity": {
+ "critical": "严重",
+ "high": "高",
+ "medium": "中",
+ "low": "低"
+ },
+ "healthUnit": "个未解决问题",
+ "securityUnit": "处位于发布代码中",
+ "securityElsewhere": "另有 {count, number} 处位于测试和文档中",
+ "refactoringUnit": "条待处理的重构机会",
+ "decisionsUnit": "条待审阅",
+ "decisionsDetail": "{awaiting, number} 条待审阅,{drifting, number} 条与代码不一致",
+ "ownershipUnit": "个单一作者文件",
+ "ownershipDetail": "只有一位作者,没有第二个人熟悉"
+ },
+ "next": {
+ "title": "下一步",
+ "titleCount": "下一步 · {count, number}",
+ "timeFrame": "时间范围",
+ "week": "本周",
+ "weekHint": "最近 7 天的提交带来了哪些变化",
+ "quarter": "本季度",
+ "quarterHint": "根据最近 90 天的情况,值得规划的事项",
+ "tier": {
+ "act_now": "立即处理",
+ "plan": "值得规划",
+ "improve_signal": "让 Repowise 看得更全"
+ },
+ "allAnswered": "这里列出的事项都已处理。在相关情况变化之前,处理结果会一直保留。",
+ "showFewer": "收起",
+ "showAll": "显示全部 {count, number} 项",
+ "listing": "显示 {shown, number} 项,共 {total, number} 项。",
+ "answered": "{count, number} 项已处理(完成、暂缓或忽略)。",
+ "notChecked": "未检查:{checks}。",
+ "runUpdate": "运行 <code>repowise update</code> 后即可纳入。",
+ "emptyChecks": "Repowise 在此索引上运行了 {count, number} 项检查,这个时间范围内没有需要处理的事项。",
+ "undo": "撤销",
+ "undoFailed": "撤销失败",
+ "saveFailed": "保存失败,该事项已放回列表",
+ "openDetails": "查看详情",
+ "markDone": "标记为完成",
+ "markedDone": "已标记为完成。相关情况变化时会重新出现。",
+ "snooze": "暂缓 14 天",
+ "snoozed": "已暂缓 14 天",
+ "dismiss": "忽略",
+ "dismissed": "已忽略。相关情况变化时会重新出现。",
+ "effort": {
+ "S": "工作量小",
+ "M": "工作量中等",
+ "L": "工作量大"
+ },
+ "worthCheck": "建议核实",
+ "inferred": "(推断)",
+ "openRow": "打开:{title}",
+ "moreFor": "{title} 的更多操作"
}
},
"risk": {
diff --git a/packages/web/src/app/repos/[id]/overview/overview-copy.ts b/packages/web/src/app/repos/[id]/overview/overview-copy.ts
new file mode 100644
index 000000000..e85a83998
--- /dev/null
+++ b/packages/web/src/app/repos/[id]/overview/overview-copy.ts
@@ -0,0 +1,124 @@
+import { getTranslations } from "next-intl/server";
+import type { OverviewBodyCopy } from "@repowise-dev/ui/overview";
+import { attentionSourceLabel } from "@repowise-dev/ui/dashboard/attention-href";
+import { relativeTimeParts } from "@repowise-dev/ui/lib/format";
+
+/** "2d ago" in the active locale, from `overview.ago.*`. */
+export async function overviewRelativeTime(): Promise<(iso: string) => string> {
+ const t = await getTranslations("overview.ago");
+ return (iso) => {
+ const { unit, value } = relativeTimeParts(iso);
+ return t(unit, { value });
+ };
+}
+
+/**
+ * Overview body copy in the active locale, from `overview.*`. Built on the
+ * server: `OverviewBody` and its children are server components here, so the
+ * function-valued fields never cross a client boundary.
+ */
+export async function overviewBodyCopy(): Promise<OverviewBodyCopy> {
+ const t = await getTranslations("overview");
+ const tBand = await getTranslations("welcome.repo.band");
+ const relativeTime = await overviewRelativeTime();
+ return {
+ exploreTitle: t("body.exploreTitle"),
+ exploreMore: t("body.exploreMore"),
+ changeLine: { since: (when) => t("changeLine.since", { when }), relativeTime },
+ healthLede: {
+ label: t("healthLede.label"),
+ unit: t("healthLede.unit"),
+ band: (band) => tBand(band),
+ reportLink: t("healthLede.reportLink"),
+ empty: t("healthLede.empty"),
+ hint: (counts) => (counts ? t("healthLede.hintHotspots", counts) : t("healthLede.hint")),
+ hotspotReading: (figure, holdsUp) =>
+ t.rich(holdsUp ? "healthLede.hotspotsHealthy" : "healthLede.hotspotsPayoff", {
+ score: () => figure,
+ }),
+ },
+ model: {
+ changeFiles: (delta) => t("changeLine.files", { count: Math.abs(delta) }),
+ changeCodeHealth: t("changeLine.codeHealth"),
+ changeHotspotHealth: t("changeLine.hotspotHealth"),
+ docsLabel: t("reads.docsLabel"),
+ docsUnit: t("reads.docsUnit"),
+ docsSplit: (prose, withoutProse) => t("reads.docsSplit", { prose, withoutProse }),
+ docsModules: (modules) => t("reads.docsModules", { modules }),
+ docsProseBar: t("reads.docsProseBar"),
+ docsIndexBar: t("reads.docsIndexBar"),
+ cardHealth: t("cards.health"),
+ cardOwnership: t("cards.ownership"),
+ cardArchitecture: t("cards.architecture"),
+ cardDecisions: t("cards.decisions"),
+ cardRefactoring: t("cards.refactoring"),
+ cardTests: t("cards.tests"),
+ healthScored: t("cards.healthScored"),
+ healthHotspots: (hotspots, files) => t("cards.healthHotspots", { hotspots, files }),
+ ownershipEmpty: t("cards.ownershipEmpty"),
+ ownershipSole: (files) => t("cards.ownershipSole", { files }),
+ architectureModules: (modules, entryPoints) =>
+ t("cards.architectureModules", { modules, entryPoints }),
+ decisionsEmpty: t("cards.decisionsEmpty"),
+ decisionsRecorded: (accepted, candidates) =>
+ t("cards.decisionsRecorded", { accepted, candidates }),
+ refactoringEmpty: t("cards.refactoringEmpty"),
+ refactoringOpen: (count) => t("cards.refactoringOpen", { count }),
+ testsCoverage: t("cards.testsCoverage"),
+ testsUnknown: t("cards.testsUnknown"),
+ testsNone: t("cards.testsNone"),
+ exploreLabels: {
+ docs: t("explore.labels.docs"),
+ chat: t("explore.labels.chat"),
+ files: t("explore.labels.files"),
+ architecture: t("explore.labels.architecture"),
+ "code-health": t("explore.labels.codeHealth"),
+ "knowledge-graph": t("explore.labels.knowledgeGraph"),
+ coupling: t("explore.labels.coupling"),
+ commits: t("explore.labels.commits"),
+ decisions: t("explore.labels.decisions"),
+ contributors: t("explore.labels.contributors"),
+ stats: t("explore.labels.stats"),
+ costs: t("explore.labels.costs"),
+ },
+ exploreDocs: (pages, modules) => t("explore.docs", { pages, modules }),
+ exploreFiles: (files) => t("explore.files", { files }),
+ exploreArchitecture: (entryPoints) => t("explore.architecture", { entryPoints }),
+ exploreCodeHealth: (findings) => t("explore.codeHealth", { findings }),
+ exploreChat: t("explore.chat"),
+ exploreKnowledgeGraph: t("explore.knowledgeGraph"),
+ exploreCoupling: t("explore.coupling"),
+ exploreCommits: t("explore.commits"),
+ exploreDecisions: t("explore.decisions"),
+ exploreContributors: t("explore.contributors"),
+ exploreStats: t("explore.stats"),
+ exploreCosts: t("explore.costs"),
+ },
+ attention: {
+ title: t("attention.title"),
+ description: t("attention.description"),
+ inventoryTitle: t("attention.inventoryTitle"),
+ inventoryDescription: t("attention.inventoryDescription"),
+ scopeAreas: (count) => t("attention.scopeAreas", { count }),
+ scopeOpen: (count) => t("attention.scopeOpen", { count }),
+ areas: {
+ // An area this build has no key for keeps the shared English name.
+ areaLabel: (key) =>
+ t.has(`attention.areas.${key}`) ? t(`attention.areas.${key}`) : attentionSourceLabel(key),
+ empty: t("attention.empty"),
+ severity: (severity) => t(`attention.severity.${severity}`),
+ },
+ inventory: {
+ healthUnit: t("attention.healthUnit"),
+ securityUnit: t("attention.securityUnit"),
+ securityElsewhere: (count) => t("attention.securityElsewhere", { count }),
+ refactoringUnit: t("attention.refactoringUnit"),
+ decisionsUnit: t("attention.decisionsUnit"),
+ decisionsDetail: (awaiting, drifting) =>
+ t("attention.decisionsDetail", { awaiting, drifting }),
+ ownershipUnit: t("attention.ownershipUnit"),
+ ownershipDetail: t("attention.ownershipDetail"),
+ },
+ },
+ };
+}
diff --git a/packages/web/src/app/repos/[id]/overview/page.tsx b/packages/web/src/app/repos/[id]/overview/page.tsx
index 91e2cd0d0..6046ecb63 100644
--- a/packages/web/src/app/repos/[id]/overview/page.tsx
+++ b/packages/web/src/app/repos/[id]/overview/page.tsx
@@ -15,6 +15,7 @@ import { NextActionsPanel } from "@/components/overview/next-actions-panel";
import { PublishOverviewSection } from "@/components/hosted/publish";
import { WelcomeMoment } from "@/components/welcome/welcome-moment";
import { welcomeFigures } from "@/lib/welcome-moment";
+import { overviewBodyCopy, overviewRelativeTime } from "./overview-copy";
import {
OverviewBody,
OverviewSection,
@@ -23,11 +24,7 @@ import {
type RepoIdentityMeta,
} from "@repowise-dev/ui/overview";
import type { OverviewSummaryResponse } from "@repowise-dev/types/overview";
-import {
- formatDateTime,
- formatLOC,
- formatRelativeTime,
-} from "@repowise-dev/ui/lib/format";
+import { formatDateTime, formatLOC } from "@repowise-dev/ui/lib/format";
export const metadata: Metadata = { title: "Overview" };
@@ -48,6 +45,8 @@ function identityMeta(
summary: OverviewSummaryResponse,
totalNloc: number | null,
lastActivityAt: string | null | undefined,
+ t: (key: string, values?: Record<string, string>) => string,
+ relativeTime: (iso: string) => string,
): RepoIdentityMeta[] {
const meta: RepoIdentityMeta[] = [];
const primaryLanguage = summary.languages[0]?.language;
@@ -55,11 +54,11 @@ function identityMeta(
meta.push({ label: summary.repo.default_branch, mono: true });
if (summary.repo.head_commit) meta.push({ label: summary.repo.head_commit.slice(0, 7), mono: true });
if (totalNloc != null) {
- meta.push({ label: `${formatLOC(totalNloc)} lines`, mono: true });
+ meta.push({ label: t("identity.lines", { lines: formatLOC(totalNloc) }), mono: true });
}
if (lastActivityAt) {
meta.push({
- label: `synced ${formatRelativeTime(lastActivityAt)}`,
+ label: t("identity.synced", { when: relativeTime(lastActivityAt) }),
title: formatDateTime(lastActivityAt),
});
}
@@ -102,7 +101,13 @@ export default async function OverviewPage({ params }: Props) {
const lastActivityAt = sync.last_sync_at ?? sync.last_resync_at ?? health.last_indexed_at;
// ── Identity ───────────────────────────────────────────────────────────
- const meta = identityMeta(summary, totalNloc, lastActivityAt);
+ const meta = identityMeta(
+ summary,
+ totalNloc,
+ lastActivityAt,
+ tOverview,
+ await overviewRelativeTime(),
+ );
// Priced by the server; no rates means the dialog shows no estimate.
const active = providers?.active;
@@ -154,6 +159,7 @@ export default async function OverviewPage({ params }: Props) {
summary={summary}
routes={routes}
LinkComponent={Link}
+ copy={await overviewBodyCopy()}
slots={{
header: (
<>
diff --git a/packages/web/src/components/architecture/code-graph-tree-view.tsx b/packages/web/src/components/architecture/code-graph-tree-view.tsx
index 9b4463f57..d9e6af2d8 100644
--- a/packages/web/src/components/architecture/code-graph-tree-view.tsx
+++ b/packages/web/src/components/architecture/code-graph-tree-view.tsx
@@ -29,6 +29,7 @@ import { fileEntityPath } from "@repowise-dev/ui/shared/entity";
import { ApiError } from "@repowise-dev/ui/shared/api-error";
import { toFriendlyMessage } from "@repowise-dev/ui/lib/errors";
import { useGraph } from "@/lib/hooks/use-graph";
+import { useGraphMapCopy } from "@/components/graph/use-graph-map-copy";
export function CodeGraphTreeView({
repoId,
@@ -43,6 +44,7 @@ export function CodeGraphTreeView({
}) {
const [graphLimit, setGraphLimit] = useState<number | undefined>(undefined);
const { graph, error, isLoading, mutate } = useGraph(repoId, graphLimit);
+ const mapCopy = useGraphMapCopy();
const fileHref = useCallback(
(path: string) => fileEntityPath(`/repos/${repoId}`, path),
@@ -75,7 +77,7 @@ export function CodeGraphTreeView({
</p>
</div>
<div className="shrink-0">
- <GraphScopeSwitcher scope={scope} onScopeChange={onScopeChange} />
+ <GraphScopeSwitcher scope={scope} onScopeChange={onScopeChange} copy={mapCopy.scope} />
</div>
</div>
@@ -85,6 +87,7 @@ export function CodeGraphTreeView({
total={graph.total_node_count}
limit={graphLimit ?? graph.nodes.length}
onLoadMore={(nextLimit) => setGraphLimit(nextLimit)}
+ copy={mapCopy.truncation}
/>
)}
diff --git a/packages/web/src/components/architecture/graph-view.tsx b/packages/web/src/components/architecture/graph-view.tsx
index e25bb865c..8b52f1a57 100644
--- a/packages/web/src/components/architecture/graph-view.tsx
+++ b/packages/web/src/components/architecture/graph-view.tsx
@@ -18,6 +18,7 @@ import { useCommunities } from "@/lib/hooks/use-graph";
import type { GraphExportResponse } from "@/lib/api/types";
import { PRODUCTION_ONLY, type GraphPopulation } from "@repowise-dev/types/graph";
import { useTranslations } from "next-intl";
+import { useGraphMapCopy } from "@/components/graph/use-graph-map-copy";
type ViewMode = "full" | "architecture" | "dead" | "hotfiles" | "unified";
type ColorMode = "language" | "community";
@@ -68,6 +69,7 @@ export function GraphView({
onScopeChange: (scope: GraphScope) => void;
}) {
const t = useTranslations("architecture");
+ const mapCopy = useGraphMapCopy();
const searchParams = useSearchParams();
const initialNode = searchParams.get("node");
@@ -275,9 +277,14 @@ export function GraphView({
activeModule={activeModule}
activeCommunity={activeCommunity}
onChange={handleNarrowingChange}
+ copy={mapCopy.narrowing}
/>
)}
- <GraphScopeSwitcher scope={effectiveScope} onScopeChange={handleScopeChange} />
+ <GraphScopeSwitcher
+ scope={effectiveScope}
+ onScopeChange={handleScopeChange}
+ copy={mapCopy.scope}
+ />
</div>
),
[
@@ -289,6 +296,7 @@ export function GraphView({
handleNarrowingChange,
effectiveScope,
handleScopeChange,
+ mapCopy,
],
);
@@ -312,6 +320,7 @@ export function GraphView({
limit={graphLimit ?? graphData.nodes.length}
onLoadMore={(nextLimit) => setGraphLimit(nextLimit)}
onSwitchToArchitecture={handleSwitchToArchitecture}
+ copy={mapCopy.truncation}
/>
) : undefined
}
diff --git a/packages/web/src/components/dashboard/quick-actions-wrapper.tsx b/packages/web/src/components/dashboard/quick-actions-wrapper.tsx
index 75b6a35f1..1c4bb741c 100644
--- a/packages/web/src/components/dashboard/quick-actions-wrapper.tsx
+++ b/packages/web/src/components/dashboard/quick-actions-wrapper.tsx
@@ -73,6 +73,12 @@ export function QuickActionsWrapper({
: key === "dead-code"
? t("quickActions.deadCode")
: labelFor(key);
+ // Button labels keep the shell's English casing, so they have their own keys.
+ const tButtons = useTranslations("overview.quickActions");
+ const actions = DEFAULT_QUICK_ACTIONS.map((a) => ({
+ ...a,
+ label: tButtons(a.key === "dead-code" ? "deadCode" : a.key),
+ }));
// The job on screen and which action started it, so its completion is
// reported in its own terms and a retry re-runs the same action.
const { watched, watch: startWatching, watchIfIdle, settle, dismiss } =
@@ -168,7 +174,7 @@ export function QuickActionsWrapper({
return (
<QuickActionsShell
- actions={DEFAULT_QUICK_ACTIONS}
+ actions={actions}
onAction={handleAction}
lastSyncAt={lastSyncAt}
lastResyncAt={lastResyncAt}
diff --git a/packages/web/src/components/graph/graph-flow.tsx b/packages/web/src/components/graph/graph-flow.tsx
index b75f580f6..f02210d96 100644
--- a/packages/web/src/components/graph/graph-flow.tsx
+++ b/packages/web/src/components/graph/graph-flow.tsx
@@ -19,6 +19,7 @@ import {
import { useRepo } from "@/lib/hooks/use-repo";
import { PathFinderPanel } from "./path-finder-panel";
import { GraphCommunityPanel } from "./graph-community-panel";
+import { useGraphMapCopy } from "./use-graph-map-copy";
import type {
GraphExport,
ExecutionFlows,
@@ -109,6 +110,7 @@ export function GraphFlow({
rail,
}: GraphFlowProps) {
const router = useRouter();
+ const { flow: copy } = useGraphMapCopy();
// Constellation (Knowledge Graph) is the default scope.
const [viewModeState, setViewModeState] = useState<ViewMode>(
initialViewMode ?? "architecture",
@@ -161,6 +163,7 @@ export function GraphFlow({
headerActions={headerActions}
banner={banner}
rail={rail}
+ copy={copy}
fullGraph={fullGraph as GraphExport | undefined}
isLoadingFullGraph={fullLoading}
constellationGraph={constellationGraph as ArchitectureGraph | undefined}
diff --git a/packages/web/src/components/graph/use-graph-map-copy.ts b/packages/web/src/components/graph/use-graph-map-copy.ts
new file mode 100644
index 000000000..e37fc55ab
--- /dev/null
+++ b/packages/web/src/components/graph/use-graph-map-copy.ts
@@ -0,0 +1,155 @@
+import { useMemo } from "react";
+import { useTranslations } from "next-intl";
+import type { GraphFlowCopy } from "@repowise-dev/ui/graph/graph-flow";
+import type { GraphTruncationBannerCopy } from "@repowise-dev/ui/graph/graph-truncation-banner";
+import type {
+ GraphScopeSwitcherCopy,
+ GraphNarrowingSelectCopy,
+} from "@repowise-dev/ui/graph/graph-scope-controls";
+
+export interface GraphMapCopy {
+ flow: GraphFlowCopy;
+ truncation: GraphTruncationBannerCopy;
+ scope: GraphScopeSwitcherCopy;
+ narrowing: GraphNarrowingSelectCopy;
+}
+
+/** The Architecture map's chrome from `architecture.map.*`, stable per locale. */
+export function useGraphMapCopy(): GraphMapCopy {
+ const t = useTranslations("architecture.map");
+ return useMemo<GraphMapCopy>(() => {
+ const communityFallback = (id: number) => t("communityFallback", { id });
+ return {
+ flow: {
+ allCommunities: t("allCommunities"),
+ insideCommunity: t("insideCommunity"),
+ openFileHint: t("openFileHint"),
+ communityFallback,
+ toolbar: {
+ trace: t("toolbar.trace"),
+ traceTitle: t("toolbar.traceTitle"),
+ traceTitleFlowsOnly: t("toolbar.traceTitleFlowsOnly"),
+ traceAriaPathOpen: t("toolbar.traceAriaPathOpen"),
+ traceAriaFlowsOpen: t("toolbar.traceAriaFlowsOpen"),
+ findPath: t("toolbar.findPath"),
+ executionFlows: t("toolbar.executionFlows"),
+ searchPlaceholder: t("toolbar.searchPlaceholder"),
+ searchLabel: t("toolbar.searchLabel"),
+ clearSearch: t("toolbar.clearSearch"),
+ },
+ nodeFilter: {
+ label: t("nodeFilter.label"),
+ filters: {
+ all: { label: t("nodeFilter.all"), hint: t("nodeFilter.allHint") },
+ hot: { label: t("nodeFilter.hot"), hint: t("nodeFilter.hotHint") },
+ dead: { label: t("nodeFilter.dead"), hint: t("nodeFilter.deadHint") },
+ },
+ },
+ population: {
+ allCounted: (total: number) => t("population.allCounted", { total }),
+ someCounted: (visible: number, total: number) =>
+ t("population.someCounted", { visible, total }),
+ allFiles: t("population.allFiles"),
+ productionFiles: t("population.productionFiles"),
+ ariaLabel: (summary: string) => t("population.ariaLabel", { summary }),
+ popoverLabel: t("population.popoverLabel"),
+ explainer: t("population.explainer"),
+ rows: {
+ tests: t("population.tests"),
+ examples: t("population.examples"),
+ docs: t("population.docs"),
+ },
+ },
+ legend: {
+ communities: (count: number) => t("legend.communities", { count }),
+ noCommunities: t("legend.noCommunities"),
+ smallerNotListed: (count: number) => t("legend.smallerNotListed", { count }),
+ notGrouped: t("legend.notGrouped"),
+ notGroupedTitle: t("legend.notGroupedTitle"),
+ scopedSummary: (members: number, boundary: number, edges: number) =>
+ [
+ t("legend.scopedFiles", { count: members }),
+ boundary > 0 ? t("legend.scopedOutside", { count: boundary }) : null,
+ t("legend.scopedEdges", { count: edges }),
+ ]
+ .filter(Boolean)
+ .join(" · "),
+ outsideGroup: t("legend.outsideGroup"),
+ overviewFiles: (count: number) => t("legend.overviewFiles", { count }),
+ overviewThirdParty: (count: number) => t("legend.overviewThirdParty", { count }),
+ overviewDependencies: (count: number) =>
+ t("legend.overviewDependencies", { count }),
+ nodesEdges: (nodes: number, edges: number) =>
+ t("legend.nodesEdges", { nodes, edges }),
+ thirdPartyShown: t("legend.thirdPartyShown"),
+ thirdPartyHidden: (count: number) => t("legend.thirdPartyHidden", { count }),
+ show: t("legend.show"),
+ hide: t("legend.hide"),
+ showThirdParty: t("legend.showThirdParty"),
+ hideThirdParty: t("legend.hideThirdParty"),
+ unlinkedNotDrawn: (count: number) => t("legend.unlinkedNotDrawn", { count }),
+ unlinkedTitle: t("legend.unlinkedTitle"),
+ weakerLinksNotDrawn: (count: number) => t("legend.weakerLinksNotDrawn", { count }),
+ weakerLinksTitle: t("legend.weakerLinksTitle"),
+ languageGroup: t("legend.languageGroup"),
+ communityGroup: t("legend.communityGroup"),
+ edgesGroup: t("legend.edgesGroup"),
+ focusGroup: t("legend.focusGroup"),
+ configLanguage: t("legend.configLanguage"),
+ otherLanguage: t("legend.otherLanguage"),
+ deselectAll: t("legend.deselectAll"),
+ selectAll: t("legend.selectAll"),
+ communityPlaceholder: communityFallback,
+ edgeKinds: {
+ crossCommunity: t("legend.edgeKinds.crossCommunity"),
+ internal: t("legend.edgeKinds.internal"),
+ dynamic: t("legend.edgeKinds.dynamic"),
+ lowConfidence: t("legend.edgeKinds.lowConfidence"),
+ },
+ scopedEdgeKinds: {
+ internal: t("legend.scopedEdgeKinds.internal"),
+ crossCommunity: t("legend.scopedEdgeKinds.crossCommunity"),
+ dynamic: t("legend.edgeKinds.dynamic"),
+ lowConfidence: t("legend.edgeKinds.lowConfidence"),
+ },
+ overviewEdgeKinds: {
+ crossCommunity: t("legend.overviewEdgeKinds.crossCommunity"),
+ internal: t("legend.overviewEdgeKinds.internal"),
+ },
+ imports: t("legend.imports"),
+ importedBy: t("legend.importedBy"),
+ toggleEdges: (label: string) => t("legend.toggleEdges", { label }),
+ toggleCommunity: (label: string) => t("legend.toggleCommunity", { label }),
+ viewCaptions: {
+ dead: t("legend.viewCaptions.dead"),
+ hotfiles: t("legend.viewCaptions.hotfiles"),
+ unified: t("legend.viewCaptions.unified"),
+ },
+ },
+ },
+ truncation: {
+ showing: (shown, total) =>
+ t.rich("truncation.showing", { shown: () => shown, total: () => total }),
+ slowerHint: t("truncation.slowerHint"),
+ seeAllGrouped: t("truncation.seeAllGrouped"),
+ loadMore: (count: string) => t("truncation.loadMore", { count }),
+ },
+ scope: {
+ label: t("scope.label"),
+ scopes: {
+ communities: { label: t("scope.communities"), hint: t("scope.communitiesHint") },
+ files: { label: t("scope.files"), hint: t("scope.filesHint") },
+ tree: { label: t("scope.tree"), hint: t("scope.treeHint") },
+ },
+ },
+ narrowing: {
+ showing: t("narrowing.showing"),
+ allFiles: t("narrowing.allFiles"),
+ community: t("narrowing.community"),
+ module: t("narrowing.module"),
+ smallerModules: t("narrowing.smallerModules"),
+ communityFallback,
+ },
+ };
+ }, [t]);
+}
diff --git a/packages/web/src/components/overview/next-actions-panel.tsx b/packages/web/src/components/overview/next-actions-panel.tsx
index f5fb3f59c..b4302e4f2 100644
--- a/packages/web/src/components/overview/next-actions-panel.tsx
+++ b/packages/web/src/components/overview/next-actions-panel.tsx
@@ -1,18 +1,62 @@
"use client";
import Link from "next/link";
-import { useCallback, useEffect } from "react";
+import { useCallback, useEffect, useMemo } from "react";
+import { useTranslations } from "next-intl";
import useSWR from "swr";
import type { ActionsResponse, NextAction } from "@repowise-dev/types/actions";
import type { AgentPromptFlavor } from "@repowise-dev/types/agent-prompts";
import { NextActions } from "@repowise-dev/ui/overview/next-actions";
-import { actionHref } from "@repowise-dev/ui/overview";
+import { actionHref, type NextActionsCopy } from "@repowise-dev/ui/overview";
import { fileEntityPath } from "@repowise-dev/ui/shared/entity";
import { getActionPrompt, getActions, setActionState } from "@/lib/api/actions";
+/** The list's own words in the active locale. The actions' text is the server's. */
+function useNextActionsCopy(): NextActionsCopy {
+ const t = useTranslations("overview.next");
+ const tSeverity = useTranslations("overview.attention.severity");
+ return useMemo(
+ () => ({
+ title: t("title"),
+ titleCount: (count) => t("titleCount", { count }),
+ timeFrame: t("timeFrame"),
+ week: t("week"),
+ weekHint: t("weekHint"),
+ quarter: t("quarter"),
+ quarterHint: t("quarterHint"),
+ tier: (tier) => (t.has(`tier.${tier}`) ? t(`tier.${tier}`) : tier),
+ allAnswered: t("allAnswered"),
+ showFewer: t("showFewer"),
+ showAll: (count) => t("showAll", { count }),
+ listing: (shown, total) => t("listing", { shown, total }),
+ answered: (count) => t("answered", { count }),
+ notChecked: (checks) => t("notChecked", { checks }),
+ emptyChecks: (count) => t("emptyChecks", { count }),
+ undo: t("undo"),
+ undoFailed: t("undoFailed"),
+ saveFailed: t("saveFailed"),
+ openDetails: t("openDetails"),
+ markDone: t("markDone"),
+ markedDone: t("markedDone"),
+ snooze: t("snooze"),
+ snoozed: t("snoozed"),
+ dismiss: t("dismiss"),
+ dismissed: t("dismissed"),
+ effort: (effort) => t(`effort.${effort}`),
+ worthCheck: t("worthCheck"),
+ inferred: t("inferred"),
+ openRow: (title) => t("openRow", { title }),
+ moreFor: (title) => t("moreFor", { title }),
+ // Same words as the attention rows' severity.
+ severity: (severity) => tSeverity(severity),
+ }),
+ [t, tSeverity],
+ );
+}
+
/**
* The local app's binding for "Do next": its routes and its write path. The
- * list itself, and every word on it, is the shared component.
+ * list itself is the shared component; its words come from `overview.next`.
*/
export function NextActionsPanel({ repoId, data }: { repoId: string; data: ActionsResponse }) {
// The server-rendered view seeds the key; after an answer, revalidating it
@@ -29,6 +73,8 @@ export function NextActionsPanel({ repoId, data }: { repoId: string; data: Actio
void mutate(data, { revalidate: false });
}, [data, mutate]);
const base = `/repos/${repoId}`;
+ const copy = useNextActionsCopy();
+ const tNext = useTranslations("overview.next");
const loadPrompt = useCallback(
async (action: NextAction, flavor: AgentPromptFlavor) =>
(await getActionPrompt(repoId, action.id, { flavor })).text,
@@ -38,6 +84,10 @@ export function NextActionsPanel({ repoId, data }: { repoId: string; data: Actio
<NextActions
data={view ?? data}
defaultOpen={false}
+ copy={copy}
+ unavailableHint={tNext.rich("runUpdate", {
+ code: (chunks) => <code className="font-mono text-[0.85em]">{chunks}</code>,
+ })}
loadPrompt={loadPrompt}
LinkComponent={Link}
hrefFor={(action) => actionHref(action, base)}
diff --git a/plugins/claude-code/hooks/lens/lens.js b/plugins/claude-code/hooks/lens/lens.js
index a853d8f02..58955368d 100644
--- a/plugins/claude-code/hooks/lens/lens.js
+++ b/plugins/claude-code/hooks/lens/lens.js
@@ -382,7 +382,7 @@ var NUMBER_FORMAT = new Intl.NumberFormat("en-US");
function formatNumber(n) {
return NUMBER_FORMAT.format(n);
}
-function formatRelativeTime(date) {
+function relativeTimeParts(date) {
const d = parseDate(date);
const now = Date.now();
const diff = now - d.getTime();
@@ -392,14 +392,18 @@ function formatRelativeTime(date) {
const days = Math.floor(hours / 24);
const weeks = Math.floor(days / 7);
const months = Math.floor(days / 30);
- if (seconds < 10) return "just now";
- if (seconds < 60) return `${seconds}s ago`;
- if (minutes < 60) return `${minutes}m ago`;
- if (hours < 24) return `${hours}h ago`;
- if (days < 7) return `${days}d ago`;
- if (weeks < 5) return `${weeks}w ago`;
- if (months < 12) return `${months}mo ago`;
- return `${Math.floor(months / 12)}y ago`;
+ if (seconds < 10) return { unit: "now", value: 0 };
+ if (seconds < 60) return { unit: "s", value: seconds };
+ if (minutes < 60) return { unit: "m", value: minutes };
+ if (hours < 24) return { unit: "h", value: hours };
+ if (days < 7) return { unit: "d", value: days };
+ if (weeks < 5) return { unit: "w", value: weeks };
+ if (months < 12) return { unit: "mo", value: months };
+ return { unit: "y", value: Math.floor(months / 12) };
+}
+function formatRelativeTime(date) {
+ const { unit, value } = relativeTimeParts(date);
+ return unit === "now" ? "just now" : `${value}${unit} ago`;
}
function formatRelativeTimeOrNull(iso, fallback = "—") {
if (!iso) return fallback;