11import { useState , useEffect , useCallback } from "react" ;
22import { ScrollArea } from "@/components/ui/scroll-area" ;
33import type { ProcessInfo } from "../lib/types" ;
4+ import { useUiMessages } from "../lib/i18n" ;
45
56/* ── Gauge component ────────────────────────────────────── */
67
@@ -30,6 +31,7 @@ function ProcessCard({ proc, selected, onSelect, onKill }: {
3031 proc : ProcessInfo ; selected : boolean ;
3132 onSelect : ( ) => void ; onKill : ( ) => void ;
3233} ) {
34+ const t = useUiMessages ( ) ;
3335 return (
3436 < button
3537 onClick = { onSelect }
@@ -46,15 +48,15 @@ function ProcessCard({ proc, selected, onSelect, onKill }: {
4648 PID { proc . pid }
4749 </ span >
4850 { proc . is_self && (
49- < span className = "text-[9px] px-1.5 py-0.5 rounded bg-primary/15 text-primary font-medium" > THIS </ span >
51+ < span className = "text-[9px] px-1.5 py-0.5 rounded bg-primary/15 text-primary font-medium" > { t . control . thisProcess } </ span >
5052 ) }
5153 </ div >
5254 { ! proc . is_self && (
5355 < button
5456 onClick = { ( e ) => { e . stopPropagation ( ) ; onKill ( ) ; } }
5557 className = "px-2 py-1 rounded-lg text-[10px] text-foreground/20 hover:text-destructive hover:bg-destructive/10 transition-all"
5658 >
57- Kill
59+ { t . control . kill }
5860 </ button >
5961 ) }
6062 </ div >
@@ -69,7 +71,7 @@ function ProcessCard({ proc, selected, onSelect, onKill }: {
6971 < p className = "text-[13px] font-semibold tabular-nums text-foreground/70" > { proc . rss_mb . toFixed ( 0 ) } MB</ p >
7072 </ div >
7173 < div >
72- < p className = "text-[9px] text-foreground/20 uppercase" > Uptime </ p >
74+ < p className = "text-[9px] text-foreground/20 uppercase" > { t . control . uptime } </ p >
7375 < p className = "text-[13px] font-semibold tabular-nums text-foreground/70" > { proc . elapsed } </ p >
7476 </ div >
7577 </ div >
@@ -82,6 +84,7 @@ function ProcessCard({ proc, selected, onSelect, onKill }: {
8284/* ── Log viewer ─────────────────────────────────────────── */
8385
8486function LogViewer ( ) {
87+ const t = useUiMessages ( ) ;
8588 const [ lines , setLines ] = useState < string [ ] > ( [ ] ) ;
8689
8790 useEffect ( ( ) => {
@@ -100,13 +103,13 @@ function LogViewer() {
100103 return (
101104 < div className = "rounded-xl border border-border/30 bg-black/30 overflow-hidden" >
102105 < div className = "px-4 py-2 border-b border-border/20" >
103- < span className = "text-[11px] font-medium text-foreground/40" > Process Logs </ span >
106+ < span className = "text-[11px] font-medium text-foreground/40" > { t . control . processLogs } </ span >
104107 < span className = "text-[10px] text-foreground/15 ml-2" > { lines . length } lines</ span >
105108 </ div >
106109 < ScrollArea className = "h-[400px]" >
107110 < div className = "p-3 font-mono text-[10px] leading-relaxed" >
108111 { lines . length === 0 ? (
109- < p className = "text-foreground/15 text-center py-8" > No logs yet </ p >
112+ < p className = "text-foreground/15 text-center py-8" > { t . control . noLogs } </ p >
110113 ) : (
111114 lines . map ( ( line , i ) => {
112115 const isErr = line . includes ( "level=error" ) ;
@@ -132,6 +135,7 @@ function LogViewer() {
132135/* ── Main Control Tab ───────────────────────────────────── */
133136
134137export function ControlTab ( ) {
138+ const t = useUiMessages ( ) ;
135139 const [ processes , setProcesses ] = useState < ProcessInfo [ ] > ( [ ] ) ;
136140 const [ selfMetrics , setSelfMetrics ] = useState ( { rss_mb : 0 , user_cpu : 0 , sys_cpu : 0 } ) ;
137141 const [ selectedPid , setSelectedPid ] = useState < number | null > ( null ) ;
@@ -156,7 +160,7 @@ export function ControlTab() {
156160 } , [ fetchProcesses ] ) ;
157161
158162 const killProcess = useCallback ( async ( pid : number ) => {
159- if ( ! confirm ( `Kill process ${ pid } ?` ) ) return ;
163+ if ( ! confirm ( t . control . killConfirm ( pid ) ) ) return ;
160164 try {
161165 await fetch ( "/api/process-kill" , {
162166 method : "POST" ,
@@ -165,7 +169,7 @@ export function ControlTab() {
165169 } ) ;
166170 setTimeout ( fetchProcesses , 1000 ) ;
167171 } catch { /* ignore */ }
168- } , [ fetchProcesses ] ) ;
172+ } , [ fetchProcesses , t . control ] ) ;
169173
170174 /* Aggregates */
171175 const totalCpu = processes . reduce ( ( s , p ) => s + p . cpu , 0 ) ;
@@ -174,32 +178,32 @@ export function ControlTab() {
174178 return (
175179 < ScrollArea className = "h-full" >
176180 < div className = "p-8 max-w-4xl mx-auto" >
177- < h2 className = "text-[15px] font-semibold text-foreground/80 mb-6" > Control Panel </ h2 >
181+ < h2 className = "text-[15px] font-semibold text-foreground/80 mb-6" > { t . control . panel } </ h2 >
178182
179183 { /* Aggregate gauges */ }
180184 < div className = "flex gap-4 mb-8" >
181- < Gauge label = "Total CPU" value = { totalCpu } max = { 100 * processes . length || 100 } unit = "%" color = "text-foreground/80" />
182- < Gauge label = "Total RAM" value = { totalRam } max = { 4096 } unit = "MB" color = "text-foreground/80" />
183- < Gauge label = "Processes" value = { processes . length } max = { 10 } unit = "" color = "text-primary" />
184- < Gauge label = "Self RAM" value = { selfMetrics . rss_mb } max = { 2048 } unit = "MB" color = "text-primary" />
185+ < Gauge label = { t . control . totalCpu } value = { totalCpu } max = { 100 * processes . length || 100 } unit = "%" color = "text-foreground/80" />
186+ < Gauge label = { t . control . totalRam } value = { totalRam } max = { 4096 } unit = "MB" color = "text-foreground/80" />
187+ < Gauge label = { t . control . processes } value = { processes . length } max = { 10 } unit = "" color = "text-primary" />
188+ < Gauge label = { t . control . selfRam } value = { selfMetrics . rss_mb } max = { 2048 } unit = "MB" color = "text-primary" />
185189 </ div >
186190
187191 { /* Process grid */ }
188192 < div className = "mb-8" >
189193 < div className = "flex items-center justify-between mb-4" >
190194 < h3 className = "text-[13px] font-medium text-foreground/50" >
191- Active Processes
195+ { t . control . activeProcesses }
192196 </ h3 >
193197 < button
194198 onClick = { fetchProcesses }
195199 className = "text-[11px] text-primary/60 hover:text-primary transition-colors"
196200 >
197- Refresh
201+ { t . common . refresh }
198202 </ button >
199203 </ div >
200204
201205 { processes . length === 0 ? (
202- < p className = "text-foreground/20 text-[12px] text-center py-8" > No processes found </ p >
206+ < p className = "text-foreground/20 text-[12px] text-center py-8" > { t . control . noProcesses } </ p >
203207 ) : (
204208 < div className = "grid grid-cols-2 gap-3" >
205209 { processes . map ( ( p ) => (
0 commit comments