Skip to content

Go implementation of DeepSeek Harness and self-hosted personal agent.

Go

feat(web): add English and Chinese interface options

xycbc9e0666f1a6
diff --git a/frontend/README.md b/frontend/README.md
index 0d51d20..9893014 100644
--- a/frontend/README.md
+++ b/frontend/README.md
@@ -19,6 +19,11 @@ Open the account menu at the bottom of the sidebar for **Settings**,
copy its absolute path, or refresh the selected directory. The panel keeps
its position when you switch chats.
+Choose **English** or **简体中文** on the account page or in **Settings**.
+The preference is saved per browser. When no preference is saved, the app uses
+the first supported browser language, with English as the fallback. Messages
+and Agent responses keep their original language.
+
You can send more messages while a reply is generating. They appear above the
composer. **Steer** adds that message to the current reply's next Agent step.
**Delete** removes just that queued message. Questions from the Agent appear
diff --git a/frontend/src/AccountEntry.tsx b/frontend/src/AccountEntry.tsx
index 1108303..a4f4791 100644
--- a/frontend/src/AccountEntry.tsx
+++ b/frontend/src/AccountEntry.tsx
@@ -1,9 +1,11 @@
import { useState, type FormEvent } from 'react'
+import { LanguagePicker, useLocale } from './locale'
import { LoaderCircle } from 'lucide-react'
import { APIError, getModelSettings, registerAccount } from './api/controller'
import { HarnessAvatar } from './HarnessAvatar'
export function AccountEntry({ onOpen }: { onOpen: (userId: string, created: boolean) => void }) {
+ const { t } = useLocale()
const [create, setCreate] = useState(false)
const [name, setName] = useState('')
const [phase, setPhase] = useState<'creating' | 'starting'>()
@@ -25,8 +27,8 @@ export function AccountEntry({ onOpen }: { onOpen: (userId: string, created: boo
} catch (error) {
if (error instanceof APIError && error.status === 404) {
setError('Account not found. Create it or check the name.')
- } else if (error instanceof APIError && error.message) {
- setError(error.message)
+ } else if (error instanceof APIError && error.status === 409) {
+ setError('This account already exists. Open it instead.')
} else {
setError('Could not open the account. Try again.')
}
@@ -38,20 +40,23 @@ export function AccountEntry({ onOpen }: { onOpen: (userId: string, created: boo
return (
<main className="account-page">
<form className="account-card" onSubmit={submit}>
- <div className="brand"><HarnessAvatar className="brand-mark" />Go Harness</div>
- <h1>{create ? 'Create an account' : 'Open your account'}</h1>
+ <div className="account-card-heading">
+ <div className="brand"><HarnessAvatar className="brand-mark" />Go Harness</div>
+ <LanguagePicker />
+ </div>
+ <h1>{create ? t('Create an account') : t('Open your account')}</h1>
<fieldset disabled={Boolean(phase)}>
- <label>Account name
+ <label>{t('Account name')}
<input autoComplete="username" autoCapitalize="none" spellCheck={false}
required pattern="[a-z0-9][a-z0-9_\x2d]{0,63}" value={name} onChange={event => setName(event.target.value)}
- title="Use 1–64 lowercase letters, digits, underscores or hyphens. Start with a letter or digit." />
+ title={t('Use 1–64 lowercase letters, digits, underscores or hyphens. Start with a letter or digit.')} />
</label>
- <button className="account-submit" type="submit">{create ? 'Create account' : 'Open account'}</button>
+ <button className="account-submit" type="submit">{create ? t('Create account') : t('Open account')}</button>
</fieldset>
- {phase && <p className="account-status" role="status"><LoaderCircle size={16} />{phase === 'creating' ? 'Creating account…' : 'Opening your account…'}</p>}
- {error && <p className="account-error" role="alert">{error}</p>}
+ {phase && <p className="account-status" role="status"><LoaderCircle size={16} />{phase === 'creating' ? t('Creating account…') : t('Opening your account…')}</p>}
+ {error && <p className="account-error" role="alert">{t(error)}</p>}
<button className="account-switch" type="button" disabled={Boolean(phase)} onClick={() => { setCreate(!create); setError('') }}>
- {create ? 'Open an existing account' : 'Create an account'}
+ {create ? t('Open an existing account') : t('Create an account')}
</button>
</form>
</main>
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index 35ea57c..c3e76e6 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -1,4 +1,5 @@
import { useCallback, useEffect, useRef, useState } from 'react'
+import { LanguagePicker, useLocale } from './locale'
import { ArrowLeft, Globe, Image, Menu, SlidersHorizontal } from 'lucide-react'
import { APIError, archiveSession, createSession, listSessions, openAccount, stopHost, type ProviderPage, type SessionRow } from './api/controller'
import { AccountEntry } from './AccountEntry'
@@ -36,6 +37,7 @@ export function App() {
}
function AccountChat({ userId, onExit }: { userId: string; onExit: () => void }) {
+ const { t } = useLocale()
const [transcriptCache] = useState(() => new TranscriptCache())
const [settingsPage, setSettingsPage] = useState(currentSettings)
const settingsOpen = settingsPage !== undefined
@@ -255,7 +257,7 @@ function AccountChat({ userId, onExit }: { userId: string; onExit: () => void })
await archiveSession(userId, row.sessionId)
} catch (error) {
if (error instanceof APIError && ['session_has_schedule', 'session_busy'].includes(error.message)) {
- if (!window.confirm('Stop this chat and delete its active schedules? The chat history and files will be kept.')) return false
+ if (!window.confirm(t('Stop this chat and delete its active schedules? The chat history and files will be kept.'))) return false
try {
await archiveSession(userId, row.sessionId, true)
} catch (stopError) {
@@ -292,20 +294,23 @@ function AccountChat({ userId, onExit }: { userId: string; onExit: () => void })
{settingsPage && <main className="model-settings" inert={drawerOpen || filesOverlay}>
<div className="settings-topbar">
<button type="button" className="icon-button drawer-toggle" onClick={() => setDrawerOpen(true)}
- aria-expanded={drawerOpen} aria-controls="chat-sidebar" aria-label="Open chats"><Menu size={22} /></button>
+ aria-expanded={drawerOpen} aria-controls="chat-sidebar" aria-label={t('Open chats')}><Menu size={22} /></button>
</div>
<div className="model-settings-panel">
<header className="settings-header">
- <button type="button" className="settings-back" onClick={closeSettings}><ArrowLeft size={17} /> Back to chats</button>
- <h1>Settings</h1>
+ <div className="settings-header-actions">
+ <button type="button" className="settings-back" onClick={closeSettings}><ArrowLeft size={17} /> {t('Back to chats')}</button>
+ <LanguagePicker />
+ </div>
+ <h1>{t('Settings')}</h1>
</header>
- <nav className="settings-nav" aria-label="Settings">
+ <nav className="settings-nav" aria-label={t('Settings')}>
<button type="button" aria-current={settingsPage === 'models' ? 'page' : undefined}
- onClick={() => selectSettings('models')}><SlidersHorizontal size={16} /> Models</button>
+ onClick={() => selectSettings('models')}><SlidersHorizontal size={16} /> {t('Models')}</button>
<button type="button" aria-current={settingsPage === 'web-search' ? 'page' : undefined}
- onClick={() => selectSettings('web-search')}><Globe size={16} /> Web search</button>
+ onClick={() => selectSettings('web-search')}><Globe size={16} /> {t('Web search')}</button>
<button type="button" aria-current={settingsPage === 'image-generation' ? 'page' : undefined}
- onClick={() => selectSettings('image-generation')}><Image size={16} /> Image generation</button>
+ onClick={() => selectSettings('image-generation')}><Image size={16} /> {t('Image generation')}</button>
</nav>
<div className="settings-content">
{settingsPage === 'models' ? <Models userId={userId} /> : <ToolProviders key={settingsPage} userId={userId} page={settingsPage} />}
diff --git a/frontend/src/chat/Chat.tsx b/frontend/src/chat/Chat.tsx
index 457e835..998b829 100644
--- a/frontend/src/chat/Chat.tsx
+++ b/frontend/src/chat/Chat.tsx
@@ -1,4 +1,5 @@
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
+import { useLocale } from '../locale'
import { ArrowUp, FileText, LoaderCircle, Menu, Plus, Square, X } from 'lucide-react'
import { HarnessAvatar } from '../HarnessAvatar'
import { APIError, readTranscript, readStream, sendMessage, stopTurn, updateQueue } from '../api/controller'
@@ -44,12 +45,13 @@ type ChatProps = {
}
export function Chat({ hidden, userId, cache, id, drawerOpen, filesOverlay, settingsVersion, onSettings, onOpenMenu, onAccepted, onUnavailable, onTitleRefresh }: ChatProps) {
+ const { t } = useLocale()
const cached = id ? cache.get(id) : undefined
const [transcript, setTranscript] = useState(() => cached?.transcript ?? emptyTranscript())
const [pending, setPending] = useState<Message[]>([])
const [input, setInput] = useState('')
const [files, setFiles] = useState<File[]>([])
- const [fileError, setFileError] = useState('')
+ const [fileIssues, setFileIssues] = useState<ReturnType<typeof addMessageFiles>['issues']>([])
const filePicker = useRef<HTMLInputElement>(null)
const [failure, setFailure] = useState('')
const [historyError, setHistoryError] = useState('')
@@ -262,7 +264,7 @@ export function Chat({ hidden, userId, cache, id, drawerOpen, filesOverlay, sett
if (!incoming.length || submittingNow.current) return
const next = addMessageFiles(files, incoming)
setFiles(next.files)
- setFileError(next.error)
+ setFileIssues(next.issues)
}
async function submit() {
@@ -283,7 +285,7 @@ export function Chat({ hidden, userId, cache, id, drawerOpen, filesOverlay, sett
kick.current()
setInput(value => value.trim() === text ? '' : value)
setFiles([])
- setFileError('')
+ setFileIssues([])
} catch (error) {
if (mounted.current) setFailure(sendError(error))
} finally {
@@ -312,21 +314,21 @@ export function Chat({ hidden, userId, cache, id, drawerOpen, filesOverlay, sett
event.currentTarget.value = ''
composer.current?.focus()
}} />
- {files.length > 0 && <ul className="draft-files" aria-label="Attachments to send">
+ {files.length > 0 && <ul className="draft-files" aria-label={t('Attachments to send')}>
{files.map((file, index) => <li key={file.name + ':' + file.lastModified + ':' + index}>
<DraftFilePreview file={file} />
<span className="draft-file-label"><strong title={file.name}>{file.name}</strong>
<small>{file.size >= 1048576 ? (file.size / 1048576).toFixed(1) + ' MB' : Math.max(1, Math.round(file.size / 1024)) + ' KB'}</small>
</span>
- <button type="button" disabled={submitting} aria-label={'Remove ' + file.name} onClick={() => {
+ <button type="button" disabled={submitting} aria-label={t('Remove {name}', { name: file.name })} onClick={() => {
setFiles(current => current.filter((_, i) => i !== index))
- setFileError('')
+ setFileIssues([])
}}><X size={15} /></button>
</li>)}
</ul>}
- {fileError && <p role="alert" className="feedback attachment-error">{fileError}</p>}
- <label className="sr-only" htmlFor="message">Message</label>
- <textarea id="message" ref={composer} value={input} rows={2} placeholder="Ask anything…"
+ {fileIssues.length > 0 && <p role="alert" className="feedback attachment-error">{fileIssues.map(issue => t(issue.message, issue.values)).join(' ')}</p>}
+ <label className="sr-only" htmlFor="message">{t('Message')}</label>
+ <textarea id="message" ref={composer} value={input} rows={2} placeholder={t('Ask anything…')}
onChange={event => setInput(event.target.value)}
onKeyDown={event => {
if (event.key === 'Enter' && !event.shiftKey && !event.nativeEvent.isComposing && event.keyCode !== 229) {
@@ -337,18 +339,18 @@ export function Chat({ hidden, userId, cache, id, drawerOpen, filesOverlay, sett
/>
<div className="composer-actions">
<div className="composer-tools">
- <button type="button" className="attachment-button" aria-label="Add attachments" title="Add attachments"
+ <button type="button" className="attachment-button" aria-label={t('Add attachments')} title={t('Add attachments')}
disabled={submitting} onClick={() => filePicker.current?.click()}><Plus size={21} /></button>
<ModelPicker userId={userId} id={id} settingsVersion={settingsVersion} onSettings={onSettings} onSaving={setModelSaving} />
{id && <PermissionPicker key={id} userId={userId} sessionId={id} streamState={transcript.permission}
disabled={activeTurn !== null || submitting} onSaving={setPermissionSaving} />}
</div>
<div className="composer-submit">
- {activeTurn !== null && <button className="stop-generation" type="button" title="Stop generating"
- aria-label="Stop generating" disabled={stopping} onClick={() => { void stopGenerating() }}>
+ {activeTurn !== null && <button className="stop-generation" type="button" title={t('Stop generating')}
+ aria-label={t('Stop generating')} disabled={stopping} onClick={() => { void stopGenerating() }}>
{stopping ? <LoaderCircle className="spinner" size={16} /> : <Square size={15} />}
</button>}
- <button className="send-button" type="submit" aria-label="Send message"
+ <button className="send-button" type="submit" aria-label={t('Send message')}
disabled={(!input.trim() && !files.length) || submitting || modelSaving || permissionSaving || loading || Boolean(historyError)}>
{submitting ? <LoaderCircle className="spinner" size={20} /> : <ArrowUp size={21} />}
</button>
@@ -360,8 +362,8 @@ export function Chat({ hidden, userId, cache, id, drawerOpen, filesOverlay, sett
return (
<main className="workspace" hidden={hidden} inert={drawerOpen || filesOverlay}>
<header className="topbar">
- <button className="icon-button drawer-toggle" type="button" onClick={onOpenMenu} aria-expanded={drawerOpen} aria-controls="chat-sidebar" aria-label="Open chats"><Menu size={22} /></button>
- <span>Go Harness Chat</span>
+ <button className="icon-button drawer-toggle" type="button" onClick={onOpenMenu} aria-expanded={drawerOpen} aria-controls="chat-sidebar" aria-label={t('Open chats')}><Menu size={22} /></button>
+ <span>{t('Go Harness Chat')}</span>
</header>
{!id ? (
<div className="chat-empty">
@@ -371,10 +373,10 @@ export function Chat({ hidden, userId, cache, id, drawerOpen, filesOverlay, sett
<div className="welcome">
<div className="welcome-copy">
<HarnessAvatar className="welcome-avatar" />
- <h1>{greeting()}</h1>
- <p>How can I help you today?</p>
+ <h1>{t(greeting())}</h1>
+ <p>{t('How can I help you today?')}</p>
</div>
- <div className="welcome-input">{form}{failure && <p className="feedback" role="alert">{failure}</p>}</div>
+ <div className="welcome-input">{form}{failure && <p className="feedback" role="alert">{t(failure)}</p>}</div>
</div>
) : (
<div className="conversation">
@@ -383,37 +385,37 @@ export function Chat({ hidden, userId, cache, id, drawerOpen, filesOverlay, sett
following.current = panel.scrollHeight - panel.scrollTop - panel.clientHeight < 88
setAtBottom(following.current)
}}>
- <div className="transcript" aria-label="Conversation">
- {loading && <p className="chat-status" role="status">Loading chat…</p>}
- {historyError && <div className="chat-status" role="alert">{historyError} <button type="button" className="text-button" onClick={() => setLoadAttempt(attempt => attempt + 1)}>Retry</button></div>}
+ <div className="transcript" aria-label={t('Conversation')}>
+ {loading && <p className="chat-status" role="status">{t('Loading chat…')}</p>}
+ {historyError && <div className="chat-status" role="alert">{t(historyError)} <button type="button" className="text-button" onClick={() => setLoadAttempt(attempt => attempt + 1)}>{t('Retry')}</button></div>}
{before !== null && <div className="history-actions">
<button type="button" className="text-button" onClick={() => { void loadOlder() }} disabled={loadingOlder}>
- {loadingOlder ? 'Loading…' : 'Load earlier messages'}
+ {loadingOlder ? t('Loading…') : t('Load earlier messages')}
</button>
- {olderError && <p className="feedback" role="alert">{olderError}</p>}
+ {olderError && <p className="feedback" role="alert">{t(olderError)}</p>}
</div>}
{replies.map(message => <MessageBubble key={message.id} message={message} tools={transcript.toolResults} userId={userId} sessionId={id} />)}
{!loading && !historyError && (waiting || generating) && <div className={waiting ? 'generation-row' : 'generation-row generation-follow'} role="status">
{waiting && <HarnessAvatar className="reply-mark" />}
- <span className="generation-copy"><span className="generation-dots" aria-hidden="true"><i /><i /><i /></span>{waiting ? 'Preparing a reply…' : 'Generating…'}</span>
+ <span className="generation-copy"><span className="generation-dots" aria-hidden="true"><i /><i /><i /></span>{waiting ? t('Preparing a reply…') : t('Generating…')}</span>
</div>}
</div>
</div>
<div className="chat-input">
- {connecting && <p className="chat-status reconnecting" role="status">Reconnecting…</p>}
- {failure && <p className="feedback" role="alert">{failure}</p>}
+ {connecting && <p className="chat-status reconnecting" role="status">{t('Reconnecting…')}</p>}
+ {failure && <p className="feedback" role="alert">{t(failure)}</p>}
{!atBottom && <button type="button" className="text-button" onClick={() => {
const panel = scroll.current
if (panel) panel.scrollTop = panel.scrollHeight
- }}>Back to latest</button>}
- {queue.length > 0 && <ul className="message-queue" aria-label="Queued messages">
+ }}>{t('Back to latest')}</button>}
+ {queue.length > 0 && <ul className="message-queue" aria-label={t('Queued messages')}>
{queue.map(item => <li key={item.id}>
- <span className="queue-summary">{messageText(item) || 'Attachment'}</span>
- {item.placement === 'steering' ? <small>Waiting to steer</small> : <>
+ <span className="queue-summary">{messageText(item) || t('Attachment')}</span>
+ {item.placement === 'steering' ? <small>{t('Waiting to steer')}</small> : <>
<button type="button" className="text-button" disabled={actionId === item.id}
- onClick={() => { void queueAction(item.id, 'steer') }}>Steer</button>
+ onClick={() => { void queueAction(item.id, 'steer') }}>{t('Steer')}</button>
<button type="button" className="text-button" disabled={actionId === item.id}
- onClick={() => { void queueAction(item.id, 'delete') }}>Delete</button>
+ onClick={() => { void queueAction(item.id, 'delete') }}>{t('Delete')}</button>
</>}
</li>)}
</ul>}
diff --git a/frontend/src/chat/ChatContent.tsx b/frontend/src/chat/ChatContent.tsx
index 54aa77b..ceaae71 100644
--- a/frontend/src/chat/ChatContent.tsx
+++ b/frontend/src/chat/ChatContent.tsx
@@ -1,4 +1,5 @@
import { useEffect, useState } from 'react'
+import { useLocale } from '../locale'
import { Check, ChevronRight, CircleAlert, FileDown, LoaderCircle, Terminal, Wrench } from 'lucide-react'
import ReactMarkdown from 'react-markdown'
import remarkGfm from 'remark-gfm'
@@ -9,7 +10,8 @@ import { groupDisplayBlocks, messageText, type AttachmentRef, type FileRef, type
type SessionAddress = { userId: string; sessionId?: string }
export function MessageBubble({ message, tools, ...address }: SessionAddress & { message: Message; tools: Transcript['toolResults'] }) {
- if (message.role === 'notice') return <p className="chat-status">{messageText(message)}</p>
+ const { t } = useLocale()
+ if (message.role === 'notice') return <p className="chat-status">{t(messageText(message))}</p>
const isAssistant = message.role === 'assistant'
return (
<article className={'message ' + (isAssistant ? 'assistant-message' : 'user-message')}>
@@ -37,6 +39,7 @@ export function MessageBubble({ message, tools, ...address }: SessionAddress & {
}
function MarkdownText({ text }: { text: string }) {
+ const { t } = useLocale()
return <div>
<ReactMarkdown remarkPlugins={[remarkGfm]} skipHtml components={{
a: ({ children, href }) => href && /^(https?:|mailto:|#)/i.test(href)
@@ -47,7 +50,7 @@ function MarkdownText({ text }: { text: string }) {
const end = node?.position?.end.offset
return start !== undefined && end !== undefined ? text.slice(start, end) : alt
},
- table: ({ children }) => <div className="markdown-table-scroll" role="region" aria-label="Table" tabIndex={0}>
+ table: ({ children }) => <div className="markdown-table-scroll" role="region" aria-label={t('Table')} tabIndex={0}>
<table>{children}</table>
</div>,
}}>{text}</ReactMarkdown>
@@ -57,18 +60,23 @@ function MarkdownText({ text }: { text: string }) {
const toolLabels: Record<string, string> = {
read_file: 'Read file', write_file: 'Write file', edit_file: 'Edit file',
readimage: 'Read image', generateimage: 'Generate image',
- bash: 'Run command', shell: 'Run command', web_search: 'Search the web', web_fetch: 'Open web page',
+ bash: 'Run command', shell: 'Run command', shellexecute: 'Run command',
+ web_search: 'Search the web', web_fetch: 'Open web page',
+ present: 'Present files', skill: 'Load skill',
+ schedule_create: 'Create scheduled task', schedule_list: 'List scheduled tasks',
+ schedule_view: 'View scheduled task', schedule_edit: 'Edit scheduled task',
}
function ToolGroup({ blocks, tools }: { blocks: ToolBlock[]; tools: Transcript['toolResults'] }) {
+ const { t } = useLocale()
const statuses = blocks.map(block => tools[block.callId]?.status)
const remaining = statuses.filter(status => !status).length
const issues = statuses.filter(status => status === 'failed' || status === 'cancelled').length
return <details className="tool-card tool-group">
<summary>
<Wrench size={15} aria-hidden="true" />
- <span>{blocks.length} tool steps</span>
- {remaining > 0 ? <small>{remaining} running</small> : issues > 0 ? <small>{issues} interrupted</small> : <Check size={15} className="tool-state done" aria-label="Finished" />}
+ <span>{t('{count} tool steps', { count: blocks.length })}</span>
+ {remaining > 0 ? <small>{t('{count} running', { count: remaining })}</small> : issues > 0 ? <small>{t('{count} interrupted', { count: issues })}</small> : <Check size={15} className="tool-state done" aria-label={t('Finished')} />}
<ChevronRight size={15} className="tool-chevron" aria-hidden="true" />
</summary>
<div className="tool-group-items">
@@ -78,25 +86,27 @@ function ToolGroup({ blocks, tools }: { blocks: ToolBlock[]; tools: Transcript['
}
function ToolCard({ block, progress }: { block: ToolBlock; progress?: Transcript['toolResults'][string] }) {
+ const { t } = useLocale()
const label = toolLabels[block.name] ?? block.name.replace(/[_-]+/g, ' ')
const status = progress?.status
const outcome = status === 'succeeded' ? 'Done' : status === 'failed' ? 'Failed' : status === 'cancelled' ? 'Stopped' : 'Running'
const duration = progress?.startedAt !== undefined && progress.endedAt !== undefined
? Math.max(0, progress.endedAt - progress.startedAt) : undefined
const timing = duration === undefined ? '' : duration < 1000 ? duration + ' ms' : (duration / 1000).toFixed(1) + ' s'
- const row = <><Terminal size={14} aria-hidden="true" /><span>{label}</span>
- {status === 'succeeded' ? <Check size={14} className="tool-state done" aria-label={outcome} />
- : status ? <CircleAlert size={14} className="tool-state issue" aria-label={outcome} />
- : <LoaderCircle size={14} className="tool-state spinner" aria-label={outcome} />}</>
+ const row = <><Terminal size={14} aria-hidden="true" /><span>{t(label)}</span>
+ {status === 'succeeded' ? <Check size={14} className="tool-state done" aria-label={t(outcome)} />
+ : status ? <CircleAlert size={14} className="tool-state issue" aria-label={t(outcome)} />
+ : <LoaderCircle size={14} className="tool-state spinner" aria-label={t(outcome)} />}</>
if (!timing && !progress?.code) return <div className="tool-card"><div className="tool-summary">{row}</div></div>
return <details className="tool-card">
<summary>{row}<ChevronRight size={14} className="tool-chevron" aria-hidden="true" /></summary>
- <div className="tool-detail">{[timing && 'Duration ' + timing, progress?.code?.replaceAll('_', ' ').toLowerCase()].filter(Boolean).join(' · ')}</div>
+ <div className="tool-detail">{[timing && t('Duration {time}', { time: timing }), progress?.code?.replaceAll('_', ' ').toLowerCase()].filter(Boolean).join(' · ')}</div>
</details>
}
function FileBlock({ name, description, file, userId, sessionId }: SessionAddress & { name?: string; description?: string; file: FileRef }) {
- const filename = name || 'Attachment'
+ const { t } = useLocale()
+ const filename = name || t('Attachment')
const [busy, setBusy] = useState(false)
const [error, setError] = useState('')
async function download() {
@@ -122,11 +132,12 @@ function FileBlock({ name, description, file, userId, sessionId }: SessionAddres
<FileDown size={16} aria-hidden="true" /> <span>{filename}</span>
</button>
{description && <div className="chat-file-description">{description}</div>}
- {error && <div className="feedback" role="status">{error}</div>}
+ {error && <div className="feedback" role="status">{t(error)}</div>}
</div>
}
function ImageBlock({ attachment, userId, sessionId }: SessionAddress & { attachment: AttachmentRef }) {
+ const { t } = useLocale()
const { attachmentId, name, width, height } = attachment
const [href, setHref] = useState('')
const [failed, setFailed] = useState(false)
@@ -146,9 +157,9 @@ function ImageBlock({ attachment, userId, sessionId }: SessionAddress & { attach
if (objectURL) URL.revokeObjectURL(objectURL)
}
}, [userId, sessionId, attachmentId, name])
- if (failed) return <span className="chat-status">Image unavailable.</span>
- if (!href) return <div className="chat-image-placeholder" aria-label="Loading image" />
- return <a href={href} target="_blank" rel="noreferrer" aria-label={name || 'Open image'}>
- <img className="chat-image" src={href} alt={name || 'Attachment'} width={width} height={height} onError={() => setFailed(true)} />
+ if (failed) return <span className="chat-status">{t('Image unavailable.')}</span>
+ if (!href) return <div className="chat-image-placeholder" aria-label={t('Loading image')} />
+ return <a href={href} target="_blank" rel="noreferrer" aria-label={name || t('Open image')}>
+ <img className="chat-image" src={href} alt={name || t('Attachment')} width={width} height={height} onError={() => setFailed(true)} />
</a>
}
diff --git a/frontend/src/chat/ModelPicker.tsx b/frontend/src/chat/ModelPicker.tsx
index d8017b4..3319d0d 100644
--- a/frontend/src/chat/ModelPicker.tsx
+++ b/frontend/src/chat/ModelPicker.tsx
@@ -1,4 +1,5 @@
import { useEffect, useRef, useState } from 'react'
+import { useLocale } from '../locale'
import { Check, ChevronDown, Cpu } from 'lucide-react'
import { getModelSettings, getSessionModel, saveSessionModel, settingsApplyFailed, type ModelSelection, type ModelSettings, type SessionModel } from '../api/controller'
@@ -9,6 +10,7 @@ export function ModelPicker({ userId, id, settingsVersion, onSettings, onSaving
onSettings: () => void
onSaving: (value: boolean) => void
}) {
+ const { t } = useLocale()
const [catalog, setCatalog] = useState<ModelSettings>()
const [route, setRoute] = useState<SessionModel>()
const [open, setOpen] = useState(false)
@@ -67,8 +69,8 @@ export function ModelPicker({ userId, id, settingsVersion, onSettings, onSaving
? { endpointId: defaultId, modelId: catalog.endpoints[defaultId].models[0] } : undefined
const activeName = active && catalog?.endpoints[active.endpointId]?.name
const choices = Object.entries(catalog?.endpoints ?? {})
- const label = route?.status === 'unavailable' ? 'Model unavailable' : activeName && active
- ? activeName + ' / ' + active.modelId : id ? 'Choose model' : 'Configure model'
+ const label = route?.status === 'unavailable' ? t('Model unavailable') : activeName && active
+ ? activeName + ' / ' + active.modelId : id ? t('Choose model') : t('Configure model')
return <div className="model-picker" ref={picker} onBlur={event => {
if (event.relatedTarget && !event.currentTarget.contains(event.relatedTarget)) setOpen(false)
}} onKeyDown={event => {
@@ -91,7 +93,7 @@ export function ModelPicker({ userId, id, settingsVersion, onSettings, onSaving
? <><small>{activeName}</small><strong>{active.modelId}</strong></> : label}</span>{id && choices.length > 0 && <ChevronDown size={14} />}
</button>
{open && catalog && <div className="model-picker-menu">
- <label>Endpoint<select value={endpointId} onChange={event => setEndpointID(event.target.value)}>
+ <label>{t('Endpoint')}<select value={endpointId} onChange={event => setEndpointID(event.target.value)}>
{choices.map(([id, endpoint]) => <option key={id} value={id}>{endpoint.name}</option>)}
</select></label>
<div className="model-picker-options">
@@ -102,6 +104,6 @@ export function ModelPicker({ userId, id, settingsVersion, onSettings, onSaving
</button>)}
</div>
</div>}
- {error && <small role="alert">{error}</small>}
+ {error && <small role="alert">{t(error)}</small>}
</div>
}
diff --git a/frontend/src/chat/PermissionControls.tsx b/frontend/src/chat/PermissionControls.tsx
index 7ca6453..16ab2c9 100644
--- a/frontend/src/chat/PermissionControls.tsx
+++ b/frontend/src/chat/PermissionControls.tsx
@@ -1,4 +1,5 @@
import { useEffect, useId, useRef, useState } from 'react'
+import { useLocale } from '../locale'
import { Check, ChevronDown, Shield, ShieldAlert } from 'lucide-react'
import { answerQuestion, getSessionPermission, saveSessionPermission } from '../api/controller'
import { permissionLabel, permissionOptions, type PermissionMode, type SessionPermission } from './permissions'
@@ -7,6 +8,7 @@ import type { PendingQuestion } from './transcript'
export function PermissionPicker({ userId, sessionId, streamState, disabled, onSaving }: {
userId: string; sessionId: string; streamState?: SessionPermission; disabled: boolean; onSaving: (value: boolean) => void
}) {
+ const { t } = useLocale()
const [mode, setMode] = useState<PermissionMode>()
const [open, setOpen] = useState(false)
const [busy, setBusy] = useState(false)
@@ -45,30 +47,31 @@ export function PermissionPicker({ userId, sessionId, streamState, disabled, onS
onSaving(true)
setError('')
try { setMode((await saveSessionPermission(userId, sessionId, next)).mode) }
- catch (error) { setError(error instanceof Error ? error.message : 'Could not change chat permission.') }
+ catch { setError('Could not change chat permission.') }
finally { setBusy(false); onSaving(false) }
}
return <div className="model-picker permission-picker" ref={root}>
- <button className="model-picker-trigger permission-trigger" type="button" aria-label="Chat permission"
+ <button className="model-picker-trigger permission-trigger" type="button" aria-label={t('Chat permission')}
aria-expanded={open} aria-controls={menuID} disabled={busy || disabled || !mode} onClick={() => setOpen(value => !value)}>
- <Shield size={16} /><span>{permissionLabel(mode) ?? 'Permissions'}</span><ChevronDown size={13} />
+ <Shield size={16} /><span>{t(permissionLabel(mode) ?? 'Permissions')}</span><ChevronDown size={13} />
</button>
{open && <div className="model-picker-menu permission-menu" id={menuID}>
- <p>Permissions for this chat</p>
+ <p>{t('Permissions for this chat')}</p>
<div className="model-picker-options">
{permissionOptions.map(option => <button key={option.mode} type="button" aria-pressed={mode === option.mode}
disabled={disabled || busy} onClick={() => void choose(option.mode)}>
- <span><strong>{option.label}</strong><small>{option.detail}</small></span>
+ <span><strong>{t(option.label)}</strong><small>{t(option.detail)}</small></span>
{mode === option.mode && <Check size={16} />}
</button>)}
</div>
</div>}
- {error && <small role="alert">{error}</small>}
+ {error && <small role="alert">{t(error)}</small>}
</div>
}
export function ApprovalPanel({ item, userId, sessionId }: { item: PendingQuestion; userId: string; sessionId: string }) {
+ const { t } = useLocale()
const [busy, setBusy] = useState(false)
const [error, setError] = useState('')
const info = item.approval
@@ -81,17 +84,17 @@ export function ApprovalPanel({ item, userId, sessionId }: { item: PendingQuesti
catch { setError('The decision could not be sent. Try again.'); setBusy(false) }
}
- return <section className="question-panel permission-approval" role="dialog" aria-label="Tool approval">
+ return <section className="question-panel permission-approval" role="dialog" aria-label={t('Tool approval')}>
<header><span className="permission-icon"><ShieldAlert size={18} /></span>
- <div><strong>Approval required</strong><small>{info.tool}{info.target && ' · ' + permissionLabel(info.target)}</small></div>
+ <div><strong>{t('Approval required')}</strong><small>{info.tool}{info.target && ' · ' + t(permissionLabel(info.target) ?? 'Permissions')}</small></div>
</header>
<p>{info.reason}</p>
{info.detail && <pre>{info.detail}</pre>}
- <small className="permission-note">Allow once applies to this operation only.</small>
- {error && <p role="alert" className="feedback">{error}</p>}
+ <small className="permission-note">{t('Allow once applies to this operation only.')}</small>
+ {error && <p role="alert" className="feedback">{t(error)}</p>}
<div className="permission-decisions">
- <button type="button" onClick={() => void decide('Deny')} disabled={busy}>Deny</button>
- <button type="button" onClick={() => void decide('Allow once')} disabled={busy}>Allow once</button>
+ <button type="button" onClick={() => void decide('Deny')} disabled={busy}>{t('Deny')}</button>
+ <button type="button" onClick={() => void decide('Allow once')} disabled={busy}>{t('Allow once')}</button>
</div>
</section>
}
diff --git a/frontend/src/chat/QuestionPanel.tsx b/frontend/src/chat/QuestionPanel.tsx
index dfcfbfc..b27a81a 100644
--- a/frontend/src/chat/QuestionPanel.tsx
+++ b/frontend/src/chat/QuestionPanel.tsx
@@ -1,8 +1,10 @@
import { useState } from 'react'
+import { useLocale } from '../locale'
import { answerQuestion } from '../api/controller'
import type { Answer, PendingQuestion } from './transcript'
export function QuestionPanel({ item, userId, sessionId }: { item: PendingQuestion; userId: string; sessionId: string }) {
+ const { t } = useLocale()
const [answers, setAnswers] = useState<Answer[]>(() => item.questions.map(question => ({ id: question.id, selected: [] })))
const [sending, setSending] = useState(false)
const [submitted, setSubmitted] = useState(false)
@@ -27,8 +29,8 @@ export function QuestionPanel({ item, userId, sessionId }: { item: PendingQuesti
}
}
- return <form className="question-panel" aria-label="Agent question" onSubmit={event => { event.preventDefault(); void submit() }}>
- <strong>{item.state === 'continued' ? 'You can still answer' : 'The agent has a question'}</strong>
+ return <form className="question-panel" aria-label={t('Agent question')} onSubmit={event => { event.preventDefault(); void submit() }}>
+ <strong>{item.state === 'continued' ? t('You can still answer') : t('The agent has a question')}</strong>
{item.questions.map((question, index) => <fieldset key={question.id} disabled={sending || submitted}>
<legend>{question.question}</legend>
{question.detail && <p>{question.detail}</p>}
@@ -44,10 +46,10 @@ export function QuestionPanel({ item, userId, sessionId }: { item: PendingQuesti
<span>{option.label}{option.description && <small>{option.description}</small>}</span>
</label>)}
<input className="question-custom" type="text" value={answers[index].custom ?? ''}
- aria-label={'Custom answer for ' + question.question} placeholder="Type your own answer"
+ aria-label={t('Custom answer for {question}', { question: question.question })} placeholder={t('Type your own answer')}
onChange={event => update(index, { custom: event.target.value })} />
</fieldset>)}
- {error && <p className="feedback" role="alert">{error}</p>}
- <button className="text-button" type="submit" disabled={!ready || sending || submitted}>{submitted ? 'Answer sent' : 'Send answer'}</button>
+ {error && <p className="feedback" role="alert">{t(error)}</p>}
+ <button className="text-button" type="submit" disabled={!ready || sending || submitted}>{submitted ? t('Answer sent') : t('Send answer')}</button>
</form>
}
diff --git a/frontend/src/chat/attachments.ts b/frontend/src/chat/attachments.ts
index d935ca2..27e502a 100644
--- a/frontend/src/chat/attachments.ts
+++ b/frontend/src/chat/attachments.ts
@@ -1,5 +1,6 @@
const imageTypes = new Set(['image/png', 'image/jpeg', 'image/webp', 'image/gif'])
const maxBytes = 200 * 1024 ** 2
+type AttachmentIssue = { message: string; values?: Record<string, string | number> }
export function isMessageImage(file: File) {
return imageTypes.has(file.type)
@@ -7,24 +8,27 @@ export function isMessageImage(file: File) {
export function addMessageFiles(current: File[], incoming: File[]) {
const files = [...current]
- const errors = new Set<string>()
+ const issues = new Map<string, AttachmentIssue>()
+ function reject(message: string, values?: AttachmentIssue['values']) {
+ issues.set(JSON.stringify([message, values]), { message, values })
+ }
let images = current.filter(isMessageImage).length
let total = current.reduce((sum, file) => sum + file.size, 0)
for (const file of incoming) {
const image = isMessageImage(file)
const limit = image ? 50 : 32
- if (image && !file.size) errors.add(`${file.name} is empty.`)
- else if (new TextEncoder().encode(file.name).length > 255) errors.add('An attachment name exceeds 255 bytes.')
- else if (file.size > limit * 1024 ** 2) errors.add(`${file.name} exceeds ${limit} MiB.`)
- else if (image ? images >= 20 : files.length - images >= 8) errors.add('A message can attach up to 20 images and 8 other files.')
- else if (total + file.size > maxBytes) errors.add('Attachments cannot exceed 200 MiB per message.')
+ if (image && !file.size) reject('{name} is empty.', { name: file.name })
+ else if (new TextEncoder().encode(file.name).length > 255) reject('An attachment name exceeds 255 bytes.')
+ else if (file.size > limit * 1024 ** 2) reject('{name} exceeds {limit} MiB.', { name: file.name, limit })
+ else if (image ? images >= 20 : files.length - images >= 8) reject('A message can attach up to 20 images and 8 other files.')
+ else if (total + file.size > maxBytes) reject('Attachments cannot exceed 200 MiB per message.')
else {
files.push(file)
total += file.size
if (image) images++
}
}
- return { files, error: [...errors].join(' ') }
+ return { files, issues: [...issues.values()] }
}
export function messageRequest(content: string, files: File[]): RequestInit {
diff --git a/frontend/src/files/HostFiles.tsx b/frontend/src/files/HostFiles.tsx
index f29ef7d..9fc8c19 100644
--- a/frontend/src/files/HostFiles.tsx
+++ b/frontend/src/files/HostFiles.tsx
@@ -1,4 +1,5 @@
import { useCallback, useEffect, useRef, useState } from 'react'
+import { useLocale } from '../locale'
import { ChevronDown, ChevronRight, Clipboard, File, Folder, RefreshCw, X } from 'lucide-react'
import { APIError, listHostFiles, type HostFile } from '../api/controller'
@@ -16,11 +17,11 @@ function parentPath(path: string) {
return path.slice(0, Math.max(0, path.lastIndexOf('/')))
}
-function fileSize(bytes: number) {
+function fileSize(bytes: number, language: string) {
if (bytes < 1024) return bytes + ' B'
const unit = bytes < 1024 ** 2 ? 'KB' : bytes < 1024 ** 3 ? 'MB' : 'GB'
const divisor = unit === 'KB' ? 1024 : unit === 'MB' ? 1024 ** 2 : 1024 ** 3
- return new Intl.NumberFormat(undefined, { maximumFractionDigits: 1 }).format(bytes / divisor) + ' ' + unit
+ return new Intl.NumberFormat(language, { maximumFractionDigits: 1 }).format(bytes / divisor) + ' ' + unit
}
function readError(error: unknown) {
@@ -32,6 +33,7 @@ function readError(error: unknown) {
type Props = { userId: string; open: boolean; overlay: boolean; onClose: () => void }
export function HostFiles({ userId, open, overlay, onClose }: Props) {
+ const { language, t } = useLocale()
const [listings, setListings] = useState(() => new Map<string, Listing>())
const [expanded, setExpanded] = useState(() => new Set<string>())
const [selected, setSelected] = useState<HostFile>()
@@ -166,44 +168,44 @@ export function HostFiles({ userId, open, overlay, onClose }: Props) {
<Folder size={16} aria-hidden="true" />
</> : <File size={16} className="host-file-leaf" aria-hidden="true" />}
<span>{file.name}</span>
- {!file.isDir && <small>{fileSize(file.size)}</small>}
+ {!file.isDir && <small>{fileSize(file.size, language)}</small>}
</button>
{file.isDir && isOpen && <div className="host-file-branch">{renderDirectory(file.path)}</div>}
</li>
})}
</ul>}
- {listing.loading && <p className="host-files-state" role="status">Loading…</p>}
- {listing.error && <p className="host-files-state" role="alert">{listing.error}
- <button type="button" className="text-button" onClick={() => { void load(path) }}>Retry</button>
+ {listing.loading && <p className="host-files-state" role="status">{t('Loading…')}</p>}
+ {listing.error && <p className="host-files-state" role="alert">{t(listing.error)}
+ <button type="button" className="text-button" onClick={() => { void load(path) }}>{t('Retry')}</button>
</p>}
{!listing.loading && !listing.error && files.length === 0 && listing.nextOffset === undefined &&
- <p className="host-files-state">Empty directory</p>}
+ <p className="host-files-state">{t('Empty directory')}</p>}
{!listing.loading && listing.nextOffset !== undefined && <button type="button" className="text-button"
- onClick={() => { void load(path, listing.nextOffset) }}>Load more</button>}
+ onClick={() => { void load(path, listing.nextOffset) }}>{t('Load more')}</button>}
</>
}
return <>
{open && overlay && <button type="button" className="host-files-scrim" onClick={onClose}
- tabIndex={-1} aria-label="Close file system" />}
+ tabIndex={-1} aria-label={t('Close file system')} />}
<aside id="host-files" className="host-files" hidden={!open} role={overlay ? 'dialog' : undefined}
aria-modal={overlay || undefined} aria-labelledby="host-files-title"
onKeyDown={event => { if (event.key === 'Escape') onClose() }}>
<header className="host-files-header">
- <h2 id="host-files-title">File system</h2>
- <button type="button" className="icon-button" title="Refresh file tree" aria-label="Refresh file tree"
+ <h2 id="host-files-title">{t('File system')}</h2>
+ <button type="button" className="icon-button" title={t('Refresh file tree')} aria-label={t('Refresh file tree')}
disabled={refreshing} onClick={() => { void refreshTree() }}><RefreshCw size={17} /></button>
- <button ref={closeButton} type="button" className="icon-button" title="Close file system"
- aria-label="Close file system" onClick={onClose}><X size={20} /></button>
+ <button ref={closeButton} type="button" className="icon-button" title={t('Close file system')}
+ aria-label={t('Close file system')} onClick={onClose}><X size={20} /></button>
</header>
{root && <div className="host-files-location">
<div className="host-files-path">
<code title={path}>{path}</code>
- <button type="button" className="icon-button" title="Copy path" aria-label="Copy path"
+ <button type="button" className="icon-button" title={t('Copy path')} aria-label={t('Copy path')}
onClick={() => { void copyPath() }}><Clipboard size={16} /></button>
</div>
- {storageLabel && <div className="host-files-state">{storageLabel}{root.source && <> · <code>{root.source}</code></>}</div>}
- {copyStatus && <div className="host-files-state" role="status">{copyStatus}</div>}
+ {storageLabel && <div className="host-files-state">{t(storageLabel)}{root.source && <> · <code>{root.source}</code></>}</div>}
+ {copyStatus && <div className="host-files-state" role="status">{t(copyStatus)}</div>}
</div>}
<div className="host-files-tree">
{root && <button type="button" className="host-file-row host-file-root" aria-current={selected === undefined ? 'true' : undefined}
diff --git a/frontend/src/locale.tsx b/frontend/src/locale.tsx
new file mode 100644
index 0000000..9db0973
--- /dev/null
+++ b/frontend/src/locale.tsx
@@ -0,0 +1,75 @@
+import { createContext, useContext, useEffect, useState, type ReactNode } from 'react'
+import { Languages } from 'lucide-react'
+import { translate, type Language } from './messages'
+
+const preferenceKey = 'go-harness.web-language'
+const languages: ReadonlyArray<{ id: Language; label: string }> = [
+ { id: 'en', label: 'English' },
+ { id: 'zh-CN', label: '简体中文' },
+]
+
+function initialLanguage(): Language {
+ try {
+ const saved = localStorage.getItem(preferenceKey)
+ if (saved === 'en' || saved === 'zh-CN') return saved
+ } catch {
+ // A browser may disable storage for this origin.
+ }
+ for (const preference of navigator.languages) {
+ const primary = preference.toLowerCase().split('-')[0]
+ if (primary === 'zh') return 'zh-CN'
+ if (primary === 'en') return 'en'
+ }
+ return 'en'
+}
+
+type Locale = {
+ language: Language
+ setLanguage: (language: Language) => void
+ t: (message: string, values?: Record<string, string | number>) => string
+}
+
+const LocaleContext = createContext<Locale | undefined>(undefined)
+
+export function LocaleProvider({ children }: { children: ReactNode }) {
+ const [language, setSelectedLanguage] = useState(initialLanguage)
+
+ useEffect(() => {
+ document.documentElement.lang = language
+ }, [language])
+
+ function setLanguage(next: Language) {
+ setSelectedLanguage(next)
+ try {
+ localStorage.setItem(preferenceKey, next)
+ } catch {
+ // The selected language still applies until the page is reloaded.
+ }
+ }
+
+ return <LocaleContext.Provider value={{
+ language,
+ setLanguage,
+ t: (message, values) => translate(language, message, values),
+ }}>{children}</LocaleContext.Provider>
+}
+
+export function useLocale() {
+ const locale = useContext(LocaleContext)
+ if (!locale) throw new Error('LocaleProvider is required')
+ return locale
+}
+
+export function LanguagePicker() {
+ const { language, setLanguage, t } = useLocale()
+ return <label className="language-picker">
+ <Languages size={16} aria-hidden="true" />
+ <span className="sr-only">{t('Language')}</span>
+ <select value={language} onChange={event => {
+ const next = languages.find(option => option.id === event.currentTarget.value)
+ if (next) setLanguage(next.id)
+ }}>
+ {languages.map(option => <option key={option.id} value={option.id} lang={option.id}>{option.label}</option>)}
+ </select>
+ </label>
+}
diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx
index 10ff195..c39fd9e 100644
--- a/frontend/src/main.tsx
+++ b/frontend/src/main.tsx
@@ -1,5 +1,6 @@
import { createRoot } from 'react-dom/client'
import { App } from './App'
+import { LocaleProvider } from './locale'
import './styles/app.css'
-createRoot(document.getElementById('root')!).render(<App />)
+createRoot(document.getElementById('root')!).render(<LocaleProvider><App /></LocaleProvider>)
diff --git a/frontend/src/messages.ts b/frontend/src/messages.ts
new file mode 100644
index 0000000..af6979b
--- /dev/null
+++ b/frontend/src/messages.ts
@@ -0,0 +1,240 @@
+export type Language = 'en' | 'zh-CN'
+
+const chinese: Readonly<Record<string, string>> = {
+ "Language": "语言",
+ "Go Harness Chat": "Go Harness 会话",
+ "Create an account": "创建账号",
+ "Open your account": "打开账号",
+ "Account name": "账号名",
+ "Use 1–64 lowercase letters, digits, underscores or hyphens. Start with a letter or digit.": "使用 1–64 个小写字母、数字、下划线或连字符,以字母或数字开头。",
+ "Create account": "创建账号",
+ "Open account": "打开账号",
+ "Creating account…": "正在创建账号…",
+ "Opening your account…": "正在打开账号…",
+ "Open an existing account": "打开已有账号",
+ "Account not found. Create it or check the name.": "找不到该账号。请创建账号或检查账号名。",
+ "This account already exists. Open it instead.": "该账号已存在,请直接打开。",
+ "Could not open the account. Try again.": "无法打开账号,请重试。",
+ "This chat is busy. Try again when it finishes.": "会话正在执行,请等待当前回复结束。",
+ "This chat still has scheduled reminders. Remove them before deleting it.": "该会话还有定时任务,请先移除任务。",
+ "The chat could not be deleted. Try again.": "无法删除会话,请重试。",
+ "Could not confirm the Host stopped. Try again to check its status.": "无法确认 Host 是否已停止,请重试以检查状态。",
+ "Could not stop your Host. Try again.": "无法停止 Host,请重试。",
+ "Could not load chats.": "无法读取会话列表。",
+ "Could not start your Host. Try again.": "无法启动 Host,请重试。",
+ "This chat is no longer available.": "该会话已不可用。",
+ "Host unavailable": "Host 不可用",
+ "Set up an endpoint and a default model before creating a chat.": "请先配置端点和默认模型,再创建会话。",
+ "Could not confirm a new chat. Check the list before trying again.": "无法确认会话是否已创建,请检查会话列表后再试。",
+ "Stop this chat and delete its active schedules? The chat history and files will be kept.": "停止此会话并删除关联的活跃任务?会话记录和文件会保留。",
+ "Open chats": "打开会话列表",
+ "Close chats": "关闭会话列表",
+ "Back to chats": "返回会话",
+ "Settings": "设置",
+ "Models": "模型",
+ "Web search": "网页搜索",
+ "Image generation": "图片生成",
+ "Chats": "会话",
+ "New chat": "新建会话",
+ "Open model settings": "打开模型设置",
+ "Retry": "重试",
+ "No chats yet": "暂无会话",
+ "Actions for {name}": "{name}的操作",
+ "Load more": "加载更多",
+ "Personal workspace": "个人工作区",
+ "Account actions": "账号操作",
+ "File system": "文件系统",
+ "Stopping Host…": "正在停止 Host…",
+ "Stop Host": "停止 Host",
+ "Chat actions": "会话操作",
+ "Delete chat": "删除会话",
+ "Delete chat?": "删除此会话?",
+ "will disappear from the chat list. Its data will stay on disk.": "将从会话列表隐藏,数据会保留在磁盘上。",
+ "Cancel": "取消",
+ "Deleting…": "正在删除…",
+ "Could not load model settings.": "无法读取模型设置。",
+ "Settings were saved, but the Host could not apply them. Reopen the account to load the saved settings.": "设置已保存,但 Host 未能应用。请重新打开账号。",
+ "Enter an API key for the new endpoint address.": "请输入新端点的 API 密钥。",
+ "Check the endpoint URL, API key, and model IDs. Model IDs must be unique.": "请检查端点地址、API 密钥和模型 ID。模型 ID 不得重复。",
+ "Could not confirm the change. Refresh settings before trying again.": "无法确认修改已生效,请刷新设置后重试。",
+ "Only OpenAI-compatible Responses API endpoints are supported.": "支持 OpenAI 兼容的 Responses API 端点。",
+ "Loading model settings…": "正在加载模型设置…",
+ "Add an endpoint to create your first chat.": "添加端点后即可创建第一个会话。",
+ "Endpoint saved.": "端点已保存。",
+ "Default endpoint": "默认端点",
+ "API key saved": "API 密钥已保存",
+ "API key missing": "缺少 API 密钥",
+ "Default model": "默认模型",
+ "Edit": "编辑",
+ "Set as default": "设为默认",
+ "Default endpoint updated.": "已更新默认端点。",
+ "Remove this endpoint? Chats that use it will need a new model.": "移除此端点?使用它的会话需要重新选择模型。",
+ "Endpoint removed.": "端点已移除。",
+ "Remove": "移除",
+ "Endpoint added.": "端点已添加。",
+ "Add endpoint": "添加端点",
+ "Edit endpoint": "编辑端点",
+ "Name": "名称",
+ "Base URL": "端点地址",
+ "API key": "API 密钥",
+ "Leave blank to keep saved key": "留空以保留已保存的密钥",
+ "Model IDs": "模型 ID",
+ "One model per line. The first model is the endpoint default.": "每行填写一个模型。第一个模型为该端点的默认模型。",
+ "Saving…": "正在保存…",
+ "Save endpoint": "保存端点",
+ "DeepSeek Search API": "DeepSeek 搜索 API",
+ "BigModel API key": "智谱 BigModel API 密钥",
+ "Doubao Search Custom API key": "豆包搜索 API 密钥",
+ "Volcengine Ark API key": "火山方舟 API 密钥",
+ "OpenAI API key": "OpenAI API 密钥",
+ "Google AI Studio API key": "Google AI Studio API 密钥",
+ "Could not load provider settings.": "无法加载供应商设置。",
+ "{name} is now in use.": "已启用 {name}。",
+ "{name} API key removed.": "已移除 {name} 的 API 密钥。",
+ "{name} settings saved.": "已保存 {name} 的设置。",
+ "Settings were saved, but the Host could not apply them. Retry or reopen the account.": "设置已保存,但 Host 未能应用。请重试或重新打开账号。",
+ "Enter a valid model name or endpoint ID.": "请输入有效的模型名称或端点 ID。",
+ "Save an API key before using this provider.": "使用该供应商前,请先保存 API 密钥。",
+ "Enter a valid API key.": "请输入有效的 API 密钥。",
+ "Could not confirm the change. Try again.": "无法确认修改已生效,请重试。",
+ "Choose the service your agent uses to generate images.": "选择 Agent 用于生成图片的服务。",
+ "Choose the service your agent uses to search the web.": "选择 Agent 用于网页搜索的服务。",
+ "Loading provider settings…": "正在加载供应商设置…",
+ "Waiting for the Host to apply the saved change.": "正在等待 Host 应用已保存的设置。",
+ "In use": "当前使用",
+ "No provider is in use. Save a key and choose a provider.": "尚未启用供应商。请保存密钥并选择供应商。",
+ "{title} providers": "{title}供应商",
+ "No API key": "未设置 API 密钥",
+ "Retry applying {name}": "重试启用 {name}",
+ "Use {name}": "使用 {name}",
+ "Edit {name}": "编辑 {name}",
+ "Set up {name}": "配置 {name}",
+ "Retry apply": "重试应用",
+ "Use provider": "使用该供应商",
+ "Set up": "配置",
+ "Model name or endpoint ID": "模型名称或端点 ID",
+ "Model name": "模型名称",
+ "Leave blank to keep the saved key": "留空以保留已保存的密钥",
+ "Save settings": "保存设置",
+ "Remove key": "移除密钥",
+ "Build a provider adapter": "编写供应商适配器",
+ "This directory is no longer available.": "该目录已不可用。",
+ "The Host is unavailable. Try again after it reconnects.": "Host 暂不可用,请在重新连接后重试。",
+ "Could not list this directory.": "无法读取此目录。",
+ "Docker volume": "Docker 卷",
+ "Instance filesystem": "实例文件系统",
+ "Path copied.": "已复制路径。",
+ "Could not copy the path.": "无法复制路径。",
+ "Loading…": "正在加载…",
+ "Empty directory": "空目录",
+ "Close file system": "关闭文件系统",
+ "Refresh file tree": "刷新文件树",
+ "Copy path": "复制路径",
+ "Good morning": "早上好",
+ "Good afternoon": "下午好",
+ "Good evening": "晚上好",
+ "Choose an available model for this chat.": "请为当前会话选择可用模型。",
+ "The Host could not apply the current model settings. Reopen the account or save the model settings again.": "Host 无法应用当前模型设置。请重新打开账号或保存模型设置。",
+ "The message or its attachments exceed the upload limit.": "消息或附件超过上传限制。",
+ "An attached image could not be read. Remove it and try again.": "无法读取图片附件,请移除后重试。",
+ "The message was not accepted. Check it and try again.": "消息未被接收,请检查后重试。",
+ "Delivery could not be confirmed. Check the conversation before sending again.": "无法确认消息已送达。再次发送前请先检查会话。",
+ "Chat history could not be loaded.": "无法加载会话记录。",
+ "Older messages could not be loaded.": "无法加载更早的消息。",
+ "The queued message could not be updated.": "无法更新排队中的消息。",
+ "Generation could not be stopped.": "无法停止生成。",
+ "Attachments to send": "待发送附件",
+ "Remove {name}": "移除 {name}",
+ "Message": "消息",
+ "Ask anything…": "问点什么…",
+ "Add attachments": "添加附件",
+ "Stop generating": "停止生成",
+ "Send message": "发送消息",
+ "How can I help you today?": "今天想做什么?",
+ "Conversation": "会话消息",
+ "Loading chat…": "正在加载会话…",
+ "Load earlier messages": "加载更早的消息",
+ "Preparing a reply…": "正在准备回复…",
+ "Generating…": "正在生成…",
+ "Reconnecting…": "正在重新连接…",
+ "Back to latest": "回到最新消息",
+ "Queued messages": "排队中的消息",
+ "Attachment": "附件",
+ "Waiting to steer": "等待引导",
+ "Steer": "引导",
+ "Delete": "删除",
+ "{name} is empty.": "{name} 是空文件。",
+ "An attachment name exceeds 255 bytes.": "附件文件名超过 255 字节。",
+ "{name} exceeds {limit} MiB.": "{name} 超过 {limit} MiB。",
+ "A message can attach up to 20 images and 8 other files.": "每条消息最多可添加 20 张图片和 8 个其他文件。",
+ "Attachments cannot exceed 200 MiB per message.": "每条消息的附件总大小不能超过 200 MiB。",
+ "Scheduled task": "定时任务",
+ "Background task": "后台任务",
+ "The reply was interrupted.": "回复已中断。",
+ "The agent could not finish its reply.": "助手未能完成回复。",
+ "Table": "表格",
+ "Read file": "读取文件",
+ "Write file": "写入文件",
+ "Edit file": "编辑文件",
+ "Read image": "读取图片",
+ "Generate image": "生成图片",
+ "Run command": "执行命令",
+ "Search the web": "搜索网页",
+ "Open web page": "打开网页",
+ "Present files": "交付文件",
+ "Load skill": "加载技能",
+ "Create scheduled task": "创建定时任务",
+ "List scheduled tasks": "列出定时任务",
+ "View scheduled task": "查看定时任务",
+ "Edit scheduled task": "修改定时任务",
+ "{count} tool steps": "{count} 个工具步骤",
+ "{count} running": "{count} 个执行中",
+ "{count} interrupted": "{count} 个已中断",
+ "Finished": "已完成",
+ "Done": "已完成",
+ "Failed": "失败",
+ "Stopped": "已停止",
+ "Running": "执行中",
+ "Duration {time}": "用时 {time}",
+ "File unavailable.": "文件不可用。",
+ "Image unavailable.": "图片不可用。",
+ "Loading image": "正在加载图片",
+ "Open image": "打开图片",
+ "Could not load the chat model.": "无法读取当前会话的模型。",
+ "Model choice was saved, but the Host could not apply it. Try again.": "模型选择已保存,但 Host 未能应用。请重试。",
+ "Could not switch models. Try again.": "无法切换模型,请重试。",
+ "Model unavailable": "模型不可用",
+ "Choose model": "选择模型",
+ "Configure model": "配置模型",
+ "Endpoint": "端点",
+ "Could not read chat permission.": "无法读取会话权限。",
+ "Could not change chat permission.": "无法切换会话权限。",
+ "Chat permission": "会话权限",
+ "Permissions": "权限",
+ "Permissions for this chat": "当前会话的权限",
+ "Full access": "全权限",
+ "Workspace write": "工作区可写",
+ "Read only": "只读",
+ "Allow writes anywhere the Host tools can access.": "允许写入 Host 工具能够访问的位置。",
+ "Allow writes in this chat’s workspace. Ask before widening access.": "允许写入当前会话工作区。扩大权限前需要审批。",
+ "Read files and ask before any writes.": "允许读取文件。写入前需要审批。",
+ "The decision could not be sent. Try again.": "无法提交审批结果,请重试。",
+ "Tool approval": "工具审批",
+ "Approval required": "需要执行审批",
+ "Allow once applies to this operation only.": "本次授权仅适用于这项操作。",
+ "Deny": "拒绝",
+ "Allow once": "仅允许一次",
+ "The answer could not be sent. Try again.": "无法发送答案,请重试。",
+ "Agent question": "助手提问",
+ "You can still answer": "仍可回答此问题",
+ "The agent has a question": "助手需要你的回答",
+ "Custom answer for {question}": "自定义回答:{question}",
+ "Type your own answer": "输入自定义答案",
+ "Answer sent": "答案已发送",
+ "Send answer": "提交答案",
+}
+
+export function translate(language: Language, message: string, values?: Record<string, string | number>) {
+ const text = language === 'zh-CN' && Object.hasOwn(chinese, message) ? chinese[message] : message
+ return values ? text.replace(/\{(\w+)\}/g, (token, key: string) => String(values[key] ?? token)) : text
+}
diff --git a/frontend/src/sessions/Sidebar.tsx b/frontend/src/sessions/Sidebar.tsx
index 7a3608b..8d25492 100644
--- a/frontend/src/sessions/Sidebar.tsx
+++ b/frontend/src/sessions/Sidebar.tsx
@@ -1,10 +1,9 @@
import { useEffect, useRef, useState } from 'react'
+import { useLocale } from '../locale'
import { ChevronDown, Ellipsis, FolderTree, MessageSquare, MessageSquarePlus, Power, Settings, Trash2, X } from 'lucide-react'
import { HarnessAvatar } from '../HarnessAvatar'
import type { SessionRow } from '../api/controller'
-export function rowTitle(row: SessionRow) { return row.title || 'New chat' }
-
type Props = {
userId: string
rows: SessionRow[]
@@ -35,6 +34,8 @@ type Props = {
type ContextMenu = { row: SessionRow; x: number; y: number; anchor: HTMLElement }
export function Sidebar(props: Props) {
+ const { language, t } = useLocale()
+ const rowTitle = (row: SessionRow) => row.title || t('New chat')
const [menu, setMenu] = useState<ContextMenu | null>(null)
const [accountOpen, setAccountOpen] = useState(false)
const accountDock = useRef<HTMLDivElement>(null)
@@ -94,22 +95,22 @@ export function Sidebar(props: Props) {
return (
<>
- {props.drawerOpen && <button type="button" className="scrim" onClick={props.onClose} aria-label="Close chats" />}
- <aside id="chat-sidebar" className={props.drawerOpen ? 'sidebar drawer-open' : 'sidebar'} aria-label="Chats"
+ {props.drawerOpen && <button type="button" className="scrim" onClick={props.onClose} aria-label={t('Close chats')} />}
+ <aside id="chat-sidebar" className={props.drawerOpen ? 'sidebar drawer-open' : 'sidebar'} aria-label={t('Chats')}
inert={props.filesOverlay}
onKeyDown={event => { if (event.key === 'Escape' && !menu && !event.defaultPrevented) props.onClose() }}>
<div className="brand">
<HarnessAvatar className="brand-mark" />
<span>Go Harness</span>
- <button ref={drawerClose} type="button" className="icon-button drawer-close" onClick={props.onClose} aria-label="Close chats"><X size={21} /></button>
+ <button ref={drawerClose} type="button" className="icon-button drawer-close" onClick={props.onClose} aria-label={t('Close chats')}><X size={21} /></button>
</div>
<button type="button" className="new-chat" onClick={props.onCreate} disabled={props.creating}>
- <MessageSquarePlus size={21} strokeWidth={1.75} /><span>New chat</span>
+ <MessageSquarePlus size={21} strokeWidth={1.75} /><span>{t('New chat')}</span>
</button>
- <div className="section-heading">Chats</div>
+ <div className="section-heading">{t('Chats')}</div>
<div className="session-list">
- {props.error && <p className="sidebar-feedback" role="alert">{props.error} <button type="button" className="text-button" onClick={props.needsModel ? props.onSettings : props.onRetry}>{props.needsModel ? 'Open model settings' : 'Retry'}</button></p>}
- {!props.error && !props.isLoading && props.rows.length === 0 && <p className="sidebar-feedback">No chats yet</p>}
+ {props.error && <p className="sidebar-feedback" role="alert">{t(props.error)} <button type="button" className="text-button" onClick={props.needsModel ? props.onSettings : props.onRetry}>{props.needsModel ? t('Open model settings') : t('Retry')}</button></p>}
+ {!props.error && !props.isLoading && props.rows.length === 0 && <p className="sidebar-feedback">{t('No chats yet')}</p>}
{props.rows.map(row => (
<div className={row.sessionId === props.selected ? 'chat-row selected' : 'chat-row'} key={row.sessionId}
onContextMenu={event => {
@@ -128,10 +129,10 @@ export function Sidebar(props: Props) {
}}>
<MessageSquare size={16} strokeWidth={1.65} />
<span className="chat-label">{rowTitle(row)}
- {!row.title && <small>{new Date(row.createdAt).toLocaleString(undefined, { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' })}</small>}
+ {!row.title && <small>{new Date(row.createdAt).toLocaleString(language, { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' })}</small>}
</span>
</button>
- <button type="button" className="icon-button row-actions" aria-label={'Actions for ' + rowTitle(row)} aria-haspopup="menu"
+ <button type="button" className="icon-button row-actions" aria-label={t('Actions for {name}', { name: rowTitle(row) })} aria-haspopup="menu"
onClick={event => {
const box = event.currentTarget.getBoundingClientRect()
openMenu(row, event.currentTarget, box.right - 168, box.bottom)
@@ -140,7 +141,7 @@ export function Sidebar(props: Props) {
</button>
</div>
))}
- {props.hasMore && <button type="button" className="text-button more" disabled={props.isLoading} onClick={props.onMore}>Load more</button>}
+ {props.hasMore && <button type="button" className="text-button more" disabled={props.isLoading} onClick={props.onMore}>{t('Load more')}</button>}
</div>
<div className="account-dock" ref={accountDock} onBlur={event => {
if (!event.currentTarget.contains(event.relatedTarget)) setAccountOpen(false)
@@ -155,28 +156,28 @@ export function Sidebar(props: Props) {
aria-expanded={accountOpen} aria-controls="account-actions" onClick={() => setAccountOpen(value => !value)}>
<span className="account-avatar" aria-hidden="true">{Array.from(props.userId)[0]?.toUpperCase()}</span>
<span className="account-identity"><strong title={props.userId}>{props.userId}</strong>
- <small>{props.hostReady ? 'Personal workspace' : 'Host unavailable'}</small></span>
+ <small>{props.hostReady ? t('Personal workspace') : t('Host unavailable')}</small></span>
<ChevronDown size={16} aria-hidden="true" className="account-chevron" />
</button>
- {accountOpen && <div id="account-actions" className="account-popover" role="group" aria-label="Account actions">
+ {accountOpen && <div id="account-actions" className="account-popover" role="group" aria-label={t('Account actions')}>
<button type="button" onClick={() => { setAccountOpen(false); props.onSettings() }}>
- <Settings size={18} aria-hidden="true" /> Settings
+ <Settings size={18} aria-hidden="true" /> {t('Settings')}
</button>
<button type="button" onClick={() => { setAccountOpen(false); props.onFiles() }}
disabled={!props.filesAvailable} aria-controls="host-files" aria-expanded={props.filesOpen}>
- <FolderTree size={18} aria-hidden="true" /> File system
+ <FolderTree size={18} aria-hidden="true" /> {t('File system')}
</button>
<div className="account-menu-divider" />
<button type="button" className="stop-host" onClick={() => { void props.onStopHost() }}
disabled={!props.hostReady || props.stoppingHost}>
- <Power size={18} aria-hidden="true" /> {props.stoppingHost ? 'Stopping Host…' : 'Stop Host'}
+ <Power size={18} aria-hidden="true" /> {props.stoppingHost ? t('Stopping Host…') : t('Stop Host')}
</button>
</div>}
- {props.stopHostError && <p className="sidebar-feedback" role="alert">{props.stopHostError}</p>}
+ {props.stopHostError && <p className="sidebar-feedback" role="alert">{t(props.stopHostError)}</p>}
</div>
</aside>
{menu && (
- <div className="context-menu" role="menu" aria-label="Chat actions"
+ <div className="context-menu" role="menu" aria-label={t('Chat actions')}
ref={node => { if (node) { node.style.left = menu.x + 'px'; node.style.top = menu.y + 'px' } }}>
<button ref={menuRef} type="button" role="menuitem"
onKeyDown={event => {
@@ -187,7 +188,7 @@ export function Sidebar(props: Props) {
}
}}
onClick={() => { setConfirm(menu); setMenu(null) }}>
- <Trash2 size={16} /> Delete chat
+ <Trash2 size={16} /> {t('Delete chat')}
</button>
</div>
)}
@@ -195,10 +196,10 @@ export function Sidebar(props: Props) {
onCancel={event => { event.preventDefault(); if (!deleting) closeConfirm(true) }}>
{confirm && (
<>
- <h2 id="archive-title">Delete chat?</h2>
- <p id="archive-copy"><strong>{rowTitle(confirm.row)}</strong> will disappear from the chat list. Its data will stay on disk.</p>
+ <h2 id="archive-title">{t('Delete chat?')}</h2>
+ <p id="archive-copy"><strong>{rowTitle(confirm.row)}</strong> {t('will disappear from the chat list. Its data will stay on disk.')}</p>
<div className="dialog-actions">
- <button type="button" autoFocus disabled={deleting} onClick={() => closeConfirm(true)}>Cancel</button>
+ <button type="button" autoFocus disabled={deleting} onClick={() => closeConfirm(true)}>{t('Cancel')}</button>
<button type="button" className="danger" disabled={deleting} onClick={async () => {
setDeleting(true)
try {
@@ -206,7 +207,7 @@ export function Sidebar(props: Props) {
closeConfirm(!removed)
if (removed) requestAnimationFrame(() => document.querySelector<HTMLElement>('.new-chat')?.focus())
} finally { setDeleting(false) }
- }}>{deleting ? 'Deleting…' : 'Delete chat'}</button>
+ }}>{deleting ? t('Deleting…') : t('Delete chat')}</button>
</div>
</>
)}
diff --git a/frontend/src/settings/Models.tsx b/frontend/src/settings/Models.tsx
index 1cd0965..ecbdc23 100644
--- a/frontend/src/settings/Models.tsx
+++ b/frontend/src/settings/Models.tsx
@@ -1,8 +1,10 @@
import { useEffect, useState, type FormEvent } from 'react'
+import { useLocale } from '../locale'
import { Plus } from 'lucide-react'
import { APIError, deleteEndpoint, getModelSettings, saveDefaultEndpoint, saveEndpoint, settingsApplyFailed, type ModelEndpoint, type ModelSettings } from '../api/controller'
export function Models({ userId }: { userId: string }) {
+ const { t } = useLocale()
const [settings, setSettings] = useState<ModelSettings>()
const [editing, setEditing] = useState<string>()
const [busy, setBusy] = useState(false)
@@ -45,36 +47,36 @@ export function Models({ userId }: { userId: string }) {
return (
<>
- <h2 className="settings-section-title">Models</h2>
- <p className="model-muted">Only OpenAI-compatible Responses API endpoints are supported.</p>
- {error && <p role="alert" className="account-error">{error}</p>}
- {notice && <p role="status">{notice}</p>}
- {!settings && !error && <p role="status">Loading model settings…</p>}
+ <h2 className="settings-section-title">{t('Models')}</h2>
+ <p className="model-muted">{t('Only OpenAI-compatible Responses API endpoints are supported.')}</p>
+ {error && <p role="alert" className="account-error">{t(error)}</p>}
+ {notice && <p role="status">{t(notice)}</p>}
+ {!settings && !error && <p role="status">{t('Loading model settings…')}</p>}
{settings && <>
- {!Object.keys(settings.endpoints).length && <p className="model-muted">Add an endpoint to create your first chat.</p>}
+ {!Object.keys(settings.endpoints).length && <p className="model-muted">{t('Add an endpoint to create your first chat.')}</p>}
{Object.entries(settings.endpoints).map(([id, endpoint]) =>
<section className="model-card" key={id}>
{editing === id ? <EndpointForm endpoint={endpoint} busy={busy} onCancel={() => setEditing(undefined)}
onSave={value => { void update(() => saveEndpoint(userId, id, value), 'Endpoint saved.') }} /> : <>
- <h2>{endpoint.name} {settings.defaultEndpointId === id && <span className="model-default">Default endpoint</span>}</h2>
- <p className="model-muted">{endpoint.baseUrl} · {endpoint.hasApiKey ? 'API key saved' : 'API key missing'}</p>
- <ul className="model-list">{endpoint.models.map((model, index) => <li key={model}>{model}{index === 0 && <span> · Default model</span>}</li>)}</ul>
+ <h2>{endpoint.name} {settings.defaultEndpointId === id && <span className="model-default">{t('Default endpoint')}</span>}</h2>
+ <p className="model-muted">{endpoint.baseUrl} · {endpoint.hasApiKey ? t('API key saved') : t('API key missing')}</p>
+ <ul className="model-list">{endpoint.models.map((model, index) => <li key={model}>{model}{index === 0 && <span> · {t('Default model')}</span>}</li>)}</ul>
<div className="model-settings-actions">
- <button type="button" disabled={busy} className="model-secondary" onClick={() => setEditing(id)}>Edit</button>
+ <button type="button" disabled={busy} className="model-secondary" onClick={() => setEditing(id)}>{t('Edit')}</button>
{settings.defaultEndpointId !== id && <button type="button" disabled={busy} className="model-secondary"
- onClick={() => { void update(() => saveDefaultEndpoint(userId, id), 'Default endpoint updated.') }}>Set as default</button>}
+ onClick={() => { void update(() => saveDefaultEndpoint(userId, id), 'Default endpoint updated.') }}>{t('Set as default')}</button>}
<button type="button" disabled={busy} className="model-secondary" onClick={() => {
- if (window.confirm('Remove this endpoint? Chats that use it will need a new model.')) {
+ if (window.confirm(t('Remove this endpoint? Chats that use it will need a new model.'))) {
void update(() => deleteEndpoint(userId, id), 'Endpoint removed.')
}
- }}>Remove</button>
+ }}>{t('Remove')}</button>
</div>
</>}
</section>
)}
{editing === '' ? <section className="model-card"><EndpointForm busy={busy} onCancel={() => setEditing(undefined)}
onSave={value => { void update(() => saveEndpoint(userId, undefined, value), 'Endpoint added.') }} /></section> :
- <button className="model-secondary settings-add" type="button" disabled={busy} onClick={() => setEditing('')}><Plus size={17} /> Add endpoint</button>}
+ <button className="model-secondary settings-add" type="button" disabled={busy} onClick={() => setEditing('')}><Plus size={17} /> {t('Add endpoint')}</button>}
</>}
</>
)
@@ -88,6 +90,7 @@ function EndpointForm({ endpoint, busy, onSave, onCancel }: {
onSave: (input: EndpointInput) => void
onCancel: () => void
}) {
+ const { t } = useLocale()
const [name, setName] = useState(endpoint?.name ?? '')
const [baseUrl, setBaseURL] = useState(endpoint?.baseUrl ?? '')
const [key, setKey] = useState('')
@@ -100,17 +103,17 @@ function EndpointForm({ endpoint, busy, onSave, onCancel }: {
}
return <form className="model-form" onSubmit={submit}>
- <h2>{endpoint ? 'Edit endpoint' : 'Add endpoint'}</h2>
+ <h2>{endpoint ? t('Edit endpoint') : t('Add endpoint')}</h2>
<fieldset disabled={busy}>
- <label>Name<input value={name} required maxLength={128} onChange={event => setName(event.target.value)} /></label>
- <label>Base URL<input type="url" value={baseUrl} required placeholder="https://api.example.com/v1" onChange={event => setBaseURL(event.target.value)} /></label>
- <label>API key<input type="password" value={key} required={!endpoint?.hasApiKey} autoComplete="new-password"
- placeholder={endpoint?.hasApiKey ? 'Leave blank to keep saved key' : undefined} onChange={event => setKey(event.target.value)} /></label>
- <label>Model IDs<textarea rows={4} value={models} required onChange={event => setModels(event.target.value)}
- aria-describedby="model-order" /><small id="model-order">One model per line. The first model is the endpoint default.</small></label>
+ <label>{t('Name')}<input value={name} required maxLength={128} onChange={event => setName(event.target.value)} /></label>
+ <label>{t('Base URL')}<input type="url" value={baseUrl} required placeholder="https://api.example.com/v1" onChange={event => setBaseURL(event.target.value)} /></label>
+ <label>{t('API key')}<input type="password" value={key} required={!endpoint?.hasApiKey} autoComplete="new-password"
+ placeholder={endpoint?.hasApiKey ? t('Leave blank to keep saved key') : undefined} onChange={event => setKey(event.target.value)} /></label>
+ <label>{t('Model IDs')}<textarea rows={4} value={models} required onChange={event => setModels(event.target.value)}
+ aria-describedby="model-order" /><small id="model-order">{t('One model per line. The first model is the endpoint default.')}</small></label>
<div className="model-settings-actions">
- <button type="submit" className="account-submit">{busy ? 'Saving…' : 'Save endpoint'}</button>
- <button type="button" className="model-secondary" onClick={onCancel}>Cancel</button>
+ <button type="submit" className="account-submit">{busy ? t('Saving…') : t('Save endpoint')}</button>
+ <button type="button" className="model-secondary" onClick={onCancel}>{t('Cancel')}</button>
</div>
</fieldset>
</form>
diff --git a/frontend/src/settings/ToolProviders.tsx b/frontend/src/settings/ToolProviders.tsx
index 329026f..4db1179 100644
--- a/frontend/src/settings/ToolProviders.tsx
+++ b/frontend/src/settings/ToolProviders.tsx
@@ -1,4 +1,5 @@
import { Check, ChevronDown, ExternalLink } from 'lucide-react'
+import { useLocale } from '../locale'
import { useEffect, useState } from 'react'
import { APIError, getProviderSettings, removeProviderKey, saveProviderSettings, settingsApplyFailed, type Provider, type ProviderPage, type ProviderSettings } from '../api/controller'
@@ -16,15 +17,16 @@ const keyHelp: Record<string, { label: string; url: string }> = {
type Action = 'save' | 'activate' | 'remove'
export function ToolProviders({ userId, page }: { userId: string; page: ProviderPage }) {
+ const { t } = useLocale()
const isImage = page === 'image-generation'
- const title = isImage ? 'Image generation' : 'Web search'
+ const title = t(isImage ? 'Image generation' : 'Web search')
const [settings, setSettings] = useState<ProviderSettings>()
const [editing, setEditing] = useState<string>()
const [model, setModel] = useState('')
const [apiKey, setAPIKey] = useState('')
const [action, setAction] = useState<Action>()
const [error, setError] = useState('')
- const [notice, setNotice] = useState('')
+ const [notice, setNotice] = useState<{ message: string; name: string }>()
const [loadAttempt, setLoadAttempt] = useState(0)
const [retry, setRetry] = useState<{ id: string; action: 'activate' | 'remove' }>()
@@ -47,7 +49,7 @@ export function ToolProviders({ userId, page }: { userId: string; page: Provider
async function update(provider: Provider, nextAction: Action) {
setAction(nextAction)
setError('')
- setNotice('')
+ setNotice(undefined)
try {
const next = nextAction === 'remove'
? await removeProviderKey(userId, page, provider.id)
@@ -57,8 +59,8 @@ export function ToolProviders({ userId, page }: { userId: string; page: Provider
setSettings(next)
if (editing === provider.id) edit(provider, next)
setRetry(undefined)
- setNotice(nextAction === 'activate' ? `${provider.name} is now in use.`
- : nextAction === 'remove' ? `${provider.name} API key removed.` : `${provider.name} settings saved.`)
+ setNotice({ name: provider.name, message: nextAction === 'activate' ? '{name} is now in use.'
+ : nextAction === 'remove' ? '{name} API key removed.' : '{name} settings saved.' })
} catch (failure) {
if (settingsApplyFailed(failure)) {
const saved = await getProviderSettings(userId, page).catch(() => undefined)
@@ -87,19 +89,19 @@ export function ToolProviders({ userId, page }: { userId: string; page: Provider
<div className="provider-settings-intro">
<h2 className="settings-section-title">{title}</h2>
<p className="model-muted">{isImage
- ? 'Choose the service your agent uses to generate images.'
- : 'Choose the service your agent uses to search the web.'}</p>
+ ? t('Choose the service your agent uses to generate images.')
+ : t('Choose the service your agent uses to search the web.')}</p>
</div>
- {error && <p className="account-error" role="alert">{error}</p>}
- {notice && <p className="provider-notice" role="status">{notice}</p>}
+ {error && <p className="account-error" role="alert">{t(error)}</p>}
+ {notice && <p className="provider-notice" role="status">{t(notice.message, { name: notice.name })}</p>}
{!settings && (error
- ? <button type="button" className="model-secondary" onClick={() => { setError(''); setLoadAttempt(attempt => attempt + 1) }}>Retry</button>
- : <p role="status">Loading provider settings…</p>)}
+ ? <button type="button" className="model-secondary" onClick={() => { setError(''); setLoadAttempt(attempt => attempt + 1) }}>{t('Retry')}</button>
+ : <p role="status">{t('Loading provider settings…')}</p>)}
{settings && <>
<p className="provider-current">
- {retry ? <>Waiting for the Host to apply the saved change.</> : activeReady ? <>In use <strong>{active.name}</strong></> : <>No provider is in use. Save a key and choose a provider.</>}
+ {retry ? <>{t('Waiting for the Host to apply the saved change.')}</> : activeReady ? <>{t('In use')} <strong>{active.name}</strong></> : <>{t('No provider is in use. Save a key and choose a provider.')}</>}
</p>
- <ul className="provider-list" aria-label={`${title} providers`}>
+ <ul className="provider-list" aria-label={t('{title} providers', { title })}>
{settings.providers.map(provider => {
const entry = settings.entries[provider.id]
const hasKey = !!entry?.hasApiKey
@@ -113,24 +115,24 @@ export function ToolProviders({ userId, page }: { userId: string; page: Provider
<div className="provider-row-main">
<div className="provider-row-identity">
<h3>{provider.name}</h3>
- <p>{isImage && hasKey ? entry?.model ?? provider.defaultModel : hasKey ? 'API key saved' : 'No API key'}</p>
+ <p>{isImage && hasKey ? entry?.model ?? provider.defaultModel : hasKey ? t('API key saved') : t('No API key')}</p>
</div>
<div className="provider-row-actions">
- {selected && hasKey && !pending && <span className="provider-active"><Check size={15} aria-hidden="true" /> In use</span>}
+ {selected && hasKey && !pending && <span className="provider-active"><Check size={15} aria-hidden="true" /> {t('In use')}</span>}
{(pending || (hasKey && !selected)) && <button type="button" className="model-secondary provider-use"
- aria-label={`${pending ? 'Retry applying' : 'Use'} ${provider.name}`}
+ aria-label={t(pending ? 'Retry applying {name}' : 'Use {name}', { name: provider.name })}
disabled={!!action || (expanded && dirty)} onClick={() => { void update(provider, pending?.action ?? 'activate') }}>
- {pending ? 'Retry apply' : 'Use provider'}
+ {pending ? t('Retry apply') : t('Use provider')}
</button>}
- <button type="button" className="provider-edit" aria-label={`${hasKey ? 'Edit' : 'Set up'} ${provider.name}`}
+ <button type="button" className="provider-edit" aria-label={t(hasKey ? 'Edit {name}' : 'Set up {name}', { name: provider.name })}
aria-expanded={expanded} aria-controls={expanded ? formId : undefined} disabled={!!action}
onClick={() => {
- setNotice('')
+ setNotice(undefined)
if (!retry) setError('')
if (expanded) { setEditing(undefined); setAPIKey('') }
else edit(provider, settings)
}}>
- {hasKey ? 'Edit' : 'Set up'} <ChevronDown size={15} aria-hidden="true" />
+ {hasKey ? t('Edit') : t('Set up')} <ChevronDown size={15} aria-hidden="true" />
</button>
</div>
</div>
@@ -139,27 +141,27 @@ export function ToolProviders({ userId, page }: { userId: string; page: Provider
void update(provider, 'save')
}}>
<fieldset disabled={!!action}>
- {isImage && <label>{provider.id === 'seedream' ? 'Model name or endpoint ID' : 'Model name'}
+ {isImage && <label>{provider.id === 'seedream' ? t('Model name or endpoint ID') : t('Model name')}
<input value={model} required maxLength={256} onChange={event => setModel(event.target.value)} />
</label>}
- <label>API key
+ <label>{t('API key')}
<input type="password" value={apiKey} required={!hasKey} maxLength={4096} autoComplete="new-password"
- placeholder={hasKey ? 'Leave blank to keep the saved key' : undefined}
+ placeholder={hasKey ? t('Leave blank to keep the saved key') : undefined}
onChange={event => setAPIKey(event.target.value)} />
</label>
- {help && <a className="provider-doc-link" href={help.url} target="_blank" rel="noreferrer">{help.label}<ExternalLink size={13} aria-hidden="true" /></a>}
+ {help && <a className="provider-doc-link" href={help.url} target="_blank" rel="noreferrer">{t(help.label)}<ExternalLink size={13} aria-hidden="true" /></a>}
<div className="model-settings-actions">
<button type="submit" className="account-submit" disabled={!dirty || (!hasKey && !apiKey.trim())}>
- {action === 'save' ? 'Saving…' : 'Save settings'}
+ {action === 'save' ? t('Saving…') : t('Save settings')}
</button>
- {hasKey && <button type="button" className="model-secondary" onClick={() => { void update(provider, 'remove') }}>Remove key</button>}
+ {hasKey && <button type="button" className="model-secondary" onClick={() => { void update(provider, 'remove') }}>{t('Remove key')}</button>}
</div>
</fieldset>
</form>}
</li>
})}
</ul>
- <a className="provider-doc-link" href={providerDocs} target="_blank" rel="noreferrer">Build a provider adapter <ExternalLink size={13} aria-hidden="true" /></a>
+ <a className="provider-doc-link" href={providerDocs} target="_blank" rel="noreferrer">{t('Build a provider adapter')} <ExternalLink size={13} aria-hidden="true" /></a>
</>}
</div>
}
diff --git a/frontend/src/styles/app.css b/frontend/src/styles/app.css
index 704dd6e..2cb6715 100644
--- a/frontend/src/styles/app.css
+++ b/frontend/src/styles/app.css
@@ -374,6 +374,16 @@ button:focus-visible, textarea:focus-visible, a:focus-visible {
box-shadow: 0 22px 64px #495a921f;
}
.account-card .brand { padding: 0; }
+.account-card-heading, .settings-header-actions {
+ display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
+}
+.language-picker, .account-card .language-picker {
+ display: inline-flex; align-items: center; gap: 6px; flex: none; color: var(--muted);
+}
+.language-picker select {
+ border: 1px solid #d8e1f0; border-radius: 8px; min-height: 32px; padding: 0 6px;
+ background: #ffffffa8; color: inherit; font: inherit; font-size: 13px;
+}
.account-card h1 { margin: 24px 0 20px; font-size: 23px; letter-spacing: -.035em; }
.account-card fieldset { display: grid; gap: 15px; margin: 0; padding: 0; border: 0; }
.account-card label { display: grid; gap: 6px; font-size: 14px; font-weight: 560; }
diff --git a/frontend/tests/attachments.test.ts b/frontend/tests/attachments.test.ts
index 4be9768..c60c7fc 100644
--- a/frontend/tests/attachments.test.ts
+++ b/frontend/tests/attachments.test.ts
@@ -18,5 +18,5 @@ test('keeps accepted drafts when a file exceeds the attachment count', () => {
const image = new File(['x'], 'preview.webp', { type: 'image/webp' })
const next = addMessageFiles(existing, [extra, image])
assert.deepEqual(next.files, [...existing, image])
- assert.match(next.error, /8 other files/)
+ assert.deepEqual(next.issues.map(issue => issue.message), ['A message can attach up to 20 images and 8 other files.'])
})