diff --git a/review-assets/pr1751/pr1751-run-detail-en.png b/review-assets/pr1751/pr1751-run-detail-en.png
new file mode 100644
index 000000000..6edac7ff7
Binary files /dev/null and b/review-assets/pr1751/pr1751-run-detail-en.png differ
diff --git a/review-img/oc-zhipu-1711.png b/review-img/oc-zhipu-1711.png
new file mode 100644
index 000000000..9868ddfca
Binary files /dev/null and b/review-img/oc-zhipu-1711.png differ
diff --git a/web/evolution.js b/web/evolution.js
index f37117c88..33bf4c237 100644
--- a/web/evolution.js
+++ b/web/evolution.js
@@ -505,9 +505,9 @@ function evoAssetsHTML(){
// ---------- 回归样本 ----------
function evoSamplesHTML(){
- const rows=(evo.samples||[]).map(s=>kbRow(kbText(evoRunLink(s.runId,s.runId),escapeHTML(s.note||'无备注')+(s.workflowId?` · ${escapeHTML(s.workflowId)}`:'')),`${kbValue(relativeTime(s.createdAt))}`));
- const note=kbCaption('钉选样本每次提案都会回放,用来守住已知的好结果。在运行详情页点「钉为回归样本」添加。');
- return kbPanel(kbPanelTitle('回归样本',`${rows.length} 个`),note+(rows.join('')||'
还没有钉选样本
'),{label:'回归样本'});
+ const rows=(evo.samples||[]).map(s=>kbRow(kbText(evoRunLink(s.runId,s.runId),escapeHTML(s.note||lfT('无备注','No note'))+(s.workflowId?` · ${escapeHTML(s.workflowId)}`:'')),`${kbValue(relativeTime(s.createdAt))}`));
+ const note=kbCaption(lfT('钉选样本每次提案都会回放,用来守住已知的好结果。在运行详情页点「钉为回归样本」添加。','Pinned samples replay on every proposal to guard known good results. Add one from a run detail page with "Pin as regression sample".'));
+ return kbPanel(kbPanelTitle(lfT('回归样本','Regression samples'),lfT(`${rows.length} 个`,`${rows.length}`)),note+(rows.join('')||`
${lfT('还没有钉选样本','No pinned samples yet')}
`),{label:lfT('回归样本','Regression samples')});
}
// ---------- 抽屉 ----------
@@ -1434,24 +1434,35 @@ async function evoSetLevel(kind,id,level){
async function evoUnpin(runId,btn){
if(btn)btn.disabled=true;
- try{await api(`/api/runs/${encodeURIComponent(runId)}/pin-sample`,{method:'DELETE'});toast('已移除样本','ok');await evoAfterChange()}
- catch(err){toast(err.message,'err');if(btn)btn.disabled=false}
+ try{await api(`/api/runs/${encodeURIComponent(runId)}/pin-sample`,{method:'DELETE'});toast(lfT('已移除样本','Sample removed'),'ok');await evoAfterChange()}
+ catch(err){toast(evoPinError(err),'err');if(btn)btn.disabled=false}
+}
+
+// The pin-sample API answers in Chinese; show the two known reasons in English.
+const EVO_PIN_ERRORS={
+ '该运行没有所属项目':'This run does not belong to a project',
+ '只能把成功的业务运行设为回归样本':'Only successful business runs (not evolution replays) can be pinned as regression samples',
+};
+function evoPinError(err){
+ const message=String(err?.message||'');
+ const en=EVO_PIN_ERRORS[message];
+ return en?lfT(message,en):message;
}
// ---------- 运行详情:反馈、钉为样本、回放标记 ----------
function evoDecorateRunDetail(host,r){
if(!host||!r)return;
if(r.executionContext?.purpose==='evolution_replay'){
- host.querySelector('.run-header-meta')?.insertAdjacentHTML('afterbegin','进化回放');
+ host.querySelector('.run-header-meta')?.insertAdjacentHTML('afterbegin',`${lfT('进化回放','Evolution replay')}`);
return;
}
- if((r.executionContext?.evolutionCanaryIds||[]).length)host.querySelector('.run-header-meta')?.insertAdjacentHTML('afterbegin','进化试用');
+ if((r.executionContext?.evolutionCanaryIds||[]).length)host.querySelector('.run-header-meta')?.insertAdjacentHTML('afterbegin',`${lfT('进化试用','Evolution trial')}`);
if(!['succeeded','failed','cancelled'].includes(r.status)||!r.executionContext?.projectId)return;
const actions=host.querySelector('.run-header-actions');if(!actions)return;
- actions.insertAdjacentHTML('afterbegin',``);
+ actions.insertAdjacentHTML('afterbegin',``);
actions.querySelector('[data-evo-feedback]')?.addEventListener('click',async ev=>{
const btn=ev.currentTarget,nodeId=state.selectedRunNode||'';
- const detail=await afPrompt({title:'反馈问题',message:'请写清预期结果、实际结果和需要改进的地方。提交后会整理为关联角色的问题。',defaultValue:'',multiline:true});
+ const detail=await afPrompt({title:lfT('反馈问题','Report an issue'),message:lfT('请写清预期结果、实际结果和需要改进的地方。提交后会整理为关联角色的问题。','Describe the expected result, the actual result and what should improve. It is filed as an issue on the related role.'),defaultValue:'',multiline:true});
if(!detail||!String(detail).trim())return;
btn.disabled=true;
try{
@@ -1460,20 +1471,20 @@ function evoDecorateRunDetail(host,r){
if(btn.isConnected){
host.querySelector('.evo-feedback-result')?.remove();
const notice=document.createElement('div');notice.className='evo-feedback-result';notice.setAttribute('role','status');
- notice.innerHTML=`${escapeHTML(result.message||'反馈已保存,请在RSI工作台检查最近运行后查看。')}${result.findingId?'':''}`;
+ notice.innerHTML=`${escapeHTML(result.message||lfT('反馈已保存,请在RSI工作台检查最近运行后查看。','Feedback saved; check the RSI workbench after the recent runs.'))}${result.findingId?``:''}`;
notice.querySelector('button')?.addEventListener('click',()=>evoOpenFeedbackFinding(result));host.prepend(notice);
}
- toast(result.findingId?'反馈已加入RSI工作台':'反馈已保存,详见提示','ok');
+ toast(result.findingId?lfT('反馈已加入RSI工作台','Feedback filed in the RSI workbench'):lfT('反馈已保存,详见提示','Feedback saved; see the notice above'),'ok');
}catch(err){toast(err.message,'err')}
finally{btn.disabled=false}
});
actions.querySelector('[data-evo-pin]')?.addEventListener('click',async ev=>{
const btn=ev.currentTarget;
- const note=await afPrompt({title:'钉为回归样本',message:'备注(可选),说明这次运行为什么值得守住:',defaultValue:''});
+ const note=await afPrompt({title:lfT('钉为回归样本','Pin as regression sample'),message:lfT('备注(可选),说明这次运行为什么值得守住:','Note (optional): why this run is worth keeping:'),defaultValue:''});
if(note===null||note===undefined)return;
btn.disabled=true;
- try{await api(`/api/runs/${encodeURIComponent(r.id)}/pin-sample`,{method:'POST',body:JSON.stringify({note})});toast('已钉为回归样本','ok')}
- catch(err){toast(err.message,'err')}
+ try{await api(`/api/runs/${encodeURIComponent(r.id)}/pin-sample`,{method:'POST',body:JSON.stringify({note})});toast(lfT('已钉为回归样本','Pinned as a regression sample'),'ok')}
+ catch(err){toast(evoPinError(err),'err')}
finally{btn.disabled=false}
});
}
@@ -1482,7 +1493,7 @@ async function evoOpenFeedbackFinding(result){
const pid=result.projectId;
if(state.projectFilter!==pid){
const picker=$('#projectSwitcher');
- if(!picker?.onchange||![...picker.options].some(o=>o.value===pid))return toast('请先选择该运行所属项目,再打开RSI工作台','warn');
+ if(!picker?.onchange||![...picker.options].some(o=>o.value===pid))return toast(lfT('请先选择该运行所属项目,再打开RSI工作台','Switch to the run\'s project first, then open the RSI workbench'),'warn');
await picker.onchange({target:{value:pid}});
if(state.projectFilter!==pid)return;
}
diff --git a/webtest/tests/evolution-feedback.test.mjs b/webtest/tests/evolution-feedback.test.mjs
index 749283ce7..b545f245f 100644
--- a/webtest/tests/evolution-feedback.test.mjs
+++ b/webtest/tests/evolution-feedback.test.mjs
@@ -63,3 +63,73 @@ test('queued findings explain why dismiss is disabled until the queue entry is r
assert.match(result[1],/取消排队/);
assert.equal(result[2],false);
});
+
+test('English mode renders the run detail feedback and pin controls in English', async (t) => {
+ const app = await loadApp({ lang: 'en' }); t.after(app.close);
+ const isEn = app.evaluate(`document.documentElement.dataset.lang==='en' && window.lfT('中文','English')==='English'`);
+ assert.equal(isEn, true, 'the app must boot in English mode for this test');
+ const labels = app.evaluate(`(() => {
+ const host=document.createElement('div');
+ host.innerHTML='';
+ evoDecorateRunDetail(host,{id:'i18n-run',status:'succeeded',executionContext:{projectId:'project-1'}});
+ const buttons=[...host.querySelectorAll('[data-evo-feedback],[data-evo-pin]')].map(b=>({label:b.textContent.trim(),title:b.title}));
+ evoDecorateRunDetail(host,{id:'i18n-replay',status:'succeeded',executionContext:{purpose:'evolution_replay',projectId:'project-1'}});
+ const chip=host.querySelector('.evo-replay-chip');
+ return {buttons,chip:{label:chip?.textContent.trim(),title:chip?.title}};
+ })()`);
+ const HAN = /[㐀-鿿]/;
+ for (const b of labels.buttons) {
+ assert.doesNotMatch(b.label, HAN);
+ assert.doesNotMatch(b.title, HAN);
+ }
+ assert.match(labels.buttons[0].label, /Report an issue/);
+ assert.match(labels.buttons[1].label, /Pin as regression sample/);
+ assert.doesNotMatch(labels.chip.label, HAN);
+ assert.doesNotMatch(labels.chip.title, HAN);
+});
+
+test('English mode unpins a regression sample with an English toast', async (t) => {
+ const app = await loadApp({ lang: 'en' }); t.after(app.close);
+ app.evaluate(`
+ window.__unpinToasts=[];
+ window.__origToast=window.toast;
+ window.toast=(msg,kind)=>{window.__unpinToasts.push(String(msg));return window.__origToast(msg,kind);};
+ window.evoAfterChange=async()=>{};
+ const view=document.createElement('div');
+ view.id='evolutionView';
+ const btn=document.createElement('button');
+ btn.dataset.evoUnpin='en-unpin-run';
+ view.appendChild(btn);
+ document.body.appendChild(view);
+ btn.click();
+ `);
+ await settle(6);
+ const toasts = app.evaluate(`(()=>{window.toast=window.__origToast;return window.__unpinToasts})()`);
+ assert.equal(toasts.length, 1);
+ assert.equal(toasts[0], 'Sample removed');
+});
+
+test('English mode localizes the server reasons when pinning a regression sample fails', async (t) => {
+ const app = await loadApp({ lang: 'en', routes: [
+ { method: 'POST', path: '/api/runs/pin-fail-run/pin-sample', status: 409, body: { error: '只能把成功的业务运行设为回归样本' } },
+ ] }); t.after(app.close);
+ app.evaluate(`
+ window.__pinToasts=[];
+ window.__origToast=window.toast;
+ window.toast=(msg,kind)=>{window.__pinToasts.push(String(msg));return window.__origToast(msg,kind);};
+ window.afPrompt=async()=>'';
+ const view=document.createElement('div');
+ view.id='evolutionView';
+ document.body.appendChild(view);
+ const host=document.createElement('div');
+ host.innerHTML='';
+ document.body.appendChild(host);
+ evoDecorateRunDetail(host,{id:'pin-fail-run',status:'succeeded',executionContext:{projectId:'project-1'}});
+ host.querySelector('[data-evo-pin]').click();
+ `);
+ await settle(8);
+ const toasts = app.evaluate('window.__pinToasts');
+ assert.equal(toasts.length, 1);
+ assert.match(toasts[0], /Only successful business runs .* can be pinned as regression samples/);
+ assert.doesNotMatch(toasts[0], /[\u3400-\u9fff]/);
+});